added init container (installation / update)... (#2)

- added memcached container (currently develop branch needed)
- put all zammad services in one kubernetes pod to be able to use empty dir volume for tmp
- switched to kubernetes deployments
- switched to ReadWriteOnce kubernetes volume claims
- added init container to elasticsearch & zammad kubernetes deployments
- added IMAGE_REPO var for docker compose to .env file
- run nginx from zammad container (preparation for stateless updates)
- removed docker-compose-build.yml
- use private docker repos in compose & kubernetes
- change compose volume names
This commit is contained in:
André Bauer 2017-11-26 21:25:57 +01:00 committed by GitHub
parent fe319eb46f
commit ce696bad8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 453 additions and 420 deletions

3
.env
View File

@ -1,3 +1,4 @@
# don't forget to add the minus before the version
# it should look like: VERSION=-2.1.0-13
# example: VERSION=-2.1.0-13
IMAGE_REPO=monotek/zammad-docker-compose
VERSION=

View File

@ -15,7 +15,9 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# docker init
USER root
COPY containers/zammad-memcached/docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
USER memcache
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zammad-memcached"]

View File

@ -1,7 +1,9 @@
#!/bin/bash
#!/bin/sh
set -e
if [ "$1" = 'zammad-memcached' ]; then
echo "starting memcached..."
exec memcached -m ${MEMCACHED_SIZE}
fi

View File

@ -1,8 +1,8 @@
FROM cpuguy83/nfs-server
MAINTAINER Zanmmad <info@zammad.org>
ENV NFS_DIR /mnt/zammad
ENV TMPFS_SIZE 1G
ENV NFS_DIR /exports
ENV TMPFS_SIZE 256M
LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.name="Zammad" \

View File

@ -3,14 +3,17 @@
set -e
if [ "$1" = 'zammad-nfs' ]; then
echo "create & mount tmpfs"
mkdir -p ${NFS_DIR}
chmod 777 ${NFS_DIR}
mount -t tmpfs -o size=${TMPFS_SIZE} none ${NFS_DIR}
echo "creating nfs dir"
test -d ${NFS_DIR}/data || mkdir -p ${NFS_DIR}/data
test -d ${NFS_DIR}/uploads || mkdir -p ${NFS_DIR}/uploads
chmod -R 777 ${NFS_DIR}
echo "create nfs exports"
echo "# NFS Export for Zammad" > /etc/exports
echo "${NFS_DIR} *(rw,sync,no_subtree_check,fsid=0,no_root_squash)" >> /etc/exports
echo "${NFS_DIR}/data *(rw,sync,no_subtree_check,no_root_squash)" >> /etc/exports
echo "${NFS_DIR}/uploads *(rw,sync,no_subtree_check,no_root_squash)" >> /etc/exports
exec runsvdir /etc/sv
fi

View File

@ -4,7 +4,7 @@ ARG BUILD_DATE
ENV BACKUP_SLEEP 86400
ENV HOLD_DAYS 10
ENV ZAMMAD_DIR /home/zammad
ENV ZAMMAD_DIR /opt/zammad
ENV BACKUP_DIR /var/tmp/zammad
LABEL org.label-schema.build-date="$BUILD_DATE" \

View File

@ -3,10 +3,9 @@
set -e
function check_railsserver_available {
# wait for zammad process coming up
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
echo "backup waiting for zammads railsserver to be ready..."
sleep 2
echo "waiting for railsserver to be ready..."
sleep 60
done
}

View File

@ -2,14 +2,15 @@ FROM ruby:2.4.1-slim
MAINTAINER Zammad <info@zammad.org>
ARG BUILD_DATE
ENV ZAMMAD_DIR /home/zammad
ENV ZAMMAD_DIR /opt/zammad
ENV ZAMMAD_TMP_DIR /tmp/zammad
ENV ZAMMAD_USER zammad
ENV RAILS_ENV production
ENV RAILS_SERVER puma
ENV GIT_URL https://github.com/zammad/zammad.git
ENV GIT_BRANCH stable
ENV GIT_BRANCH develop
ENV GOSU_VERSION 1.10
ENV ZAMMAD_READY_FILE tmp/zammad.ready
LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.name="Zammad" \
@ -23,7 +24,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# install dependencies, GOSU & zammad
RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev nfs-common rsync" \
RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev nfs-common nginx rsync" \
GOSU_DEPENDENCIES="ca-certificates wget" \
set -ex \
&& apt-get update && apt-get install -y --force-yes --no-install-recommends ${BUILD_DEPENDENCIES} ${GOSU_DEPENDENCIES} && rm -rf /var/lib/apt/lists/* \
@ -45,6 +46,7 @@ RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev nfs-comm
&& bundle exec rake assets:precompile \
&& sed -e 's#.*adapter: postgresql# adapter: postgresql#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < config/database.yml.pkgr > config/database.yml \
&& rm -r tmp/cache \
&& sed -e 's#server localhost:3000#server zammad-railsserver:3000#g' -e 's#localhost:6042#zammad-websocket:6042#g' -e 's#server_name localhost#server_name _#g' -e 's#.*\(access\|error\)_log.*log;##g' < contrib/nginx/zammad.conf > /etc/nginx/sites-enabled/default \
&& chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR}
# docker init

View File

@ -2,38 +2,40 @@
set -e
function check_railsserver_available {
# wait for zammad process coming up
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
echo "backup waiting for zammads railsserver to be ready..."
sleep 2
function check_zammad_ready {
until [ -f "${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}" ]; do
echo "waiting for install or update to be ready..."
sleep 5
done
}
function mount_nfs {
if [ -n "$(env|grep KUBERNETES)" ]; then
mount -t nfs4 zammad-nfs:/ /home/zammad/tmp
test -d ${ZAMMAD_DIR} || mkdir -p ${ZAMMAD_DIR}
mount -t nfs4 zammad-nfs:/data /opt/zammad
chown ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_DIR}
fi
}
# zammad-railsserver
if [ "$1" = 'zammad-railsserver' ]; then
# wait for postgres process coming up on zammad-postgresql
# zammad init
if [ "$1" = 'zammad-init' ]; then
until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do
echo "zammad railsserver waiting for postgresql server to be ready..."
sleep 5
done
echo "railsserver can access postgresql server now..."
rsync -a --delete --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
cd ${ZAMMAD_DIR}
gem update bundler
bundle install
mount_nfs
# install / update zammad
rsync -a --delete --exclude 'storage/fs/*' --exclude 'public/assets/images/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
rsync -a ${ZAMMAD_TMP_DIR}/public/assets/images/ ${ZAMMAD_DIR}/public/assets/images
cd ${ZAMMAD_DIR}
# enable memcached
sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, 'zammad-memcached:11211'\n config.session_store = :dalli_store, 'zammad-memcached:11211'/" config/application.rb
echo "initialising / updating database..."
# db mirgrate
set +e
bundle exec rake db:migrate &> /dev/null
@ -41,52 +43,95 @@ if [ "$1" = 'zammad-railsserver' ]; then
set -e
if [ "${DB_CHECK}" != "0" ]; then
echo "creating db & searchindex..."
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:seed
fi
echo "changing settings..."
# es config
bundle exec rails r "Setting.set('es_url', 'http://zammad-elasticsearch:9200')"
until (echo > /dev/tcp/zammad-elasticsearch/9200) &> /dev/null; do
echo "zammad railsserver waiting for elasticsearch server to be ready..."
sleep 5
done
echo "rebuilding es searchindex..."
bundle exec rake searchindex:rebuild
# chown everything to zammad user
chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_DIR}
# run zammad
echo "starting zammad..."
echo "zammad will be accessable on http://localhost in some seconds"
# create install ready file
su -c "echo 'zammad-init' > ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}" ${ZAMMAD_USER}
fi
if [ "${RAILS_SERVER}" == "puma" ]; then
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}
elif [ "${RAILS_SERVER}" == "unicorn" ]; then
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV}
# zammad nginx
if [ "$1" = 'zammad-nginx' ]; then
mount_nfs
if [ -n "$(env|grep KUBERNETES)" ]; then
sed -i -e 's#server zammad-\(railsserver\|websocket\):#server zammad:#g' /etc/nginx/sites-enabled/default
fi
until [ -f "${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}" ] && [ -n "$(grep zammad-railsserver < ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE})" ] && [ -n "$(grep zammad-scheduler < ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE})" ] && [ -n "$(grep zammad-websocket < ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE})" ] ; do
echo "waiting for all zammad services to start..."
sleep 5
done
rm ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}
echo "starting nginx..."
exec /usr/sbin/nginx -g 'daemon off;'
fi
# zammad-railsserver
if [ "$1" = 'zammad-railsserver' ]; then
mount_nfs
check_zammad_ready
cd ${ZAMMAD_DIR}
echo "starting railsserver..."
echo "zammad-railsserver" >> ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}
fi
# zammad-scheduler
if [ "$1" = 'zammad-scheduler' ]; then
check_railsserver_available
echo "scheduler can access raillsserver now..."
mount_nfs
# start scheduler
check_zammad_ready
cd ${ZAMMAD_DIR}
echo "starting scheduler..."
echo "zammad-scheduler" >> ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run
fi
# zammad-websocket
if [ "$1" = 'zammad-websocket' ]; then
check_railsserver_available
echo "websocket server can access raillsserver now..."
mount_nfs
check_zammad_ready
cd ${ZAMMAD_DIR}
echo "starting websocket server..."
echo "zammad-websocket" >> ${ZAMMAD_DIR}/${ZAMMAD_READY_FILE}
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start
fi

View File

@ -1,93 +0,0 @@
version: '3.3'
services:
zammad-backup:
build:
context: .
dockerfile: containers/zammad-postgresql/Dockerfile
depends_on:
- zammad-railsserver
links:
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
- backup-zammad:/var/tmp/zammad
entrypoint: /usr/local/bin/backup.sh
command: ["zammad-backup"]
zammad-elasticsearch:
build:
context: .
dockerfile: containers/zammad-elasticsearch/Dockerfile
restart: always
zammad-nginx:
build:
context: .
dockerfile: containers/zammad-nginx/Dockerfile
depends_on:
- zammad-railsserver
links:
- zammad-railsserver
- zammad-websocket
ports:
- "80:80"
restart: always
volumes:
- data-zammad:/home/zammad
zammad-postgresql:
build:
context: .
dockerfile: containers/zammad-postgresql/Dockerfile
restart: always
zammad-railsserver:
build:
context: .
dockerfile: containers/zammad/Dockerfile
depends_on:
- zammad-postgresql
links:
- zammad-elasticsearch
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-railsserver"]
zammad-scheduler:
build:
context: .
dockerfile: containers/zammad/Dockerfile
depends_on:
- zammad-railsserver
links:
- zammad-elasticsearch
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-scheduler"]
zammad-websocket:
build:
context: .
dockerfile: containers/zammad/Dockerfile
depends_on:
- zammad-railsserver
links:
- zammad-elasticsearch
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-websocket"]
volumes:
backup-zammad:
driver: local
data-zammad:
driver: local

View File

@ -3,32 +3,54 @@ version: '3.3'
services:
zammad-backup:
command: ["zammad-backup"]
depends_on:
- zammad-railsserver
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
entrypoint: /usr/local/bin/backup.sh
image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
labels:
io.rancher.container.pull_image: always
links:
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
- backup-zammad:/var/tmp/zammad
entrypoint: /usr/local/bin/backup.sh
command: zammad-backup
- zammad-backup:/var/tmp/zammad
- zammad-data:/opt/zammad
zammad-elasticsearch:
image: zammad/zammad-docker-compose:zammad-elasticsearch${VERSION}
image: ${IMAGE_REPO}:zammad-elasticsearch${VERSION}
labels:
io.rancher.container.pull_image: always
restart: always
volumes:
- data-elasticsearch:/usr/share/elasticsearch/data
- elasticsearch-data:/usr/share/elasticsearch/data
zammad-init:
command: ["zammad-init"]
depends_on:
- zammad-postgresql
image: ${IMAGE_REPO}:zammad${VERSION}
labels:
io.rancher.container.pull_image: always
links:
- zammad-elasticsearch
- zammad-postgresql
restart: on-failure
volumes:
- zammad-data:/opt/zammad
zammad-memcached:
command: ["zammad-memcached"]
image: ${IMAGE_REPO}:zammad-memcached${VERSION}
labels:
io.rancher.container.pull_image: always
restart: always
zammad-nginx:
command: ["zammad-nginx"]
depends_on:
- zammad-railsserver
image: zammad/zammad-docker-compose:zammad-nginx${VERSION}
image: ${IMAGE_REPO}:zammad${VERSION}
labels:
io.rancher.container.pull_image: always
links:
@ -36,59 +58,65 @@ services:
- zammad-websocket
restart: always
volumes:
- data-zammad:/home/zammad
- zammad-data:/opt/zammad
zammad-postgresql:
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
labels:
io.rancher.container.pull_image: always
restart: always
zammad-railsserver:
command: ["zammad-railsserver"]
depends_on:
- zammad-memcached
- zammad-postgresql
image: zammad/zammad-docker-compose:zammad${VERSION}
image: ${IMAGE_REPO}:zammad${VERSION}
labels:
io.rancher.container.pull_image: always
links:
- zammad-elasticsearch
- zammad-memcached
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-railsserver"]
- zammad-data:/opt/zammad
zammad-scheduler:
command: ["zammad-scheduler"]
depends_on:
- zammad-memcached
- zammad-railsserver
image: zammad/zammad-docker-compose:zammad${VERSION}
image: ${IMAGE_REPO}:zammad${VERSION}
labels:
io.rancher.container.pull_image: always
links:
- zammad-elasticsearch
- zammad-memcached
- zammad-postgresql
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-scheduler"]
- zammad-data:/opt/zammad
zammad-websocket:
command: ["zammad-websocket"]
depends_on:
- zammad-memcached
- zammad-railsserver
image: zammad/zammad-docker-compose:zammad${VERSION}
image: ${IMAGE_REPO}:zammad${VERSION}
labels:
io.rancher.container.pull_image: always
links:
- zammad-postgresql
- zammad-memcached
restart: always
volumes:
- data-zammad:/home/zammad
command: ["zammad-websocket"]
- zammad-data:/opt/zammad
volumes:
backup-zammad:
elasticsearch-data:
driver: local
data-zammad:
zammad-backup:
driver: local
data-elasticsearch:
zammad-data:
driver: local

View File

@ -2,42 +2,40 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zammad-postgresql
name: zammad
namespace: zammad
annotations:
volume.beta.kubernetes.io/storage-class: standard
spec:
storageClassName: standard
accessModes:
- ReadWriteMany
- ReadWriteOnce
resources:
requests:
storage: 10G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zammad-elasticsearch
namespace: zammad
annotations:
volume.beta.kubernetes.io/storage-class: standard
spec:
storageClassName: standard
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zammad-home
namespace: zammad
annotations:
volume.beta.kubernetes.io/storage-class: standard
spec:
accessModes:
- ReadWriteMany
- ReadWriteOnce
resources:
requests:
storage: 10G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zammad-postgresql
namespace: zammad
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10G

View File

@ -0,0 +1,87 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: zammad
namespace: zammad
spec:
replicas: 1
template:
metadata:
labels:
app: zammad
component: services
spec:
terminationGracePeriodSeconds: 10
# volumes:
# - name: cache-volume
# emptyDir: {}
# - name: data
# nfs:
# # FIXME: use the nfs service IP instead of 'zammad-nfs'
# server: zammad-nfs
# path: /data
# - name: uploads
# nfs:
# # FIXME: use nfs service IP instead of 'zammad-nfs'
# server: zammad-nfs
# path: /uploads
initContainers:
- name: zammad-init
image: monotek/zammad-docker-compose:zammad
args: [ "zammad-init" ]
imagePullPolicy: Always
securityContext:
privileged: true
# volumeMounts:
# - name: cache-volume
# mountPath: /opt/zammad/tmp
# - name: data
# mountPath: /opt/zammad/storage
# - name: uploads
# mountPath: /opt/zammad/assets/uploads
containers:
- name: zammad-scheduler
image: monotek/zammad-docker-compose:zammad
args: [ "zammad-scheduler" ]
imagePullPolicy: Always
securityContext:
privileged: true
# volumeMounts:
# - name: cache-volume
# mountPath: /opt/zammad/tmp
# - name: data
# mountPath: /opt/zammad/storage
- name: zammad-railsserver
image: monotek/zammad-docker-compose:zammad
args: ["zammad-railsserver"]
imagePullPolicy: Always
ports:
- name: railsserver
containerPort: 3000
securityContext:
privileged: true
# volumeMounts:
# - name: cache-volume
# mountPath: /opt/zammad/tmp
# - name: data
# mountPath: /opt/zammad/storage
# - name: uploads
# mountPath: /opt/zammad/assets/uploads
- name: zammad-websocket
image: monotek/zammad-docker-compose:zammad
args: [ "zammad-websocket" ]
imagePullPolicy: Always
ports:
- name: websocket
containerPort: 6042
securityContext:
privileged: true
# volumeMounts:
# - name: cache-volume
# mountPath: /opt/zammad/tmp
# - name: data
# mountPath: /opt/zammad/storage

View File

@ -0,0 +1,33 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: zammad-nginx
namespace: zammad
spec:
replicas: 1
template:
metadata:
labels:
app: nginx
component: webserver
spec:
terminationGracePeriodSeconds: 10
# volumes:
# - name: uploads
# nfs:
# # FIXME: use nfs service IP instead of 'zammad-nfs'
# server: zammad-nfs
# path: /uploads
containers:
- name: zammad-nginx
image: monotek/zammad-docker-compose:zammad
args: [ "zammad-nginx" ]
ports:
- containerPort: 80
name: nginx
imagePullPolicy: Always
securityContext:
privileged: true
# volumeMounts:
# - name: uploads
# mountPath: /opt/zammad/assets/uploads

View File

@ -0,0 +1,23 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: zammad-memcached
namespace: zammad
spec:
replicas: 1
template:
metadata:
labels:
app: memcached
component: cache
spec:
terminationGracePeriodSeconds: 10
containers:
- name: zammad-memcached
image: monotek/zammad-docker-compose:zammad-memcached
args: [ "zammad-memcached" ]
ports:
- containerPort: 11211
name: memcached
imagePullPolicy: Always

View File

@ -1,13 +1,9 @@
apiVersion: apps/v1beta1
kind: StatefulSet
kind: Deployment
metadata:
name: zammad-postgresql
namespace: zammad
labels:
component: database
app: postgresql
spec:
serviceName: zammad-postgresql
replicas: 1
template:
metadata:
@ -20,13 +16,14 @@ spec:
- name: zammad-postgresql
persistentVolumeClaim:
claimName: zammad-postgresql
containers:
- name: zammad-postgresql
image: zammad/zammad-docker-compose:zammad-postgresql
image: monotek/zammad-docker-compose:zammad-postgresql
ports:
- containerPort: 5432
name: postgresql
- name: postgresql
containerPort: 5432
imagePullPolicy: Always
volumeMounts:
- mountPath: /var/lib/postgresql
name: zammad-postgresql
- name: zammad-postgresql
mountPath: /var/lib/postgresql

View File

@ -1,13 +1,9 @@
apiVersion: apps/v1beta1
kind: StatefulSet
kind: Deployment
metadata:
name: zammad-elasticsearch
namespace: zammad
labels:
component: database
app: elasticsearch
spec:
serviceName: zammad-elasticsearch
replicas: 1
template:
metadata:
@ -20,19 +16,21 @@ spec:
- name: zammad-elasticsearch
persistentVolumeClaim:
claimName: zammad-elasticsearch
initContainers:
- name: sysctl
image: busybox
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
containers:
- name: zammad-elasticsearch
image: zammad/zammad-docker-compose:zammad-elasticsearch
image: monotek/zammad-docker-compose:zammad-elasticsearch
ports:
- containerPort: 9200
name: elasticsearch
- name: elasticsearch
containerPort: 9200
imagePullPolicy: Always
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: zammad-elasticsearch
- name: zammad-elasticsearch
mountPath: /usr/share/elasticsearch/data

View File

@ -0,0 +1,33 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: zammad-nfs
namespace: zammad
spec:
replicas: 1
template:
metadata:
labels:
component: networkstorage
app: nfs
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad
persistentVolumeClaim:
claimName: zammad
containers:
- name: zammad-nfs
image: monotek/zammad-docker-compose:zammad-nfs
imagePullPolicy: Always
ports:
- name: nfsserver
containerPort: 2049
- name: rpc
containerPort: 111
securityContext:
privileged: true
volumeMounts:
- name: zammad
mountPath: /exports

View File

@ -1,35 +0,0 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-railsserver
namespace: zammad
labels:
component: railsserver
app: zammad
spec:
serviceName: zammad-railsserver
replicas: 1
template:
metadata:
labels:
component: railsserver
app: zammad
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad-home
persistentVolumeClaim:
claimName: zammad-home
containers:
- name: zammad-railsserver
image: zammad/zammad-docker-compose:zammad
imagePullPolicy: Always
args: ["zammad-railsserver"]
ports:
- containerPort: 3000
name: railsserver
securityContext:
privileged: true
volumeMounts:
- mountPath: /home/zammad
name: zammad-home

View File

@ -1,35 +0,0 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-websocket
namespace: zammad
labels:
component: websocket
app: zammad
spec:
serviceName: zammad-websocket
replicas: 1
template:
metadata:
labels:
component: websocket
app: zammad
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad-home
persistentVolumeClaim:
claimName: zammad-home
containers:
- name: zammad-websocket
image: zammad/zammad-docker-compose:zammad
args: [ "zammad-websocket" ]
ports:
- containerPort: 6042
name: websocket
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- mountPath: /home/zammad
name: zammad-home

View File

@ -1,34 +0,0 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-nginx
namespace: zammad
labels:
component: nginx
app: zammad
spec:
serviceName: zammad-nginx
replicas: 1
template:
metadata:
labels:
component: nginx
app: zammad
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad-home
persistentVolumeClaim:
claimName: zammad-home
containers:
- name: zammad-nginx
image: zammad/zammad-docker-compose:zammad-nginx
ports:
- containerPort: 80
name: nginx
- containerPort: 6042
name: nginx-ws
imagePullPolicy: Always
volumeMounts:
- mountPath: /home/zammad
name: zammad-home

View File

@ -1,32 +0,0 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-scheduler
namespace: zammad
labels:
component: scheduler
app: zammad
spec:
serviceName: zammad-scheduler
replicas: 1
template:
metadata:
labels:
component: scheduler
app: zammad
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad-home
persistentVolumeClaim:
claimName: zammad-home
containers:
- name: zammad-scheduler
image: zammad/zammad-docker-compose:zammad
args: [ "zammad-scheduler" ]
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- mountPath: /home/zammad
name: zammad-home

View File

@ -1,30 +0,0 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-nfs
namespace: zammad
labels:
component: netfs
app: zammad
spec:
serviceName: zammad-nfs
replicas: 1
template:
metadata:
labels:
component: netfs
app: nfs
spec:
terminationGracePeriodSeconds: 10
containers:
- name: zammad-nfs
image: zammad/zammad-docker-compose:zammad-nfs
args: [ "zammad-nfs" ]
imagePullPolicy: Always
ports:
- containerPort: 2049
name: nfsserver
- containerPort: 111
name: rpc
securityContext:
privileged: true

View File

@ -2,19 +2,22 @@
kind: Service
apiVersion: v1
metadata:
name: zammad-postgresql
name: zammad
namespace: zammad
labels:
component: database
app: postgresql
app: zammad
component: services
spec:
ports:
- name: postgresql
port: 5432
- name: railsserver
port: 3000
- name: websocket
port: 6042
selector:
component: database
app: postgresql
app: zammad
component: services
type: NodePort
---
kind: Service
apiVersion: v1
@ -22,67 +25,35 @@ metadata:
name: zammad-elasticsearch
namespace: zammad
labels:
component: searchindex
app: elasticsearch
component: searchindex
spec:
ports:
- name: elasticsearch
port: 9200
selector:
component: searchindex
app: elasticsearch
component: searchindex
type: NodePort
---
kind: Service
apiVersion: v1
metadata:
name: zammad-railsserver
name: zammad-memcached
namespace: zammad
labels:
component: railsserver
app: zammad
app: memcached
component: cache
spec:
ports:
- name: railsserver
port: 3000
- name: memcached
port: 11211
selector:
component: railsserver
app: zammad
type: NodePort
---
kind: Service
apiVersion: v1
metadata:
name: zammad-websocket
namespace: zammad
labels:
component: websocket
app: zammad
spec:
ports:
- name: websocket
port: 6042
selector:
component: websocket
app: zammad
type: NodePort
---
kind: Service
apiVersion: v1
metadata:
name: zammad-nginx
namespace: zammad
labels:
component: nginx
app: zammad
spec:
ports:
- name: nginx
port: 80
selector:
component: nginx
app: zammad
app: memcached
component: cache
type: NodePort
---
kind: Service
apiVersion: v1
@ -90,8 +61,8 @@ metadata:
name: zammad-nfs
namespace: zammad
labels:
component: netfs
app: nfs
component: networkstorage
spec:
ports:
- name: nfsserver
@ -99,6 +70,42 @@ spec:
- name: rpc
port: 111
selector:
component: netfs
app: nfs
component: networkstorage
type: NodePort
---
kind: Service
apiVersion: v1
metadata:
name: zammad-nginx
namespace: zammad
labels:
app: nginx
component: webserver
spec:
ports:
- name: nginx
port: 80
selector:
app: nginx
component: webserver
type: NodePort
---
kind: Service
apiVersion: v1
metadata:
name: zammad-postgresql
namespace: zammad
labels:
app: postgresql
component: database
spec:
ports:
- name: postgresql
port: 5432
selector:
app: postgresql
component: database
type: NodePort

View File

@ -4,7 +4,7 @@ metadata:
name: zammad.example.com
namespace: zammad
labels:
component: website
component: webserver
app: zammad
host: zammad.example.com
annotations:

View File

@ -1,13 +1,16 @@
# Zammad kubernetes example deployment (beta)
# Zammad kubernetes example deployment
This is a proof of concept of a Kubernetes deployment, which should be considered
beta and not ready for production.
## Prerequisites
- Change the ingress to your needs.
- Change the ingress to your needs
## Deploy zammad
## Deploy Zammad
### Install on Minikube example
### Install on Minikube
* Install kubectl
* https://kubernetes.io/docs/tasks/tools/install-kubectl/
@ -22,3 +25,26 @@
* open "Overview" and wait until all pods are green
* access zammad on:
* http://zammad.example.com
### Install on Google Kubernetes Engine
* connect to cluster via gcloud command
* kubectl apply -f .
## If you want to help to improve the Kuberntes deployments here are some todos:
* fix the nfs mount from entrypoint, which is currently used because of:
* https://github.com/kubernetes/kubernetes/issues/8735
* otherwise you have to manually:
* kubectl apply -f 00_namespace.yaml -f 80_svc.yaml
* kubectl --namespace=zammad describe services zammad-nfs
* use the NFS server IP to update
* 40_deployment_zammad.yaml
* 41_deployment_nginx.yaml
* kubectl apply -f 10_pvc.yaml -f 40_deployment_zammad.yaml -f 41_deployment_nginx.yaml -f 42_deployment_memcached.yaml -f 43_deployment_postgesql.yaml -f 44_deployment_elasticsearch.yaml -f 45_deployment_nfs.yaml -f 90_ingress.yaml
* create config map for nginx
* create a zammad helm chart
* document steps to use existing helm charts for elasticsearch, postgresql and so on
* add cpu & mem limits
* add rolling upgrade strategy to deployments

View File

@ -10,6 +10,14 @@ services:
scale: 1
start_on_create: true
zammad-init:
scale: 1
start_on_create: true
zammad-memcached:
scale: 1
start_on_create: true
zammad-nginx:
scale: 1
start_on_create: true