added nfs server for kubernetes
This commit is contained in:
parent
aa0f636d8a
commit
0019469221
22
containers/zammad-nfs/Dockerfile
Normal file
22
containers/zammad-nfs/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
FROM cpuguy83/nfs-server
|
||||||
|
MAINTAINER Zanmmad <info@zammad.org>
|
||||||
|
|
||||||
|
ENV NFS_DIR /mnt/zammad
|
||||||
|
ENV TMPFS_SIZE 1G
|
||||||
|
|
||||||
|
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
||||||
|
org.label-schema.name="Zammad" \
|
||||||
|
org.label-schema.license="AGPL-3.0" \
|
||||||
|
org.label-schema.description="Docker container for Zammad - NFS Server Container for Kubernetes" \
|
||||||
|
org.label-schema.url="https://zammad.org" \
|
||||||
|
org.label-schema.vcs-url="https://github.com/zammad/zammad" \
|
||||||
|
org.label-schema.vcs-type="Git" \
|
||||||
|
org.label-schema.vendor="Zammad" \
|
||||||
|
org.label-schema.schema-version="1.2" \
|
||||||
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
|
||||||
|
# docker init
|
||||||
|
COPY containers/zammad-nfs/docker-entrypoint.sh /
|
||||||
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
CMD ["zammad-nfs"]
|
18
containers/zammad-nfs/docker-entrypoint.sh
Normal file
18
containers/zammad-nfs/docker-entrypoint.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
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 "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
|
||||||
|
|
||||||
|
exec runsvdir /etc/sv
|
||||||
|
fi
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
function check_railsserver_available {
|
function check_railsserver_available {
|
||||||
# wait for zammad process coming up
|
# wait for zammad process coming up
|
||||||
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
||||||
|
@ -23,7 +23,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \
|
|||||||
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
|
||||||
# install dependencies, GOSU & zammad
|
# install dependencies, GOSU & zammad
|
||||||
RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev rsync" \
|
RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev nfs-common rsync" \
|
||||||
GOSU_DEPENDENCIES="ca-certificates wget" \
|
GOSU_DEPENDENCIES="ca-certificates wget" \
|
||||||
set -ex \
|
set -ex \
|
||||||
&& apt-get update && apt-get install -y --force-yes --no-install-recommends ${BUILD_DEPENDENCIES} ${GOSU_DEPENDENCIES} && rm -rf /var/lib/apt/lists/* \
|
&& apt-get update && apt-get install -y --force-yes --no-install-recommends ${BUILD_DEPENDENCIES} ${GOSU_DEPENDENCIES} && rm -rf /var/lib/apt/lists/* \
|
||||||
@ -49,7 +49,7 @@ RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev rsync" \
|
|||||||
|
|
||||||
# docker init
|
# docker init
|
||||||
COPY containers/zammad/docker-entrypoint.sh /
|
COPY containers/zammad/docker-entrypoint.sh /
|
||||||
RUN chown ${ZAMMAD_USER}:${ZAMMAD_USER} /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
|
||||||
WORKDIR ${ZAMMAD_DIR}
|
WORKDIR ${ZAMMAD_DIR}
|
||||||
|
@ -1,7 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
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
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function mount_nfs {
|
||||||
|
if [ -n "$(env|grep KUBERNETES)" ]; then
|
||||||
|
mount -t nfs4 zammad-nfs:/ /home/zammad/tmp
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# zammad-railsserver
|
# zammad-railsserver
|
||||||
if [ "$1" = 'zammad-railsserver' ]; then
|
if [ "$1" = 'zammad-railsserver' ]; then
|
||||||
|
|
||||||
# wait for postgres process coming up on zammad-postgresql
|
# wait for postgres process coming up on zammad-postgresql
|
||||||
until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do
|
until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do
|
||||||
echo "zammad railsserver waiting for postgresql server to be ready..."
|
echo "zammad railsserver waiting for postgresql server to be ready..."
|
||||||
@ -11,13 +30,12 @@ if [ "$1" = 'zammad-railsserver' ]; then
|
|||||||
echo "railsserver can access postgresql server now..."
|
echo "railsserver can access postgresql server now..."
|
||||||
|
|
||||||
rsync -a --delete --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
|
rsync -a --delete --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
|
||||||
|
|
||||||
cd ${ZAMMAD_DIR}
|
cd ${ZAMMAD_DIR}
|
||||||
|
|
||||||
# update zammad
|
|
||||||
gem update bundler
|
gem update bundler
|
||||||
bundle install
|
bundle install
|
||||||
|
|
||||||
|
mount_nfs
|
||||||
|
|
||||||
# db mirgrate
|
# db mirgrate
|
||||||
bundle exec rake db:migrate &> /dev/null
|
bundle exec rake db:migrate &> /dev/null
|
||||||
|
|
||||||
@ -48,14 +66,12 @@ fi
|
|||||||
|
|
||||||
# zammad-scheduler
|
# zammad-scheduler
|
||||||
if [ "$1" = 'zammad-scheduler' ]; then
|
if [ "$1" = 'zammad-scheduler' ]; then
|
||||||
# wait for zammad process coming up
|
check_railsserver_available
|
||||||
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
|
||||||
echo "scheduler waiting for zammads railsserver to be ready..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "scheduler can access raillsserver now..."
|
echo "scheduler can access raillsserver now..."
|
||||||
|
|
||||||
|
mount_nfs
|
||||||
|
|
||||||
# start scheduler
|
# start scheduler
|
||||||
cd ${ZAMMAD_DIR}
|
cd ${ZAMMAD_DIR}
|
||||||
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run
|
||||||
@ -64,14 +80,12 @@ fi
|
|||||||
|
|
||||||
# zammad-websocket
|
# zammad-websocket
|
||||||
if [ "$1" = 'zammad-websocket' ]; then
|
if [ "$1" = 'zammad-websocket' ]; then
|
||||||
# wait for zammad process coming up
|
check_railsserver_available
|
||||||
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
|
||||||
echo "websocket server waiting for zammads railsserver to be ready..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "websocket server can access raillsserver now..."
|
echo "websocket server can access raillsserver now..."
|
||||||
|
|
||||||
|
mount_nfs
|
||||||
|
|
||||||
cd ${ZAMMAD_DIR}
|
cd ${ZAMMAD_DIR}
|
||||||
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start
|
||||||
fi
|
fi
|
||||||
|
@ -5,7 +5,7 @@ services:
|
|||||||
zammad-backup:
|
zammad-backup:
|
||||||
depends_on:
|
depends_on:
|
||||||
- zammad-railsserver
|
- zammad-railsserver
|
||||||
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
|
image: monotek/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
links:
|
links:
|
||||||
@ -18,7 +18,7 @@ services:
|
|||||||
command: zammad-backup
|
command: zammad-backup
|
||||||
|
|
||||||
zammad-elasticsearch:
|
zammad-elasticsearch:
|
||||||
image: zammad/zammad-docker-compose:zammad-elasticsearch${VERSION}
|
image: monotek/zammad-docker-compose:zammad-elasticsearch${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
restart: always
|
restart: always
|
||||||
@ -28,7 +28,7 @@ services:
|
|||||||
zammad-nginx:
|
zammad-nginx:
|
||||||
depends_on:
|
depends_on:
|
||||||
- zammad-railsserver
|
- zammad-railsserver
|
||||||
image: zammad/zammad-docker-compose:zammad-nginx${VERSION}
|
image: monotek/zammad-docker-compose:zammad-nginx${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
links:
|
links:
|
||||||
@ -39,7 +39,7 @@ services:
|
|||||||
- data-zammad:/home/zammad
|
- data-zammad:/home/zammad
|
||||||
|
|
||||||
zammad-postgresql:
|
zammad-postgresql:
|
||||||
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
|
image: monotek/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
restart: always
|
restart: always
|
||||||
@ -47,7 +47,7 @@ services:
|
|||||||
zammad-railsserver:
|
zammad-railsserver:
|
||||||
depends_on:
|
depends_on:
|
||||||
- zammad-postgresql
|
- zammad-postgresql
|
||||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
links:
|
links:
|
||||||
@ -61,7 +61,7 @@ services:
|
|||||||
zammad-scheduler:
|
zammad-scheduler:
|
||||||
depends_on:
|
depends_on:
|
||||||
- zammad-railsserver
|
- zammad-railsserver
|
||||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
links:
|
links:
|
||||||
@ -75,7 +75,7 @@ services:
|
|||||||
zammad-websocket:
|
zammad-websocket:
|
||||||
depends_on:
|
depends_on:
|
||||||
- zammad-railsserver
|
- zammad-railsserver
|
||||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.container.pull_image: always
|
io.rancher.container.pull_image: always
|
||||||
links:
|
links:
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
# build hooks config
|
# build hooks config
|
||||||
#
|
#
|
||||||
|
|
||||||
DOCKER_IMAGES="zammad zammad-elasticsearch zammad-nginx zammad-postgresql"
|
DOCKER_IMAGES="zammad zammad-elasticsearch zammad-nfs zammad-nginx zammad-postgresql"
|
||||||
|
@ -40,3 +40,4 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 10G
|
storage: 10G
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ spec:
|
|||||||
claimName: zammad-postgresql
|
claimName: zammad-postgresql
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-postgresql
|
- name: zammad-postgresql
|
||||||
image: zammad/zammad-docker-compose:zammad-postgresql
|
image: monotek/zammad-docker-compose:zammad-postgresql
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5432
|
- containerPort: 5432
|
||||||
name: postgresql
|
name: postgresql
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /var/lib/postgresql
|
- mountPath: /var/lib/postgresql
|
||||||
name: zammad-postgresql
|
name: zammad-postgresql
|
||||||
|
@ -25,10 +25,10 @@ spec:
|
|||||||
image: busybox
|
image: busybox
|
||||||
command: ["sysctl", "-w", "vm.max_map_count=262144"]
|
command: ["sysctl", "-w", "vm.max_map_count=262144"]
|
||||||
securityContext:
|
securityContext:
|
||||||
privileged: true
|
privileged: true
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-elasticsearch
|
- name: zammad-elasticsearch
|
||||||
image: zammad/zammad-docker-compose:zammad-elasticsearch
|
image: monotek/zammad-docker-compose:zammad-elasticsearch
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 9200
|
- containerPort: 9200
|
||||||
name: elasticsearch
|
name: elasticsearch
|
||||||
|
@ -22,12 +22,14 @@ spec:
|
|||||||
claimName: zammad-home
|
claimName: zammad-home
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-railsserver
|
- name: zammad-railsserver
|
||||||
image: zammad/zammad-docker-compose:zammad-railsserver
|
image: monotek/zammad-docker-compose:zammad
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
args: ["zammad-railsserver"]
|
args: ["zammad-railsserver"]
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3000
|
- containerPort: 3000
|
||||||
name: railsserver
|
name: railsserver
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /home/zammad
|
- mountPath: /home/zammad
|
||||||
name: zammad-home
|
name: zammad-home
|
||||||
|
@ -22,12 +22,14 @@ spec:
|
|||||||
claimName: zammad-home
|
claimName: zammad-home
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-websocket
|
- name: zammad-websocket
|
||||||
image: zammad/zammad-docker-compose:zammad
|
image: monotek/zammad-docker-compose:zammad
|
||||||
args: [ "zammad-websocket" ]
|
args: [ "zammad-websocket" ]
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 6042
|
- containerPort: 6042
|
||||||
name: websocket
|
name: websocket
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /home/zammad
|
- mountPath: /home/zammad
|
||||||
name: zammad-home
|
name: zammad-home
|
||||||
|
@ -22,7 +22,7 @@ spec:
|
|||||||
claimName: zammad-home
|
claimName: zammad-home
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-nginx
|
- name: zammad-nginx
|
||||||
image: zammad/zammad-docker-compose:zammad-nginx
|
image: monotek/zammad-docker-compose:zammad-nginx
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: nginx
|
name: nginx
|
||||||
@ -31,4 +31,4 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /home/zammad
|
- mountPath: /home/zammad
|
||||||
name: zammad-home
|
name: zammad-home
|
||||||
|
@ -19,12 +19,14 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: zammad-home
|
- name: zammad-home
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: zammad-home
|
claimName: zammad-home
|
||||||
containers:
|
containers:
|
||||||
- name: zammad-scheduler
|
- name: zammad-scheduler
|
||||||
image: zammad/zammad-docker-compose:zammad
|
image: monotek/zammad-docker-compose:zammad
|
||||||
args: [ "zammad-scheduler" ]
|
args: [ "zammad-scheduler" ]
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /home/zammad
|
- mountPath: /home/zammad
|
||||||
name: zammad-home
|
name: zammad-home
|
||||||
|
30
kubernetes/56_statefulset_nfs.yaml
Normal file
30
kubernetes/56_statefulset_nfs.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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: monotek/zammad-docker-compose:zammad-nfs
|
||||||
|
args: [ "zammad-nfs" ]
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 2049
|
||||||
|
name: nfsserver
|
||||||
|
- containerPort: 111
|
||||||
|
name: rpc
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
@ -82,4 +82,23 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
component: nginx
|
component: nginx
|
||||||
app: zammad
|
app: zammad
|
||||||
type: NodePort
|
type: NodePort
|
||||||
|
---
|
||||||
|
kind: Service
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: zammad-nfs
|
||||||
|
namespace: zammad
|
||||||
|
labels:
|
||||||
|
component: netfs
|
||||||
|
app: nfs
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: nfsserver
|
||||||
|
port: 2049
|
||||||
|
- name: rpc
|
||||||
|
port: 111
|
||||||
|
selector:
|
||||||
|
component: netfs
|
||||||
|
app: nfs
|
||||||
|
type: NodePort
|
||||||
|
Loading…
Reference in New Issue
Block a user