From e1766c7535dd527a193b9306408f5046ba675503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 06:21:37 +0200 Subject: [PATCH 01/17] always delete cron pod gracefully --- deploy/parts/deploy.sh | 14 +++----- kubernetes/deployments/cron.yaml | 34 +++++++++++++------ .../basic-production/expected/cron.yaml | 25 ++++++++------ .../expected/cron.yaml | 25 ++++++++------ .../scenarios/escaping-env/expected/cron.yaml | 25 ++++++++------ .../expected/cron.yaml | 25 ++++++++------ 6 files changed, 84 insertions(+), 64 deletions(-) diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 9f3265c..8d48a7a 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -77,14 +77,10 @@ else fi fi -DEPLOYED_CRON_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=cron -o=jsonpath='{.items[?(@.status.containerStatuses[0].state.running)].metadata.name}') || true - -if [[ -n ${DEPLOYED_CRON_POD} ]]; then - echo -n "Lock crons to prevent run next iteration " - runCommand "ERROR" "kubectl exec -t --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD} -- bash -c \"./phing -S cron-lock > /dev/null 2>&1 & disown\"" - - echo -n "Waiting until all cron instances are done " - runCommand "ERROR" "kubectl exec --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD} -- ./phing -S cron-watch" +if kubectl get deployment/cron --namespace="${PROJECT_NAME}" >/dev/null 2>&1; then + echo -n "Waiting until all cron instances are done and stop cron" + runCommand "ERROR" "kubectl scale deployment/cron --namespace=${PROJECT_NAME} --replicas=0" + runCommand "ERROR" "kubectl rollout status deployment/cron --namespace=${PROJECT_NAME} --timeout=60m" fi echo "Migrate Application (database migrations, elasticsearch migrations, ...):" @@ -130,7 +126,7 @@ if [ ${MIGRATION_COMPLETE_EXIT_CODE} -eq 1 ]; then echo -e "[${RED}ERROR${NO_COLOR}]" echo -n "Restore previous cron container " - runCommand "SKIP" "kubectl delete pod --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD}" + runCommand "SKIP" "kubectl scale deployment/cron --namespace=${PROJECT_NAME} --replicas=1" RUNNING_WEBSERVER_PHP_FPM_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=webserver-php-fpm -o=jsonpath='{.items[0].metadata.name}') diff --git a/kubernetes/deployments/cron.yaml b/kubernetes/deployments/cron.yaml index eaf8ec7..7467f2e 100644 --- a/kubernetes/deployments/cron.yaml +++ b/kubernetes/deployments/cron.yaml @@ -5,13 +5,9 @@ metadata: labels: app: cron spec: - progressDeadlineSeconds: 1500 replicas: 1 strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate selector: matchLabels: app: cron @@ -25,6 +21,7 @@ spec: labels: app: cron spec: + terminationGracePeriodSeconds: 3000 tolerations: - key: "workload" operator: "Equal" @@ -38,8 +35,7 @@ spec: matchExpressions: - key: workload operator: In - values: - - background + values: ["background"] volumes: - name: domains-urls configMap: @@ -61,14 +57,30 @@ spec: runAsUser: 0 imagePullPolicy: IfNotPresent workingDir: /var/www/html - command: ["/bin/sh","-c"] - args: ["cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe"] + command: ["/bin/sh","-lc"] + args: + - > + ./phing warmup > /dev/null + + # FIFO for logs + rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + + # crontab + crontab -u root /var/spool/cron/template + + # run on backround + stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + + exec crond -f || exec cron -f lifecycle: preStop: exec: command: - - sleep - - '5' + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true volumeMounts: - name: domains-urls mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}} diff --git a/tests/scenarios/basic-production/expected/cron.yaml b/tests/scenarios/basic-production/expected/cron.yaml index 6d85982..b55c052 100644 --- a/tests/scenarios/basic-production/expected/cron.yaml +++ b/tests/scenarios/basic-production/expected/cron.yaml @@ -60,16 +60,12 @@ metadata: name: cron namespace: myproject-production spec: - progressDeadlineSeconds: 1500 replicas: 1 selector: matchLabels: app: cron strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate template: metadata: annotations: @@ -93,12 +89,15 @@ spec: weight: 100 containers: - args: - - cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && - mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template - && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f command: - /bin/sh - - -c + - -lc env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -140,8 +139,11 @@ spec: preStop: exec: command: - - sleep - - "5" + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true name: cron securityContext: runAsUser: 0 @@ -161,6 +163,7 @@ spec: workingDir: /var/www/html imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 3000 tolerations: - effect: NoSchedule key: workload diff --git a/tests/scenarios/development-single-domain/expected/cron.yaml b/tests/scenarios/development-single-domain/expected/cron.yaml index faae19b..1d97d62 100644 --- a/tests/scenarios/development-single-domain/expected/cron.yaml +++ b/tests/scenarios/development-single-domain/expected/cron.yaml @@ -58,16 +58,12 @@ metadata: name: cron namespace: myproject-dev spec: - progressDeadlineSeconds: 1500 replicas: 1 selector: matchLabels: app: cron strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate template: metadata: annotations: @@ -91,12 +87,15 @@ spec: weight: 100 containers: - args: - - cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && - mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template - && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f command: - /bin/sh - - -c + - -lc env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -138,8 +137,11 @@ spec: preStop: exec: command: - - sleep - - "5" + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true name: cron securityContext: runAsUser: 0 @@ -159,6 +161,7 @@ spec: workingDir: /var/www/html imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 3000 tolerations: - effect: NoSchedule key: workload diff --git a/tests/scenarios/escaping-env/expected/cron.yaml b/tests/scenarios/escaping-env/expected/cron.yaml index 759d1b1..29f3e89 100644 --- a/tests/scenarios/escaping-env/expected/cron.yaml +++ b/tests/scenarios/escaping-env/expected/cron.yaml @@ -61,16 +61,12 @@ metadata: name: cron namespace: myproject-production spec: - progressDeadlineSeconds: 1500 replicas: 1 selector: matchLabels: app: cron strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate template: metadata: annotations: @@ -94,12 +90,15 @@ spec: weight: 100 containers: - args: - - cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && - mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template - && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f command: - /bin/sh - - -c + - -lc env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -143,8 +142,11 @@ spec: preStop: exec: command: - - sleep - - "5" + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true name: cron securityContext: runAsUser: 0 @@ -164,6 +166,7 @@ spec: workingDir: /var/www/html imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 3000 tolerations: - effect: NoSchedule key: workload diff --git a/tests/scenarios/production-with-cloudflare/expected/cron.yaml b/tests/scenarios/production-with-cloudflare/expected/cron.yaml index 4604bb6..51447ac 100644 --- a/tests/scenarios/production-with-cloudflare/expected/cron.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/cron.yaml @@ -61,16 +61,12 @@ metadata: name: cron namespace: shop-production spec: - progressDeadlineSeconds: 1500 replicas: 1 selector: matchLabels: app: cron strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate template: metadata: annotations: @@ -94,12 +90,15 @@ spec: weight: 100 containers: - args: - - cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && - mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template - && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f command: - /bin/sh - - -c + - -lc env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -141,8 +140,11 @@ spec: preStop: exec: command: - - sleep - - "5" + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true name: cron securityContext: runAsUser: 0 @@ -162,6 +164,7 @@ spec: workingDir: /var/www/html imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 3000 tolerations: - effect: NoSchedule key: workload From ae6b5d83eb74f4146b1092fe714dc17fe64c0dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 06:23:00 +0200 Subject: [PATCH 02/17] deploy autoscalers as part of webserver kustomize --- deploy/parts/deploy.sh | 28 ------------- .../kustomize/webserver/kustomization.yaml | 2 + .../basic-production/expected/webserver.yaml | 41 +++++++++++++++++++ .../expected/webserver.yaml | 41 +++++++++++++++++++ .../escaping-env/expected/webserver.yaml | 41 +++++++++++++++++++ .../expected/webserver.yaml | 41 +++++++++++++++++++ 6 files changed, 166 insertions(+), 28 deletions(-) diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 8d48a7a..993d0c1 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -165,40 +165,12 @@ if [ $DISPLAY_FINAL_CONFIGURATION -eq "1" ]; then echo "" fi -if [ ${ENABLE_AUTOSCALING} = true ]; then - echo -n " Delete previous Horizontal pod autoscaler for Backend " - runCommand "SKIP" "kubectl delete hpa webserver-php-fpm --namespace=${PROJECT_NAME}" - - echo -n " Delete previous Horizontal pod autoscaler for Storefront " - runCommand "SKIP" "kubectl delete hpa storefront --namespace=${PROJECT_NAME}" -fi - echo -n " Deploy Webserver and PHP-FPM container with Storefront" runCommand "ERROR" "kustomize build --load_restrictor none \"${CONFIGURATION_TARGET_PATH}/kustomize/webserver\" | kubectl apply -f -" echo -n " Waiting for start new PHP-FPM and Storefront container (In case of fail you need to manually check what is state of application)" runCommand "ERROR" "kubectl rollout status --namespace=${PROJECT_NAME} deployment/webserver-php-fpm deployment/storefront --watch" -if [ ${ENABLE_AUTOSCALING} = true ]; then - echo -n " Deploy Horizontal pod autoscaler for Backend " - - if [ ${RUNNING_PRODUCTION} -eq "0" ]; then - yq e -i '.spec.minReplicas = 2' "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" - yq e -i '.spec.maxReplicas = 2' "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" - fi - - runCommand "ERROR" "kubectl apply -f ${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" - - echo -n " Deploy Horizontal pod autoscaler for Storefront " - - if [ ${RUNNING_PRODUCTION} -eq "0" ]; then - yq e -i '.spec.minReplicas = 2' "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" - yq e -i '.spec.maxReplicas = 2' "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" - fi - - runCommand "ERROR" "kubectl apply -f ${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" -fi - RUNNING_WEBSERVER_PHP_FPM_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=webserver-php-fpm -o=jsonpath='{.items[?(@.status.containerStatuses[0].state.running)].metadata.name}') echo -n "Disable maintenance page " diff --git a/kubernetes/kustomize/webserver/kustomization.yaml b/kubernetes/kustomize/webserver/kustomization.yaml index 50b7351..ff093e6 100644 --- a/kubernetes/kustomize/webserver/kustomization.yaml +++ b/kubernetes/kustomize/webserver/kustomization.yaml @@ -8,6 +8,8 @@ resources: - ../../configmap/production-php-fpm.yaml - ../../configmap/production-php-opcache.yaml - ../../ingress/ingress-rabbitmq.yaml + - ../../horizontalPodAutoscaler.yaml + - ../../horizontalStorefrontAutoscaler.yaml namespace: "{{PROJECT_NAME}}" configMapGenerator: - name: domains-urls diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 1b8af9e..33e0700 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -665,6 +665,47 @@ spec: defaultMode: 420 secretName: fe-api-keys --- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: storefront + namespace: myproject-production +spec: + maxReplicas: 3 + metrics: + - resource: + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: Resource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: storefront +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: webserver-php-fpm + namespace: myproject-production +spec: + maxReplicas: 3 + metrics: + - containerResource: + container: php-fpm + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: ContainerResource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webserver-php-fpm +--- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index f2dd9ea..825d6f4 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -659,6 +659,47 @@ spec: defaultMode: 420 secretName: fe-api-keys --- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: storefront + namespace: myproject-dev +spec: + maxReplicas: 3 + metrics: + - resource: + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: Resource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: storefront +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: webserver-php-fpm + namespace: myproject-dev +spec: + maxReplicas: 3 + metrics: + - containerResource: + container: php-fpm + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: ContainerResource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webserver-php-fpm +--- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index dc64a13..78d0789 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -669,6 +669,47 @@ spec: defaultMode: 420 secretName: fe-api-keys --- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: storefront + namespace: myproject-production +spec: + maxReplicas: 3 + metrics: + - resource: + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: Resource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: storefront +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: webserver-php-fpm + namespace: myproject-production +spec: + maxReplicas: 3 + metrics: + - containerResource: + container: php-fpm + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: ContainerResource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webserver-php-fpm +--- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 3db750c..42da41e 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -665,6 +665,47 @@ spec: defaultMode: 420 secretName: fe-api-keys --- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: storefront + namespace: shop-production +spec: + maxReplicas: 3 + metrics: + - resource: + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: Resource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: storefront +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: webserver-php-fpm + namespace: shop-production +spec: + maxReplicas: 3 + metrics: + - containerResource: + container: php-fpm + name: cpu + target: + averageUtilization: 120 + type: Utilization + type: ContainerResource + minReplicas: 2 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webserver-php-fpm +--- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: From dabc43d55d2d290113a804aa69c9b1b3b1e6aa1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 07:35:51 +0200 Subject: [PATCH 03/17] update rolling strategy --- deploy/parts/autoscaling.sh | 45 +++++++++++-------- deploy/parts/deploy.sh | 1 - kubernetes/deployments/storefront.yaml | 5 +++ kubernetes/deployments/webserver-php-fpm.yaml | 2 +- .../basic-production/expected/webserver.yaml | 7 ++- .../expected/horizontalPodAutoscaler.yaml | 2 +- .../horizontalStorefrontAutoscaler.yaml | 2 +- .../expected/webserver.yaml | 11 +++-- .../escaping-env/expected/webserver.yaml | 7 ++- .../expected/webserver.yaml | 7 ++- 10 files changed, 60 insertions(+), 29 deletions(-) diff --git a/deploy/parts/autoscaling.sh b/deploy/parts/autoscaling.sh index bd925a2..3fbb5d0 100644 --- a/deploy/parts/autoscaling.sh +++ b/deploy/parts/autoscaling.sh @@ -1,29 +1,34 @@ #!/bin/bash -e -echo -n "Prepare Autoscaling " +patch_rollout() { + local file="$1" min_replicas="$2" + + if (( min_replicas >= 4 )); then + yq e -i ".spec.strategy.rollingUpdate.maxUnavailable=25%" "$file" + fi + + if (( min_replicas >= 6 )); then + yq e -i ".spec.strategy.rollingUpdate.maxSurge=25%" "$file" + fi +} assertVariable "BASE_PATH" assertVariable "CONFIGURATION_TARGET_PATH" +assertVariable "RUNNING_PRODUCTION" -if [ -z ${ENABLE_AUTOSCALING} ]; then - ENABLE_AUTOSCALING=false -fi - -if [ ${ENABLE_AUTOSCALING} = true ]; then - if [ -z ${MIN_PHP_FPM_REPLICAS} ]; then - MIN_PHP_FPM_REPLICAS=2 - fi +if [[ "${ENABLE_AUTOSCALING:-false}" == "true" ]]; then + echo -n "Prepare Autoscaling " - if [ -z ${MAX_PHP_FPM_REPLICAS} ]; then - MAX_PHP_FPM_REPLICAS=3 - fi + MIN_PHP_FPM_REPLICAS="${MIN_PHP_FPM_REPLICAS:-2}" + MAX_PHP_FPM_REPLICAS="${MAX_PHP_FPM_REPLICAS:-3}" + MIN_STOREFRONT_REPLICAS="${MIN_STOREFRONT_REPLICAS:-2}" + MAX_STOREFRONT_REPLICAS="${MAX_STOREFRONT_REPLICAS:-3}" - if [ -z ${MIN_STOREFRONT_REPLICAS} ]; then + if [[ "${RUNNING_PRODUCTION}" -eq 0 || "${DOWNSCALE_RESOURCE:-0}" -eq 1 ]]; then + MIN_PHP_FPM_REPLICAS=2 + MAX_PHP_FPM_REPLICAS=2 MIN_STOREFRONT_REPLICAS=2 - fi - - if [ -z ${MAX_STOREFRONT_REPLICAS} ]; then - MAX_STOREFRONT_REPLICAS=3 + MAX_STOREFRONT_REPLICAS=2 fi yq e -i ".spec.minReplicas=${MIN_PHP_FPM_REPLICAS}" "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" @@ -31,7 +36,9 @@ if [ ${ENABLE_AUTOSCALING} = true ]; then yq e -i ".spec.minReplicas=${MIN_STOREFRONT_REPLICAS}" "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" yq e -i ".spec.maxReplicas=${MAX_STOREFRONT_REPLICAS}" "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" -fi + patch_rollout "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "${MIN_PHP_FPM_REPLICAS}" + patch_rollout "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "${MIN_STOREFRONT_REPLICAS}" -echo -e "[${GREEN}OK${NO_COLOR}]" + echo -e "[${GREEN}OK${NO_COLOR}]" +fi diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 993d0c1..55977cc 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -11,7 +11,6 @@ assertVariable "DEPLOY_REGISTER_USER" assertVariable "DEPLOY_REGISTER_PASSWORD" assertVariable "BASIC_AUTH_PATH" -assertVariable "ENABLE_AUTOSCALING" assertVariable "RUNNING_PRODUCTION" FIRST_DEPLOY_LOAD_DEMO_DATA=${FIRST_DEPLOY_LOAD_DEMO_DATA:-0} diff --git a/kubernetes/deployments/storefront.yaml b/kubernetes/deployments/storefront.yaml index 000a70f..d59e3b7 100644 --- a/kubernetes/deployments/storefront.yaml +++ b/kubernetes/deployments/storefront.yaml @@ -4,6 +4,11 @@ metadata: name: storefront spec: replicas: 1 + strategy: + rollingUpdate: + maxSurge: 50% + maxUnavailable: 0 + type: RollingUpdate selector: matchLabels: app: storefront diff --git a/kubernetes/deployments/webserver-php-fpm.yaml b/kubernetes/deployments/webserver-php-fpm.yaml index a3e756c..0151a5e 100644 --- a/kubernetes/deployments/webserver-php-fpm.yaml +++ b/kubernetes/deployments/webserver-php-fpm.yaml @@ -9,7 +9,7 @@ spec: replicas: 1 strategy: rollingUpdate: - maxSurge: 1 + maxSurge: 50% maxUnavailable: 0 type: RollingUpdate selector: diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 33e0700..887fdab 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -387,6 +387,11 @@ spec: selector: matchLabels: app: storefront + strategy: + rollingUpdate: + maxSurge: 50% + maxUnavailable: 0 + type: RollingUpdate template: metadata: annotations: @@ -472,7 +477,7 @@ spec: app: webserver-php-fpm strategy: rollingUpdate: - maxSurge: 1 + maxSurge: 50% maxUnavailable: 0 type: RollingUpdate template: diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml index 95e34f3..cc48783 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml @@ -9,7 +9,7 @@ spec: kind: Deployment name: webserver-php-fpm minReplicas: 2 - maxReplicas: 3 + maxReplicas: 2 metrics: - type: ContainerResource containerResource: diff --git a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml index 892de0a..cf49cc9 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml @@ -9,7 +9,7 @@ spec: kind: Deployment name: storefront minReplicas: 2 - maxReplicas: 3 + maxReplicas: 2 metrics: - type: Resource resource: diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 825d6f4..554ccbf 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -385,6 +385,11 @@ spec: selector: matchLabels: app: storefront + strategy: + rollingUpdate: + maxSurge: 50% + maxUnavailable: 0 + type: RollingUpdate template: metadata: annotations: @@ -466,7 +471,7 @@ spec: app: webserver-php-fpm strategy: rollingUpdate: - maxSurge: 1 + maxSurge: 50% maxUnavailable: 0 type: RollingUpdate template: @@ -665,7 +670,7 @@ metadata: name: storefront namespace: myproject-dev spec: - maxReplicas: 3 + maxReplicas: 2 metrics: - resource: name: cpu @@ -685,7 +690,7 @@ metadata: name: webserver-php-fpm namespace: myproject-dev spec: - maxReplicas: 3 + maxReplicas: 2 metrics: - containerResource: container: php-fpm diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index 78d0789..b99fc08 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -387,6 +387,11 @@ spec: selector: matchLabels: app: storefront + strategy: + rollingUpdate: + maxSurge: 50% + maxUnavailable: 0 + type: RollingUpdate template: metadata: annotations: @@ -474,7 +479,7 @@ spec: app: webserver-php-fpm strategy: rollingUpdate: - maxSurge: 1 + maxSurge: 50% maxUnavailable: 0 type: RollingUpdate template: diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 42da41e..e0ea520 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -387,6 +387,11 @@ spec: selector: matchLabels: app: storefront + strategy: + rollingUpdate: + maxSurge: 50% + maxUnavailable: 0 + type: RollingUpdate template: metadata: annotations: @@ -472,7 +477,7 @@ spec: app: webserver-php-fpm strategy: rollingUpdate: - maxSurge: 1 + maxSurge: 50% maxUnavailable: 0 type: RollingUpdate template: From ad85516c1780c46840f9e021f3444cfb45862c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 07:50:59 +0200 Subject: [PATCH 04/17] deploy cron together with webserver --- deploy/parts/deploy.sh | 3 - kubernetes/kustomize/cron/kustomization.yaml | 10 - .../kustomize/webserver/kustomization.yaml | 3 + .../basic-production/expected/cron.yaml | 185 ----------------- .../basic-production/expected/webserver.yaml | 168 ++++++++++++++++ .../expected/cron.yaml | 183 ----------------- .../expected/webserver.yaml | 168 ++++++++++++++++ .../scenarios/escaping-env/expected/cron.yaml | 188 ------------------ .../escaping-env/expected/webserver.yaml | 171 ++++++++++++++++ .../expected/cron.yaml | 186 ----------------- .../expected/webserver.yaml | 169 ++++++++++++++++ 11 files changed, 679 insertions(+), 755 deletions(-) delete mode 100644 kubernetes/kustomize/cron/kustomization.yaml delete mode 100644 tests/scenarios/basic-production/expected/cron.yaml delete mode 100644 tests/scenarios/development-single-domain/expected/cron.yaml delete mode 100644 tests/scenarios/escaping-env/expected/cron.yaml delete mode 100644 tests/scenarios/production-with-cloudflare/expected/cron.yaml diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 55977cc..c026888 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -146,9 +146,6 @@ else kubectl logs job/migrate-application --namespace=${PROJECT_NAME} echo -e "section_end:`date +%s`:migrate_application_logs_section\r\e[0K" echo "" - - echo -n "Deploy new cron container " - runCommand "ERROR" "kustomize build --load_restrictor none \"${CONFIGURATION_TARGET_PATH}/kustomize/cron\" | kubectl apply -f -" fi echo "Deploy new Webserver and PHP-FPM container:" diff --git a/kubernetes/kustomize/cron/kustomization.yaml b/kubernetes/kustomize/cron/kustomization.yaml deleted file mode 100644 index 6a91ca1..0000000 --- a/kubernetes/kustomize/cron/kustomization.yaml +++ /dev/null @@ -1,10 +0,0 @@ -resources: - - ../../namespace.yaml - - ../../deployments/cron.yaml - - ../../configmap/cron-env.yaml - - ../../configmap/cron-list.yaml -namespace: "{{PROJECT_NAME}}" -configMapGenerator: - - name: domains-urls - files: - - ../../../../../{{DOMAINS_URLS_FILEPATH}} diff --git a/kubernetes/kustomize/webserver/kustomization.yaml b/kubernetes/kustomize/webserver/kustomization.yaml index ff093e6..5835fbb 100644 --- a/kubernetes/kustomize/webserver/kustomization.yaml +++ b/kubernetes/kustomize/webserver/kustomization.yaml @@ -3,10 +3,13 @@ resources: - ../../services/webserver-php-fpm.yaml - ../../deployments/storefront.yaml - ../../services/storefront.yaml + - ../../deployments/cron.yaml - ../../namespace.yaml - ../../configmap/nginx.yaml - ../../configmap/production-php-fpm.yaml - ../../configmap/production-php-opcache.yaml + - ../../configmap/cron-env.yaml + - ../../configmap/cron-list.yaml - ../../ingress/ingress-rabbitmq.yaml - ../../horizontalPodAutoscaler.yaml - ../../horizontalStorefrontAutoscaler.yaml diff --git a/tests/scenarios/basic-production/expected/cron.yaml b/tests/scenarios/basic-production/expected/cron.yaml deleted file mode 100644 index b55c052..0000000 --- a/tests/scenarios/basic-production/expected/cron.yaml +++ /dev/null @@ -1,185 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 -data: - .project_env.sh: | - export ELASTICSEARCH_HOST='http://elasticsearch:9200' - export TRUSTED_PROXY='10.0.0.0/8' - export DATABASE_NAME='myproject-production' - export S3_ENDPOINT='https://s3.example.com' - export MAILER_FORCE_WHITELIST='false' - export DATABASE_USER='myproject-production' - export DATABASE_PORT='5432' - export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' - export REDIS_PREFIX='myproject-production' - export DATABASE_PASSWORD='test-db-password' - export DATABASE_HOST='10.0.0.100' - export ELASTIC_SEARCH_INDEX_PREFIX='myproject-production' - export S3_SECRET='test-s3-secret' - export MAILER_DSN='smtp://mailhog:1025' - export S3_BUCKET_NAME='myproject-production' - export S3_ACCESS_KEY='myproject-production' - export APP_SECRET='test-app-secret-key' -kind: ConfigMap -metadata: - name: cron-env - namespace: myproject-production ---- -apiVersion: v1 -data: - cron: |+ - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 - -kind: ConfigMap -metadata: - name: cron-list - namespace: myproject-production ---- -apiVersion: v1 -data: - domains_urls.yaml: | - domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk -kind: ConfigMap -metadata: - name: domains-urls-m8t7497btf - namespace: myproject-production ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: cron - name: cron - namespace: myproject-production -spec: - replicas: 1 - selector: - matchLabels: - app: cron - strategy: - type: Recreate - template: - metadata: - annotations: - logging/enabled: "true" - project/app: cron - project/environment: production - project/name: myproject - labels: - app: cron - date: "1234567890" - spec: - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - preference: - matchExpressions: - - key: workload - operator: In - values: - - background - weight: 100 - containers: - - args: - - | - ./phing warmup > /dev/null - # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe - # crontab crontab -u root /var/spool/cron/template - # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & - exec crond -f || exec cron -f - command: - - /bin/sh - - -lc - env: - - name: ELASTICSEARCH_HOST - value: http://elasticsearch:9200 - - name: TRUSTED_PROXY - value: 10.0.0.0/8 - - name: DATABASE_NAME - value: myproject-production - - name: S3_ENDPOINT - value: https://s3.example.com - - name: MAILER_FORCE_WHITELIST - value: "false" - - name: DATABASE_USER - value: myproject-production - - name: DATABASE_PORT - value: "5432" - - name: MESSENGER_TRANSPORT_DSN - value: amqp://guest:guest@rabbitmq:5672/%2f/messages - - name: REDIS_PREFIX - value: myproject-production - - name: DATABASE_PASSWORD - value: test-db-password - - name: DATABASE_HOST - value: 10.0.0.100 - - name: ELASTIC_SEARCH_INDEX_PREFIX - value: myproject-production - - name: S3_SECRET - value: test-s3-secret - - name: MAILER_DSN - value: smtp://mailhog:1025 - - name: S3_BUCKET_NAME - value: myproject-production - - name: S3_ACCESS_KEY - value: myproject-production - - name: APP_SECRET - value: test-app-secret-key - image: v1.0.0 - imagePullPolicy: IfNotPresent - lifecycle: - preStop: - exec: - command: - - /bin/sh - - -lc - - | - ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & - ./bin/console deploy:cron:watch || true - name: cron - securityContext: - runAsUser: 0 - volumeMounts: - - mountPath: /var/www/html/config/domains_urls.yaml - name: domains-urls - subPath: domains_urls.yaml - - mountPath: /var/spool/cron/template - name: cron-list - subPath: cron - - mountPath: /root/.project_env.sh - name: cron-env - subPath: .project_env.sh - - mountPath: /var/www/html/config/frontend-api - name: fe-api-keys-volume - readOnly: true - workingDir: /var/www/html - imagePullSecrets: - - name: dockerregistry - terminationGracePeriodSeconds: 3000 - tolerations: - - effect: NoSchedule - key: workload - operator: Equal - value: background - volumes: - - configMap: - name: domains-urls-m8t7497btf - name: domains-urls - - configMap: - name: cron-list - name: cron-list - - configMap: - name: cron-env - name: cron-env - - name: fe-api-keys-volume - secret: - defaultMode: 420 - secretName: fe-api-keys diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 887fdab..21514cf 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -4,6 +4,42 @@ metadata: name: myproject-production --- apiVersion: v1 +data: + .project_env.sh: | + export ELASTICSEARCH_HOST='http://elasticsearch:9200' + export TRUSTED_PROXY='10.0.0.0/8' + export DATABASE_NAME='myproject-production' + export S3_ENDPOINT='https://s3.example.com' + export MAILER_FORCE_WHITELIST='false' + export DATABASE_USER='myproject-production' + export DATABASE_PORT='5432' + export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' + export REDIS_PREFIX='myproject-production' + export DATABASE_PASSWORD='test-db-password' + export DATABASE_HOST='10.0.0.100' + export ELASTIC_SEARCH_INDEX_PREFIX='myproject-production' + export S3_SECRET='test-s3-secret' + export MAILER_DSN='smtp://mailhog:1025' + export S3_BUCKET_NAME='myproject-production' + export S3_ACCESS_KEY='myproject-production' + export APP_SECRET='test-app-secret-key' +kind: ConfigMap +metadata: + name: cron-env + namespace: myproject-production +--- +apiVersion: v1 +data: + cron: |+ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 + +kind: ConfigMap +metadata: + name: cron-list + namespace: myproject-production +--- +apiVersion: v1 data: domains_urls.yaml: | domains_urls: @@ -379,6 +415,138 @@ spec: --- apiVersion: apps/v1 kind: Deployment +metadata: + labels: + app: cron + name: cron + namespace: myproject-production +spec: + replicas: 1 + selector: + matchLabels: + app: cron + strategy: + type: Recreate + template: + metadata: + annotations: + logging/enabled: "true" + project/app: cron + project/environment: production + project/name: myproject + labels: + app: cron + date: "1234567890" + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: workload + operator: In + values: + - background + weight: 100 + containers: + - args: + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f + command: + - /bin/sh + - -lc + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: myproject-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-production + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-production + - name: S3_ACCESS_KEY + value: myproject-production + - name: APP_SECRET + value: test-app-secret-key + image: v1.0.0 + imagePullPolicy: IfNotPresent + lifecycle: + preStop: + exec: + command: + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true + name: cron + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml + - mountPath: /var/spool/cron/template + name: cron-list + subPath: cron + - mountPath: /root/.project_env.sh + name: cron-env + subPath: .project_env.sh + - mountPath: /var/www/html/config/frontend-api + name: fe-api-keys-volume + readOnly: true + workingDir: /var/www/html + imagePullSecrets: + - name: dockerregistry + terminationGracePeriodSeconds: 3000 + tolerations: + - effect: NoSchedule + key: workload + operator: Equal + value: background + volumes: + - configMap: + name: domains-urls-m8t7497btf + name: domains-urls + - configMap: + name: cron-list + name: cron-list + - configMap: + name: cron-env + name: cron-env + - name: fe-api-keys-volume + secret: + defaultMode: 420 + secretName: fe-api-keys +--- +apiVersion: apps/v1 +kind: Deployment metadata: name: storefront namespace: myproject-production diff --git a/tests/scenarios/development-single-domain/expected/cron.yaml b/tests/scenarios/development-single-domain/expected/cron.yaml deleted file mode 100644 index 1d97d62..0000000 --- a/tests/scenarios/development-single-domain/expected/cron.yaml +++ /dev/null @@ -1,183 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: myproject-dev ---- -apiVersion: v1 -data: - .project_env.sh: | - export ELASTICSEARCH_HOST='http://elasticsearch:9200' - export TRUSTED_PROXY='10.0.0.0/8' - export DATABASE_NAME='myproject-dev' - export S3_ENDPOINT='https://s3.example.com' - export MAILER_FORCE_WHITELIST='true' - export DATABASE_USER='myproject-dev' - export DATABASE_PORT='5432' - export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' - export REDIS_PREFIX='myproject-dev' - export DATABASE_PASSWORD='test-db-password' - export DATABASE_HOST='10.0.0.100' - export ELASTIC_SEARCH_INDEX_PREFIX='myproject-dev' - export S3_SECRET='test-s3-secret' - export MAILER_DSN='smtp://mailhog:1025' - export S3_BUCKET_NAME='myproject-dev' - export S3_ACCESS_KEY='myproject-dev' - export APP_SECRET='test-app-secret-key' -kind: ConfigMap -metadata: - name: cron-env - namespace: myproject-dev ---- -apiVersion: v1 -data: - cron: |+ - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 - -kind: ConfigMap -metadata: - name: cron-list - namespace: myproject-dev ---- -apiVersion: v1 -data: - domains_urls.yaml: | - domains_urls: - - id: 1 - url: https://dev.example.com -kind: ConfigMap -metadata: - name: domains-urls-5f46tgkghd - namespace: myproject-dev ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: cron - name: cron - namespace: myproject-dev -spec: - replicas: 1 - selector: - matchLabels: - app: cron - strategy: - type: Recreate - template: - metadata: - annotations: - logging/enabled: "true" - project/app: cron - project/environment: dev - project/name: myproject - labels: - app: cron - date: "1234567890" - spec: - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - preference: - matchExpressions: - - key: workload - operator: In - values: - - background - weight: 100 - containers: - - args: - - | - ./phing warmup > /dev/null - # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe - # crontab crontab -u root /var/spool/cron/template - # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & - exec crond -f || exec cron -f - command: - - /bin/sh - - -lc - env: - - name: ELASTICSEARCH_HOST - value: http://elasticsearch:9200 - - name: TRUSTED_PROXY - value: 10.0.0.0/8 - - name: DATABASE_NAME - value: myproject-dev - - name: S3_ENDPOINT - value: https://s3.example.com - - name: MAILER_FORCE_WHITELIST - value: "true" - - name: DATABASE_USER - value: myproject-dev - - name: DATABASE_PORT - value: "5432" - - name: MESSENGER_TRANSPORT_DSN - value: amqp://guest:guest@rabbitmq:5672/%2f/messages - - name: REDIS_PREFIX - value: myproject-dev - - name: DATABASE_PASSWORD - value: test-db-password - - name: DATABASE_HOST - value: 10.0.0.100 - - name: ELASTIC_SEARCH_INDEX_PREFIX - value: myproject-dev - - name: S3_SECRET - value: test-s3-secret - - name: MAILER_DSN - value: smtp://mailhog:1025 - - name: S3_BUCKET_NAME - value: myproject-dev - - name: S3_ACCESS_KEY - value: myproject-dev - - name: APP_SECRET - value: test-app-secret-key - image: dev-latest - imagePullPolicy: IfNotPresent - lifecycle: - preStop: - exec: - command: - - /bin/sh - - -lc - - | - ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & - ./bin/console deploy:cron:watch || true - name: cron - securityContext: - runAsUser: 0 - volumeMounts: - - mountPath: /var/www/html/config/domains_urls.yaml - name: domains-urls - subPath: domains_urls.yaml - - mountPath: /var/spool/cron/template - name: cron-list - subPath: cron - - mountPath: /root/.project_env.sh - name: cron-env - subPath: .project_env.sh - - mountPath: /var/www/html/config/frontend-api - name: fe-api-keys-volume - readOnly: true - workingDir: /var/www/html - imagePullSecrets: - - name: dockerregistry - terminationGracePeriodSeconds: 3000 - tolerations: - - effect: NoSchedule - key: workload - operator: Equal - value: background - volumes: - - configMap: - name: domains-urls-5f46tgkghd - name: domains-urls - - configMap: - name: cron-list - name: cron-list - - configMap: - name: cron-env - name: cron-env - - name: fe-api-keys-volume - secret: - defaultMode: 420 - secretName: fe-api-keys diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 554ccbf..e290c4b 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -4,6 +4,42 @@ metadata: name: myproject-dev --- apiVersion: v1 +data: + .project_env.sh: | + export ELASTICSEARCH_HOST='http://elasticsearch:9200' + export TRUSTED_PROXY='10.0.0.0/8' + export DATABASE_NAME='myproject-dev' + export S3_ENDPOINT='https://s3.example.com' + export MAILER_FORCE_WHITELIST='true' + export DATABASE_USER='myproject-dev' + export DATABASE_PORT='5432' + export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' + export REDIS_PREFIX='myproject-dev' + export DATABASE_PASSWORD='test-db-password' + export DATABASE_HOST='10.0.0.100' + export ELASTIC_SEARCH_INDEX_PREFIX='myproject-dev' + export S3_SECRET='test-s3-secret' + export MAILER_DSN='smtp://mailhog:1025' + export S3_BUCKET_NAME='myproject-dev' + export S3_ACCESS_KEY='myproject-dev' + export APP_SECRET='test-app-secret-key' +kind: ConfigMap +metadata: + name: cron-env + namespace: myproject-dev +--- +apiVersion: v1 +data: + cron: |+ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 + +kind: ConfigMap +metadata: + name: cron-list + namespace: myproject-dev +--- +apiVersion: v1 data: domains_urls.yaml: | domains_urls: @@ -377,6 +413,138 @@ spec: --- apiVersion: apps/v1 kind: Deployment +metadata: + labels: + app: cron + name: cron + namespace: myproject-dev +spec: + replicas: 1 + selector: + matchLabels: + app: cron + strategy: + type: Recreate + template: + metadata: + annotations: + logging/enabled: "true" + project/app: cron + project/environment: dev + project/name: myproject + labels: + app: cron + date: "1234567890" + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: workload + operator: In + values: + - background + weight: 100 + containers: + - args: + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f + command: + - /bin/sh + - -lc + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-dev + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "true" + - name: DATABASE_USER + value: myproject-dev + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-dev + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-dev + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-dev + - name: S3_ACCESS_KEY + value: myproject-dev + - name: APP_SECRET + value: test-app-secret-key + image: dev-latest + imagePullPolicy: IfNotPresent + lifecycle: + preStop: + exec: + command: + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true + name: cron + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml + - mountPath: /var/spool/cron/template + name: cron-list + subPath: cron + - mountPath: /root/.project_env.sh + name: cron-env + subPath: .project_env.sh + - mountPath: /var/www/html/config/frontend-api + name: fe-api-keys-volume + readOnly: true + workingDir: /var/www/html + imagePullSecrets: + - name: dockerregistry + terminationGracePeriodSeconds: 3000 + tolerations: + - effect: NoSchedule + key: workload + operator: Equal + value: background + volumes: + - configMap: + name: domains-urls-5f46tgkghd + name: domains-urls + - configMap: + name: cron-list + name: cron-list + - configMap: + name: cron-env + name: cron-env + - name: fe-api-keys-volume + secret: + defaultMode: 420 + secretName: fe-api-keys +--- +apiVersion: apps/v1 +kind: Deployment metadata: name: storefront namespace: myproject-dev diff --git a/tests/scenarios/escaping-env/expected/cron.yaml b/tests/scenarios/escaping-env/expected/cron.yaml deleted file mode 100644 index 29f3e89..0000000 --- a/tests/scenarios/escaping-env/expected/cron.yaml +++ /dev/null @@ -1,188 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 -data: - .project_env.sh: | - export ELASTICSEARCH_HOST='http://elasticsearch:9200' - export TRUSTED_PROXY='10.0.0.0/8' - export DATABASE_NAME='myproject-production' - export S3_ENDPOINT='https://s3.example.com' - export MAILER_FORCE_WHITELIST='false' - export DATABASE_USER='myproject-production' - export DATABASE_PORT='5432' - export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' - export REDIS_PREFIX='myproject-production' - export DATABASE_PASSWORD='test-db-password' - export DATABASE_HOST='10.0.0.100' - export ELASTIC_SEARCH_INDEX_PREFIX='myproject-production' - export SENTRY_RELEASE='479411e7' - export S3_SECRET='test-s3-secret' - export MAILER_DSN='smtp://mailhog:1025' - export S3_BUCKET_NAME='myproject-production' - export S3_ACCESS_KEY='myproject-production' - export APP_SECRET='test-app-secret-key' -kind: ConfigMap -metadata: - name: cron-env - namespace: myproject-production ---- -apiVersion: v1 -data: - cron: |+ - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 - -kind: ConfigMap -metadata: - name: cron-list - namespace: myproject-production ---- -apiVersion: v1 -data: - domains_urls.yaml: | - domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk -kind: ConfigMap -metadata: - name: domains-urls-m8t7497btf - namespace: myproject-production ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: cron - name: cron - namespace: myproject-production -spec: - replicas: 1 - selector: - matchLabels: - app: cron - strategy: - type: Recreate - template: - metadata: - annotations: - logging/enabled: "true" - project/app: cron - project/environment: production - project/name: myproject - labels: - app: cron - date: "1234567890" - spec: - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - preference: - matchExpressions: - - key: workload - operator: In - values: - - background - weight: 100 - containers: - - args: - - | - ./phing warmup > /dev/null - # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe - # crontab crontab -u root /var/spool/cron/template - # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & - exec crond -f || exec cron -f - command: - - /bin/sh - - -lc - env: - - name: ELASTICSEARCH_HOST - value: http://elasticsearch:9200 - - name: TRUSTED_PROXY - value: 10.0.0.0/8 - - name: DATABASE_NAME - value: myproject-production - - name: S3_ENDPOINT - value: https://s3.example.com - - name: MAILER_FORCE_WHITELIST - value: "false" - - name: DATABASE_USER - value: myproject-production - - name: DATABASE_PORT - value: "5432" - - name: MESSENGER_TRANSPORT_DSN - value: amqp://guest:guest@rabbitmq:5672/%2f/messages - - name: REDIS_PREFIX - value: myproject-production - - name: DATABASE_PASSWORD - value: test-db-password - - name: DATABASE_HOST - value: 10.0.0.100 - - name: ELASTIC_SEARCH_INDEX_PREFIX - value: myproject-production - - name: SENTRY_RELEASE - value: "479411e7" - - name: S3_SECRET - value: test-s3-secret - - name: MAILER_DSN - value: smtp://mailhog:1025 - - name: S3_BUCKET_NAME - value: myproject-production - - name: S3_ACCESS_KEY - value: myproject-production - - name: APP_SECRET - value: test-app-secret-key - image: v1.0.0 - imagePullPolicy: IfNotPresent - lifecycle: - preStop: - exec: - command: - - /bin/sh - - -lc - - | - ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & - ./bin/console deploy:cron:watch || true - name: cron - securityContext: - runAsUser: 0 - volumeMounts: - - mountPath: /var/www/html/config/domains_urls.yaml - name: domains-urls - subPath: domains_urls.yaml - - mountPath: /var/spool/cron/template - name: cron-list - subPath: cron - - mountPath: /root/.project_env.sh - name: cron-env - subPath: .project_env.sh - - mountPath: /var/www/html/config/frontend-api - name: fe-api-keys-volume - readOnly: true - workingDir: /var/www/html - imagePullSecrets: - - name: dockerregistry - terminationGracePeriodSeconds: 3000 - tolerations: - - effect: NoSchedule - key: workload - operator: Equal - value: background - volumes: - - configMap: - name: domains-urls-m8t7497btf - name: domains-urls - - configMap: - name: cron-list - name: cron-list - - configMap: - name: cron-env - name: cron-env - - name: fe-api-keys-volume - secret: - defaultMode: 420 - secretName: fe-api-keys diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index b99fc08..9027719 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -4,6 +4,43 @@ metadata: name: myproject-production --- apiVersion: v1 +data: + .project_env.sh: | + export ELASTICSEARCH_HOST='http://elasticsearch:9200' + export TRUSTED_PROXY='10.0.0.0/8' + export DATABASE_NAME='myproject-production' + export S3_ENDPOINT='https://s3.example.com' + export MAILER_FORCE_WHITELIST='false' + export DATABASE_USER='myproject-production' + export DATABASE_PORT='5432' + export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' + export REDIS_PREFIX='myproject-production' + export DATABASE_PASSWORD='test-db-password' + export DATABASE_HOST='10.0.0.100' + export ELASTIC_SEARCH_INDEX_PREFIX='myproject-production' + export SENTRY_RELEASE='479411e7' + export S3_SECRET='test-s3-secret' + export MAILER_DSN='smtp://mailhog:1025' + export S3_BUCKET_NAME='myproject-production' + export S3_ACCESS_KEY='myproject-production' + export APP_SECRET='test-app-secret-key' +kind: ConfigMap +metadata: + name: cron-env + namespace: myproject-production +--- +apiVersion: v1 +data: + cron: |+ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 + +kind: ConfigMap +metadata: + name: cron-list + namespace: myproject-production +--- +apiVersion: v1 data: domains_urls.yaml: | domains_urls: @@ -379,6 +416,140 @@ spec: --- apiVersion: apps/v1 kind: Deployment +metadata: + labels: + app: cron + name: cron + namespace: myproject-production +spec: + replicas: 1 + selector: + matchLabels: + app: cron + strategy: + type: Recreate + template: + metadata: + annotations: + logging/enabled: "true" + project/app: cron + project/environment: production + project/name: myproject + labels: + app: cron + date: "1234567890" + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: workload + operator: In + values: + - background + weight: 100 + containers: + - args: + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f + command: + - /bin/sh + - -lc + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: myproject-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-production + - name: SENTRY_RELEASE + value: "479411e7" + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-production + - name: S3_ACCESS_KEY + value: myproject-production + - name: APP_SECRET + value: test-app-secret-key + image: v1.0.0 + imagePullPolicy: IfNotPresent + lifecycle: + preStop: + exec: + command: + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true + name: cron + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml + - mountPath: /var/spool/cron/template + name: cron-list + subPath: cron + - mountPath: /root/.project_env.sh + name: cron-env + subPath: .project_env.sh + - mountPath: /var/www/html/config/frontend-api + name: fe-api-keys-volume + readOnly: true + workingDir: /var/www/html + imagePullSecrets: + - name: dockerregistry + terminationGracePeriodSeconds: 3000 + tolerations: + - effect: NoSchedule + key: workload + operator: Equal + value: background + volumes: + - configMap: + name: domains-urls-m8t7497btf + name: domains-urls + - configMap: + name: cron-list + name: cron-list + - configMap: + name: cron-env + name: cron-env + - name: fe-api-keys-volume + secret: + defaultMode: 420 + secretName: fe-api-keys +--- +apiVersion: apps/v1 +kind: Deployment metadata: name: storefront namespace: myproject-production diff --git a/tests/scenarios/production-with-cloudflare/expected/cron.yaml b/tests/scenarios/production-with-cloudflare/expected/cron.yaml deleted file mode 100644 index 51447ac..0000000 --- a/tests/scenarios/production-with-cloudflare/expected/cron.yaml +++ /dev/null @@ -1,186 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: shop-production ---- -apiVersion: v1 -data: - .project_env.sh: | - export ELASTICSEARCH_HOST='http://elasticsearch:9200' - export TRUSTED_PROXY='10.0.0.0/8' - export DATABASE_NAME='shop-production' - export S3_ENDPOINT='https://s3.example.com' - export MAILER_FORCE_WHITELIST='false' - export DATABASE_USER='shop-production' - export DATABASE_PORT='5432' - export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' - export REDIS_PREFIX='shop-production' - export DATABASE_PASSWORD='test-db-password' - export DATABASE_HOST='10.0.0.100' - export ELASTIC_SEARCH_INDEX_PREFIX='shop-production' - export S3_SECRET='test-s3-secret' - export MAILER_DSN='smtp://mailhog:1025' - export S3_BUCKET_NAME='shop-production' - export S3_ACCESS_KEY='shop-production' - export APP_SECRET='test-app-secret-key' -kind: ConfigMap -metadata: - name: cron-env - namespace: shop-production ---- -apiVersion: v1 -data: - cron: |+ - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 - 0 */2 * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing feed-generator > /dev/null 2>&1 - -kind: ConfigMap -metadata: - name: cron-list - namespace: shop-production ---- -apiVersion: v1 -data: - domains_urls.yaml: | - domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de -kind: ConfigMap -metadata: - name: domains-urls-47t6ghttc4 - namespace: shop-production ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: cron - name: cron - namespace: shop-production -spec: - replicas: 1 - selector: - matchLabels: - app: cron - strategy: - type: Recreate - template: - metadata: - annotations: - logging/enabled: "true" - project/app: cron - project/environment: production - project/name: shop - labels: - app: cron - date: "1234567890" - spec: - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - preference: - matchExpressions: - - key: workload - operator: In - values: - - background - weight: 100 - containers: - - args: - - | - ./phing warmup > /dev/null - # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe - # crontab crontab -u root /var/spool/cron/template - # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & - exec crond -f || exec cron -f - command: - - /bin/sh - - -lc - env: - - name: ELASTICSEARCH_HOST - value: http://elasticsearch:9200 - - name: TRUSTED_PROXY - value: 10.0.0.0/8 - - name: DATABASE_NAME - value: shop-production - - name: S3_ENDPOINT - value: https://s3.example.com - - name: MAILER_FORCE_WHITELIST - value: "false" - - name: DATABASE_USER - value: shop-production - - name: DATABASE_PORT - value: "5432" - - name: MESSENGER_TRANSPORT_DSN - value: amqp://guest:guest@rabbitmq:5672/%2f/messages - - name: REDIS_PREFIX - value: shop-production - - name: DATABASE_PASSWORD - value: test-db-password - - name: DATABASE_HOST - value: 10.0.0.100 - - name: ELASTIC_SEARCH_INDEX_PREFIX - value: shop-production - - name: S3_SECRET - value: test-s3-secret - - name: MAILER_DSN - value: smtp://mailhog:1025 - - name: S3_BUCKET_NAME - value: shop-production - - name: S3_ACCESS_KEY - value: shop-production - - name: APP_SECRET - value: test-app-secret-key - image: v2.5.0 - imagePullPolicy: IfNotPresent - lifecycle: - preStop: - exec: - command: - - /bin/sh - - -lc - - | - ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & - ./bin/console deploy:cron:watch || true - name: cron - securityContext: - runAsUser: 0 - volumeMounts: - - mountPath: /var/www/html/config/domains_urls.yaml - name: domains-urls - subPath: domains_urls.yaml - - mountPath: /var/spool/cron/template - name: cron-list - subPath: cron - - mountPath: /root/.project_env.sh - name: cron-env - subPath: .project_env.sh - - mountPath: /var/www/html/config/frontend-api - name: fe-api-keys-volume - readOnly: true - workingDir: /var/www/html - imagePullSecrets: - - name: dockerregistry - terminationGracePeriodSeconds: 3000 - tolerations: - - effect: NoSchedule - key: workload - operator: Equal - value: background - volumes: - - configMap: - name: domains-urls-47t6ghttc4 - name: domains-urls - - configMap: - name: cron-list - name: cron-list - - configMap: - name: cron-env - name: cron-env - - name: fe-api-keys-volume - secret: - defaultMode: 420 - secretName: fe-api-keys diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index e0ea520..b58fb06 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -4,6 +4,43 @@ metadata: name: shop-production --- apiVersion: v1 +data: + .project_env.sh: | + export ELASTICSEARCH_HOST='http://elasticsearch:9200' + export TRUSTED_PROXY='10.0.0.0/8' + export DATABASE_NAME='shop-production' + export S3_ENDPOINT='https://s3.example.com' + export MAILER_FORCE_WHITELIST='false' + export DATABASE_USER='shop-production' + export DATABASE_PORT='5432' + export MESSENGER_TRANSPORT_DSN='amqp://guest:guest@rabbitmq:5672/%2f/messages' + export REDIS_PREFIX='shop-production' + export DATABASE_PASSWORD='test-db-password' + export DATABASE_HOST='10.0.0.100' + export ELASTIC_SEARCH_INDEX_PREFIX='shop-production' + export S3_SECRET='test-s3-secret' + export MAILER_DSN='smtp://mailhog:1025' + export S3_BUCKET_NAME='shop-production' + export S3_ACCESS_KEY='shop-production' + export APP_SECRET='test-app-secret-key' +kind: ConfigMap +metadata: + name: cron-env + namespace: shop-production +--- +apiVersion: v1 +data: + cron: |+ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + */5 * * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing cron > /dev/null 2>&1 + 0 */2 * * * . /root/.project_env.sh && cd /var/www/html/ && ./phing feed-generator > /dev/null 2>&1 + +kind: ConfigMap +metadata: + name: cron-list + namespace: shop-production +--- +apiVersion: v1 data: domains_urls.yaml: | domains_urls: @@ -379,6 +416,138 @@ spec: --- apiVersion: apps/v1 kind: Deployment +metadata: + labels: + app: cron + name: cron + namespace: shop-production +spec: + replicas: 1 + selector: + matchLabels: + app: cron + strategy: + type: Recreate + template: + metadata: + annotations: + logging/enabled: "true" + project/app: cron + project/environment: production + project/name: shop + labels: + app: cron + date: "1234567890" + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: workload + operator: In + values: + - background + weight: 100 + containers: + - args: + - | + ./phing warmup > /dev/null + # FIFO for logs rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe + # crontab crontab -u root /var/spool/cron/template + # run on backround stdbuf -o0 tail -n +1 -f /tmp/log-pipe & + exec crond -f || exec cron -f + command: + - /bin/sh + - -lc + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: shop-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: shop-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: shop-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: shop-production + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: shop-production + - name: S3_ACCESS_KEY + value: shop-production + - name: APP_SECRET + value: test-app-secret-key + image: v2.5.0 + imagePullPolicy: IfNotPresent + lifecycle: + preStop: + exec: + command: + - /bin/sh + - -lc + - | + ( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) & + ./bin/console deploy:cron:watch || true + name: cron + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml + - mountPath: /var/spool/cron/template + name: cron-list + subPath: cron + - mountPath: /root/.project_env.sh + name: cron-env + subPath: .project_env.sh + - mountPath: /var/www/html/config/frontend-api + name: fe-api-keys-volume + readOnly: true + workingDir: /var/www/html + imagePullSecrets: + - name: dockerregistry + terminationGracePeriodSeconds: 3000 + tolerations: + - effect: NoSchedule + key: workload + operator: Equal + value: background + volumes: + - configMap: + name: domains-urls-47t6ghttc4 + name: domains-urls + - configMap: + name: cron-list + name: cron-list + - configMap: + name: cron-env + name: cron-env + - name: fe-api-keys-volume + secret: + defaultMode: 420 + secretName: fe-api-keys +--- +apiVersion: apps/v1 +kind: Deployment metadata: name: storefront namespace: shop-production From 975e7c95d5565405f753825628824aaaf1b8cb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 09:06:36 +0200 Subject: [PATCH 05/17] fix liveness and readiness probes for webserver --- kubernetes/configmap/nginx.yaml | 9 +++- kubernetes/configmap/production-php-fpm.yaml | 2 + kubernetes/deployments/webserver-php-fpm.yaml | 35 ++++++++++----- .../basic-production/expected/webserver.yaml | 45 ++++++++++++++----- .../expected/webserver.yaml | 45 ++++++++++++++----- .../escaping-env/expected/webserver.yaml | 45 ++++++++++++++----- .../expected/webserver.yaml | 45 ++++++++++++++----- 7 files changed, 174 insertions(+), 52 deletions(-) diff --git a/kubernetes/configmap/nginx.yaml b/kubernetes/configmap/nginx.yaml index 8bf897e..9838510 100644 --- a/kubernetes/configmap/nginx.yaml +++ b/kubernetes/configmap/nginx.yaml @@ -73,8 +73,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } diff --git a/kubernetes/configmap/production-php-fpm.yaml b/kubernetes/configmap/production-php-fpm.yaml index 22e11fd..89eb840 100644 --- a/kubernetes/configmap/production-php-fpm.yaml +++ b/kubernetes/configmap/production-php-fpm.yaml @@ -15,6 +15,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 diff --git a/kubernetes/deployments/webserver-php-fpm.yaml b/kubernetes/deployments/webserver-php-fpm.yaml index 0151a5e..8c4d615 100644 --- a/kubernetes/deployments/webserver-php-fpm.yaml +++ b/kubernetes/deployments/webserver-php-fpm.yaml @@ -94,10 +94,19 @@ spec: command: ["/var/www/html/phing", "-S", "warmup"] preStop: exec: - command: - - sh - - '-c' - - sleep 10 && kill -SIGQUIT 1 + command: ["/bin/sh","-lc","sleep 10; kill -QUIT 1 || true"] + livenessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 2 + readinessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 volumeMounts: - name: source-codes mountPath: /var/www/html @@ -125,20 +134,24 @@ spec: ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 httpGet: path: /health - port: 80 + port: health + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 3 + failureThreshold: 6 readinessProbe: httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 3 volumeMounts: - name: nginx-default-config mountPath: /etc/nginx/nginx.conf diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 21514cf..8e64f5d 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -124,8 +124,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -353,6 +360,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -729,10 +738,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -764,23 +785,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index e290c4b..b5b5913 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -122,8 +122,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -351,6 +358,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -723,10 +732,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -758,23 +779,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index 9027719..a5dcf01 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -125,8 +125,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -354,6 +361,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -736,10 +745,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -771,23 +792,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index b58fb06..e842533 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -125,8 +125,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -354,6 +361,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -730,10 +739,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -765,23 +786,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi From 51354409c47a59f29224fcd60eeee741dc9793ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 09:06:53 +0200 Subject: [PATCH 06/17] move warmup to init container --- deploy/parts/environment-variables.sh | 8 +++ kubernetes/deployments/webserver-php-fpm.yaml | 12 +++- .../basic-production/expected/webserver.yaml | 53 ++++++++++++++++-- .../expected/webserver.yaml | 53 ++++++++++++++++-- .../escaping-env/expected/webserver.yaml | 55 +++++++++++++++++-- .../expected/webserver.yaml | 53 ++++++++++++++++-- 6 files changed, 207 insertions(+), 27 deletions(-) diff --git a/deploy/parts/environment-variables.sh b/deploy/parts/environment-variables.sh index da3d96c..40baacf 100644 --- a/deploy/parts/environment-variables.sh +++ b/deploy/parts/environment-variables.sh @@ -36,6 +36,14 @@ for key in "${!ENVIRONMENT_VARIABLES[@]}"; do } " "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" + # Webserver PHP-FPM warmup container + yq e -i " + .spec.template.spec.initContainers[1].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" + # Cron deployment yq e -i " .spec.template.spec.containers[0].env[${ITERATOR}] = { diff --git a/kubernetes/deployments/webserver-php-fpm.yaml b/kubernetes/deployments/webserver-php-fpm.yaml index 8c4d615..98ee714 100644 --- a/kubernetes/deployments/webserver-php-fpm.yaml +++ b/kubernetes/deployments/webserver-php-fpm.yaml @@ -83,15 +83,21 @@ spec: - name: domains-urls mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}} subPath: "{{DOMAINS_URLS_FILENAME}}" + - name: warmup + image: "{{TAG}}" + command: ["/var/www/html/phing", "-S", "warmup"] + volumeMounts: + - name: source-codes + mountPath: /var/www/html + - name: domains-urls + mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}} + subPath: "{{DOMAINS_URLS_FILENAME}}" containers: - image: "{{TAG}}" name: php-fpm imagePullPolicy: IfNotPresent workingDir: /var/www/html lifecycle: - postStart: - exec: - command: ["/var/www/html/phing", "-S", "warmup"] preStop: exec: command: ["/bin/sh","-lc","sleep 10; kill -QUIT 1 || true"] diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 8e64f5d..46f007a 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -729,12 +729,6 @@ spec: image: v1.0.0 imagePullPolicy: IfNotPresent lifecycle: - postStart: - exec: - command: - - /var/www/html/phing - - -S - - warmup preStop: exec: command: @@ -842,6 +836,53 @@ spec: - mountPath: /var/www/html/config/domains_urls.yaml name: domains-urls subPath: domains_urls.yaml + - command: + - /var/www/html/phing + - -S + - warmup + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: myproject-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-production + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-production + - name: S3_ACCESS_KEY + value: myproject-production + - name: APP_SECRET + value: test-app-secret-key + image: v1.0.0 + name: warmup + volumeMounts: + - mountPath: /var/www/html + name: source-codes + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml terminationGracePeriodSeconds: 120 volumes: - emptyDir: {} diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index b5b5913..0e5a5fe 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -723,12 +723,6 @@ spec: image: dev-latest imagePullPolicy: IfNotPresent lifecycle: - postStart: - exec: - command: - - /var/www/html/phing - - -S - - warmup preStop: exec: command: @@ -836,6 +830,53 @@ spec: - mountPath: /var/www/html/config/domains_urls.yaml name: domains-urls subPath: domains_urls.yaml + - command: + - /var/www/html/phing + - -S + - warmup + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-dev + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "true" + - name: DATABASE_USER + value: myproject-dev + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-dev + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-dev + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-dev + - name: S3_ACCESS_KEY + value: myproject-dev + - name: APP_SECRET + value: test-app-secret-key + image: dev-latest + name: warmup + volumeMounts: + - mountPath: /var/www/html + name: source-codes + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml terminationGracePeriodSeconds: 120 volumes: - emptyDir: {} diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index a5dcf01..f4387af 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -736,12 +736,6 @@ spec: image: v1.0.0 imagePullPolicy: IfNotPresent lifecycle: - postStart: - exec: - command: - - /var/www/html/phing - - -S - - warmup preStop: exec: command: @@ -849,6 +843,55 @@ spec: - mountPath: /var/www/html/config/domains_urls.yaml name: domains-urls subPath: domains_urls.yaml + - command: + - /var/www/html/phing + - -S + - warmup + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: myproject-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: myproject-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: myproject-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: myproject-production + - name: SENTRY_RELEASE + value: "479411e7" + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: myproject-production + - name: S3_ACCESS_KEY + value: myproject-production + - name: APP_SECRET + value: test-app-secret-key + image: v1.0.0 + name: warmup + volumeMounts: + - mountPath: /var/www/html + name: source-codes + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml terminationGracePeriodSeconds: 120 volumes: - emptyDir: {} diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index e842533..55cbca2 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -730,12 +730,6 @@ spec: image: v2.5.0 imagePullPolicy: IfNotPresent lifecycle: - postStart: - exec: - command: - - /var/www/html/phing - - -S - - warmup preStop: exec: command: @@ -843,6 +837,53 @@ spec: - mountPath: /var/www/html/config/domains_urls.yaml name: domains-urls subPath: domains_urls.yaml + - command: + - /var/www/html/phing + - -S + - warmup + env: + - name: ELASTICSEARCH_HOST + value: http://elasticsearch:9200 + - name: TRUSTED_PROXY + value: 10.0.0.0/8 + - name: DATABASE_NAME + value: shop-production + - name: S3_ENDPOINT + value: https://s3.example.com + - name: MAILER_FORCE_WHITELIST + value: "false" + - name: DATABASE_USER + value: shop-production + - name: DATABASE_PORT + value: "5432" + - name: MESSENGER_TRANSPORT_DSN + value: amqp://guest:guest@rabbitmq:5672/%2f/messages + - name: REDIS_PREFIX + value: shop-production + - name: DATABASE_PASSWORD + value: test-db-password + - name: DATABASE_HOST + value: 10.0.0.100 + - name: ELASTIC_SEARCH_INDEX_PREFIX + value: shop-production + - name: S3_SECRET + value: test-s3-secret + - name: MAILER_DSN + value: smtp://mailhog:1025 + - name: S3_BUCKET_NAME + value: shop-production + - name: S3_ACCESS_KEY + value: shop-production + - name: APP_SECRET + value: test-app-secret-key + image: v2.5.0 + name: warmup + volumeMounts: + - mountPath: /var/www/html + name: source-codes + - mountPath: /var/www/html/config/domains_urls.yaml + name: domains-urls + subPath: domains_urls.yaml terminationGracePeriodSeconds: 120 volumes: - emptyDir: {} From a31b53adca7df19f25edef4970bdbd33b66960bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 09:26:39 +0200 Subject: [PATCH 07/17] change order for redis container to be able to connect it without container specified --- kubernetes/deployments/redis.yaml | 26 +++++++++---------- .../expected/migrate-continuous-deploy.yaml | 26 +++++++++---------- .../migrate-first-deploy-with-demo-data.yaml | 26 +++++++++---------- .../expected/migrate-first-deploy.yaml | 26 +++++++++---------- .../expected/migrate-continuous-deploy.yaml | 26 +++++++++---------- .../migrate-first-deploy-with-demo-data.yaml | 26 +++++++++---------- .../expected/migrate-first-deploy.yaml | 26 +++++++++---------- .../expected/migrate-continuous-deploy.yaml | 26 +++++++++---------- .../migrate-first-deploy-with-demo-data.yaml | 26 +++++++++---------- .../expected/migrate-first-deploy.yaml | 26 +++++++++---------- .../expected/migrate-continuous-deploy.yaml | 26 +++++++++---------- .../migrate-first-deploy-with-demo-data.yaml | 26 +++++++++---------- .../expected/migrate-first-deploy.yaml | 26 +++++++++---------- 13 files changed, 169 insertions(+), 169 deletions(-) diff --git a/kubernetes/deployments/redis.yaml b/kubernetes/deployments/redis.yaml index 715b7dc..d5f4aaf 100644 --- a/kubernetes/deployments/redis.yaml +++ b/kubernetes/deployments/redis.yaml @@ -27,19 +27,6 @@ spec: name: redis defaultMode: 0755 containers: - - name: redis-exporter - image: "oliver006/redis_exporter" - imagePullPolicy: Always - ports: - - name: exporter - containerPort: 9121 - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - name: redis image: "{{REDIS_VERSION}}" ports: @@ -76,3 +63,16 @@ spec: requests: memory: "2500Mi" cpu: "100m" + - name: redis-exporter + image: "oliver006/redis_exporter" + imagePullPolicy: Always + ports: + - name: exporter + containerPort: 9121 + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi diff --git a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml index 79076f9..db00365 100644 --- a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml @@ -236,19 +236,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -285,6 +272,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml index bf040b1..00b1604 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml @@ -236,19 +236,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -285,6 +272,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml index 7b9ec6c..f754b94 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml @@ -236,19 +236,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -285,6 +272,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml index 0e74d2e..f6cdf4f 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml @@ -117,19 +117,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -166,6 +153,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml index 76dc46e..14a9bc2 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml @@ -117,19 +117,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -166,6 +153,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml index a047f20..1596709 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml @@ -117,19 +117,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -166,6 +153,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml index 340088c..95f63d7 100644 --- a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml @@ -238,19 +238,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -287,6 +274,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml index b81c351..f4a6620 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml @@ -238,19 +238,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -287,6 +274,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml index 62b915e..3ae5277 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml @@ -238,19 +238,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -287,6 +274,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml index c4225cb..d053b0b 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml @@ -353,19 +353,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -402,6 +389,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml index 780ffd8..02eb055 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml @@ -353,19 +353,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -402,6 +389,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml index 3e0da2b..42dc97a 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml @@ -353,19 +353,6 @@ spec: app: redis spec: containers: - - image: oliver006/redis_exporter - imagePullPolicy: Always - name: redis-exporter - ports: - - containerPort: 9121 - name: exporter - protocol: TCP - resources: - limits: - memory: 128Mi - requests: - cpu: 10m - memory: 128Mi - args: - /usr/local/etc/redis/redis.conf image: redis:7.4-alpine @@ -402,6 +389,19 @@ spec: - mountPath: /usr/local/etc/redis/redis.conf name: config subPath: redis.conf + - image: oliver006/redis_exporter + imagePullPolicy: Always + name: redis-exporter + ports: + - containerPort: 9121 + name: exporter + protocol: TCP + resources: + limits: + memory: 128Mi + requests: + cpu: 10m + memory: 128Mi volumes: - configMap: defaultMode: 493 From 8e303e5bd10545a6acd873cb9ed25ed98cdf6c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Thu, 4 Sep 2025 09:29:23 +0200 Subject: [PATCH 08/17] improve graceful stop for storefront --- kubernetes/deployments/storefront.yaml | 22 +++++++++++------- .../basic-production/expected/webserver.yaml | 23 +++++++++++++------ .../expected/webserver.yaml | 23 +++++++++++++------ .../escaping-env/expected/webserver.yaml | 23 +++++++++++++------ .../expected/webserver.yaml | 23 +++++++++++++------ 5 files changed, 78 insertions(+), 36 deletions(-) diff --git a/kubernetes/deployments/storefront.yaml b/kubernetes/deployments/storefront.yaml index d59e3b7..708d8c2 100644 --- a/kubernetes/deployments/storefront.yaml +++ b/kubernetes/deployments/storefront.yaml @@ -44,29 +44,35 @@ spec: lifecycle: preStop: exec: - command: - - sleep - - '10' + command: ["/bin/sh","-lc","sleep 10"] resources: limits: memory: "1.5Gi" requests: cpu: "500m" memory: "800Mi" + startupProbe: + httpGet: + path: /api/health + port: 3000 + periodSeconds: 2 + timeoutSeconds: 2 + failureThreshold: 60 livenessProbe: httpGet: path: /api/health port: 3000 - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 2 + failureThreshold: 3 readinessProbe: httpGet: path: /api/health port: 3000 initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 3 + timeoutSeconds: 2 + failureThreshold: 1 terminationGracePeriodSeconds: 60 imagePullSecrets: - name: dockerregistry diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 46f007a..3a38871 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -608,33 +608,42 @@ spec: preStop: exec: command: - - sleep - - "10" + - /bin/sh + - -lc + - sleep 10 livenessProbe: + failureThreshold: 3 httpGet: path: /api/health port: 3000 - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 2 name: storefront ports: - containerPort: 3000 name: storefront protocol: TCP readinessProbe: + failureThreshold: 1 httpGet: path: /api/health port: 3000 initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 3 + timeoutSeconds: 2 resources: limits: memory: 1.5Gi requests: cpu: 500m memory: 800Mi + startupProbe: + failureThreshold: 60 + httpGet: + path: /api/health + port: 3000 + periodSeconds: 2 + timeoutSeconds: 2 imagePullSecrets: - name: dockerregistry terminationGracePeriodSeconds: 60 diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 0e5a5fe..100fbb7 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -602,33 +602,42 @@ spec: preStop: exec: command: - - sleep - - "10" + - /bin/sh + - -lc + - sleep 10 livenessProbe: + failureThreshold: 3 httpGet: path: /api/health port: 3000 - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 2 name: storefront ports: - containerPort: 3000 name: storefront protocol: TCP readinessProbe: + failureThreshold: 1 httpGet: path: /api/health port: 3000 initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 3 + timeoutSeconds: 2 resources: limits: memory: 1.5Gi requests: cpu: 500m memory: 800Mi + startupProbe: + failureThreshold: 60 + httpGet: + path: /api/health + port: 3000 + periodSeconds: 2 + timeoutSeconds: 2 imagePullSecrets: - name: dockerregistry terminationGracePeriodSeconds: 60 diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index f4387af..c44379c 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -613,33 +613,42 @@ spec: preStop: exec: command: - - sleep - - "10" + - /bin/sh + - -lc + - sleep 10 livenessProbe: + failureThreshold: 3 httpGet: path: /api/health port: 3000 - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 2 name: storefront ports: - containerPort: 3000 name: storefront protocol: TCP readinessProbe: + failureThreshold: 1 httpGet: path: /api/health port: 3000 initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 3 + timeoutSeconds: 2 resources: limits: memory: 1.5Gi requests: cpu: 500m memory: 800Mi + startupProbe: + failureThreshold: 60 + httpGet: + path: /api/health + port: 3000 + periodSeconds: 2 + timeoutSeconds: 2 imagePullSecrets: - name: dockerregistry terminationGracePeriodSeconds: 60 diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 55cbca2..0e104a1 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -609,33 +609,42 @@ spec: preStop: exec: command: - - sleep - - "10" + - /bin/sh + - -lc + - sleep 10 livenessProbe: + failureThreshold: 3 httpGet: path: /api/health port: 3000 - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 2 name: storefront ports: - containerPort: 3000 name: storefront protocol: TCP readinessProbe: + failureThreshold: 1 httpGet: path: /api/health port: 3000 initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 3 + timeoutSeconds: 2 resources: limits: memory: 1.5Gi requests: cpu: 500m memory: 800Mi + startupProbe: + failureThreshold: 60 + httpGet: + path: /api/health + port: 3000 + periodSeconds: 2 + timeoutSeconds: 2 imagePullSecrets: - name: dockerregistry terminationGracePeriodSeconds: 60 From 07f17f82889eff391037b2535c8a36763f07f143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 04:32:01 +0100 Subject: [PATCH 09/17] define scaling behavior for autoscalers --- kubernetes/horizontalPodAutoscaler.yaml | 21 ++++++++++ .../horizontalStorefrontAutoscaler.yaml | 21 ++++++++++ .../expected/horizontalPodAutoscaler.yaml | 21 ++++++++++ .../horizontalStorefrontAutoscaler.yaml | 21 ++++++++++ .../basic-production/expected/webserver.yaml | 42 +++++++++++++++++++ .../expected/horizontalPodAutoscaler.yaml | 21 ++++++++++ .../horizontalStorefrontAutoscaler.yaml | 21 ++++++++++ .../expected/webserver.yaml | 42 +++++++++++++++++++ .../expected/horizontalPodAutoscaler.yaml | 21 ++++++++++ .../horizontalStorefrontAutoscaler.yaml | 21 ++++++++++ .../escaping-env/expected/webserver.yaml | 42 +++++++++++++++++++ .../expected/horizontalPodAutoscaler.yaml | 21 ++++++++++ .../horizontalStorefrontAutoscaler.yaml | 21 ++++++++++ .../expected/webserver.yaml | 42 +++++++++++++++++++ 14 files changed, 378 insertions(+) diff --git a/kubernetes/horizontalPodAutoscaler.yaml b/kubernetes/horizontalPodAutoscaler.yaml index 3a22f50..3091ed8 100644 --- a/kubernetes/horizontalPodAutoscaler.yaml +++ b/kubernetes/horizontalPodAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: webserver-php-fpm minReplicas: 2 maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: ContainerResource containerResource: diff --git a/kubernetes/horizontalStorefrontAutoscaler.yaml b/kubernetes/horizontalStorefrontAutoscaler.yaml index 6da411e..9f9f208 100644 --- a/kubernetes/horizontalStorefrontAutoscaler.yaml +++ b/kubernetes/horizontalStorefrontAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: storefront minReplicas: 2 maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: Resource resource: diff --git a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml index 74fbf30..d9732c8 100644 --- a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: webserver-php-fpm minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: ContainerResource containerResource: diff --git a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml index 212d868..9392d13 100644 --- a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: storefront minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: Resource resource: diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 3a38871..c18552b 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -919,6 +919,27 @@ metadata: name: storefront namespace: myproject-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - resource: @@ -939,6 +960,27 @@ metadata: name: webserver-php-fpm namespace: myproject-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - containerResource: diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml index cc48783..193fbc2 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: webserver-php-fpm minReplicas: 2 maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: ContainerResource containerResource: diff --git a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml index cf49cc9..1c5f76f 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: storefront minReplicas: 2 maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: Resource resource: diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 100fbb7..810c582 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -913,6 +913,27 @@ metadata: name: storefront namespace: myproject-dev spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 2 metrics: - resource: @@ -933,6 +954,27 @@ metadata: name: webserver-php-fpm namespace: myproject-dev spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 2 metrics: - containerResource: diff --git a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml index 74fbf30..d9732c8 100644 --- a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: webserver-php-fpm minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: ContainerResource containerResource: diff --git a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml index 212d868..9392d13 100644 --- a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: storefront minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: Resource resource: diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index c44379c..a66a15e 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -928,6 +928,27 @@ metadata: name: storefront namespace: myproject-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - resource: @@ -948,6 +969,27 @@ metadata: name: webserver-php-fpm namespace: myproject-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - containerResource: diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml index 13e1051..705c8b0 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: webserver-php-fpm minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: ContainerResource containerResource: diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml index 2ef81ef..b275fee 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml @@ -10,6 +10,27 @@ spec: name: storefront minReplicas: 2 maxReplicas: 3 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 metrics: - type: Resource resource: diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 0e104a1..b5e6893 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -920,6 +920,27 @@ metadata: name: storefront namespace: shop-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - resource: @@ -940,6 +961,27 @@ metadata: name: webserver-php-fpm namespace: shop-production spec: + behavior: + scaleDown: + policies: + - periodSeconds: 60 + type: Pods + value: 1 + - periodSeconds: 60 + type: Percent + value: 30 + selectPolicy: Max + stabilizationWindowSeconds: 900 + scaleUp: + policies: + - periodSeconds: 60 + type: Pods + value: 2 + - periodSeconds: 60 + type: Percent + value: 50 + selectPolicy: Max + stabilizationWindowSeconds: 60 maxReplicas: 3 metrics: - containerResource: From 7cf49cc54e7d0b29ff99c724b79ba1713f5ddf7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 04:33:57 +0100 Subject: [PATCH 10/17] remove namespace definition --- .../migrate-application/continuous-deploy/kustomization.yaml | 1 - .../first-deploy-with-demo-data/kustomization.yaml | 1 - .../migrate-application/first-deploy/kustomization.yaml | 1 - kubernetes/kustomize/webserver/kustomization.yaml | 1 - kubernetes/namespace.yaml | 4 ---- .../basic-production/expected/migrate-continuous-deploy.yaml | 5 ----- .../expected/migrate-first-deploy-with-demo-data.yaml | 5 ----- .../basic-production/expected/migrate-first-deploy.yaml | 5 ----- tests/scenarios/basic-production/expected/namespace.yaml | 4 ---- tests/scenarios/basic-production/expected/webserver.yaml | 5 ----- .../expected/migrate-continuous-deploy.yaml | 5 ----- .../expected/migrate-first-deploy-with-demo-data.yaml | 5 ----- .../expected/migrate-first-deploy.yaml | 5 ----- .../development-single-domain/expected/namespace.yaml | 4 ---- .../development-single-domain/expected/webserver.yaml | 5 ----- .../escaping-env/expected/migrate-continuous-deploy.yaml | 5 ----- .../expected/migrate-first-deploy-with-demo-data.yaml | 5 ----- .../escaping-env/expected/migrate-first-deploy.yaml | 5 ----- tests/scenarios/escaping-env/expected/namespace.yaml | 4 ---- tests/scenarios/escaping-env/expected/webserver.yaml | 5 ----- .../expected/migrate-continuous-deploy.yaml | 5 ----- .../expected/migrate-first-deploy-with-demo-data.yaml | 5 ----- .../expected/migrate-first-deploy.yaml | 5 ----- .../production-with-cloudflare/expected/namespace.yaml | 4 ---- .../production-with-cloudflare/expected/webserver.yaml | 5 ----- 25 files changed, 104 deletions(-) delete mode 100644 kubernetes/namespace.yaml delete mode 100644 tests/scenarios/basic-production/expected/namespace.yaml delete mode 100644 tests/scenarios/development-single-domain/expected/namespace.yaml delete mode 100644 tests/scenarios/escaping-env/expected/namespace.yaml delete mode 100644 tests/scenarios/production-with-cloudflare/expected/namespace.yaml diff --git a/kubernetes/kustomize/migrate-application/continuous-deploy/kustomization.yaml b/kubernetes/kustomize/migrate-application/continuous-deploy/kustomization.yaml index a89a153..4228f6e 100644 --- a/kubernetes/kustomize/migrate-application/continuous-deploy/kustomization.yaml +++ b/kubernetes/kustomize/migrate-application/continuous-deploy/kustomization.yaml @@ -1,7 +1,6 @@ resources: - ../../../deployments/redis.yaml - ../../../services/redis.yaml - - ../../../namespace.yaml - ../../../configmap/redis.yaml - ../../../configmap/redis-health.yaml - ../../../deployments/rabbitmq.yaml diff --git a/kubernetes/kustomize/migrate-application/first-deploy-with-demo-data/kustomization.yaml b/kubernetes/kustomize/migrate-application/first-deploy-with-demo-data/kustomization.yaml index a89a153..4228f6e 100644 --- a/kubernetes/kustomize/migrate-application/first-deploy-with-demo-data/kustomization.yaml +++ b/kubernetes/kustomize/migrate-application/first-deploy-with-demo-data/kustomization.yaml @@ -1,7 +1,6 @@ resources: - ../../../deployments/redis.yaml - ../../../services/redis.yaml - - ../../../namespace.yaml - ../../../configmap/redis.yaml - ../../../configmap/redis-health.yaml - ../../../deployments/rabbitmq.yaml diff --git a/kubernetes/kustomize/migrate-application/first-deploy/kustomization.yaml b/kubernetes/kustomize/migrate-application/first-deploy/kustomization.yaml index a89a153..4228f6e 100644 --- a/kubernetes/kustomize/migrate-application/first-deploy/kustomization.yaml +++ b/kubernetes/kustomize/migrate-application/first-deploy/kustomization.yaml @@ -1,7 +1,6 @@ resources: - ../../../deployments/redis.yaml - ../../../services/redis.yaml - - ../../../namespace.yaml - ../../../configmap/redis.yaml - ../../../configmap/redis-health.yaml - ../../../deployments/rabbitmq.yaml diff --git a/kubernetes/kustomize/webserver/kustomization.yaml b/kubernetes/kustomize/webserver/kustomization.yaml index 5835fbb..820ee90 100644 --- a/kubernetes/kustomize/webserver/kustomization.yaml +++ b/kubernetes/kustomize/webserver/kustomization.yaml @@ -4,7 +4,6 @@ resources: - ../../deployments/storefront.yaml - ../../services/storefront.yaml - ../../deployments/cron.yaml - - ../../namespace.yaml - ../../configmap/nginx.yaml - ../../configmap/production-php-fpm.yaml - ../../configmap/production-php-opcache.yaml diff --git a/kubernetes/namespace.yaml b/kubernetes/namespace.yaml deleted file mode 100644 index 74708ba..0000000 --- a/kubernetes/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: "{{PROJECT_NAME}}" diff --git a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml index db00365..9e73e85 100644 --- a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml index 00b1604..d23bc1d 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml index f754b94..eb9ce22 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/basic-production/expected/namespace.yaml b/tests/scenarios/basic-production/expected/namespace.yaml deleted file mode 100644 index 47f129e..0000000 --- a/tests/scenarios/basic-production/expected/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: "myproject-production" diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index c18552b..457263e 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: .project_env.sh: | export ELASTICSEARCH_HOST='http://elasticsearch:9200' diff --git a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml index f6cdf4f..995eb88 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-dev ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml index 14a9bc2..53e27ec 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-dev ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml index 1596709..25b9593 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-dev ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/development-single-domain/expected/namespace.yaml b/tests/scenarios/development-single-domain/expected/namespace.yaml deleted file mode 100644 index 9827882..0000000 --- a/tests/scenarios/development-single-domain/expected/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: "myproject-dev" diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 810c582..317d497 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-dev ---- -apiVersion: v1 data: .project_env.sh: | export ELASTICSEARCH_HOST='http://elasticsearch:9200' diff --git a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml index 95f63d7..79153d6 100644 --- a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml index f4a6620..b706f83 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml index 3ae5277..4fb3fbc 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/escaping-env/expected/namespace.yaml b/tests/scenarios/escaping-env/expected/namespace.yaml deleted file mode 100644 index 47f129e..0000000 --- a/tests/scenarios/escaping-env/expected/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: "myproject-production" diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index a66a15e..167ed6b 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: myproject-production ---- -apiVersion: v1 data: .project_env.sh: | export ELASTICSEARCH_HOST='http://elasticsearch:9200' diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml index d053b0b..13bec2d 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: shop-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml index 02eb055..64b8e07 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: shop-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml index 42dc97a..5a0c3bd 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: shop-production ---- -apiVersion: v1 data: domains_urls.yaml: | domains_urls: diff --git a/tests/scenarios/production-with-cloudflare/expected/namespace.yaml b/tests/scenarios/production-with-cloudflare/expected/namespace.yaml deleted file mode 100644 index b842341..0000000 --- a/tests/scenarios/production-with-cloudflare/expected/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: "shop-production" diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index b5e6893..27a2250 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -1,9 +1,4 @@ apiVersion: v1 -kind: Namespace -metadata: - name: shop-production ---- -apiVersion: v1 data: .project_env.sh: | export ELASTICSEARCH_HOST='http://elasticsearch:9200' From d3cd493cbed966e85935d343f70c8cc124b91a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 06:26:28 +0100 Subject: [PATCH 11/17] add probes to rabbitmq, graceful shutdown --- kubernetes/deployments/rabbitmq.yaml | 32 ++++++++++++++ .../expected/migrate-continuous-deploy.yaml | 44 ++++++++++++++++++- .../migrate-first-deploy-with-demo-data.yaml | 44 ++++++++++++++++++- .../expected/migrate-first-deploy.yaml | 44 ++++++++++++++++++- .../expected/migrate-continuous-deploy.yaml | 44 ++++++++++++++++++- .../migrate-first-deploy-with-demo-data.yaml | 44 ++++++++++++++++++- .../expected/migrate-first-deploy.yaml | 44 ++++++++++++++++++- .../expected/migrate-continuous-deploy.yaml | 44 ++++++++++++++++++- .../migrate-first-deploy-with-demo-data.yaml | 44 ++++++++++++++++++- .../expected/migrate-first-deploy.yaml | 44 ++++++++++++++++++- .../expected/migrate-continuous-deploy.yaml | 44 ++++++++++++++++++- .../migrate-first-deploy-with-demo-data.yaml | 44 ++++++++++++++++++- .../expected/migrate-first-deploy.yaml | 44 ++++++++++++++++++- 13 files changed, 548 insertions(+), 12 deletions(-) diff --git a/kubernetes/deployments/rabbitmq.yaml b/kubernetes/deployments/rabbitmq.yaml index c2b9891..42dbe59 100644 --- a/kubernetes/deployments/rabbitmq.yaml +++ b/kubernetes/deployments/rabbitmq.yaml @@ -5,6 +5,10 @@ metadata: spec: serviceName: rabbitmq replicas: 1 + updateStrategy: + type: RollingUpdate + rollingUpdate: + partition: 0 selector: matchLabels: app: rabbitmq @@ -30,6 +34,9 @@ spec: image: rabbitmq:4.1-management-alpine ports: - name: rabbitmq + containerPort: 5672 + protocol: TCP + - name: rabbitmq-management containerPort: 15672 protocol: TCP - name: exporter @@ -40,12 +47,37 @@ spec: value: "{{RABBITMQ_DEFAULT_USER}}" - name: RABBITMQ_DEFAULT_PASS value: "{{RABBITMQ_DEFAULT_PASS}}" + lifecycle: + preStop: + exec: + command: [ "sh", "-c", "rabbitmqctl stop_app && sleep 5" ] resources: requests: cpu: "20m" + memory: "256Mi" + limits: + memory: "512Mi" + startupProbe: + exec: + command: [ "rabbitmq-diagnostics", "ping" ] + failureThreshold: 30 + periodSeconds: 10 + livenessProbe: + exec: + command: ["rabbitmq-diagnostics", "ping"] + periodSeconds: 30 + timeoutSeconds: 15 + failureThreshold: 5 + readinessProbe: + exec: + command: [ "rabbitmq-diagnostics", "-q", "check_running" ] + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 volumeMounts: - name: rabbitmq-data mountPath: /var/lib/rabbitmq + terminationGracePeriodSeconds: 90 imagePullSecrets: - name: dockerregistry volumeClaimTemplates: diff --git a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml index 9e73e85..9305d46 100644 --- a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml @@ -325,22 +325,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml index d23bc1d..678ed98 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy-with-demo-data.yaml @@ -325,22 +325,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml index eb9ce22..917eb46 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml @@ -325,22 +325,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml index 995eb88..b5ba1ae 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml @@ -206,22 +206,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml index 53e27ec..9de21ed 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy-with-demo-data.yaml @@ -206,22 +206,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml index 25b9593..a4284c3 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml @@ -206,22 +206,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml index 79153d6..b3080de 100644 --- a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml @@ -327,22 +327,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml index b706f83..1653b97 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy-with-demo-data.yaml @@ -327,22 +327,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml index 4fb3fbc..74231ec 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml @@ -327,22 +327,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml index 13bec2d..da3b222 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml @@ -442,22 +442,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml index 64b8e07..12318ab 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy-with-demo-data.yaml @@ -442,22 +442,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data diff --git a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml index 5a0c3bd..6cd76e8 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml @@ -442,22 +442,64 @@ spec: - name: RABBITMQ_DEFAULT_PASS value: rabbitmq-password image: rabbitmq:4.1-management-alpine + lifecycle: + preStop: + exec: + command: + - sh + - -c + - rabbitmqctl stop_app && sleep 5 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 5 + periodSeconds: 30 + timeoutSeconds: 15 name: rabbitmq ports: - - containerPort: 15672 + - containerPort: 5672 name: rabbitmq protocol: TCP + - containerPort: 15672 + name: rabbitmq-management + protocol: TCP - containerPort: 15692 name: exporter protocol: TCP + readinessProbe: + exec: + command: + - rabbitmq-diagnostics + - -q + - check_running + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 10 resources: + limits: + memory: 512Mi requests: cpu: 20m + memory: 256Mi + startupProbe: + exec: + command: + - rabbitmq-diagnostics + - ping + failureThreshold: 30 + periodSeconds: 10 volumeMounts: - mountPath: /var/lib/rabbitmq name: rabbitmq-data imagePullSecrets: - name: dockerregistry + terminationGracePeriodSeconds: 90 + updateStrategy: + rollingUpdate: + partition: 0 + type: RollingUpdate volumeClaimTemplates: - metadata: name: rabbitmq-data From 48dc048fd92cc224b88cfe917e803444b72325bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 06:27:33 +0100 Subject: [PATCH 12/17] fix and update request resources for devel --- deploy/parts/deploy.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index c026888..8c75ab0 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -50,14 +50,11 @@ fi if [ "${RUNNING_PRODUCTION}" -eq "0" ] || [ "${DOWNSCALE_RESOURCE:-0}" -eq "1" ]; then echo -n " Replace pods CPU requests to minimum (for Devel cluster only) " - yq e -i '.spec.template.spec.containers[0].resources.requests.cpu = "0.01"' "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" - yq e -i '.spec.template.spec.containers[0].resources.requests.cpu = "0.01"' "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" - yq e -i '.spec.template.spec.containers[1].resources.requests.cpu = "0.01"' "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" - yq e -i '.spec.template.spec.containers[1].resources.requests.cpu = "0.01"' "${CONFIGURATION_TARGET_PATH}/deployments/redis.yaml" - yq e -i '.spec.template.spec.containers[0].resources.requests.cpu = "0.01"' "${CONFIGURATION_TARGET_PATH}/deployments/rabbitmq.yaml" + yq e -i '.spec.template.spec.containers[0].resources.requests.cpu = "0.1"' "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" + yq e -i '.spec.template.spec.containers[0].resources.requests.cpu = "0.1"' "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" yq e -i '.spec.template.spec.containers[0].resources.requests.memory = "100Mi"' "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" - yq e -i '.spec.template.spec.containers[1].resources.requests.memory = "100Mi"' "${CONFIGURATION_TARGET_PATH}/deployments/redis.yaml" + yq e -i '.spec.template.spec.containers[0].resources.requests.memory = "100Mi"' "${CONFIGURATION_TARGET_PATH}/deployments/redis.yaml" echo -e "[${GREEN}OK${NO_COLOR}]" else From cef4c661983764df7529f86edc28c38dce70f011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 06:52:49 +0100 Subject: [PATCH 13/17] return possibility to disable HPA --- deploy/parts/autoscaling.sh | 7 ++ .../kustomize/webserver/kustomization.yaml | 2 - .../deploy-project.sh | 2 +- .../expected/horizontalPodAutoscaler.yaml | 74 ++++++++--------- .../horizontalStorefrontAutoscaler.yaml | 72 ++++++++-------- .../expected/webserver.yaml | 83 ------------------- 6 files changed, 81 insertions(+), 159 deletions(-) diff --git a/deploy/parts/autoscaling.sh b/deploy/parts/autoscaling.sh index 3fbb5d0..64b8dcc 100644 --- a/deploy/parts/autoscaling.sh +++ b/deploy/parts/autoscaling.sh @@ -40,5 +40,12 @@ if [[ "${ENABLE_AUTOSCALING:-false}" == "true" ]]; then patch_rollout "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "${MIN_PHP_FPM_REPLICAS}" patch_rollout "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "${MIN_STOREFRONT_REPLICAS}" + yq e -i ' + .resources += [ + "../../horizontalPodAutoscaler.yaml", + "../../horizontalStorefrontAutoscaler.yaml" + ] + ' "${CONFIGURATION_TARGET_PATH}/kustomize/webserver/kustomization.yaml" + echo -e "[${GREEN}OK${NO_COLOR}]" fi diff --git a/kubernetes/kustomize/webserver/kustomization.yaml b/kubernetes/kustomize/webserver/kustomization.yaml index 820ee90..395d313 100644 --- a/kubernetes/kustomize/webserver/kustomization.yaml +++ b/kubernetes/kustomize/webserver/kustomization.yaml @@ -10,8 +10,6 @@ resources: - ../../configmap/cron-env.yaml - ../../configmap/cron-list.yaml - ../../ingress/ingress-rabbitmq.yaml - - ../../horizontalPodAutoscaler.yaml - - ../../horizontalStorefrontAutoscaler.yaml namespace: "{{PROJECT_NAME}}" configMapGenerator: - name: domains-urls diff --git a/tests/scenarios/development-single-domain/deploy-project.sh b/tests/scenarios/development-single-domain/deploy-project.sh index 4858fbe..46eca63 100644 --- a/tests/scenarios/development-single-domain/deploy-project.sh +++ b/tests/scenarios/development-single-domain/deploy-project.sh @@ -6,7 +6,7 @@ source "$(dirname "$0")/../../lib/scenario-base.sh" DOMAINS=(DOMAIN_HOSTNAME_1) export RUNNING_PRODUCTION=0 export WHITELIST_IPS="10.0.0.0/8,192.168.0.0/16" -ENABLE_AUTOSCALING=true +ENABLE_AUTOSCALING=false declare -A CRON_INSTANCES=( ["cron"]='*/5 * * * *' diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml index 193fbc2..1beb2c8 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml @@ -1,41 +1,41 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: - name: webserver-php-fpm - namespace: "myproject-dev" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment name: webserver-php-fpm - minReplicas: 2 - maxReplicas: 2 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 900 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 + namespace: "myproject-dev" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: webserver-php-fpm + minReplicas: 2 + maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 + metrics: + - type: ContainerResource + containerResource: + name: cpu + container: php-fpm + target: + type: Utilization + averageUtilization: 120 diff --git a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml index 1c5f76f..4456cd2 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml @@ -1,40 +1,40 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: - name: storefront - namespace: "myproject-dev" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment name: storefront - minReplicas: 2 - maxReplicas: 2 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 900 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 + namespace: "myproject-dev" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: storefront + minReplicas: 2 + maxReplicas: 2 + behavior: + scaleUp: + stabilizationWindowSeconds: 60 + selectPolicy: Max + policies: + - type: Pods + value: 2 + periodSeconds: 60 + - type: Percent + value: 50 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 900 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 60 + - type: Percent + value: 30 + periodSeconds: 60 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 120 diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 317d497..88032a0 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -902,89 +902,6 @@ spec: defaultMode: 420 secretName: fe-api-keys --- -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: storefront - namespace: myproject-dev -spec: - behavior: - scaleDown: - policies: - - periodSeconds: 60 - type: Pods - value: 1 - - periodSeconds: 60 - type: Percent - value: 30 - selectPolicy: Max - stabilizationWindowSeconds: 900 - scaleUp: - policies: - - periodSeconds: 60 - type: Pods - value: 2 - - periodSeconds: 60 - type: Percent - value: 50 - selectPolicy: Max - stabilizationWindowSeconds: 60 - maxReplicas: 2 - metrics: - - resource: - name: cpu - target: - averageUtilization: 120 - type: Utilization - type: Resource - minReplicas: 2 - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: storefront ---- -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: webserver-php-fpm - namespace: myproject-dev -spec: - behavior: - scaleDown: - policies: - - periodSeconds: 60 - type: Pods - value: 1 - - periodSeconds: 60 - type: Percent - value: 30 - selectPolicy: Max - stabilizationWindowSeconds: 900 - scaleUp: - policies: - - periodSeconds: 60 - type: Pods - value: 2 - - periodSeconds: 60 - type: Percent - value: 50 - selectPolicy: Max - stabilizationWindowSeconds: 60 - maxReplicas: 2 - metrics: - - containerResource: - container: php-fpm - name: cpu - target: - averageUtilization: 120 - type: Utilization - type: ContainerResource - minReplicas: 2 - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: webserver-php-fpm ---- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: From 7f5ec787288044d762bbd62e54040528bd5336bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 07:07:45 +0100 Subject: [PATCH 14/17] remove gcloud registry --- deploy/parts/deploy.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 8c75ab0..4af6c86 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -25,11 +25,7 @@ echo -n " Delete secret for docker registry " runCommand "SKIP" "kubectl delete secret dockerregistry -n ${PROJECT_NAME}" echo -n " Create new secret for docker registry " -if [ "${GCLOUD_DEPLOY}" = "true" ]; then - runCommand "ERROR" "kubectl create secret docker-registry dockerregistry --docker-server=eu.gcr.io --docker-username _json_key --docker-email ${GCLOUD_CONTAINER_REGISTRY_EMAIL} --docker-password='${GCLOUD_CONTAINER_REGISTRY_ACCOUNT}' -n ${PROJECT_NAME}" -else - runCommand "ERROR" "kubectl create secret docker-registry dockerregistry --docker-server=${CI_REGISTRY} --docker-username=${DEPLOY_REGISTER_USER} --docker-password=${DEPLOY_REGISTER_PASSWORD} -n ${PROJECT_NAME}" -fi +runCommand "ERROR" "kubectl create secret docker-registry dockerregistry --docker-server=${CI_REGISTRY} --docker-username=${DEPLOY_REGISTER_USER} --docker-password=${DEPLOY_REGISTER_PASSWORD} -n ${PROJECT_NAME}" if [ ${RUNNING_PRODUCTION} -eq "0" ] || [ ${#FORCE_HTTP_AUTH_IN_PRODUCTION[@]} -ne "0" ]; then echo -n " Create or update secret for http auth " From e6caa53baf9140d2366185c12057bab967a98555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 07:14:04 +0100 Subject: [PATCH 15/17] autoscaling is enabled by default --- README.md | 8 ++++---- deploy/parts/autoscaling.sh | 2 +- docs/deploy-project.sh | 2 -- tests/scenarios/basic-production/deploy-project.sh | 1 - tests/scenarios/escaping-env/deploy-project.sh | 1 - .../production-with-cloudflare/deploy-project.sh | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 49470dc..d54a5bb 100644 --- a/README.md +++ b/README.md @@ -196,11 +196,11 @@ Add new variable to `deploy/deploy-project.sh` and specify your redis version ... ``` -### Enable Horizontal pod autoscaling +### Disable Horizontal pod autoscaling -Add new variables to `deploy/deploy-project.sh` to enable pod autoscaling: +Add new variables to `deploy/deploy-project.sh` to disable pod autoscaling: -- Enable this functionality: +- Disable this functionality: ```diff ... function deploy() { @@ -209,7 +209,7 @@ Add new variables to `deploy/deploy-project.sh` to enable pod autoscaling: ... ) - + ENABLE_AUTOSCALING=true + + ENABLE_AUTOSCALING=false ... ``` - If you need more replicas, then you can adjust those variables (default values are set to 2): diff --git a/deploy/parts/autoscaling.sh b/deploy/parts/autoscaling.sh index 64b8dcc..dd16ac2 100644 --- a/deploy/parts/autoscaling.sh +++ b/deploy/parts/autoscaling.sh @@ -16,7 +16,7 @@ assertVariable "BASE_PATH" assertVariable "CONFIGURATION_TARGET_PATH" assertVariable "RUNNING_PRODUCTION" -if [[ "${ENABLE_AUTOSCALING:-false}" == "true" ]]; then +if [[ "${ENABLE_AUTOSCALING:-true}" == "true" ]]; then echo -n "Prepare Autoscaling " MIN_PHP_FPM_REPLICAS="${MIN_PHP_FPM_REPLICAS:-2}" diff --git a/docs/deploy-project.sh b/docs/deploy-project.sh index 21e2cfc..38ec18b 100644 --- a/docs/deploy-project.sh +++ b/docs/deploy-project.sh @@ -11,8 +11,6 @@ function deploy() { DOMAIN_HOSTNAME_2 ) - ENABLE_AUTOSCALING=true - declare -A ENVIRONMENT_VARIABLES=( ["APP_SECRET"]=${APP_SECRET} ["DATABASE_HOST"]=${POSTGRES_DATABASE_IP_ADDRESS} diff --git a/tests/scenarios/basic-production/deploy-project.sh b/tests/scenarios/basic-production/deploy-project.sh index 65c8654..4eb8fde 100644 --- a/tests/scenarios/basic-production/deploy-project.sh +++ b/tests/scenarios/basic-production/deploy-project.sh @@ -5,7 +5,6 @@ source "$(dirname "$0")/../../lib/scenario-base.sh" # Scenario-specific configuration DOMAINS=(DOMAIN_HOSTNAME_1 DOMAIN_HOSTNAME_2) export RUNNING_PRODUCTION=1 -ENABLE_AUTOSCALING=true declare -A CRON_INSTANCES=( ["cron"]='*/5 * * * *' diff --git a/tests/scenarios/escaping-env/deploy-project.sh b/tests/scenarios/escaping-env/deploy-project.sh index 7911499..9d451c1 100644 --- a/tests/scenarios/escaping-env/deploy-project.sh +++ b/tests/scenarios/escaping-env/deploy-project.sh @@ -5,7 +5,6 @@ source "$(dirname "$0")/../../lib/scenario-base.sh" DOMAINS=(DOMAIN_HOSTNAME_1 DOMAIN_HOSTNAME_2) export RUNNING_PRODUCTION=1 export FIRST_DEPLOY=0 -ENABLE_AUTOSCALING=true declare -A CRON_INSTANCES=( ["cron"]='*/5 * * * *' diff --git a/tests/scenarios/production-with-cloudflare/deploy-project.sh b/tests/scenarios/production-with-cloudflare/deploy-project.sh index dbcece0..71a5250 100644 --- a/tests/scenarios/production-with-cloudflare/deploy-project.sh +++ b/tests/scenarios/production-with-cloudflare/deploy-project.sh @@ -7,7 +7,6 @@ DOMAINS=(DOMAIN_HOSTNAME_1 DOMAIN_HOSTNAME_2) export RUNNING_PRODUCTION=1 export USING_CLOUDFLARE=1 export CLOUDFLARE_IPS="103.21.244.0/22,103.22.200.0/22,104.16.0.0/13" -ENABLE_AUTOSCALING=true declare -A CRON_INSTANCES=( ["cron"]='*/5 * * * *' From 4f7ea19e33f3ed64427309e67f37306ca1e35fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 07:30:57 +0100 Subject: [PATCH 16/17] decrease stabilization window for scale down --- kubernetes/horizontalPodAutoscaler.yaml | 2 +- kubernetes/horizontalStorefrontAutoscaler.yaml | 2 +- .../basic-production/expected/horizontalPodAutoscaler.yaml | 2 +- .../expected/horizontalStorefrontAutoscaler.yaml | 2 +- tests/scenarios/basic-production/expected/webserver.yaml | 4 ++-- .../expected/horizontalPodAutoscaler.yaml | 2 +- .../expected/horizontalStorefrontAutoscaler.yaml | 2 +- .../escaping-env/expected/horizontalPodAutoscaler.yaml | 2 +- .../escaping-env/expected/horizontalStorefrontAutoscaler.yaml | 2 +- tests/scenarios/escaping-env/expected/webserver.yaml | 4 ++-- .../expected/horizontalPodAutoscaler.yaml | 2 +- .../expected/horizontalStorefrontAutoscaler.yaml | 2 +- .../production-with-cloudflare/expected/webserver.yaml | 4 ++-- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/kubernetes/horizontalPodAutoscaler.yaml b/kubernetes/horizontalPodAutoscaler.yaml index 3091ed8..e698dfd 100644 --- a/kubernetes/horizontalPodAutoscaler.yaml +++ b/kubernetes/horizontalPodAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/kubernetes/horizontalStorefrontAutoscaler.yaml b/kubernetes/horizontalStorefrontAutoscaler.yaml index 9f9f208..ede46a1 100644 --- a/kubernetes/horizontalStorefrontAutoscaler.yaml +++ b/kubernetes/horizontalStorefrontAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml index d9732c8..a929704 100644 --- a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml index 9392d13..2db344c 100644 --- a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 457263e..e671161 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -924,7 +924,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 @@ -965,7 +965,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml index 1beb2c8..4b5ef1c 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml index 4456cd2..9b11081 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml index d9732c8..a929704 100644 --- a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml index 9392d13..2db344c 100644 --- a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index 167ed6b..1d92237 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -933,7 +933,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 @@ -974,7 +974,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml index 705c8b0..6aacd28 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml index b275fee..92f7c22 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml @@ -22,7 +22,7 @@ spec: value: 50 periodSeconds: 60 scaleDown: - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 selectPolicy: Max policies: - type: Pods diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 27a2250..f816b14 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -925,7 +925,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 @@ -966,7 +966,7 @@ spec: type: Percent value: 30 selectPolicy: Max - stabilizationWindowSeconds: 900 + stabilizationWindowSeconds: 600 scaleUp: policies: - periodSeconds: 60 From 28f27f93fac18f8295c922cd26ed413183ec5320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3recki?= Date: Wed, 4 Feb 2026 09:23:29 +0100 Subject: [PATCH 17/17] fix --- kubernetes/horizontalPodAutoscaler.yaml | 1 - .../horizontalStorefrontAutoscaler.yaml | 1 - tests/run-tests.sh | 5 --- .../expected/horizontalPodAutoscaler.yaml | 41 ------------------- .../horizontalStorefrontAutoscaler.yaml | 40 ------------------ .../expected/horizontalPodAutoscaler.yaml | 41 ------------------- .../horizontalStorefrontAutoscaler.yaml | 40 ------------------ .../expected/horizontalPodAutoscaler.yaml | 41 ------------------- .../horizontalStorefrontAutoscaler.yaml | 40 ------------------ .../expected/horizontalPodAutoscaler.yaml | 41 ------------------- .../horizontalStorefrontAutoscaler.yaml | 40 ------------------ 11 files changed, 331 deletions(-) delete mode 100644 tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml delete mode 100644 tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml delete mode 100644 tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml delete mode 100644 tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml delete mode 100644 tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml delete mode 100644 tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml delete mode 100644 tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml delete mode 100644 tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml diff --git a/kubernetes/horizontalPodAutoscaler.yaml b/kubernetes/horizontalPodAutoscaler.yaml index e698dfd..02551c8 100644 --- a/kubernetes/horizontalPodAutoscaler.yaml +++ b/kubernetes/horizontalPodAutoscaler.yaml @@ -2,7 +2,6 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: webserver-php-fpm - namespace: "{{PROJECT_NAME}}" spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/kubernetes/horizontalStorefrontAutoscaler.yaml b/kubernetes/horizontalStorefrontAutoscaler.yaml index ede46a1..86164c5 100644 --- a/kubernetes/horizontalStorefrontAutoscaler.yaml +++ b/kubernetes/horizontalStorefrontAutoscaler.yaml @@ -2,7 +2,6 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: storefront - namespace: "{{PROJECT_NAME}}" spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 33e732e..314a3ee 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -171,11 +171,6 @@ build_outputs() { build_kustomize "${config_path}/kustomize/cron" "${output_dir}/cron.yaml" || true fi - # Copy individual files that aren't built by kustomize - cp "${config_path}/horizontalPodAutoscaler.yaml" "${output_dir}/" 2>/dev/null || true - cp "${config_path}/horizontalStorefrontAutoscaler.yaml" "${output_dir}/" 2>/dev/null || true - cp "${config_path}/namespace.yaml" "${output_dir}/" 2>/dev/null || true - echo "$output_dir" } diff --git a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml deleted file mode 100644 index a929704..0000000 --- a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: webserver-php-fpm - namespace: "myproject-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: webserver-php-fpm - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml deleted file mode 100644 index 2db344c..0000000 --- a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: storefront - namespace: "myproject-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: storefront - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml deleted file mode 100644 index 4b5ef1c..0000000 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: webserver-php-fpm - namespace: "myproject-dev" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: webserver-php-fpm - minReplicas: 2 - maxReplicas: 2 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml deleted file mode 100644 index 9b11081..0000000 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: storefront - namespace: "myproject-dev" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: storefront - minReplicas: 2 - maxReplicas: 2 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml deleted file mode 100644 index a929704..0000000 --- a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: webserver-php-fpm - namespace: "myproject-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: webserver-php-fpm - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml deleted file mode 100644 index 2db344c..0000000 --- a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: storefront - namespace: "myproject-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: storefront - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml deleted file mode 100644 index 6aacd28..0000000 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: webserver-php-fpm - namespace: "shop-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: webserver-php-fpm - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml deleted file mode 100644 index 92f7c22..0000000 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: storefront - namespace: "shop-production" -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: storefront - minReplicas: 2 - maxReplicas: 3 - behavior: - scaleUp: - stabilizationWindowSeconds: 60 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 60 - - type: Percent - value: 50 - periodSeconds: 60 - scaleDown: - stabilizationWindowSeconds: 600 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 60 - - type: Percent - value: 30 - periodSeconds: 60 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120