From 75f6ab4ad61ebe80a904e7100d60987cfcb57293 Mon Sep 17 00:00:00 2001 From: Gerrit Gogel Date: Wed, 14 Feb 2024 11:37:13 +0100 Subject: [PATCH] update k8s files with restart policy and probes --- compose/docker-compose-kompose.yml | 41 +++++++++++------------------- k8s/db-deployment.yaml | 18 +++++++++++++ k8s/db-service.yaml | 4 +++ k8s/seafile-server-deployment.yaml | 11 ++++++++ k8s/seafile-server-service.yaml | 3 +++ 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/compose/docker-compose-kompose.yml b/compose/docker-compose-kompose.yml index c45571d..380260d 100644 --- a/compose/docker-compose-kompose.yml +++ b/compose/docker-compose-kompose.yml @@ -1,3 +1,6 @@ +# This is a compose file with additional fields for the tool kompose. +# Generate Kubernetes manifests with the following command: +# kompose convert --with-kompose-annotation=false -o k8s -f compose/docker-compose-kompose.yml version: '3.8' services: seafile-server: @@ -10,10 +13,6 @@ services: - TIME_ZONE=Europe/Berlin - HTTPS=true - SEAFILE_URL=seafile.mydomain.com # Mandatory on first deployment! - depends_on: - - db - - memcached - - seafile-caddy networks: - seafile-net expose: @@ -24,6 +23,10 @@ services: labels: kompose.volume.size: 1Gi kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.tcp_port: 8082 + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.timeout: 10s + restart: always seahub: image: ggogel/seahub:11.0.4 @@ -34,22 +37,17 @@ services: environment: - SEAFILE_ADMIN_EMAIL=me@example.com - SEAFILE_ADMIN_PASSWORD=asecret - depends_on: - - seafile-server - - seafile-caddy - - seahub-media networks: - seafile-net expose: - 8000 + restart: always seahub-media: image: ggogel/seahub-media:11.0.4 volumes: - seahub-avatars:/usr/share/caddy/media/avatars - seahub-custom:/usr/share/caddy/media/custom - depends_on: - - seafile-caddy networks: - seafile-net expose: @@ -57,6 +55,7 @@ services: labels: kompose.volume.size: 100Mi kompose.service.expose.storage-class-name: default + restart: always db: image: mariadb:10.11.7 @@ -73,6 +72,11 @@ services: labels: kompose.volume.size: 1Gi kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.test: "healthcheck.sh --su-mysql --connect --innodb_initialized" + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.timeout: 10s + kompose.service.healthcheck.readiness.retries: 3 + restart: always memcached: image: memcached:1.6.23 @@ -81,22 +85,7 @@ services: - seafile-net expose: - 11211 - - seafile-caddy: - image: ggogel/seafile-caddy:2.7.6 - networks: - - seafile-net - - default - labels: - kompose.service.expose: localhost - kompose.service.expose.ingress-class-name: nginx - nginx.ingress.kubernetes.io/proxy-body-size: 0 - nginx.ingress.kubernetes.io/proxy-connect-timeout: 36000 - nginx.ingress.kubernetes.io/proxy-read-timeout: 36000 - nginx.ingress.kubernetes.io/proxy-send-timeout: 36000 - nginx.ingress.kubernetes.io/send-timeout: 36000 - expose: - - 80 + restart: always networks: seafile-net: diff --git a/k8s/db-deployment.yaml b/k8s/db-deployment.yaml index e80bac0..1c40151 100644 --- a/k8s/db-deployment.yaml +++ b/k8s/db-deployment.yaml @@ -3,6 +3,10 @@ kind: Deployment metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.retries: "3" + kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: @@ -19,6 +23,10 @@ spec: metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.retries: "3" + kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: @@ -38,6 +46,16 @@ spec: ports: - containerPort: 3306 protocol: TCP + readinessProbe: + exec: + command: + - healthcheck.sh + - --su-mysql + - --connect + - --innodb_initialized + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: {} volumeMounts: - mountPath: /var/lib/mysql diff --git a/k8s/db-service.yaml b/k8s/db-service.yaml index 666004c..5470e20 100644 --- a/k8s/db-service.yaml +++ b/k8s/db-service.yaml @@ -3,6 +3,10 @@ kind: Service metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.retries: "3" + kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: diff --git a/k8s/seafile-server-deployment.yaml b/k8s/seafile-server-deployment.yaml index fb13ca4..0c11991 100644 --- a/k8s/seafile-server-deployment.yaml +++ b/k8s/seafile-server-deployment.yaml @@ -3,6 +3,9 @@ kind: Deployment metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.tcp_port: "8082" + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: @@ -19,6 +22,9 @@ spec: metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.tcp_port: "8082" + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: @@ -48,6 +54,11 @@ spec: protocol: TCP - containerPort: 8083 protocol: TCP + readinessProbe: + periodSeconds: 10 + tcpSocket: + port: 8082 + timeoutSeconds: 10 resources: {} volumeMounts: - mountPath: /shared diff --git a/k8s/seafile-server-service.yaml b/k8s/seafile-server-service.yaml index f443a78..6e20572 100644 --- a/k8s/seafile-server-service.yaml +++ b/k8s/seafile-server-service.yaml @@ -3,6 +3,9 @@ kind: Service metadata: annotations: kompose.service.expose.storage-class-name: default + kompose.service.healthcheck.readiness.interval: 10s + kompose.service.healthcheck.readiness.tcp_port: "8082" + kompose.service.healthcheck.readiness.timeout: 10s kompose.volume.size: 1Gi creationTimestamp: null labels: