diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c5dd8c5..d56292b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: name: Test Kubernetes Manifests runs-on: ubuntu-latest container: - image: shopsys/kubernetes-buildpack:1.2 + image: shopsys/kubernetes-buildpack:2.0 steps: - name: Checkout code diff --git a/README.md b/README.md index 1f2a641..49470dc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ```yaml .deploy: &deploy image: - name: shopsys/kubernetes-buildpack:0.9 + name: shopsys/kubernetes-buildpack:2.0 stage: deploy tags: - docker diff --git a/UPGRADE.md b/UPGRADE.md index f8799da..7f42c9e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -10,6 +10,11 @@ 2. Run `composer update shopsys/deployment` 3. Check files in mentioned pull requests and if you have any of them extended in your project, apply changes manually +## Upgrade from v4.3.0 to v4.4.0 + +- yq was updated to the newest version ([#63](https://github.com/shopsys/deployment/pull/63)) + - If you are using `shopsys/kubernetes-buildpack:1.x` in your GitLab CI pipeline, update it to `shopsys/kubernetes-buildpack:2.0` + ## Upgrade from v4.1.1 to v4.2.0 - improved nginx configuration ([#59](https://github.com/shopsys/deployment/pull/59)) diff --git a/deploy/parts/autoscaling.sh b/deploy/parts/autoscaling.sh index c20a7b1..bd925a2 100644 --- a/deploy/parts/autoscaling.sh +++ b/deploy/parts/autoscaling.sh @@ -26,11 +26,11 @@ if [ ${ENABLE_AUTOSCALING} = true ]; then MAX_STOREFRONT_REPLICAS=3 fi - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" spec.minReplicas "${MIN_PHP_FPM_REPLICAS}" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" spec.maxReplicas "${MAX_PHP_FPM_REPLICAS}" + yq e -i ".spec.minReplicas=${MIN_PHP_FPM_REPLICAS}" "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" + yq e -i ".spec.maxReplicas=${MAX_PHP_FPM_REPLICAS}" "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" spec.minReplicas "${MIN_STOREFRONT_REPLICAS}" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" spec.maxReplicas "${MAX_STOREFRONT_REPLICAS}" + 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 diff --git a/deploy/parts/cron.sh b/deploy/parts/cron.sh index 3bbffc3..adfce78 100644 --- a/deploy/parts/cron.sh +++ b/deploy/parts/cron.sh @@ -19,6 +19,6 @@ unset CRON_INSTANCES # Use FREEZE_TIMESTAMP for testing, otherwise use current timestamp CRON_TIMESTAMP="${FREEZE_TIMESTAMP:-$(date +%s)}" -yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/cron.yaml" "spec.template.metadata.labels.date" "\"${CRON_TIMESTAMP}\"" +yq e -i ".spec.template.metadata.labels.date=\"${CRON_TIMESTAMP}\"" "${CONFIGURATION_TARGET_PATH}/deployments/cron.yaml" echo -e "[${GREEN}OK${NO_COLOR}]" diff --git a/deploy/parts/deploy.sh b/deploy/parts/deploy.sh index 5d3b209..9f3265c 100644 --- a/deploy/parts/deploy.sh +++ b/deploy/parts/deploy.sh @@ -51,14 +51,14 @@ 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 write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].resources.requests.cpu" "0.01" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[0].resources.requests.cpu" "0.01" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[1].resources.requests.cpu" "0.01" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/redis.yaml" "spec.template.spec.containers[1].resources.requests.cpu" "0.01" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/rabbitmq.yaml" "spec.template.spec.containers[0].resources.requests.cpu" "0.01" + 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 write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[0].resources.requests.memory" "100Mi" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/redis.yaml" "spec.template.spec.containers[1].resources.requests.memory" "100Mi" + 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" echo -e "[${GREEN}OK${NO_COLOR}]" else @@ -66,11 +66,11 @@ else echo -n " Replace pods CPU requests " if [ -v PHP_FPM_CPU_REQUEST ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[0].resources.requests.cpu" "${PHP_FPM_CPU_REQUEST}" + yq e -i ".spec.template.spec.containers[0].resources.requests.cpu = \"${PHP_FPM_CPU_REQUEST}\"" "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" fi if [ -v STOREFRONT_CPU_REQUEST ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].resources.requests.cpu" "${STOREFRONT_CPU_REQUEST}" + yq e -i ".spec.template.spec.containers[0].resources.requests.cpu = \"${STOREFRONT_CPU_REQUEST}\"" "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" fi echo -e "[${GREEN}OK${NO_COLOR}]" @@ -187,8 +187,8 @@ if [ ${ENABLE_AUTOSCALING} = true ]; then echo -n " Deploy Horizontal pod autoscaler for Backend " if [ ${RUNNING_PRODUCTION} -eq "0" ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" spec.minReplicas 2 - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalPodAutoscaler.yaml" spec.maxReplicas 2 + 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" @@ -196,8 +196,8 @@ if [ ${ENABLE_AUTOSCALING} = true ]; then echo -n " Deploy Horizontal pod autoscaler for Storefront " if [ ${RUNNING_PRODUCTION} -eq "0" ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" spec.minReplicas 2 - yq write --inplace "${CONFIGURATION_TARGET_PATH}/horizontalStorefrontAutoscaler.yaml" spec.maxReplicas 2 + 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" diff --git a/deploy/parts/domain-rabbitmq-management.sh b/deploy/parts/domain-rabbitmq-management.sh index b017cf7..e67bb71 100644 --- a/deploy/parts/domain-rabbitmq-management.sh +++ b/deploy/parts/domain-rabbitmq-management.sh @@ -9,11 +9,11 @@ if [ -z "${RABBITMQ_DOMAIN_HOSTNAME}" ]; then RABBITMQ_DOMAIN_HOSTNAME="rabbitmq.${DOMAIN_HOSTNAME_1}" fi -yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" spec.rules[0].host ${RABBITMQ_DOMAIN_HOSTNAME} -yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" spec.tls[0].hosts[+] ${RABBITMQ_DOMAIN_HOSTNAME} +yq e -i ".spec.rules[0].host=\"${RABBITMQ_DOMAIN_HOSTNAME}\"" "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" +yq e -i ".spec.tls[0].hosts[0] = \"${RABBITMQ_DOMAIN_HOSTNAME}\"" "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" if [ -n "${RABBITMQ_IP_WHITELIST}" ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" metadata.annotations."\"nginx.ingress.kubernetes.io/whitelist-source-range\"" "${RABBITMQ_IP_WHITELIST}" + yq e -i ".metadata.annotations.\"nginx.ingress.kubernetes.io/whitelist-source-range\"=\"${RABBITMQ_IP_WHITELIST}\"" "${CONFIGURATION_TARGET_PATH}/ingress/ingress-rabbitmq.yaml" fi echo -e "[${GREEN}OK${NO_COLOR}]" diff --git a/deploy/parts/domains.sh b/deploy/parts/domains.sh index 9a56df1..9a018fc 100644 --- a/deploy/parts/domains.sh +++ b/deploy/parts/domains.sh @@ -50,42 +50,43 @@ for DOMAIN in ${DOMAINS[@]}; do BASE_DOMAIN=${BASENAME} REDIRECT_DOMAIN=${BASENAME#"www."} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/configuration-snippet\"" 'if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; }' + yq e -i '.metadata.annotations."nginx.ingress.kubernetes.io/configuration-snippet"="if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; }"' "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" else BASE_DOMAIN=${BASENAME} REDIRECT_DOMAIN="www.${BASENAME}" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/configuration-snippet\"" 'if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^www\.(?.+)$) { return 308 https://$domain$request_uri; }' + yq e -i '.metadata.annotations."nginx.ingress.kubernetes.io/configuration-snippet"="if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^www\.(?.+)$) { return 308 https://$domain$request_uri; }"' "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" fi if [ ! -z "${DOMAIN_PATH}" ]; then - yq write --inplace ${DOMAINS_URLS_FILEPATH} domains_urls[${DOMAIN_ITERATOR}].url https://${BASE_DOMAIN}/${DOMAIN_PATH} + yq e -i ".domains_urls[${DOMAIN_ITERATOR}].url=\"https://${BASE_DOMAIN}/${DOMAIN_PATH}\"" "${DOMAINS_URLS_FILEPATH}" else - yq write --inplace ${DOMAINS_URLS_FILEPATH} domains_urls[${DOMAIN_ITERATOR}].url https://${BASE_DOMAIN} + yq e -i ".domains_urls[${DOMAIN_ITERATOR}].url=\"https://${BASE_DOMAIN}\"" "${DOMAINS_URLS_FILEPATH}" fi - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.name "eshop-domain-${DOMAIN_ITERATOR}" + yq e -i ".metadata.name=\"eshop-domain-${DOMAIN_ITERATOR}\"" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" # Generate TLS secret name from BASE_DOMAIN to ensure domains with same host share the same certificate # Sanitize to meet Kubernetes naming requirements: lowercase alphanumeric and hyphens only, no leading/trailing hyphens SECRET_NAME="tls-$(echo "${BASE_DOMAIN}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/^-\+\|-\+$//g')" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.tls[0].secretName "${SECRET_NAME}" + yq e -i ".spec.tls[0].secretName=\"${SECRET_NAME}\"" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.rules[0].host ${BASE_DOMAIN} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.tls[0].hosts[+] ${BASE_DOMAIN} + yq e -i ".spec.rules[0].host=\"${BASE_DOMAIN}\"" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" + yq e -i ".spec.rules += [{\"host\": \"${REDIRECT_DOMAIN}\"}]" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" + + yq e -i ".spec.tls[0].hosts += [\"${BASE_DOMAIN}\", \"${REDIRECT_DOMAIN}\"]" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" if [ ! -z "${DOMAIN_PATH}" ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.rules[0].http.paths[0].path "/${DOMAIN_PATH}" + yq e -i ".spec.rules[0].http.paths[0].path = \"/${DOMAIN_PATH}\"" "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" fi - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.rules[+].host ${REDIRECT_DOMAIN} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" spec.tls[0].hosts[+] ${REDIRECT_DOMAIN} - # When domain is not in production we need to whitelist our IPs. But this also enables access outside Cloudflare if [ ${RUNNING_PRODUCTION} -ne "1" ] || containsElement ${DOMAIN} ${FORCE_HTTP_AUTH_IN_PRODUCTION[@]}; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/auth-type\"" basic - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/auth-secret\"" http-auth - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/auth-realm\"" "Authentication Required - ok" + yq e -i ' + .metadata.annotations."nginx.ingress.kubernetes.io/auth-type" = "basic" | + .metadata.annotations."nginx.ingress.kubernetes.io/auth-secret" = "http-auth" | + .metadata.annotations."nginx.ingress.kubernetes.io/auth-realm" = "Authentication Required - ok" + ' "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" # Clean up whitespace and trailing commas from both variables DEFAULT_WHITELIST_IPS_CLEAN=$(echo "${DEFAULT_WHITELIST_IPS}" | tr -d ' ' | sed 's/,$//') @@ -103,15 +104,17 @@ for DOMAIN in ${DOMAINS[@]}; do # Apply the final whitelist if we have any IPs if [ -n "${FINAL_WHITELIST_IPS}" ]; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/whitelist-source-range\"" "${FINAL_WHITELIST_IPS}" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/satisfy\"" "any" + yq e -i ' + .metadata.annotations."nginx.ingress.kubernetes.io/whitelist-source-range" = "'"${FINAL_WHITELIST_IPS}"'" | + .metadata.annotations."nginx.ingress.kubernetes.io/satisfy" = "any" + ' "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" fi if [ "${USING_CLOUDFLARE}" = "1" ] && ! containsElement ${DOMAIN} ${CLOUDFLARE_EXCLUDED_DOMAINS[@]}; then - yq write --inplace "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" metadata.annotations."\"nginx.ingress.kubernetes.io/server-snippet\"" "real_ip_header CF-Connecting-IP;" + yq e -i '.metadata.annotations."nginx.ingress.kubernetes.io/server-snippet" = "real_ip_header CF-Connecting-IP;"' "${CONFIGURATION_TARGET_PATH}/ingress/${INGRESS_FILENAME}" fi - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/webserver/kustomization.yaml" resources[+] "../../ingress/${INGRESS_FILENAME}" + yq e -i ".resources += [\"../../ingress/${INGRESS_FILENAME}\"]" "${CONFIGURATION_TARGET_PATH}/kustomize/webserver/kustomization.yaml" DOMAIN_ITERATOR=$(expr $DOMAIN_ITERATOR + 1) done diff --git a/deploy/parts/environment-variables.sh b/deploy/parts/environment-variables.sh index 2815b19..da3d96c 100644 --- a/deploy/parts/environment-variables.sh +++ b/deploy/parts/environment-variables.sh @@ -19,34 +19,58 @@ for key in "${!ENVIRONMENT_VARIABLES[@]}"; do # Consumer deployments for CONSUMER_FILE in "${CONFIGURATION_TARGET_PATH}/deployments/"consumer-*.yaml; do if [ -f "$CONSUMER_FILE" ]; then - yq write --inplace "${CONSUMER_FILE}" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONSUMER_FILE}" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONSUMER_FILE}" fi done # Webserver PHP-FPM deployment - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/webserver-php-fpm.yaml" # Cron deployment - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/cron.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/cron.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/cron.yaml" # Environment configmap for cronjob ENV_LINE=" export ${key}='${ENVIRONMENT_VARIABLES[${key}]}'" echo "${ENV_LINE}" >> "${CONFIGURATION_TARGET_PATH}/configmap/cron-env.yaml" # Migration Job - First deploy - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy/migrate-application.yaml" # Migration Job - First deploy with demo data - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy-with-demo-data/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy-with-demo-data/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/first-deploy-with-demo-data/migrate-application.yaml" # Migration Job - Continuous deploy - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/continuous-deploy/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/continuous-deploy/migrate-application.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/kustomize/migrate-application/continuous-deploy/migrate-application.yaml" ITERATOR=$(expr $ITERATOR + 1) fi @@ -61,8 +85,12 @@ for key in ${!STOREFRONT_ENVIRONMENT_VARIABLES[@]}; do then echo "Variable '${key}' couldn't be set because it's empty" else - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" ${key} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"${STOREFRONT_ENVIRONMENT_VARIABLES[${key}]}\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${key}\", + \"value\": \"${STOREFRONT_ENVIRONMENT_VARIABLES[$key]}\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" ITERATOR=$(expr $ITERATOR + 1) fi @@ -75,19 +103,31 @@ find ${CONFIGURATION_TARGET_PATH} -type f | xargs sed -i 's/nullPlaceholder//' for DOMAIN in ${DOMAINS[@]}; do BASENAME=${!DOMAIN} - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" "\"${DOMAIN}\"" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"https://${BASENAME}/\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${DOMAIN}\", + \"value\": \"https://${BASENAME}/\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" ITERATOR=$(expr $ITERATOR + 1) - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" "\"${DOMAIN/DOMAIN_HOSTNAME/PUBLIC_GRAPHQL_ENDPOINT_HOSTNAME}\"" - yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"https://${BASENAME}/graphql/\"" + yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"${DOMAIN/DOMAIN_HOSTNAME/PUBLIC_GRAPHQL_ENDPOINT_HOSTNAME}\", + \"value\": \"https://${BASENAME}/graphql/\" + } + " "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" ITERATOR=$(expr $ITERATOR + 1) done -yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].name" "\"INTERNAL_ENDPOINT\"" -yq write --inplace "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" "spec.template.spec.containers[0].env[${ITERATOR}].value" "\"http://webserver-php-fpm:8080/\"" +yq e -i " + .spec.template.spec.containers[0].env[${ITERATOR}] = { + \"name\": \"INTERNAL_ENDPOINT\", + \"value\": \"http://webserver-php-fpm:8080/\" + } +" "${CONFIGURATION_TARGET_PATH}/deployments/storefront.yaml" echo -e "[${GREEN}OK${NO_COLOR}]" diff --git a/tests/README.md b/tests/README.md index d941223..7597dc8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,22 +7,22 @@ Tests for verifying Kubernetes manifest generation produces expected output. ```bash # Run all tests docker run --rm -v $(pwd):/workspace -w /workspace \ - shopsys/kubernetes-buildpack:1.2 \ + shopsys/kubernetes-buildpack:2.0 \ ./tests/run-tests.sh # Run specific scenario docker run --rm -v $(pwd):/workspace -w /workspace \ - shopsys/kubernetes-buildpack:1.2 \ + shopsys/kubernetes-buildpack:2.0 \ ./tests/run-tests.sh basic-production # Update expected files after intentional changes docker run --rm -v $(pwd):/workspace -w /workspace \ - shopsys/kubernetes-buildpack:1.2 \ + shopsys/kubernetes-buildpack:2.0 \ ./tests/run-tests.sh --update # List available scenarios docker run --rm -v $(pwd):/workspace -w /workspace \ - shopsys/kubernetes-buildpack:1.2 \ + shopsys/kubernetes-buildpack:2.0 \ ./tests/run-tests.sh --list ``` diff --git a/tests/scenarios/basic-production/expected/cron.yaml b/tests/scenarios/basic-production/expected/cron.yaml index 88c57ee..6d85982 100644 --- a/tests/scenarios/basic-production/expected/cron.yaml +++ b/tests/scenarios/basic-production/expected/cron.yaml @@ -43,13 +43,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: apps/v1 @@ -93,7 +93,9 @@ 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 + - 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 - -c @@ -166,7 +168,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - configMap: name: cron-list diff --git a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml index c34f83f..74fbf30 100644 --- a/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalPodAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: webserver-php-fpm - namespace: myproject-production + namespace: "myproject-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,10 +11,10 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 + - 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 index cd52645..212d868 100644 --- a/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/basic-production/expected/horizontalStorefrontAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: storefront - namespace: myproject-production + namespace: "myproject-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,9 +11,9 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 120 diff --git a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml index 22080f2..79076f9 100644 --- a/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-continuous-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -367,7 +370,8 @@ spec: - command: - sh - -c - - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance build-deploy-part-2-db-dependent + - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance + build-deploy-part-2-db-dependent env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -414,5 +418,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: 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 4c0677a..bf040b1 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 @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -367,7 +370,8 @@ spec: - command: - sh - -c - - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export + - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo + plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -414,5 +418,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: 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 84af106..7b9ec6c 100644 --- a/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/basic-production/expected/migrate-first-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -414,5 +417,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index f4d9c32..1b8af9e 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -649,7 +649,7 @@ spec: - emptyDir: {} name: source-codes - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - configMap: name: nginx-default-config @@ -671,7 +671,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m name: eshop-domain-0 namespace: myproject-production @@ -701,7 +703,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m name: eshop-domain-1 namespace: myproject-production diff --git a/tests/scenarios/development-single-domain/expected/cron.yaml b/tests/scenarios/development-single-domain/expected/cron.yaml index fda463c..faae19b 100644 --- a/tests/scenarios/development-single-domain/expected/cron.yaml +++ b/tests/scenarios/development-single-domain/expected/cron.yaml @@ -43,11 +43,11 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://dev.example.com + - id: 1 + url: https://dev.example.com kind: ConfigMap metadata: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd namespace: myproject-dev --- apiVersion: apps/v1 @@ -91,7 +91,9 @@ 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 + - 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 - -c @@ -164,7 +166,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd name: domains-urls - configMap: name: cron-list diff --git a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml index 55a913b..95e34f3 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalPodAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: webserver-php-fpm - namespace: myproject-dev + namespace: "myproject-dev" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,10 +11,10 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 + - 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 43e1de7..892de0a 100644 --- a/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/development-single-domain/expected/horizontalStorefrontAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: storefront - namespace: myproject-dev + namespace: "myproject-dev" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,9 +11,9 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 120 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 23f4bf6..0e74d2e 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-continuous-deploy.yaml @@ -7,11 +7,11 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://dev.example.com + - id: 1 + url: https://dev.example.com kind: ConfigMap metadata: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd namespace: myproject-dev --- apiVersion: v1 @@ -251,7 +251,8 @@ spec: - command: - sh - -c - - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance build-deploy-part-2-db-dependent + - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance + build-deploy-part-2-db-dependent env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -298,5 +299,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd name: 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 e4468b6..76dc46e 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 @@ -7,11 +7,11 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://dev.example.com + - id: 1 + url: https://dev.example.com kind: ConfigMap metadata: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd namespace: myproject-dev --- apiVersion: v1 @@ -251,7 +251,8 @@ spec: - command: - sh - -c - - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export + - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo + plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -298,5 +299,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd name: 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 54e2c49..a047f20 100644 --- a/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/development-single-domain/expected/migrate-first-deploy.yaml @@ -7,11 +7,11 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://dev.example.com + - id: 1 + url: https://dev.example.com kind: ConfigMap metadata: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd namespace: myproject-dev --- apiVersion: v1 @@ -298,5 +298,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd name: domains-urls diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 61bfd18..f2dd9ea 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -7,11 +7,11 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://dev.example.com + - id: 1 + url: https://dev.example.com kind: ConfigMap metadata: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd namespace: myproject-dev --- apiVersion: v1 @@ -643,7 +643,7 @@ spec: - emptyDir: {} name: source-codes - configMap: - name: domains-urls-2k8b4hbtb5 + name: domains-urls-5f46tgkghd name: domains-urls - configMap: name: nginx-default-config @@ -668,7 +668,9 @@ metadata: nginx.ingress.kubernetes.io/auth-realm: Authentication Required - ok nginx.ingress.kubernetes.io/auth-secret: http-auth nginx.ingress.kubernetes.io/auth-type: basic - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^www\.(?.+)$) { return 308 https://$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^www\.(?.+)$) { return + 308 https://$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m nginx.ingress.kubernetes.io/satisfy: any nginx.ingress.kubernetes.io/whitelist-source-range: 10.0.0.0/8,192.168.0.0/16 diff --git a/tests/scenarios/escaping-env/deploy-project.sh b/tests/scenarios/escaping-env/deploy-project.sh index 7bd7622..7911499 100644 --- a/tests/scenarios/escaping-env/deploy-project.sh +++ b/tests/scenarios/escaping-env/deploy-project.sh @@ -1,94 +1,25 @@ #!/bin/bash -e +SCENARIO_NAME="escaping-env" +source "$(dirname "$0")/../../lib/scenario-base.sh" -# Use exported BASE_PATH from test runner, or fall back to relative path -BASE_PATH="${BASE_PATH:-$(realpath "$(dirname "$0")/../../tmp/basic-production")}" -CONFIGURATION_TARGET_PATH="${CONFIGURATION_TARGET_PATH:-${BASE_PATH}/var/deployment/kubernetes}" -BASIC_AUTH_PATH="${BASIC_AUTH_PATH:-${BASE_PATH}/deploy/basicHttpAuth}" -DEPLOY_TARGET_PATH="${DEPLOY_TARGET_PATH:-${BASE_PATH}/var/deployment/deploy}" +DOMAINS=(DOMAIN_HOSTNAME_1 DOMAIN_HOSTNAME_2) +export RUNNING_PRODUCTION=1 +export FIRST_DEPLOY=0 +ENABLE_AUTOSCALING=true -function generate() { - # Domain configuration - DOMAINS=( - DOMAIN_HOSTNAME_1 - DOMAIN_HOSTNAME_2 - ) +declare -A CRON_INSTANCES=( + ["cron"]='*/5 * * * *' +) - # Production mode - export RUNNING_PRODUCTION=1 - export FIRST_DEPLOY=0 - export DISPLAY_FINAL_CONFIGURATION=0 +DEFAULT_CONSUMERS=( + "email:email_transport:1" +) - # Autoscaling - ENABLE_AUTOSCALING=true - - declare -A ENVIRONMENT_VARIABLES=( - ["APP_SECRET"]="${APP_SECRET}" - ["DATABASE_HOST"]="${POSTGRES_DATABASE_IP_ADDRESS}" - ["DATABASE_NAME"]="${PROJECT_NAME}" - ["DATABASE_PORT"]="${POSTGRES_DATABASE_PORT}" - ["DATABASE_USER"]="${PROJECT_NAME}" - ["DATABASE_PASSWORD"]="${POSTGRES_DATABASE_PASSWORD}" - ["S3_ENDPOINT"]="${S3_ENDPOINT}" - ["S3_ACCESS_KEY"]="${PROJECT_NAME}" - ["S3_SECRET"]="${S3_SECRET}" - ["S3_BUCKET_NAME"]="${PROJECT_NAME}" - ["ELASTICSEARCH_HOST"]="${ELASTICSEARCH_URLS}" - ["ELASTIC_SEARCH_INDEX_PREFIX"]="${PROJECT_NAME}" - ["REDIS_PREFIX"]="${PROJECT_NAME}" - ["MAILER_DSN"]="${MAILER_DSN}" - ["TRUSTED_PROXY"]="10.0.0.0/8" - ["MESSENGER_TRANSPORT_DSN"]="${MESSENGER_TRANSPORT_DSN}" - ["SENTRY_RELEASE"]="${SENTRY_RELEASE}" - ) - - declare -A STOREFRONT_ENVIRONMENT_VARIABLES=( - ["SENTRY_RELEASE"]="${SENTRY_RELEASE}" - ) - - declare -A CRON_INSTANCES=( - ["cron"]='*/5 * * * *' - ) - - VARS=( - TAG - STOREFRONT_TAG - PROJECT_NAME - BASE_PATH - RABBITMQ_DEFAULT_USER - RABBITMQ_DEFAULT_PASS - RABBITMQ_IP_WHITELIST - ) - - source "${DEPLOY_TARGET_PATH}/functions.sh" - source "${DEPLOY_TARGET_PATH}/parts/domains.sh" - source "${DEPLOY_TARGET_PATH}/parts/domain-rabbitmq-management.sh" - source "${DEPLOY_TARGET_PATH}/parts/environment-variables.sh" - source "${DEPLOY_TARGET_PATH}/parts/kubernetes-variables.sh" - source "${DEPLOY_TARGET_PATH}/parts/cron.sh" - source "${DEPLOY_TARGET_PATH}/parts/autoscaling.sh" - # NOTE: deploy.sh is skipped - it contains kubectl commands for actual deployment -} - -function merge() { - DEFAULT_CONSUMERS=( - "email:email_transport:1" - ) - - source "${BASE_PATH}/vendor/shopsys/deployment/deploy/functions.sh" - merge_configuration - create_consumer_manifests "${DEFAULT_CONSUMERS[@]}" -} +VARS+=(SENTRY_RELEASE) +ENVIRONMENT_VARIABLES["SENTRY_RELEASE"]="${SENTRY_RELEASE}" +STOREFRONT_ENVIRONMENT_VARIABLES["SENTRY_RELEASE"]="${SENTRY_RELEASE}" case "$1" in - "generate") - merge - generate - ;; - "merge") - merge - ;; - *) - echo "invalid option" - exit 1 - ;; + "generate") run_merge; run_generate ;; + *) echo "Usage: $0 generate"; exit 1 ;; esac diff --git a/tests/scenarios/escaping-env/expected/cron.yaml b/tests/scenarios/escaping-env/expected/cron.yaml index 2d8ac73..759d1b1 100644 --- a/tests/scenarios/escaping-env/expected/cron.yaml +++ b/tests/scenarios/escaping-env/expected/cron.yaml @@ -44,13 +44,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: apps/v1 @@ -94,7 +94,9 @@ 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 + - 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 - -c @@ -124,7 +126,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -169,7 +171,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - configMap: name: cron-list diff --git a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml index c34f83f..74fbf30 100644 --- a/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalPodAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: webserver-php-fpm - namespace: myproject-production + namespace: "myproject-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,10 +11,10 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 + - 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 index cd52645..212d868 100644 --- a/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/escaping-env/expected/horizontalStorefrontAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: storefront - namespace: myproject-production + namespace: "myproject-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,9 +11,9 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 120 diff --git a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml index e30a983..340088c 100644 --- a/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-continuous-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -168,7 +171,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -207,7 +210,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -369,7 +372,8 @@ spec: - command: - sh - -c - - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance build-deploy-part-2-db-dependent + - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance + build-deploy-part-2-db-dependent env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -396,7 +400,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -418,5 +422,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: 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 6f1307d..b81c351 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 @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -168,7 +171,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -207,7 +210,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -369,7 +372,8 @@ spec: - command: - sh - -c - - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export + - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo + plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -396,7 +400,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -418,5 +422,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: 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 36aa85a..62b915e 100644 --- a/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/escaping-env/expected/migrate-first-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -168,7 +171,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -207,7 +210,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - name: fe-api-keys-volume secret: @@ -396,7 +399,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -418,5 +421,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index 54a5686..dc64a13 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.example.com - - id: 2 - url: https://www.example.sk + - id: 1 + url: https://www.example.com + - id: 2 + url: https://www.example.sk kind: ConfigMap metadata: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf namespace: myproject-production --- apiVersion: v1 @@ -412,7 +412,7 @@ spec: containers: - env: - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: DOMAIN_HOSTNAME_1 value: https://www.example.com/ - name: PUBLIC_GRAPHQL_ENDPOINT_HOSTNAME_1 @@ -537,7 +537,7 @@ spec: - name: ELASTIC_SEARCH_INDEX_PREFIX value: myproject-production - name: SENTRY_RELEASE - value: 4794110000000 + value: "479411e7" - name: S3_SECRET value: test-s3-secret - name: MAILER_DSN @@ -653,7 +653,7 @@ spec: - emptyDir: {} name: source-codes - configMap: - name: domains-urls-64tm462t8h + name: domains-urls-m8t7497btf name: domains-urls - configMap: name: nginx-default-config @@ -675,7 +675,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m name: eshop-domain-0 namespace: myproject-production @@ -705,7 +707,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m name: eshop-domain-1 namespace: myproject-production diff --git a/tests/scenarios/production-with-cloudflare/expected/cron.yaml b/tests/scenarios/production-with-cloudflare/expected/cron.yaml index a6ee7a2..4604bb6 100644 --- a/tests/scenarios/production-with-cloudflare/expected/cron.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/cron.yaml @@ -44,13 +44,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de + - id: 1 + url: https://www.shop.com + - id: 2 + url: https://www.shop.de kind: ConfigMap metadata: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 namespace: shop-production --- apiVersion: apps/v1 @@ -94,7 +94,9 @@ 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 + - 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 - -c @@ -167,7 +169,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - configMap: name: cron-list diff --git a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml index 9758bab..13e1051 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalPodAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: webserver-php-fpm - namespace: shop-production + namespace: "shop-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,10 +11,10 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: ContainerResource - containerResource: - name: cpu - container: php-fpm - target: - type: Utilization - averageUtilization: 120 + - 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 index 26c74ee..2ef81ef 100644 --- a/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/horizontalStorefrontAutoscaler.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: storefront - namespace: shop-production + namespace: "shop-production" spec: scaleTargetRef: apiVersion: apps/v1 @@ -11,9 +11,9 @@ spec: minReplicas: 2 maxReplicas: 3 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 120 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 120 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 ef9878b..c4225cb 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-continuous-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de + - id: 1 + url: https://www.shop.com + - id: 2 + url: https://www.shop.de kind: ConfigMap metadata: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 namespace: shop-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -252,7 +255,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume order_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume order_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -319,7 +325,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -481,7 +487,8 @@ spec: - command: - sh - -c - - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance build-deploy-part-2-db-dependent + - cd /var/www/html && ./phing -verbose db-migrations-count-with-maintenance + build-deploy-part-2-db-dependent env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -528,5 +535,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: 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 0b18e04..780ffd8 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 @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de + - id: 1 + url: https://www.shop.com + - id: 2 + url: https://www.shop.de kind: ConfigMap metadata: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 namespace: shop-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -252,7 +255,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume order_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume order_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -319,7 +325,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -481,7 +487,8 @@ spec: - command: - sh - -c - - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export + - cd /var/www/html && sleep 30 && ./phing cluster-first-deploy db-fixtures-demo + plugin-demo-data-load friendly-urls-generate domains-urls-replace elasticsearch-export env: - name: ELASTICSEARCH_HOST value: http://elasticsearch:9200 @@ -528,5 +535,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: 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 ad3e4af..3e0da2b 100644 --- a/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/migrate-first-deploy.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de + - id: 1 + url: https://www.shop.com + - id: 2 + url: https://www.shop.de kind: ConfigMap metadata: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 namespace: shop-production --- apiVersion: v1 @@ -138,7 +138,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume email_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume email_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -205,7 +208,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -252,7 +255,10 @@ spec: weight: 100 containers: - args: - - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer ]; do \n php /var/www/html/bin/console messenger:consume order_transport --time-limit=300 --quiet\n sleep 2\ndone\n" + - "PIPE=/tmp/log-pipe\nrm -rf $PIPE\nmkfifo $PIPE\nchmod 666 $PIPE\nstdbuf + -o0 tail -n +1 -f $PIPE &\n\nsleep 5\n\nwhile [ ! -f /tmp/stop_consumer + ]; do \n php /var/www/html/bin/console messenger:consume order_transport + --time-limit=300 --quiet\n sleep 2\ndone\n" command: - /bin/sh - -c @@ -319,7 +325,7 @@ spec: value: background volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - name: fe-api-keys-volume secret: @@ -528,5 +534,5 @@ spec: restartPolicy: Never volumes: - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 87cd5aa..3db750c 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -7,13 +7,13 @@ apiVersion: v1 data: domains_urls.yaml: | domains_urls: - - id: 1 - url: https://www.shop.com - - id: 2 - url: https://www.shop.de + - id: 1 + url: https://www.shop.com + - id: 2 + url: https://www.shop.de kind: ConfigMap metadata: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 namespace: shop-production --- apiVersion: v1 @@ -649,7 +649,7 @@ spec: - emptyDir: {} name: source-codes - configMap: - name: domains-urls-997f7g7mb7 + name: domains-urls-47t6ghttc4 name: domains-urls - configMap: name: nginx-default-config @@ -671,7 +671,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m nginx.ingress.kubernetes.io/server-snippet: real_ip_header CF-Connecting-IP; name: eshop-domain-0 @@ -702,7 +704,9 @@ metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return 308 https://www.$domain$request_uri; } + nginx.ingress.kubernetes.io/configuration-snippet: if ($scheme = http) { return + 308 https://$host$request_uri; } if ($host ~ ^(?!www\.)(?.+)$) { return + 308 https://www.$domain$request_uri; } nginx.ingress.kubernetes.io/proxy-body-size: 32m nginx.ingress.kubernetes.io/server-snippet: real_ip_header CF-Connecting-IP; name: eshop-domain-1