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
|
||||
|
||||
set -e
|
||||
|
||||
function check_railsserver_available {
|
||||
# wait for zammad process coming up
|
||||
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"
|
||||
|
||||
# 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" \
|
||||
set -ex \
|
||||
&& 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
|
||||
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"]
|
||||
|
||||
WORKDIR ${ZAMMAD_DIR}
|
||||
|
@ -1,7 +1,26 @@
|
||||
#!/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
|
||||
if [ "$1" = 'zammad-railsserver' ]; then
|
||||
|
||||
# wait for postgres process coming up on zammad-postgresql
|
||||
until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do
|
||||
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..."
|
||||
|
||||
rsync -a --delete --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
|
||||
|
||||
cd ${ZAMMAD_DIR}
|
||||
|
||||
# update zammad
|
||||
gem update bundler
|
||||
bundle install
|
||||
|
||||
mount_nfs
|
||||
|
||||
# db mirgrate
|
||||
bundle exec rake db:migrate &> /dev/null
|
||||
|
||||
@ -48,14 +66,12 @@ fi
|
||||
|
||||
# zammad-scheduler
|
||||
if [ "$1" = 'zammad-scheduler' ]; then
|
||||
# wait for zammad process coming up
|
||||
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
||||
echo "scheduler waiting for zammads railsserver to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
check_railsserver_available
|
||||
|
||||
echo "scheduler can access raillsserver now..."
|
||||
|
||||
mount_nfs
|
||||
|
||||
# start scheduler
|
||||
cd ${ZAMMAD_DIR}
|
||||
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run
|
||||
@ -64,14 +80,12 @@ fi
|
||||
|
||||
# zammad-websocket
|
||||
if [ "$1" = 'zammad-websocket' ]; then
|
||||
# wait for zammad process coming up
|
||||
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
||||
echo "websocket server waiting for zammads railsserver to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
check_railsserver_available
|
||||
|
||||
echo "websocket server can access raillsserver now..."
|
||||
|
||||
mount_nfs
|
||||
|
||||
cd ${ZAMMAD_DIR}
|
||||
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start
|
||||
fi
|
||||
|
@ -5,7 +5,7 @@ services:
|
||||
zammad-backup:
|
||||
depends_on:
|
||||
- zammad-railsserver
|
||||
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
links:
|
||||
@ -18,7 +18,7 @@ services:
|
||||
command: zammad-backup
|
||||
|
||||
zammad-elasticsearch:
|
||||
image: zammad/zammad-docker-compose:zammad-elasticsearch${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad-elasticsearch${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
restart: always
|
||||
@ -28,7 +28,7 @@ services:
|
||||
zammad-nginx:
|
||||
depends_on:
|
||||
- zammad-railsserver
|
||||
image: zammad/zammad-docker-compose:zammad-nginx${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad-nginx${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
links:
|
||||
@ -39,7 +39,7 @@ services:
|
||||
- data-zammad:/home/zammad
|
||||
|
||||
zammad-postgresql:
|
||||
image: zammad/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad-postgresql${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
restart: always
|
||||
@ -47,7 +47,7 @@ services:
|
||||
zammad-railsserver:
|
||||
depends_on:
|
||||
- zammad-postgresql
|
||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
links:
|
||||
@ -61,7 +61,7 @@ services:
|
||||
zammad-scheduler:
|
||||
depends_on:
|
||||
- zammad-railsserver
|
||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
links:
|
||||
@ -75,7 +75,7 @@ services:
|
||||
zammad-websocket:
|
||||
depends_on:
|
||||
- zammad-railsserver
|
||||
image: zammad/zammad-docker-compose:zammad${VERSION}
|
||||
image: monotek/zammad-docker-compose:zammad${VERSION}
|
||||
labels:
|
||||
io.rancher.container.pull_image: always
|
||||
links:
|
||||
|
@ -3,4 +3,4 @@
|
||||
# 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:
|
||||
requests:
|
||||
storage: 10G
|
||||
|
||||
|
@ -22,7 +22,7 @@ spec:
|
||||
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
|
||||
|
@ -28,7 +28,7 @@ spec:
|
||||
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
|
||||
|
@ -22,12 +22,14 @@ spec:
|
||||
claimName: zammad-home
|
||||
containers:
|
||||
- name: zammad-railsserver
|
||||
image: zammad/zammad-docker-compose:zammad-railsserver
|
||||
image: monotek/zammad-docker-compose:zammad
|
||||
imagePullPolicy: Always
|
||||
args: ["zammad-railsserver"]
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: railsserver
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /home/zammad
|
||||
name: zammad-home
|
@ -22,12 +22,14 @@ spec:
|
||||
claimName: zammad-home
|
||||
containers:
|
||||
- name: zammad-websocket
|
||||
image: zammad/zammad-docker-compose:zammad
|
||||
image: monotek/zammad-docker-compose:zammad
|
||||
args: [ "zammad-websocket" ]
|
||||
ports:
|
||||
- containerPort: 6042
|
||||
name: websocket
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /home/zammad
|
||||
name: zammad-home
|
@ -22,7 +22,7 @@ spec:
|
||||
claimName: zammad-home
|
||||
containers:
|
||||
- name: zammad-nginx
|
||||
image: zammad/zammad-docker-compose:zammad-nginx
|
||||
image: monotek/zammad-docker-compose:zammad-nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: nginx
|
||||
|
@ -22,9 +22,11 @@ spec:
|
||||
claimName: zammad-home
|
||||
containers:
|
||||
- name: zammad-scheduler
|
||||
image: zammad/zammad-docker-compose:zammad
|
||||
image: monotek/zammad-docker-compose:zammad
|
||||
args: [ "zammad-scheduler" ]
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /home/zammad
|
||||
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
|
@ -83,3 +83,22 @@ spec:
|
||||
component: nginx
|
||||
app: zammad
|
||||
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