helm lamp stack chart (#1288)

This commit is contained in:
lead4good
2017-12-05 21:01:06 +01:00
committed by Reinhard Nägele
parent dc7479fd18
commit d284317c22
32 changed files with 3003 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
+7
View File
@@ -0,0 +1,7 @@
apiVersion: v1
description: Modular and transparent LAMP stack chart supporting PHP-FPM, Release Cloning, LoadBalancer, Ingress, SSL and lots more!
name: lamp
version: 0.1.0
home: https://github.com/lead4good/helm-lamp-stack
maintainers:
- name: lead4good
+319
View File
@@ -0,0 +1,319 @@
# LAMP
Ever wanted to deploy a [LAMP Stack](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) on Kubernetes?
## TL;DR;
```console
$ helm install stable/lamp
```
## Introduction
This chart bootstraps a [LAMP Stack](https://en.wikipedia.org/wiki/LAMP_(software_bundle)) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
It was designed in a very modular and transparent way. Instead of using a custom built docker container running multiple services like apache and php-fpm inside with no control or overwatch of these processes from within kubernetes, this chart takes the approach of using one service per container.
The charts default configurations were made with performance in mind. By default PHP-FPM is enabled and communication between php and mysql as well as apache and php is realized over unix sockets.
By default the chart is exposed to the public via LoadBalancer IP but exposing the chart via an ingress controller is also supported. If a working [lego container](https://github.com/jetstack/kube-lego) is configured the chart supports creating lets encrypt certificates.
Setting up your website is easy, you can either use [git](#git-container) or [svn](#svn-container) to copy your repo into the pod or use [sftp](#sftp-container) or [webdav](#webdav-container) and simply transfer your files into the container. If you have a different method of setting up your website, you can [manually prepare](#manually-preparing-the-webroot-and-database) it inside of an init container before the services start.
Once you've set up your website, you'd like to have seperate development environments for testing? Don't worry, with one additional setting you can [clone an existing release](#cloning-charts) without downtime using the [xtrabackup](https://www.percona.com/software/mysql-database/percona-xtrabackup) [init container](https://hub.docker.com/r/lead4good/xtrabackup/).
Official containers are used wherever possible ( namingly [php](https://hub.docker.com/_/php/), [apache](https://hub.docker.com/_/httpd/), [mysql](https://hub.docker.com/_/mysql/), [mariadb](https://hub.docker.com/_/mariadb/) and [percona](https://hub.docker.com/_/percona/) ) while the use of well established containers was anticipated otherwise ( [phpmyadmin/phpmyadmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/), [atmoz/sftp](https://hub.docker.com/r/atmoz/sftp/),
[openweb/git-sync](https://hub.docker.com/r/openweb/git-sync/) ) . To provide some of its unique features such as chart cloning and wordpress support some containers had to be newly created. All of those are hosted as automated builds on docker hub - with their respective sources on GitHub ([lead4good/init-wp](https://hub.docker.com/r/lead4good/init-wp/), [lead4good/svn-sync](https://hub.docker.com/r/lead4good/svn-sync/), [lead4good/webdav](https://hub.docker.com/r/lead4good/webdav/), [lead4good/xtrabackup](https://hub.docker.com/r/lead4good/xtrabackup/)).
## Prerequisites
- Kubernetes 1.7+
- LoadBalancer support or Ingress Controller
## Installing the Chart
To install the chart with the release name `my-release`:
```console
$ helm install --name my-release stable/lamp
```
The command deploys the LAMP chart on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```console
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Examples
To try out one of the [examples](examples/). you can run, e.g. for wordpress:
```console
$ helm install -f examples/wordpress.yaml --name wordpress stable/lamp
```
Currently you can try the following examples:
* [examples/wordpress.yaml](examples/wordpress.yaml)
* [examples/wordpress-ingress-ssl.yaml](examples/wordpress-ingress-ssl.yaml)
* [examples/wordpress-php-ini.yaml](examples/wordpress-php-ini.yaml)
* [examples/drupal.yaml](examples/drupal.yaml)
* [examples/joomla.yaml](examples/joomla.yaml)
* [examples/joomla.yaml](examples/grav.yaml)
* [examples/owncloud.yaml](examples/owncloud.yaml)
* [examples/nextcloud.yaml](examples/nextcloud.yaml)
## Configuration
The following tables list the configurable parameters of the LAMP chart and their default values.
You can specify each of the parameters using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install --name my-release \
--set init.clone.release=my-first-release-lamp,php.sockets=false,php.oldHTTPRoot=/var/www/my-website.com \
stable/lamp
```
The above command sets up the chart to create its persistent contents by cloning its content from `my-first-release-lamp`, sets PHP socket communication to `false` and sets an old http root to compensate for absolute path file links
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install --name my-release -f values.yaml stable/lamp
```
> **Tip**: You can use the default [values.yaml](values.yaml) file as a template
### Manually preparing the webroot and database
The manual init container enables you to manually pull a websites backup from somewhere and set it up inside the container before the chart is deployed. Set `init.manually.enabled` to `true` and connect to the container by replacing `example-com-lamp` and executing
```console
$ kubectl exec -it \
$(kubectl get pods -l app=example-com-lamp --output=jsonpath={.items..metadata.name}) \
-c init-manually /bin/bash
```
The container has the document root mounted at `/var/www/html` and the database directory mounted at `/var/lib/mysql` . The default manual init container is derived from the official [mysql](https://hub.docker.com/_/mysql/) container and can create and startup a mysql db by setting the necessary environment variables and then executing
```console
$ /entrypoint.sh mysqld &
```
If another flavor of DB is used ([mariadb](https://hub.docker.com/_/mariadb/) or [percona](https://hub.docker.com/_/percona/)) then the repository and tag need to be pointing to the right container.
After setting up your DB backup you can stop the database by executing
```console
$ mysqladmin -uroot -p$MYSQL_ROOT_PASSWORD shutdown
```
Now copy all necessary files into the web directory, but do not forget to recursivly chown the webroot to the `www-data` user ( id 33 ) by executing
```console
$ chown -R 33:33 /var/www/html
```
Once everything is setup stopping the init container is done by executing
```console
$ im-done
```
| Parameter | Description | Default |
| - | - | - |
| `init.manually.enabled` | Enables container for manual initialization | false |
| `init.manually.repository` | Containers repository | lead4good/init-wp |
| `init.manually.tag` | Repository tag | latest |
| `init.manually.pullPolicy` | Image pull policy | Always |
### Cloning charts
If `init.clone.release` is set to the fullname of an existing, already running LAMP chart (e.g. `example-com-lamp`), the persistent storage of that chart (web files and db) will be copied to this charts persistent storage. It is mandatory that both database containers are of the same type ([mysql](https://hub.docker.com/_/mysql/), [mariadb](https://hub.docker.com/_/mariadb/) or [percona](https://hub.docker.com/_/percona/)). Mixing them will not work.
| Parameter | Description | Default |
| - | - | - |
| `init.clone.release` | Fullname of the release to clone | _empty_ |
| `init.clone.hostPath` | If the release to clone uses hostPath instead of PVC, set it here. This will only work if both releases are deployed on the same node | _empty_ |
### Init Containers Resources
| `init.resources` | init containers resource requests/limits | `resources` |
### PHP and HTTPD Containers
The PHP container is at the heart of the LAMP chart. By default, the LAMP chart uses the official PHP container from docker hub with PHP version 7.1. You can also use your own PHP container, which needs to have the official PHP container at its base.
FPM is enabled by default, this creates an additional HTTPD container which routes PHP request via FCGI to the PHP container. Set `php.fpmEnabled` to false to work with the official `php:apache` image.
> **Note**: If you are using a custom container, be sure to use the official `php:apache` or `php:fpm` containers at its base and set `php.fpmEnabled` accordingly
| Parameter | Description | Default |
| - | - | - |
| `php.version` | default php repository version, you can specify a differnt version like 5 or 7.0 | 7 |
| `php.repository` | If not empty, repository is chosen over default php repo | _empty_ |
| `php.tag` | Repository tag | _empty_ |
| `php.pullPolicy` | Image pull policy | Always |
| `php.fpmEnabled` | Enables docker FPM repository, be sure to disable if working with a custom repository based on the apache tag | true |
| `php.sockets` | If FPM is enabled, enables communication between HTTPD and PHP via sockets instead of TCP | true |
| `php.oldHTTPRoot` | Additionaly mounts the webroot at `php.oldHTTPRoot` to compansate for absolute path file links | _empty_ |
| `php.ini` | additional PHP config values, see examples on how to use | _empty_ |
| `php.copyRoot` | if true, copies the containers web root `/var/www/html` into persistent storage. This must be enabled, if the container already comes with files installed to `/var/www/html` | false |
| `php.persistentSubpaths` | instead of enabling persistence for the whole webroot, only subpaths of webroot can be enabled for persistence. Have a look at the [nextcloud example](examples/nextcloud.yaml) to see how it works | _empty_ |
| `php.resources` | PHP container resource requests/limits | `resources` |
| `httpd.resources` | HTTPD container resource requests/limits | `resources` |
### MySQL Container
The MySQL container is disabled by default, any container with the base image of the offical [mysql](https://hub.docker.com/_/mysql/), [mariadb](https://hub.docker.com/_/mariadb/) or [percona](https://hub.docker.com/_/percona/) should work.
| Parameter | Description | Default |
| - | - | - |
| `mysql.rootPassword` | Sets the MySQL root password, enables MySQL service if not empty | _empty_ |
| `mysql.user` | MySQL user | _empty_ |
| `mysql.password` | MySQL user password | _empty_ |
| `mysql.database` | MySQL user database | _empty_ |
| `mysql.repository` | MySQL repository - choose one of the official [mysql](https://hub.docker.com/_/mysql/), [mariadb](https://hub.docker.com/_/mariadb/) or [percona](https://hub.docker.com/_/percona/) images | mysql |
| `mysql.tag` | Repository tag | 5.7 |
| `mysql.imagePullPolicy` | Image pull policy | Always |
| `mysql.sockets` | Enables communication between MySQL and PHP via sockets instead of TCP | true |
| `mysql.resources` | Resource requests/limits | `resources` |
### SFTP Container
SFTP is an instance of the atmoz/sftp container, through which you can access the webroot.
| Parameter | Description | Default |
| - | - | - |
| `sftp.enabled` | Enables sftp service | false |
| `sftp.port` | Port to advertise service in LoadBalancer mode | 22 |
| `sftp.nodePort` | Port to advertise service in Ingress mode| _empty_ |
| `sftp.user` | SFTP User | _empty_ |
| `sftp.password` | SFTP Password | _empty_ |
| `sftp.resources` | resource requests/limits | `resources` |
### WebDAV Container
An instance of WebDAV, through which you can access the webroot.
| Parameter | Description | Default |
| - | - | - |
| `webdav.enabled` | Enables webdav service | false |
| `webdav.port` | Port to advertise service in LoadBalancer mode | 8001 |
| `webdav.subdomain` | Subdomain to advertise service on if ingress is enabled | webdav |
| `webdav.user` | WebDAV User | _empty_ |
| `webdav.password` | WebDAV Password | _empty_ |
| `webdav.resources` | resource requests/limits | `resources` |
### Git Container
If Git is enabled, the contents of the specified repository will be synchronized every `git.wait` seconds to the web root. The web root needs to be empty otherwise the container will fail exit.
> **Note**: You should not combine SFTP or WebDAV with the Git container since this might cause confusion if someone edits a file via SFTP just to find out that its changes got reverted by the Git sync process
| Parameter | Description | Default |
| - | - | - |
| `git.enabled` | Enables Git service | false |
| `git.repoURL` | Git Repository URL | _empty_ |
| `git.branch` | Repository branch to sync | master |
| `git.revision` | Revision to sync | FETCH_HEAD |
| `git.wait` | Time between Git syncs | 30 |
| `git.resources` | resource requests/limits | `resources` |
### SVN Container
If SVN is enabled, the contents of the specified repository will be synchronized every 30 seconds to the web root. If allowOverwrite is disabled and files already exist in the web folder then it will not create a working clone or sync files.
> **Note**: You should not combine SFTP or WebDAV with the SVN container since this might cause confusion if someone edits a file via SFTP just to find out that its changes got reverted by the SVN sync process
| Parameter | Description | Default |
| - | - | - |
| `svn.enabled` | Enables svn service | false |
| `svn.user` | SVN User | _empty_ |
| `svn.password` | SVN Password | _empty_ |
| `svn.repoURL` | SVN Repository URL | _empty_ |
| `svn.allowOverwrite` | if disabled and files already exist in the web folder will not create working clone or sync files | true |
| `svn.resources` | resource requests/limits | `resources` |
### PHPMyAdmin Container
An instance of PHPMyAdmin through which you can access the database.
| Parameter | Description | Default |
| - | - | - |
| `phpmyadmin.enabled` | Enables phpmyadmin service | false |
| `phpmyadmin.port` | Port to advertise service in LoadBalancer mode | 8080 |
| `phpmyadmin.subdomain` | Subdomain to advertise service on if ingress is enabled | phpmyadmin |
| `phpmyadmin.resources` | resource requests/limits | `resources` |
### Default Resources
Default resources are used by all containers which have no custom resources configured.
| Parameter | Description | Default |
| - | - | - |
| `resources.requests.cpu` | CPU resource requests | 1 |
| `resources.requests.memory` | Memory resource requests | 1Mi |
| `resources.limits.cpu` | CPU resource limits | _empty_ |
| `resources.limits.memory` | Memory resource limits | _empty_ |
### Persistence
If `persistence` is enabled, PVC's will be used to store the web root and the db root. If a pod then is redeployed to another node, it will restart within seconds with the old state prevailing. If it is disabled, `EmptyDir` is used, which would lead to deletion of the persistent storage once the pod is moved. Also cloning a chart with `persistence` disabled will not work. Therefor persistence is enabled by default and should only be disabled in a testing environment. In environments where no PVCs are available you can use `persistence.hostPath` instead. This will store the charts persistent data on the node it is running on.
| Parameter | Description | Default |
| - | - | - |
| `persistence.enabled` | Enables persistent volume - PV provisioner support necessary | true |
| `persistence.keep` | Keep persistent volume after helm delete | false |
| `persistence.accessMode` | PVC Access Mode | ReadWriteOnce |
| `persistence.size` | PVC Size | 5Gi |
| `persistence.storageClass` | PVC Storage Class | _empty_ |
| `persistence.hostPath` | if specified, used as persistent storage instead of PVC | _empty_ |
### Network
To be able to connect to the services provided by the LAMP chart, a Kubernetes cluster with working LoadBalancer or Ingress Controller support is necessary.
By default the chart will create a LoadBalancer Service, all services will be available via LoadBalancer IP through differnt ports. You can set `service.type` to ClusterIP if you do not want your chart to be exposed at all.
If `ingress.enabled` is set to true, the LAMP charts services are made accessible via ingress rules. Those services which are not provided by HTTP protocol via `nodePorts`. In ingress mode the LAMP chart also supports ssl wiht certificates signed by lets encrypt. This requires a working [lego](https://github.com/jetstack/kube-lego) container running on the cluster.
> **Note**: In ingress mode it is mandatory to set `ingress.domain`, otherwise the ingress rules won't know how to route the traffic to the services.
| Parameter | Description | Default |
| - | - | - |
| `service.type` | Changes to ClusterIP automatically if ingress enabled | LoadBalancer |
| `service.HTTPPort` | Port to advertise the main web service in LoadBalancer mode | 80 |
| `ingress.enabled` | Enables ingress support - working ingress controller necessary | false |
| `ingress.domain` | domain to advertise the services - A records need to point to ingress controllers IP | _empty_ |
| `ingress.subdomainWWW` | enables www subdomain and 301 redirect from domain. Requires nginx ingress controller. | false |
| `ingress.ssl` | Enables [lego](https://github.com/jetstack/kube-lego) letsencrypt ssl support - working nginx controller and lego container necessary | false |
| `ingress.htpasswdString` | if specified main web service requires authentication. Requires nginx ingress controller. Format: _user:$apr1$F..._ | _empty_ |
| `ingress.annotations` | specify custom ingress annotations such as e.g. `ingress.kubernetes.io/proxy-body-size` | |
### Wordpress
The LAMP chart offers additional wordpress features during the init stage. It supports two modes, normal mode sets up the chart completely automatic by downloading an InfiniteWP backup from google drive, while the other mode gets executed when in manual mode (see: `init.manually`). While in manual mode, the web files and db backup need to be manually downloaded and stashed in the appropriate folders (`/var/www/html` <-- web root, `/var/www/mysql` <-- sql backup). The automatic mode does this automatically. Both modes then import the backup and do some necesssary config file changes. So even in manual mode it is not necessary to import the db backup.
In development mode everything that gets executed in normal mode will also get executed. Additionally the wordpress domain is automatically search replaced inside the database. Also the `wp_content/uploads` and `wp_content/cache` directories are deleted. The `.htaccess` file is modified to redirect requests to the uploads directory to the uploads directory of `wordpress.domain`.
| Parameter | Description | Default |
| - | - | - |
| `wordpress.enabled` | Enables wordpress normal mode | false |
| `wordpress.gdriveRToken` | gdrive rtoken for authentication used for downloading InfiniteWP backup from gdrive | _empty_ |
| `wordpress.gdriveFolder` | gdrive backup folder - the latest backup inside of the folder where the name includes the string `_full` will be downloaded | `wordpress.domain` |
| `wordpress.domain` | wordpress domain used in dev mode to be search replaced | _empty_ |
| `wordpress.develop.enabled` | enables develop mode | false |
| `wordpress.develop.deleteUploads` | deletes `wp_content/uploads` folder and links to live site within htaccess | false |
| `wordpress.develop.devDomain` | used to search replace `wordpress.domain` to `fullname of template`.`develop.devDomain` e.g `mysite-com-lamp.dev.example.com` | _empty_ |
### Other
| Parameter | Description | Default |
| - | - | - |
| `keepSecrets` | Keep secrets after helm delete | false |
| `replicaCount` | > 1 will corrupt your database if one is used. Future releases might enable elastic scaling via galeradb | 1 |
+17
View File
@@ -0,0 +1,17 @@
mysql:
rootPassword: "Root Password here..."
user: drupal
password: "User Password here..."
database: drupal
php:
repository: drupal
tag: 7-fpm
persistentSubpaths:
- modules
- profiles
- sites
- themes
# copies web root to persistent storage upon creation. remember to disable on subsequent
# upgrades of the chart, otherwise your storage might get overwritten...
copyRoot: true
+6
View File
@@ -0,0 +1,6 @@
mysql:
enabled: false
php:
repository: lead4good/grav
tag: fpm-alpine
+18
View File
@@ -0,0 +1,18 @@
mysql:
rootPassword: "Root Password here..."
user: joomla
password: "User Password here..."
database: joomla
php:
repository: joomla
tag: fpm-php7
envVars:
- name: JOOMLA_DB_HOST
value: localhost
- name: JOOMLA_DB_USER
value: joomla
- name: JOOMLA_DB_PASSWORD
value: "User Password here..."
- name: JOOMLA_DB_DATABASE
value: joomla
+13
View File
@@ -0,0 +1,13 @@
mysql:
rootPassword: "Root Password here..."
user: nextcloud
password: "User Password here..."
database: nextcloud
php:
repository: nextcloud
tag: fpm
persistentSubpaths:
- apps
- config
- data
+9
View File
@@ -0,0 +1,9 @@
mysql:
rootPassword: "Root Password here..."
user: owncloud
password: "User Password here..."
database: owncloud
php:
repository: owncloud
tag: fpm
@@ -0,0 +1,29 @@
# This example deploys a wordpress lamp stack with ingress and ssl enabled.
# Note: for this to work you need to have a working nginx ingress controller
# and a working lego container running on your cluster, as well as `ingress.domain`
# and www.`ingress.domain` pointing to your ingress controllers public IP
mysql:
rootPassword: "Root Password here..."
user: wordpress
password: "User Password here..."
database: wordpress
php:
repository: "wordpress"
tag: "php7.1-fpm"
envVars:
- name: WORDPRESS_DB_HOST
value: localhost
- name: WORDPRESS_DB_USER
value: wordpress
- name: WORDPRESS_DB_PASSWORD
value: "User Password here..."
- name: WORDPRESS_DB_DATABASE
value: wordpress
ingress:
enabled: true
ssl: true
domain: example.com
subdomainWWW: enabled
@@ -0,0 +1,21 @@
mysql:
rootPassword: "Root Password here..."
user: wordpress
password: "User Password here..."
database: wordpress
php:
repository: "wordpress"
tag: "php7.1-fpm"
envVars:
- name: WORDPRESS_DB_HOST
value: localhost
- name: WORDPRESS_DB_USER
value: wordpress
- name: WORDPRESS_DB_PASSWORD
value: "User Password here..."
- name: WORDPRESS_DB_DATABASE
value: wordpress
# List your additional php configurations with 4 spaces indent after " ini: |"
ini: |
short_open_tag=On
+18
View File
@@ -0,0 +1,18 @@
mysql:
rootPassword: "Root Password here..."
user: wordpress
password: "User Password here..."
database: wordpress
php:
repository: "wordpress"
tag: "php7.1-fpm"
envVars:
- name: WORDPRESS_DB_HOST
value: localhost
- name: WORDPRESS_DB_USER
value: wordpress
- name: WORDPRESS_DB_PASSWORD
value: "User Password here..."
- name: WORDPRESS_DB_DATABASE
value: wordpress
@@ -0,0 +1,19 @@
<VirtualHost *:80>
DocumentRoot /var/www/html
Define K8S_ENV
<Directory /var/www/html>
DirectoryIndex index.html index.php
Options +FollowSymLinks
AllowOverride All
Require all granted
<FilesMatch "\.php(/.*)?$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost:9000/"
</If>
</FilesMatch>
</Directory>
</VirtualHost>
+19
View File
@@ -0,0 +1,19 @@
<VirtualHost *:80>
DocumentRoot /var/www/html
Define K8S_ENV
<Directory /var/www/html>
DirectoryIndex index.html index.php
Options +FollowSymLinks
AllowOverride All
Require all granted
<FilesMatch "\.php(/.*)?$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:fcgi://localhost:9000/"
</If>
</FilesMatch>
</Directory>
</VirtualHost>
+543
View File
@@ -0,0 +1,543 @@
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used. If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/usr/local/apache2"
#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule allowmethods_module modules/mod_allowmethods.so
#LoadModule isapi_module modules/mod_isapi.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule macro_module modules/mod_macro.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule bucketeer_module modules/mod_bucketeer.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule echo_module modules/mod_echo.so
#LoadModule example_hooks_module modules/mod_example_hooks.so
#LoadModule case_filter_module modules/mod_case_filter.so
#LoadModule case_filter_in_module modules/mod_case_filter_in.so
#LoadModule example_ipc_module modules/mod_example_ipc.so
#LoadModule buffer_module modules/mod_buffer.so
#LoadModule data_module modules/mod_data.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule request_module modules/mod_request.so
#LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
LoadModule deflate_module modules/mod_deflate.so
#LoadModule xml2enc_module modules/mod_xml2enc.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule mime_module modules/mod_mime.so
#LoadModule ldap_module modules/mod_ldap.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule logio_module modules/mod_logio.so
#LoadModule lua_module modules/mod_lua.so
LoadModule env_module modules/mod_env.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
#LoadModule remoteip_module modules/mod_remoteip.so
LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule optional_hook_export_module modules/mod_optional_hook_export.so
#LoadModule optional_hook_import_module modules/mod_optional_hook_import.so
#LoadModule optional_fn_import_module modules/mod_optional_fn_import.so
#LoadModule optional_fn_export_module modules/mod_optional_fn_export.so
#LoadModule dialup_module modules/mod_dialup.so
#LoadModule http2_module modules/mod_http2.so
#LoadModule proxy_http2_module modules/mod_proxy_http2.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
LoadModule unixd_module modules/mod_unixd.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule info_module modules/mod_info.so
#LoadModule suexec_module modules/mod_suexec.so
<IfModule !mpm_prefork_module>
#LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
#LoadModule cgi_module modules/mod_cgi.so
</IfModule>
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule imagemap_module modules/mod_imagemap.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User xfs
Group xfs
</IfModule>
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin you@example.com
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog /proc/self/fd/2
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
<IfModule log_config_module>
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog /proc/self/fd/1 common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
</IfModule>
<IfModule cgid_module>
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
#Scriptsock cgisock
</IfModule>
#
# "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
#
# Avoid passing HTTP_PROXY environment to CGI's on this or any proxied
# backend servers which have lingering "httpoxy" defects.
# 'Proxy' request header is undefined by the IETF, not listed by IANA
#
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
</IfModule>
#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited
#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
#EnableSendfile on
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.
# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf
# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf
# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf
# Language settings
#Include conf/extra/httpd-languages.conf
# User home directories
#Include conf/extra/httpd-userdir.conf
# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf
# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf
# Various default settings
Include conf/extra/httpd-default.conf
# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
# starting without SSL on platforms with no /dev/random equivalent
# but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
export WEBDIR=/data/web
export DBDIR=/data/db
export CLONEWEBDIR=/clone_data/web
export CLONEDBDIR=/clone_data/db
if [ -n "$(ls -A $WEBDIR)" ]; then
echo "Pod allready initialized, continuing..."
else
xtrabackup -uroot -p"$MYSQL_ROOT_PASSWORD" -H$MYSQL_HOST -h $CLONEDBDIR --backup --target-dir=$DBDIR
if ! [ "$?" -eq 0 ]; then
echo "Failed to generate DB backup, exiting..."
exit 1
fi
xtrabackup --prepare --target-dir=$DBDIR
rsync -avzh $CLONEWEBDIR/ $WEBDIR
if ! [ "$?" -eq 0 ]; then
echo "Failed to clone html files, exiting..."
exit 1
fi
rm "$WEBDIR/db_initialized"
echo "Successfully copied all data."
fi
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
export WEBDIR=/var/www/html
function start_mysql
{
if [ -z "$1" ]; then
PASSWORD="$MYSQL_ROOT_PASSWORD"
else
PASSWORD="$1"
fi
/entrypoint.sh mysqld &
until mysql -uroot -p"$PASSWORD" -e ";"
do
echo "Can't connect to mysql, retrying in 5 seconds."
sleep 5
done
}
function stop_mysql
{
mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown
while ! [ -z "$(ps aux | grep mysqld | grep -v grep)" ]
do
sleep 1
done
}
function init_from_backup
{
#change owner of httpdir
chown -R www-data:www-data /var/www/html
#change owner of mysqldir
chown -R mysql:mysql /var/lib/mysql
start_mysql "$OLD_MYSQL_ROOT_PASSWORD"
mysqladmin -uroot -p"$OLD_MYSQL_ROOT_PASSWORD" password "$MYSQL_ROOT_PASSWORD"
mysql -uroot -p"$OLD_MYSQL_ROOT_PASSWORD" -e "ALTER USER 'root' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD'; flush privileges"
stop_mysql
echo "Successfully prepared mysql backup."
}
if [ -e "$WEBDIR/db_clone_initialized" ]; then
echo "Pod allready initialized, continuing..."
else
init_from_backup
touch "$WEBDIR/db_clone_initialized"
fi
+154
View File
@@ -0,0 +1,154 @@
#!/bin/bash
export WEBDIR=/var/www/html
export MYSQLDIR=/var/www/mysql
function download_backup
{
if [ -z "$GDRIVE_FOLDER" ]; then
export GDRIVE_FOLDER="$WEB_DOMAIN"
fi
FOLDERID="$(gdrive --refresh-token $RTOKEN list -q "name='$GDRIVE_FOLDER'" --no-header | head -n1 | awk '{print $1;}')"
FILELIST="$(gdrive --refresh-token $RTOKEN list -q " '$FOLDERID' in parents" --no-header --name-width 0)"
while read -r line; do
# continue if not full backup
if ! [[ "$line" == *"full_"* ]]; then
continue
fi
FILEID=$(echo "$line" | awk '{print $1;}')
echo "Downloading: $FILEINFO"
gdrive --refresh-token $RTOKEN download $FILEID
if ! [ "$?" -eq 0 ]; then
echo "Failed to download backup file from gdrive, exiting..."
exit_clean
fi
# quit if not part of backup
if ! [[ "$line" == *"part_"* ]]; then
break
fi
done <<< "$FILELIST"
}
function exit_clean
{
exit 1
}
function prepare_iwpbackup
{
cd /var/www
download_backup
echo "Unzipping backup(s) to $WEBDIR"
find . -name '*.zip' | xargs -l unzip -d $WEBDIR
cd $WEBDIR
echo "Getting sql file"
if ! [ 1 == "$(find iwp_db/ -name '*.sql' | grep -c sql)" ]; then
find . -name "*.sql" | awk '{print substr( $0, length($0) - 8, length($0) ),$0}' | sort -n | cut -f2- -d' ' | xargs cat > $MYSQLDIR/backup.sql
else
mv iwp_db/*sql $MYSQLDIR
fi
touch /var/www/html/prepared_db_backup
rm -r iwp_db/
}
function prepare_html
{
echo "Removing any existent svn directories"
find . -name .svn | xargs -n1 rm -rf
echo "Removing php.ini, if exists"
rm -f php.ini
## WP CONFIG ##
#https proxy
if [ "$SSL_ENABLED" == "true" ]; then
sed -i -n 'H;${x;s/require_once.*$/if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) \&\& $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https")\
$_SERVER["HTTPS"] = "on";\
&/;p;}' wp-config.php
fi
#mysql port rather than socket
echo "Replacing strings in config files"
if [ -z $USE_MYSQL_SOCKETS ]; then
sed -i -r "s/'DB_HOST' ?, ?'([^']+)'/'DB_HOST', '127.0.0.1'/g" wp-config.php
else
sed -i -r "s/'DB_HOST' ?, ?'([^']+)'/'DB_HOST', 'localhost'/g" wp-config.php
fi
#hardcoded paths
sed -i s/^.*WPCACHEHOME.*$/define\(\'WPCACHEHOME\',\'\\/var\\/www\\/html\\/wp-content\\/plugins\\/wp-super-cache\\/\'\)\;/g wp-config.php
sed -i s/^\$cache_path.*$/\$cache_path=\'\\/var\\/www\\/html\\/wp-content\\/cache\'\;/g wp-content/wp-cache-config.php
# if ! [ -z "$OLD_HTTP_ROOT" ]; then
# echo "Search and Replacing old http root dir entries"
# grep -lr "$OLD_HTTP_ROOT" . | xargs -l sed -i "s/$(echo ${OLD_HTTP_ROOT//\//\\/})/\/var\/www\/html\//"
# fi
#htaccess
echo "Deleting https rules in htaccess"
cat .htaccess | sed '/First rewrite any request to www with https/,/RewriteRule/ d' | sed '/Force HTTPS/,/RewriteRule/ d' > .htaccess.tmp
mv .htaccess.tmp .htaccess
if ! [ -z "$DEVELOPMENT" ]; then
echo "Removing cache directory"
rm -rf wp-content/cache/
if ! [ -z "$DELETE_UPLOADS" ]; then
echo "Removing uploads directory"
rm -rf wp-content/uploads/
echo "Linking uploads directory to live site"
(echo "#route all access to downloads directory to real site
RewriteRule ^wp-content/uploads/(.*)$ http://www.$WEB_DOMAIN/wp-content/uploads/\$1 [R=302,L]
" && cat .htaccess) > .htaccess.tmp
mv .htaccess.tmp .htaccess
fi
if ! [ -z "$HTACCESS_AUTH" ]; then
echo "Adding .htaccess Authentication"
echo "$HTACCESS_AUTH" > .htpasswd
(echo -e "AuthType Basic\nAuthName \"Authenticate\"\nAuthUserFile /var/www/html/.htpasswd\nRequire valid-user\n" && cat .htaccess) > .htaccess.tmp
mv .htaccess.tmp .htaccess
fi
fi
}
if [ -z "$(ls -A $WEBDIR)" ] || ( [ -n "$MANUAL_INIT" ] && ! [ -e "$WEBDIR/manually_initialized" ] ); then
if ! [ -z "$SVN_ENABLED" ] && [ -z "$ALLOW_OVERWRITE" ]; then
export WEBDIR=/tmp/backup
fi
if [ -z "$MANUAL_INIT" ]; then
prepare_iwpbackup
fi
prepare_html
if [ -n "$MANUAL_INIT" ]; then
touch "$WEBDIR/manually_initialized"
fi
echo "Successfully downloaded and prepared backup image."
elif ! [ -e "$WEBDIR/prepared_db_backup" ] && [ -z "$MANUAL_INIT" ]; then
export WEBDIR=/tmp/backup
mkdir $WEBDIR
prepare_iwpbackup
echo "Successfully downloaded and prepared db backup."
else
echo "Web Dir already initialized, continuing..."
fi
+186
View File
@@ -0,0 +1,186 @@
#!/bin/bash
shopt -s expand_aliases
export WEBDIR=/var/www/html
export MYSQLDIR=/var/www/mysql
alias msql="mysql -uroot -p\"$MYSQL_ROOT_PASSWORD\" -e"
alias wpc="su www-data -s /bin/bash -c"
SQLHEADER=$(cat <<EOF
-- MySQL dump 10.13 Distrib 5.5.52, for debian-linux-gnu (i686)
--
-- Host: localhost Database: xc218_db1
-- ------------------------------------------------------
-- Server version 5.5.52-0+deb7u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
EOF
)
function exit_clean
{
exit 1
}
function start_mysql
{
if [ -z "$1" ]; then
PASSWORD="$MYSQL_ROOT_PASSWORD"
else
PASSWORD="$1"
fi
/entrypoint.sh mysqld &
until mysql -uroot -p"$PASSWORD" -e ";"
do
echo "Can't connect to mysql, retrying in 5 seconds."
sleep 5
done
}
function stop_mysql
{
mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown
while ! [ -z "$(ps aux | grep mysqld | grep -v grep)" ]
do
sleep 1
done
}
function search-replace
{
if ! [ -z "$WEB_DOMAIN" ] && ! [ -z "$WEB_TEST_DOMAIN" ]; then
echo "Search replacing: $WEB_DOMAIN with $WEB_TEST_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables $WEB_DOMAIN $WEB_TEST_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
echo "Search replacing: www.$WEB_TEST_DOMAIN $WEB_TEST_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables www.$WEB_TEST_DOMAIN $WEB_TEST_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
if [ "$SSL_ENABLED" == "true" ]; then
echo "Search replacing: http://$WEB_TEST_DOMAIN with https://$WEB_TEST_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables http://$WEB_TEST_DOMAIN https://$WEB_TEST_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
else
echo "Search replacing: https://$WEB_TEST_DOMAIN with http://$WEB_TEST_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables https://$WEB_TEST_DOMAIN http://$WEB_TEST_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
fi
echo "Search replacing: @$WEB_TEST_DOMAIN with @$WEB_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables @$WEB_TEST_DOMAIN @$WEB_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
fi
return 0
}
function init_from_sql
{
name="$(grep DB_ $WEBDIR/wp-config.php)"
re="define ?\( ?'DB_NAME' ?, ?'([^']+)' ?\);"
if [[ $name =~ $re ]]; then
export MYSQL_DATABASE=${BASH_REMATCH[1]};
else
echo "Could not get DB Name from wp-config.php. Aborting."
exit_clean
fi
re="define ?\( ?'DB_USER' ?, ?'([^']+)' ?\);"
if [[ $name =~ $re ]]; then
export MYSQL_USER=${BASH_REMATCH[1]};
else
echo "Could not get DB User from wp-config.php. Aborting."
exit_clean
fi
re="define ?\( ?'DB_PASSWORD' ?, ?'([^']+)' ?\);"
if [[ $name =~ $re ]]; then
export MYSQL_PASSWORD=${BASH_REMATCH[1]};
else
echo "Could not get DB Password from wp-config.php. Aborting."
exit_clean
fi
start_mysql
LATEST_SQL="$(ls -t $MYSQLDIR/*.sql | head -n1)"
grep "MySQL dump" "$LATEST_SQL" 1>/dev/null
if [ "$?" -eq 1 ]; then
echo "MySQL header missing, adding to sql file..."
(echo "$SQLHEADER" && cat "$LATEST_SQL") > "$LATEST_SQL.tmp"
mv "$LATEST_SQL.tmp" "$LATEST_SQL"
fi
echo "Importing SQL file..."
mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < "$LATEST_SQL"
if ! [ "$?" -eq 0 ]; then
echo "Could not import DB, exiting..."
exit_clean
fi
if ! [ -z "$WEB_TEST_DOMAIN" ]; then
until search-replace
do
echo "Search Replace failed, retrying in 30 seconds"
sleep 30
done
fi
stop_mysql
echo "Successfully imported and prepared backup sql image."
}
function init_from_backup
{
start_mysql
OLD_DOMAIN=$(wpc "wp --path=$WEBDIR option get siteurl" | sed "s/.*\/\/\(.*\)/\1/g")
echo "Search replacing: $OLD_DOMAIN with $WEB_TEST_DOMAIN"
wpc "wp --path=$WEBDIR search-replace --all-tables $OLD_DOMAIN $WEB_TEST_DOMAIN"
if ! [ "$?" -eq 0 ]; then
return 1
fi
stop_mysql
echo "Successfully prepared backup files."
}
if [ -e "$WEBDIR/db_initialized" ]; then
echo "DB allready initialized, continuing..."
else
if [ -z "$CLONE_INIT" ]; then
init_from_sql
elif ! [ -z "$WEB_TEST_DOMAIN" ]; then
init_from_backup
fi
touch "$WEBDIR/db_initialized"
fi
+109
View File
@@ -0,0 +1,109 @@
INIT:
Please wait for all init containers to finish before connecting to
the charts services. This might take a few minutes depending on their
tasks.
{{- if .Values.ingress.enabled }}
INGRESS:
Please make sure that you have an ingress controller instance {{ if .Values.ingress.ssl }}and a lego instance
{{- end -}} running
and that you have configured the A Records of {{ template "lamp.domain" . }} and its
subdomains to point to your ingress controllers ip address.
{{- else }}{{ if contains "LoadBalancer" .Values.service.type }}
LOADBALANCER:
Please wait until the service has been routed to an IP address.
You can watch the status of by running 'kubectl get svc -w {{ template "lamp.fullname" . }}'
{{- end }}
{{- end }}
{{- if .Values.init.manually.enabled }}
MAN:
Connect to the init pod to prepare your web root and database
M.1. Connect to the init pod by executing
kubectl exec -it $(kubectl get pods -l app={{ template "lamp.fullname" . }} --output=jsonpath={.items..metadata.name}) -c init-manually /bin/bash
{{- if .Values.wordpress.enabled }}
M.2. Download your files and prepare your webroot at /var/www/html
M.3. Dowload your DB Backup and stash it in /var/www/mysql
{{- else }}
M.2. Download your files and prepare your webroot at /var/www/html, then
set correct permissions
chown -R 33:33 /var/www/html
M.3. Start the mysql daemon, import your backup and stop the daemon again
/entrypoint.sh mysqld &
mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE < yourbackup.sql
mysqladmin -uroot -p$MYSQL_ROOT_PASSWORD shutdown
{{- end }}
M.4. To stop the container and finish init phase, run
im-done
{{- else }}{{ if .Values.wordpress.enabled }}
WP:
Wordpress features are enabled. Please wait while the init containers finish.
You can watch the logs by running:
kubectl logs $(get pods -l app={{ template "lamp.fullname" . }} -c init-wp
or
kubectl logs $(get pods -l app={{ template "lamp.fullname" . }} -c init-wp-db
{{- end }}
{{- end }}
{{- if .Values.init.clone.release }}
CLONE:
The chart has been started with reference to a clone chart. Please wait while
the persistent storage is copied. You can watch the logs by running:
kubectl logs $(get pods -l app={{ template "lamp.fullname" . }} -c init-clone
or
kubectl logs $(get pods -l app={{ template "lamp.fullname" . }} -c init-db-clone
{{- end }}
1. You can now connect to the following services:
{{- if not .Values.ingress.enabled }}
export CHARTIP=$(kubectl get svc {{ template "lamp.fullname" . }} --output=jsonpath={.status.loadBalancer.ingress..ip})
{{- end }}
Main Site:
{{- if .Values.ingress.enabled }}
http{{ if .Values.ingress.ssl }}s{{ end }}://{{ template "lamp.domain" . }}
{{- else }}
http://$CHARTIP
{{- end }}
{{- if .Values.phpmyadmin.enabled }}
PHPMyAdmin:
{{- if .Values.ingress.enabled }}
http{{ if .Values.ingress.ssl }}s{{ end }}://{{ .Values.phpmyadmin.subdomain }}.{{ template "lamp.domain" . }}
{{- else }}
http://$CHARTIP:{{ .Values.phpmyadmin.port }}
{{- end }}
{{- end }}
{{- if .Values.webdav.enabled }}
WebDAV:
{{- if .Values.ingress.enabled }}
http{{ if .Values.ingress.ssl }}s{{ end }}://{{ .Values.webdav.subdomain }}.{{ template "lamp.domain" . }}
{{- else }}
http://$CHARTIP:{{ .Values.webdav.port }}
{{- end }}
{{- end }}
{{- if .Values.sftp.enabled }}
SFTP:
{{- if .Values.ingress.enabled }}
sftp -P {{ .Values.sftp.nodePort }} {{ .Values.sftp.user }}@ip_of_kubernetes_node
{{- else }}
sftp -P {{ .Values.sftp.port }} {{ .Values.sftp.user }}@$CHARTIP
{{- end }}
{{- end }}
+31
View File
@@ -0,0 +1,31 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "lamp.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "lamp.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Get the domain name of the chart - used for ingress rules
*/}}
{{- define "lamp.domain" -}}
{{- if .Values.wordpress.develop.enabled -}}
{{- required "Please specify a develop domain at .Values.wordpress.develop.devDomain" .Values.wordpress.develop.devDomain | printf "%s.%s" ( include "lamp.fullname" .) -}}
{{- else -}}
{{- if not .Values.ingress.enabled -}}
no_domain_specified
{{- else -}}
{{- required "Please specify an ingress domain at .Values.ingress.domain" .Values.ingress.domain -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,15 @@
{{- if .Values.php.fpmEnabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "lamp.fullname" . }}-httpd
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
data:
{{ (.Files.Glob "files/httpd/httpd.conf").AsConfig | indent 2 }}
{{ (.Files.Glob "files/httpd/httpd-vhosts.conf").AsConfig | indent 2 }}
{{ (.Files.Glob "files/httpd/httpd-vhosts-socket.conf").AsConfig | indent 2 }}
{{- end }}
+20
View File
@@ -0,0 +1,20 @@
{{- if or .Values.init.clone.release .Values.wordpress.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{template "lamp.fullname" .}}-init
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
data:
{{- if .Values.init.clone.release }}
{{ (.Files.Glob "files/init/init_clone.sh").AsConfig | indent 2 }}
{{ (.Files.Glob "files/init/init_db_clone.sh").AsConfig | indent 2 }}
{{- end }}
{{- if .Values.wordpress.enabled }}
{{ (.Files.Glob "files/init/init_wp.sh").AsConfig | indent 2 }}
{{ (.Files.Glob "files/init/init_wp_db.sh").AsConfig | indent 2 }}
{{- end }}
{{- end }}
+28
View File
@@ -0,0 +1,28 @@
{{- if or .Values.mysql.sockets ( or .Values.php.fpmEnabled .Values.php.ini ) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{template "lamp.fullname" .}}-php
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
data:
additional.ini: |
{{- if .Values.php.ini }}
{{ .Values.php.ini | indent 4 }}
{{- end }}
{{- if .Values.mysql.sockets }}
mysqli.default_socket=/var/run/mysqld/mysqld.sock
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock
{{- end }}
{{- if .Values.php.fpmEnabled }}
zz-docker.conf: |
[global]
daemonize = no
[www]
listen = /var/run/php/php-fpm.sock
listen.mode = 0666
{{- end }}
{{- end }}
+730
View File
@@ -0,0 +1,730 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "lamp.fullname" . }}
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "lamp.name" . }}
release: {{ .Release.Name }}
spec:
initContainers:
- name: "init-chown-mysql"
image: "busybox"
command: ["chown", "-R", "999:999", "/tmp/mysqld"]
volumeMounts:
- name: sockets
mountPath: /tmp/mysqld
subPath: mysqld
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
- name: "init-chown-data"
image: "busybox"
command: ["sh", "-c", "chown -R 33:33 /data/web"]
volumeMounts:
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /data/web/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
mountPath: /data/web
subPath: web
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- if .Values.php.copyRoot}}
- name: "copy-root"
image: "{{ .Values.php.repository }}:{{ .Values.php.tag }}"
imagePullPolicy: "Always"
command: ["/bin/bash", "-c", "cp -ua /var/www/html/* /data/web/ && cp -ua /var/www/html/.[^.]* /data/web/ && chown 33:33 -R /data/web/"]
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /data/web/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /data/web
subPath: web
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if and .Values.php.fpmEnabled .Values.php.sockets }}
- name: "init-chown-php"
image: "busybox"
command: ["chown", "-R", "33:33", "/tmp/php"]
volumeMounts:
- name: sockets
mountPath: /tmp/php
subPath: php
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
{{- if .Values.init.clone.release }}
- name: "init-clone"
image: "lead4good/xtrabackup"
imagePullPolicy: "Always"
command: ["sh", "/init/init_clone.sh"]
volumeMounts:
- name: httpd-data
mountPath: /data
- name: clone-data
mountPath: /clone_data
- name: init
mountPath: /init
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.init.clone.release }}
key: mysql-root-password
- name: MYSQL_HOST
value: {{ .Values.init.clone.release }}
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
- name: "init-db-clone"
image: "{{ .Values.mysql.repository }}:{{ .Values.mysql.tag }}"
imagePullPolicy: {{ .Values.mysql.pullPolicy }}
command: ["bash", "/init/init_db_clone.sh"]
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
- name: httpd-data
mountPath: /var/lib/mysql
subPath: db
- name: init
mountPath: /init
env:
- name: OLD_MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.init.clone.release }}
key: mysql-root-password
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-root-password
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
{{- if .Values.init.manually.enabled }}
- name: init-manually
image: {{ .Values.init.manually.repository }}:{{ .Values.init.manually.tag }}
imagePullPolicy: {{ .Values.init.manually.pullPolicy }}
command: ["bash", "-c", "if [ -z $(ls -A /var/www/html) ]; then echo -e \"touch /done\" > /bin/im-done && chmod +x /bin/im-done && while ! [ -e /done ]; do sleep 5; done; fi"]
volumeMounts:
{{- if or .Values.mysql.sockets .Values.php.ini }}
- name: configmap-php
mountPath: /etc/php5/cli/conf.d/additional.ini
subPath: additional.ini
{{- end }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
{{- if .Values.php.oldHTTPRoot }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: {{ .Values.php.oldHTTPRoot }}/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: {{ .Values.php.oldHTTPRoot }}
subPath: web
{{- end }}
- name: httpd-data
mountPath: /var/www/mysql
subPath: mysql
- name: httpd-data
mountPath: /var/lib/mysql
subPath: db
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-root-password
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
{{- if .Values.wordpress.enabled }}
{{- if not .Values.init.clone.release }}
- name: init-wp
image: lead4good/init-wp
imagePullPolicy: Always
command: ["bash", "-c", "chown -R www-data:www-data /var/www/ && su -s /bin/bash -c \"bash /init/init_wp.sh\" www-data"]
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
- name: httpd-data
mountPath: /var/www/mysql
subPath: mysql
- name: init
mountPath: /init
env:
{{- if .Values.wordpress.develop.delete_uploads }}
- name: DELETE_UPLOADS
value: "1"
{{- end }}
{{- if .Values.svn.enabled }}
- name: SVN_ENABLED
value: "1"
{{- end }}
{{- if .Values.mysql.sockets }}
- name: USE_MYSQL_SOCKETS
value: "1"
{{- end }}
{{- if and .Values.ingress.htpasswdString ( not .Values.ingress.enabled ) }}
- name: HTACCESS_AUTH
value: {{ .Values.htpasswdString }}
{{- end }}
{{- if .Values.svn.allowOverwrite }}
- name: ALLOW_OVERWRITE
value: "true"
{{- end }}
{{- if .Values.ingress.ssl }}
- name: SSL_ENABLED
value: "true"
{{- end }}
{{- if .Values.init.manually.enabled }}
- name: MANUAL_INIT
value: "true"
{{- end }}
{{- if .Values.wordpress.develop.enabled }}
- name: DEVELOPMENT
value: "true"
{{- end }}
- name: GDRIVE_FOLDER
{{- if .Values.wordpress.gdriveFolder }}
value: {{ .Values.wordpress.gdriveFolder }}
{{- else }}
value: {{ required "Please specify the domain of the wordpress backup at .Values.wordpress.domain" .Values.wordpress.domain }}
{{- end }}
- name: RTOKEN
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: gdrive-rtoken
- name: WEB_DOMAIN
value: {{ required "Please specify the domain of the wordpress backup at .Values.wordpress.domain" .Values.wordpress.domain }}
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
- name: init-wp-db
image: lead4good/init-wp
imagePullPolicy: Always
command: ["bash", "-c", "bash /init/init_wp_db.sh"]
volumeMounts:
{{- if or .Values.mysql.sockets .Values.php.ini }}
- name: configmap-php
mountPath: /etc/php5/cli/conf.d/additional.ini
subPath: "additional.ini"
{{- end }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
{{- if .Values.php.oldHTTPRoot }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: {{ .Values.php.oldHTTPRoot }}/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: {{ .Values.php.oldHTTPRoot }}
subPath: web
{{- end }}
- name: httpd-data
mountPath: /var/www/mysql
subPath: mysql
- name: httpd-data
mountPath: /var/lib/mysql
subPath: db
- name: init
mountPath: /init
env:
{{- if .Values.wordpress.develop.enabled }}
- name: WEB_TEST_DOMAIN
value: {{ template "lamp.domain" . }}
- name: WEB_DOMAIN
value: {{ required "Please specify the domain of the wordpress backup at .Values.wordpress.domain" .Values.wordpress.domain }}
{{- end }}
{{ if .Values.ingress.ssl }}
- name: SSL_ENABLED
value: "true"
{{- end }}
{{- if .Values.init.clone.release }}
- name: CLONE_INIT
value: "true"
{{- end }}
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-root-password
resources:
{{- if .Values.init.resources }}
{{ toYaml .Values.init.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
containers:
{{- if .Values.php.fpmEnabled }}
- name: "httpd"
image: "httpd:2.4-alpine"
imagePullPolicy: "Always"
ports:
- containerPort: 80
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
{{- if .Values.php.sockets }}
- mountPath: /var/run/php
name: sockets
subPath: php
{{- end }}
- mountPath: /usr/local/apache2/conf/extra/httpd-vhosts.conf
name: httpd-config
subPath: httpd-vhosts{{ if .Values.php.sockets }}-socket{{ end }}.conf
- mountPath: /usr/local/apache2/conf/httpd.conf
name: httpd-config
subPath: httpd.conf
resources:
{{- if .Values.httpd.resources }}
{{ toYaml .Values.httpd.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
- name: "php"
{{- if .Values.php.repository }}
image: "{{ .Values.php.repository }}:{{ .Values.php.tag }}"
{{- else }}
image: "php:{{ .Values.php.version }}-fpm"
{{- end }}
{{- if not .Values.php.sockets }}
ports:
- containerPort: 9000
{{- end }}
{{- else }}
- name: "httpdphp"
{{- if .Values.php.repository }}
image: "{{ .Values.php.repository }}:{{ .Values.php.tag }}"
{{- else }}
image: "php:{{ .Values.php.version }}-apache"
{{- end }}
ports:
- containerPort: 80
{{- end }}
imagePullPolicy: {{ .Values.php.pullPolicy }}
{{- if .Values.php.envVars }}
env:
{{ toYaml .Values.php.envVars | indent 8 }}
{{- end }}
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/html/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www/html
subPath: web
- name: httpd-data
mountPath: /var/www/mysql
subPath: mysql
{{- if .Values.php.oldHTTPRoot }}
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: {{ .Values.php.oldHTTPRoot }}/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: {{ .Values.php.oldHTTPRoot }}
subPath: web
{{- end }}
{{- if and .Values.php.fpmEnabled .Values.php.sockets }}
- mountPath: /var/run/php
name: sockets
subPath: php
- mountPath: /usr/local/etc/php-fpm.d/zz-docker.conf
name: configmap-php
subPath: zz-docker.conf
{{- end }}
{{- if .Values.mysql.sockets }}
- mountPath: /var/run/mysqld
name: sockets
subPath: mysqld
{{- end }}
{{- if or .Values.php.ini .Values.mysql.sockets }}
- name: configmap-php
mountPath: /usr/local/etc/php/conf.d/additional.ini
subPath: additional.ini
{{- end }}
resources:
{{- if .Values.php.resources }}
{{ toYaml .Values.php.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- if .Values.mysql.rootPassword }}
- name: "mysql"
image: "{{ .Values.mysql.repository }}:{{ .Values.mysql.tag }}"
imagePullPolicy: {{ .Values.mysql.pullPolicy }}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-root-password
{{- if and .Values.mysql.user .Values.mysql.password }}
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-password
{{- if .Values.mysql.database }}
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: mysql-database
{{- end }}
{{- end }}
volumeMounts:
- name: httpd-data
mountPath: /var/lib/mysql
subPath: db
{{- if .Values.mysql.sockets }}
- mountPath: /var/run/mysqld
name: sockets
subPath: mysqld
{{- end }}
resources:
{{- if .Values.mysql.resources }}
{{ toYaml .Values.mysql.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
{{ if .Values.sftp.enabled }}
- name: sftp
image: atmoz/sftp
command: [/bin/bash, -c, "bash /entrypoint $SFTP_USER:$SFTP_PASSWORD:33:33:web"]
ports:
- containerPort: 22
env:
- name: SFTP_USER
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: sftp-user
- name: SFTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: sftp-password
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /home/{{ .Values.sftp.user }}/web/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /home/{{ .Values.sftp.user }}/web
subPath: web
resources:
{{- if .Values.sftp.resources }}
{{ toYaml .Values.sftp.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{ end }}
{{ if .Values.webdav.enabled }}
- name: webdav
image: lead4good/webdav
command: [/bin/bash, -c, "sed -i s/80/8001/g /etc/nginx/sites-enabled/webdav-site.conf && /set_htpasswd.sh && nginx -g \"daemon off;\""]
env:
- name: WEBDAV_USERNAME
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: webdav-user
- name: WEBDAV_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: webdav-password
ports:
- containerPort: 8001
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /var/www/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /var/www
subPath: web
resources:
{{- if .Values.svn.resources }}
{{ toYaml .Values.svn.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{ end }}
{{ if .Values.git.enabled }}
- name: git
image: openweb/git-sync
command: [/bin/bash, -c, "chown www-data:www-data /git/ && su -s /bin/bash -c '/go/bin/git-sync' www-data"]
env:
- name: GIT_SYNC_REPO
value: {{ required "Please specify the GIT repository at .Values.git.repoURL" .Values.git.repoURL }}
- name: GIT_SYNC_BRANCH
value: {{ .Values.git.branch }}
- name: GIT_SYNC_REV
value: {{ .Values.git.revision }}
- name: GIT_SYNC_WAIT
value: {{ .Values.git.wait }}
- name: GIT_SYNC_DEST
value: /git
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /git/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /git
subPath: web
resources:
{{- if .Values.git.resources }}
{{ toYaml .Values.git.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{ end }}
{{ if .Values.svn.enabled }}
- name: svn
image: lead4good/svn-sync
command: [/bin/sh, -c, "chown xfs:xfs /svn/ && su -s /bin/sh -c '/bin/sh /entrypoint.sh /sync.sh' xfs"]
env:
- name: SYNC_USER
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: svn-user
- name: SYNC_PASS
valueFrom:
secretKeyRef:
name: {{ template "lamp.fullname" . }}
key: svn-password
- name: SYNC_URL
value: {{required "Please specify the SVN repository at .Values.svn.repoURL" .Values.svn.repoURL }}
{{ if .Values.svn.allowOverwrite }}
- name: ALLOW_OVERWRITE
value: "true"
{{- end }}
volumeMounts:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
{{- range $subPath := .Values.php.persistentSubpaths }}
- name: httpd-data
mountPath: /svn/{{ $subPath }}
subPath: {{ $subPath }}
{{- end }}
- name: httpd-data-nonpersistent
{{- else }}
- name: httpd-data
{{- end }}
mountPath: /svn
subPath: web
resources:
{{- if .Values.svn.resources }}
{{ toYaml .Values.svn.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{ end }}
{{ if .Values.phpmyadmin.enabled }}
- image: phpmyadmin/phpmyadmin
name: phpmyadmin
command: [sh, -c, sed -i 's/listen\ 80/listen 8080/g' /etc/nginx.conf && /run.sh phpmyadmin]
env:
- name: PMA_HOST
value: 127.0.0.1
ports:
- {containerPort: 8080}
resources:
{{- if .Values.phpmyadmin.resources }}
{{ toYaml .Values.phpmyadmin.resources | indent 12 }}
{{- else }}
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{ end }}
volumes:
{{- if and .Values.php.persistentSubpaths (or .Values.persistence.hostPath .Values.persistence.enabled)}}
- name: httpd-data-nonpersistent
emptyDir: {}
{{- end }}
- name: httpd-data
{{- if .Values.persistence.hostPath }}
hostPath:
path: {{ .Values.persistence.hostPath }}
{{- else }}{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "lamp.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if or .Values.mysql.sockets .Values.php.sockets }}
- name: sockets
emptyDir: {}
{{- end }}
{{- if or .Values.mysql.sockets ( or ( and .Values.php.fpmEnabled .Values.php.sockets) .Values.php.ini ) }}
- configMap: {name: {{template "lamp.fullname" .}}-php }
name: configmap-php
{{- end }}
{{- if or .Values.init.clone.release .Values.wordpress.enabled }}
- configMap: {name: {{template "lamp.fullname" .}}-init }
name: init
{{- end }}
{{- if .Values.php.fpmEnabled }}
- configMap: {name: {{template "lamp.fullname" .}}-httpd }
name: httpd-config
{{- end }}
{{- if .Values.init.clone.release }}
- name: clone-data
{{- if .Values.init.clone.hostPath }}
hostPath:
path: {{ .Values.init.clone.hostPath }}
{{- else }}
persistentVolumeClaim:
claimName: {{ .Values.init.clone.release }}
{{- end }}
{{- end }}
@@ -0,0 +1,42 @@
{{- if and .Values.ingress.enabled (or .Values.phpmyadmin.enabled .Values.webdav.enabled) }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "lamp.fullname" . }}-service
annotations:
{{- if .Values.ingress.ssl }}
kubernetes.io/tls-acme: "true"
{{- end }}
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
{{- if .Values.ingress.ssl }}
tls:
- secretName: {{ template "lamp.fullname" . }}-tls-service
hosts:
{{- if .Values.phpmyadmin.enabled }}
- {{ .Values.phpmyadmin.subdomain }}.{{ template "lamp.domain" . }}
{{- end }}
{{- if .Values.webdav.enabled }}
- {{ .Values.webdav.subdomain }}.{{ template "lamp.domain" . }}
{{- end }}
{{- end }}
rules:
{{- if .Values.phpmyadmin.enabled }}
- host: {{ .Values.phpmyadmin.subdomain }}.{{ template "lamp.domain" . }}
http:
paths:
- path: /
backend:
serviceName: {{ template "lamp.fullname" . }}
servicePort: {{ .Values.phpmyadmin.port }}
{{- end }}
{{- if .Values.webdav.enabled }}
- host: {{ .Values.webdav.subdomain }}.{{ template "lamp.domain" . }}
http:
paths:
- path: /
backend:
serviceName: {{ template "lamp.fullname" . }}
servicePort: {{ .Values.webdav.port }}
{{- end }}
{{- end }}
+31
View File
@@ -0,0 +1,31 @@
{{- if and .Values.ingress.enabled .Values.ingress.subdomainWWW }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "lamp.fullname" . }}-www
annotations:
{{- if .Values.ingress.ssl }}
kubernetes.io/tls-acme: "true"
{{- end }}
{{- if .Values.ingress.htpasswdString }}
ingress.kubernetes.io/auth-type: basic
ingress.kubernetes.io/auth-secret: {{ template "lamp.fullname" . }}
ingress.kubernetes.io/auth-realm: "Authenticate"
{{- end }}
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
{{- if .Values.ingress.ssl }}
tls:
- secretName: {{ template "lamp.fullname" . }}-tls-www
hosts:
- www.{{ template "lamp.domain" . }}
{{- end }}
rules:
- host: www.{{ template "lamp.domain" . }}
http:
paths:
- path: /
backend:
serviceName: {{ template "lamp.fullname" . }}
servicePort: {{ .Values.service.HTTPPort }}
{{- end }}
+35
View File
@@ -0,0 +1,35 @@
{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "lamp.fullname" . }}-app
annotations:
{{- if .Values.ingress.ssl }}
kubernetes.io/tls-acme: "true"
{{- end }}
{{- if .Values.ingress.htpasswdString }}
ingress.kubernetes.io/auth-type: basic
ingress.kubernetes.io/auth-secret: {{ template "lamp.fullname" . }}
ingress.kubernetes.io/auth-realm: "Authenticate"
{{- end }}
{{- if .Values.ingress.subdomainWWW }}
ingress.kubernetes.io/configuration-snippet: |
rewrite ^(.*)$ $scheme://www.{{ template "lamp.domain" . }}$1;
{{- end }}
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
{{- if .Values.ingress.ssl }}
tls:
- secretName: {{ template "lamp.fullname" . }}-tls-app
hosts:
- {{ template "lamp.domain" . }}
{{- end }}
rules:
- host: {{ template "lamp.domain" . }}
http:
paths:
- path: /
backend:
serviceName: {{ template "lamp.fullname" . }}
servicePort: {{ .Values.service.HTTPPort }}
{{- end }}
+27
View File
@@ -0,0 +1,27 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.hostPath) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "lamp.fullname" . }}
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.persistence.keep }}
helm.sh/resource-policy: keep
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end -}}
+43
View File
@@ -0,0 +1,43 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "lamp.fullname" . }}
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.keepSecrets }}
annotations:
helm.sh/resource-policy: keep
{{- end }}
type: Opaque
data:
{{- if .Values.mysql.rootPassword }}
mysql-root-password: {{ .Values.mysql.rootPassword | b64enc | quote }}
{{- if and .Values.mysql.user .Values.mysql.password }}
mysql-user: {{ .Values.mysql.user | b64enc | quote }}
mysql-password: {{ .Values.mysql.password | b64enc | quote }}
{{- if .Values.mysql.database}}
mysql-database: {{ .Values.mysql.database | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.wordpress.gdriveRToken }}
gdrive-rtoken: {{ .Values.wordpress.gdriveRToken | b64enc | quote }}
{{- end }}
{{- if .Values.ingress.htpasswdString }}
auth: {{ .Values.ingress.htpasswdString | b64enc | quote }}
{{- end }}
{{- if .Values.sftp.enabled }}
sftp-user: {{ required "Please specify the SFTP user name at .Values.sftp.user" .Values.sftp.user | b64enc | quote }}
sftp-password: {{ required "Please specify the SFTP user password at .Values.sftp.password" .Values.sftp.password | b64enc | quote }}
{{- end }}
{{- if .Values.svn.enabled }}
svn-user: {{ required "Please specify the SVN user name at .Values.svn.user" .Values.svn.user | b64enc | quote }}
svn-password: {{ required "Please specify the SVN user password at .Values.svn.password" .Values.svn.password | b64enc | quote }}
{{- end }}
{{- if .Values.webdav.enabled }}
webdav-user: {{ required "Please specify the WebDAV user name at .Values.webdav.user" .Values.webdav.user | b64enc | quote }}
webdav-password: {{ required "Please specify the WebDAV user password at .Values.webdav.password" .Values.webdav.password | b64enc | quote }}
{{- end }}
+24
View File
@@ -0,0 +1,24 @@
{{- if and .Values.sftp.enabled .Values.ingress.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "lamp.fullname" . }}-sftp
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
type: NodePort
ports:
- targetPort: 22
port: {{ .Values.sftp.port }}
{{- if .Values.sftp.nodePort }}
nodePort: {{ .Values.sftp.nodePort }}
{{- end }}
protocol: TCP
name: sftp
selector:
app: {{ template "lamp.name" . }}
release: {{ .Release.Name }}
{{- end -}}
+47
View File
@@ -0,0 +1,47 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "lamp.fullname" . }}
labels:
app: {{ template "lamp.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
{{- if .Values.ingress.enabled }}
type: ClusterIP
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
ports:
- port: {{ .Values.service.HTTPPort }}
targetPort: 80
protocol: TCP
name: httpd
{{ if .Values.mysql.rootPassword }}
- port: 3306
targetPort: 3306
protocol: TCP
name: mysql
{{ end }}
{{ if and .Values.sftp.enabled (not .Values.ingress.enabled) }}
- port: {{ .Values.sftp.port }}
targetPort: 22
protocol: TCP
name: sftp
{{ end }}
{{ if .Values.webdav.enabled }}
- port: {{ .Values.webdav.port }}
targetPort: 8001
protocol: TCP
name: webdav
{{ end }}
{{ if .Values.phpmyadmin.enabled }}
- port: {{ .Values.phpmyadmin.port }}
targetPort: 8080
protocol: TCP
name: phpmyadmin
{{ end }}
selector:
app: {{ template "lamp.name" . }}
release: {{ .Release.Name }}
+339
View File
@@ -0,0 +1,339 @@
### CONTAINERS ###
init:
clone:
## init.clone.release Fullname of the release to clone
release: false
## init.clone.hostPath If the release to clone uses hostPath instead of PVC, set
## it here. This will only work if both releases are deployed on the same node
# hostPath: /path/to/volume
manually:
## init.manually.enabled Enables container for manual initialization
enabled: false
## init.manually.repository Containers repository
repository: lead4good/init-wp
## init.manually.tag Repository tag
tag: latest
## init.manually.pullPolicy Image pull policy
pullPolicy: Always
## init.resources init containers resource requests/limits
resources: false
php:
## php.version default php repository version, you can specify a differnt version like 5 or 7.0
version: "7"
## php.repository If not empty, repository is chosen over default php repo
# repository: php
## php.tag Repository tag
# tag: fpm
## php.pullPolicy Image pull policy
pullPolicy: Always
## php.fpmEnabled Enables docker FPM repository, be sure to disable if working with
## a custom repository based on the apache tag
fpmEnabled: true
## php.sockets If FPM is enabled, enables communication between HTTPD and PHP via
## sockets instead of TCP
sockets: true
## php.oldHTTPRoot Additionaly mounts the webroot at `php.oldHTTPRoot` to compansate
## for absolute path file links
# oldHTTPRoot: /var/www/html
## php.ini additional PHP config values, see examples on how to use
# ini: |
# short_open_tag=On
## php.copyRoot if true, copies the containers web root `/var/www/html` into
copyRoot: false
## persistent storage. This must be enabled, if the container already comes with
## files installed to `/var/www/html`
## php.persistentSubpaths instead of enabling persistence for the whole webroot,
## only subpaths of webroot can be enabled for persistence. Have a look at the
## github.com/kubernetes/charts/stable/lamp/examples/nextcloud.yaml to see how it works
persistentSubpaths: false
# persistentSubpaths:
# - subPath1
# - subPath2
## php.resources PHP container resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
httpd:
## httpd.resources HTTPD container resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
mysql:
## mysql.rootPassword Sets the MySQL root password, enables MySQL service if not empty
# rootPassword: root_password
## mysql.user MySQL user
# user: user
## mysql.password MySQL user password
# password: user_password
## mysql.database MySQL user database
# database: database
## mysql.repository MySQL repository - choose one of the official images
## [mysql](https://hub.docker.com/_/mysql/)
## [mariadb](https://hub.docker.com/_/mariadb/)
## [percona](https://hub.docker.com/_/percona/)
repository: mysql
## mysql.tag Repository tag
tag: 5.7
## mysql.imagePullPolicy Image pull policy
imagePullPolicy: Always
## mysql.sockets Enables communication between MySQL and PHP via sockets instead of TCP
sockets: true
## mysql.resources Resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
sftp:
## sftp.enabled Enables sftp service
enabled: false
## sftp.port Port to advertise service in LoadBalancer mode
port: 22
## sftp.nodePort Port to advertise service in Ingress mode
# nodePort: 30111
## sftp.user SFTP User
# user: user
## sftp.password SFTP Password
# password: password
## sftp.resources resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
webdav:
## webdav.enabled Enables webdav service
enabled: false
## webdav.port Port to advertise service in LoadBalancer mode
port: 8001
## webdav.subdomain Subdomain to advertise service on if ingress is enabled
subdomain: webdav
## webdav.user WebDAV User
# user:
## webdav.password WebDAV Password
# password:
## webdav.resources resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
git:
## git.enabled Enables Git service
enabled: false
## git.repoURL Git Repository URL
# repoURL:
## git.branch Repository branch to sync
branch: master
## git.revision Revision to sync
revision: FETCH_HEAD
## git.wait Time between Git syncs
wait: 30
## git.resources resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
svn:
## svn.enabled Enables svn service
enabled: false
## svn.user SVN User
# user: user
## svn.password SVN Password
# password: password
## svn.repoURL SVN Repository URL
# repoURL:
## svn.allowOverwrite if disabled and files already exist in the web folder will
## not create working clone or sync files
allowOverwrite: true
## svn.resources resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
phpmyadmin:
## phpmyadmin.enabled Enables phpmyadmin service
enabled: false
## phpmyadmin.port Port to advertise service in LoadBalancer mode
port: 8080
## phpmyadmin.subdomain Subdomain to advertise service on if ingress is enabled
subdomain: phpmyadmin
## phpmyadmin.resources resource requests/limits
resources: false
# requests:
# cpu: 1m
# memory: 1Mi
resources:
requests:
## resources.requests.cpu CPU resource requests
cpu: 1m
## resources.requests.memory Memory resource requests
memory: 1Mi
# limits:
## resources.limits.cpu CPU resource limits
# cpu: 1000m
## resources.limits.memory Memory resource limits
# memory: 1024Mi
### STORAGE ###
persistence:
## persistence.enabled Enables persistent volume - PV provisioner support necessary
enabled: true
## persistence.keep Keep persistent volume after helm delete
keep: false
## persistence.accessMode PVC Access Mode
accessMode: ReadWriteOnce
## persistence.size PVC Size
size: 5Gi
## persistence.storageClass PVC Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
## persistence.hostPath if specified, used as persistent storage instead of PVC
# hostPath: /path/to/volume
### NETWORKING ###
service:
## service.type Changes to ClusterIP automatically if ingress enabled
type: LoadBalancer
## service.HTTPPort Port to advertise the main web service in LoadBalancer mode
HTTPPort: 80
ingress:
## ingress.enabled Enables ingress support - working ingress controller necessary
enabled: false
## ingress.domain domain to advertise the services - A records need to point to
## ingress controllers IP
# domain: example.com
## ingress.subdomainWWW enables www subdomain and 301 redirect from domain
## > NOTE: Requires nginx ingress controller
# subdomainWWW: false
## ingress.ssl Enables [lego](https://github.com/jetstack/kube-lego) letsencrypt
## ssl support - working lego container necessary
## > NOTE: Requires nginx ingress controller
# ssl: false
## ingress.htpasswdString if specified main web service requires authentication.
## Format: _user:$apr1$F..._
## > NOTE: Requires nginx ingress controller
# htpasswdString: "user:$apr1$FfVI2PRr$f9MW8rsr5RmmxbdV0Iipk1"
## ingress.annotations specify custom ingress annotations such as e.g.
# annotations:
# ingress.kubernetes.io/proxy-body-size: "50m"
# kubernetes.io/ingress.class: nginx
### WORDPRESS ###
wordpress:
## wordpress.enabled Enables wordpress normal mode
enabled: false
## wordpress.gdriveRToken gdrive rtoken for authentication used for downloading
## InfiniteWP backup from gdrive
# gdriveRToken:
## wordpress.gdriveFolder gdrive backup folder - the latest backup inside of the
## folder where the name includes the string `_full` will be downloaded
# gdriveFolder: example.com
## wordpress.domain wordpress domain used in dev mode to be search replaced
# domain: "example.com"
develop:
## wordpress.develop.enabled enables develop mode
enabled: false
## wordpress.develop.deleteUploads deletes `wp_content/uploads` folder and links
## to live site within htaccess
deleteUploads: false
## wordpress.develop.devDomain used to search replace `wordpress.domain` to
## `fullname of template`.`develop.devDomain` e.g `mysite-com-lamp.dev.example.com`
# devDomain: dev.example.com
### OTHER ###
## keepSecrets Keep secrets after helm delete
keepSecrets: false
## replicaCount > 1 will corrupt your database if one is used. Future releases
## might enable elastic scaling via galeradb
replicaCount: 1