From 3efca6cd8bdbd141f5a7595f9da2a5abad97123d Mon Sep 17 00:00:00 2001 From: Kersten Burkhardt Date: Tue, 24 Oct 2017 15:57:42 +0200 Subject: [PATCH] Added kubernetes yaml files --- kubernetes/00_namespace.yaml | 4 + kubernetes/10_pvc.yaml | 42 ++++++++++ kubernetes/50_statefulset_postgesql.yaml | 32 ++++++++ kubernetes/51_statefulset_elasticsearch.yaml | 32 ++++++++ kubernetes/52_statefulset_railsserver.yaml | 33 ++++++++ kubernetes/53_statefulset_websocket.yaml | 33 ++++++++ kubernetes/54_statefulset_nginx.yaml | 32 ++++++++ kubernetes/55_statefulset_scheduler.yaml | 30 +++++++ kubernetes/80_sv.yaml | 85 ++++++++++++++++++++ kubernetes/90_ingress.yaml | 25 ++++++ kubernetes/Readme.md | 7 ++ 11 files changed, 355 insertions(+) create mode 100644 kubernetes/00_namespace.yaml create mode 100644 kubernetes/10_pvc.yaml create mode 100644 kubernetes/50_statefulset_postgesql.yaml create mode 100644 kubernetes/51_statefulset_elasticsearch.yaml create mode 100644 kubernetes/52_statefulset_railsserver.yaml create mode 100644 kubernetes/53_statefulset_websocket.yaml create mode 100644 kubernetes/54_statefulset_nginx.yaml create mode 100644 kubernetes/55_statefulset_scheduler.yaml create mode 100644 kubernetes/80_sv.yaml create mode 100644 kubernetes/90_ingress.yaml create mode 100644 kubernetes/Readme.md diff --git a/kubernetes/00_namespace.yaml b/kubernetes/00_namespace.yaml new file mode 100644 index 0000000..dfe25d6 --- /dev/null +++ b/kubernetes/00_namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: zammad \ No newline at end of file diff --git a/kubernetes/10_pvc.yaml b/kubernetes/10_pvc.yaml new file mode 100644 index 0000000..acd8d93 --- /dev/null +++ b/kubernetes/10_pvc.yaml @@ -0,0 +1,42 @@ +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: zammad-postgresql + namespace: zammad + annotations: + volume.beta.kubernetes.io/storage-class: standard +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10G +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: zammad-elasticsearch + namespace: zammad + annotations: + volume.beta.kubernetes.io/storage-class: standard +spec: + 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 + resources: + requests: + storage: 10G \ No newline at end of file diff --git a/kubernetes/50_statefulset_postgesql.yaml b/kubernetes/50_statefulset_postgesql.yaml new file mode 100644 index 0000000..8fea411 --- /dev/null +++ b/kubernetes/50_statefulset_postgesql.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: zammad-postgresql + namespace: zammad + labels: + component: database + app: postgresql +spec: + serviceName: zammad-postgresql + replicas: 1 + template: + metadata: + labels: + component: database + app: postgresql + spec: + terminationGracePeriodSeconds: 10 + volumes: + - name: zammad-postgresql + persistentVolumeClaim: + claimName: zammad-postgresql + containers: + - name: zammad-postgresql + image: zammad/zammad-docker-compose:zammad-postgresql + ports: + - containerPort: 5432 + name: postgresql + imagePullPolicy: Always + volumeMounts: + - mountPath: /var/lib/postgresql + name: zammad-postgresql \ No newline at end of file diff --git a/kubernetes/51_statefulset_elasticsearch.yaml b/kubernetes/51_statefulset_elasticsearch.yaml new file mode 100644 index 0000000..46f65db --- /dev/null +++ b/kubernetes/51_statefulset_elasticsearch.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: zammad-elasticsearch + namespace: zammad + labels: + component: database + app: elasticsearch +spec: + serviceName: zammad-elasticsearch + replicas: 1 + template: + metadata: + labels: + component: searchindex + app: elasticsearch + spec: + terminationGracePeriodSeconds: 10 + volumes: + - name: zammad-elasticsearch + persistentVolumeClaim: + claimName: zammad-elasticsearch + containers: + - name: zammad-elasticsearch + image: zammad/zammad-docker-compose:zammad-elasticsearch + ports: + - containerPort: 9200 + name: elasticsearch + imagePullPolicy: Always + volumeMounts: + - mountPath: /usr/share/elasticsearch/data + name: zammad-elasticsearch \ No newline at end of file diff --git a/kubernetes/52_statefulset_railsserver.yaml b/kubernetes/52_statefulset_railsserver.yaml new file mode 100644 index 0000000..49ac67e --- /dev/null +++ b/kubernetes/52_statefulset_railsserver.yaml @@ -0,0 +1,33 @@ +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-railsserver + imagePullPolicy: Always + args: ["zammad-railsserver"] + ports: + - containerPort: 3000 + name: railsserver + volumeMounts: + - mountPath: /home/zammad + name: zammad-home \ No newline at end of file diff --git a/kubernetes/53_statefulset_websocket.yaml b/kubernetes/53_statefulset_websocket.yaml new file mode 100644 index 0000000..9651843 --- /dev/null +++ b/kubernetes/53_statefulset_websocket.yaml @@ -0,0 +1,33 @@ +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 + volumeMounts: + - mountPath: /home/zammad + name: zammad-home \ No newline at end of file diff --git a/kubernetes/54_statefulset_nginx.yaml b/kubernetes/54_statefulset_nginx.yaml new file mode 100644 index 0000000..3e7a6f8 --- /dev/null +++ b/kubernetes/54_statefulset_nginx.yaml @@ -0,0 +1,32 @@ +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 + imagePullPolicy: Always + volumeMounts: + - mountPath: /home/zammad + name: zammad-home \ No newline at end of file diff --git a/kubernetes/55_statefulset_scheduler.yaml b/kubernetes/55_statefulset_scheduler.yaml new file mode 100644 index 0000000..d7f2f54 --- /dev/null +++ b/kubernetes/55_statefulset_scheduler.yaml @@ -0,0 +1,30 @@ +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 + volumeMounts: + - mountPath: /home/zammad + name: zammad-home \ No newline at end of file diff --git a/kubernetes/80_sv.yaml b/kubernetes/80_sv.yaml new file mode 100644 index 0000000..c171f66 --- /dev/null +++ b/kubernetes/80_sv.yaml @@ -0,0 +1,85 @@ +--- +kind: Service +apiVersion: v1 +metadata: + name: zammad-postgresql + namespace: zammad + labels: + component: database + app: postgresql +spec: + ports: + - name: postgresql + port: 5432 + selector: + component: database + app: postgresql + type: NodePort +--- +kind: Service +apiVersion: v1 +metadata: + name: zammad-elasticsearch + namespace: zammad + labels: + component: searchindex + app: elasticsearch +spec: + ports: + - name: elasticsearch + port: 9200 + selector: + component: searchindex + app: elasticsearch + type: NodePort +--- +kind: Service +apiVersion: v1 +metadata: + name: zammad-railsserver + namespace: zammad + labels: + component: railsserver + app: zammad +spec: + ports: + - name: railsserver + port: 3000 + 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 + type: NodePort \ No newline at end of file diff --git a/kubernetes/90_ingress.yaml b/kubernetes/90_ingress.yaml new file mode 100644 index 0000000..eaa32fc --- /dev/null +++ b/kubernetes/90_ingress.yaml @@ -0,0 +1,25 @@ +kind: Ingress +apiVersion: extensions/v1beta1 +metadata: + name: zammad.example.com + namespace: zammad + labels: + component: website + app: zammad + host: zammad.example.com + annotations: + ingress.kubernetes.io/ssl-redirect: 'true' + kubernetes.io/tls-acme: 'true' +spec: + tls: + - hosts: + - zammad.example.com + secretName: zammad-example-com-tls + rules: + - host: zammad.example.com + http: + paths: + - path: / + backend: + serviceName: zammad-nginx + servicePort: 80 \ No newline at end of file diff --git a/kubernetes/Readme.md b/kubernetes/Readme.md new file mode 100644 index 0000000..46b4c8d --- /dev/null +++ b/kubernetes/Readme.md @@ -0,0 +1,7 @@ +# Zammad kubernetes example deployment + +## Perquisites + +- On every node you need to set `sysctl -w vm.max_map_count=262144` +- Change the ingress to your needs. +- Hit `kubectl apply -f ./` and wait till everything is setup. \ No newline at end of file