cache warmup is now run as an init container#73
cache warmup is now run as an init container#73henzigo wants to merge 1 commit intojg/cron-graceful-shutdownfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Moves the application cache warmup step from a postStart lifecycle hook into a dedicated Kubernetes init container to ensure warmup completes before the main containers start.
Changes:
- Updated
webserver-php-fpmdeployment template to add awarmupinitContainer and remove thepostStarthook. - Extended deployment generation script to inject environment variables into the new warmup initContainer.
- Updated scenario expected manifests and documented the upgrade note.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scenarios/production-with-cloudflare/expected/webserver.yaml | Updates expected rendered manifest to reflect warmup as an initContainer. |
| tests/scenarios/escaping-env/expected/webserver.yaml | Updates expected rendered manifest to reflect warmup as an initContainer. |
| tests/scenarios/development-single-domain/expected/webserver.yaml | Updates expected rendered manifest to reflect warmup as an initContainer. |
| tests/scenarios/basic-production/expected/webserver.yaml | Updates expected rendered manifest to reflect warmup as an initContainer. |
| kubernetes/deployments/webserver-php-fpm.yaml | Adds warmup initContainer and removes postStart warmup hook from php-fpm. |
| deploy/parts/environment-variables.sh | Injects env vars into the warmup initContainer in generated manifests. |
| UPGRADE.md | Documents the behavioral change for upgrading users. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - 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}}" |
There was a problem hiding this comment.
The warmup initContainer runs phing but doesn’t set workingDir. Elsewhere in this repo, containers that run phing explicitly set workingDir: /var/www/html (e.g., cron.yaml) or cd /var/www/html before invoking it, which suggests phing depends on the CWD to find the build file. Consider setting workingDir: /var/www/html for this initContainer (or wrapping the command with a cd) to avoid initContainer failures and pods stuck in Init state.
| \"name\": \"${key}\", | ||
| \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" |
There was a problem hiding this comment.
This yq edit interpolates ${key} / ${ENVIRONMENT_VARIABLES[$key]} directly into the expression instead of using strenv(...) like the other env injections above. This can break when values contain quotes/newlines/backslashes and also risks yq-expression injection via unescaped content. Prefer reusing YQ_KEY/YQ_VALUE with strenv() (consistent with the other blocks) so values are safely escaped.
| \"name\": \"${key}\", | |
| \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" | |
| \"name\": strenv(YQ_KEY), | |
| \"value\": strenv(YQ_VALUE) |
| .spec.template.spec.initContainers[1].env[${ITERATOR}] = { | ||
| \"name\": \"${key}\", | ||
| \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" |
There was a problem hiding this comment.
The script writes warmup env vars to .spec.template.spec.initContainers[1], which is brittle if initContainers are reordered or additional initContainers are added later (env vars could end up on the wrong container). Consider selecting the initContainer by name (e.g., matching name == "warmup") rather than relying on a fixed index.
| .spec.template.spec.initContainers[1].env[${ITERATOR}] = { | |
| \"name\": \"${key}\", | |
| \"value\": \"${ENVIRONMENT_VARIABLES[$key]}\" | |
| (.spec.template.spec.initContainers[] | select(.name == \"warmup\")).env[${ITERATOR}] = { | |
| \"name\": strenv(YQ_KEY), | |
| \"value\": strenv(YQ_VALUE) |
No description provided.