fix: deploy demos with immutable image tag
This commit is contained in:
parent
0d8067b566
commit
27186662f9
|
|
@ -23,8 +23,8 @@ spec:
|
|||
fsGroupChangePolicy: OnRootMismatch
|
||||
containers:
|
||||
- name: demos-static
|
||||
image: 192.168.100.73:30500/demos-static:latest
|
||||
imagePullPolicy: Always
|
||||
image: 192.168.100.73:30500/demos-static:bootstrap
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ locals {
|
|||
kustomize = {
|
||||
images = ["php-website=${var.website_image_ref}"]
|
||||
}
|
||||
} : {},
|
||||
name == "demos-static" && var.demos_image_ref != "" ? {
|
||||
kustomize = {
|
||||
images = ["demos-static=${var.demos_image_ref}"]
|
||||
}
|
||||
} : {}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ variable "website_image_ref" {
|
|||
default = ""
|
||||
}
|
||||
|
||||
variable "demos_image_ref" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "applications" {
|
||||
type = map(object({
|
||||
project = string
|
||||
|
|
|
|||
|
|
@ -3821,6 +3821,12 @@ website_image_tag() {
|
|||
printf 'src-%s\n' "${source_hash:0:12}"
|
||||
}
|
||||
|
||||
demos_image_tag() {
|
||||
local source_hash="$1"
|
||||
|
||||
printf 'src-%s\n' "${source_hash:0:12}"
|
||||
}
|
||||
|
||||
apps_registry_endpoint() {
|
||||
if [[ -n "${TF_VAR_registry_endpoint:-}" ]]; then
|
||||
printf '%s\n' "${TF_VAR_registry_endpoint}"
|
||||
|
|
@ -3929,6 +3935,7 @@ demos_image_is_current() {
|
|||
local platforms="$3"
|
||||
local image_ref="$4"
|
||||
local registry_endpoint="$5"
|
||||
local image_tag
|
||||
local saved_hash
|
||||
local saved_platforms
|
||||
local saved_image
|
||||
|
|
@ -3943,7 +3950,8 @@ demos_image_is_current() {
|
|||
[[ "${saved_platforms}" == "${platforms}" ]] || return 1
|
||||
[[ "${saved_image}" == "${image_ref}" ]] || return 1
|
||||
|
||||
registry_image_exists "${registry_endpoint}" demos-static latest
|
||||
image_tag="$(image_ref_tag "${image_ref}")"
|
||||
registry_image_exists "${registry_endpoint}" demos-static "${image_tag}"
|
||||
}
|
||||
|
||||
write_website_image_state() {
|
||||
|
|
@ -6333,16 +6341,17 @@ apps() {
|
|||
|
||||
registry_endpoint="$(apps_registry_endpoint)"
|
||||
demos_registry_endpoint="$(demos_registry_endpoint)"
|
||||
demos_image_ref="${registry_endpoint}/demos-static:latest"
|
||||
demos_image_state_file="${REPO_ROOT}/.lab/demos-static-image.state"
|
||||
demos_platforms="${DEMOS_IMAGE_PLATFORMS:-linux/amd64,linux/arm64}"
|
||||
demos_source_hash="$(demos_source_hash)"
|
||||
demos_image_ref="${registry_endpoint}/demos-static:${DEMOS_IMAGE_TAG:-$(demos_image_tag "${demos_source_hash}")}"
|
||||
website_image_state_file="${REPO_ROOT}/.lab/php-website-image.state"
|
||||
website_platforms="${WEBSITE_IMAGE_PLATFORMS:-linux/amd64,linux/arm64}"
|
||||
website_source_hash="$(website_source_hash)"
|
||||
website_image_ref="${registry_endpoint}/php-website:${WEBSITE_IMAGE_TAG:-$(website_image_tag "${website_source_hash}")}"
|
||||
export TF_VAR_registry_endpoint="${TF_VAR_registry_endpoint:-${registry_endpoint}}"
|
||||
export TF_VAR_website_image_ref="${TF_VAR_website_image_ref:-${website_image_ref}}"
|
||||
export TF_VAR_demos_image_ref="${TF_VAR_demos_image_ref:-${demos_image_ref}}"
|
||||
export TF_VAR_kubeconfig_path="${TF_VAR_kubeconfig_path:-${KUBECONFIG_PATH}}"
|
||||
export KUBECONFIG_PATH="${TF_VAR_kubeconfig_path}"
|
||||
|
||||
|
|
@ -6364,6 +6373,10 @@ apps() {
|
|||
echo "TF_VAR_website_image_ref must match the buildx website image ref (${website_image_ref})" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${TF_VAR_demos_image_ref}" != "${demos_image_ref}" ]]; then
|
||||
echo "TF_VAR_demos_image_ref must match the buildx demos image ref (${demos_image_ref})" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${demos_registry_endpoint}" != "${registry_endpoint}" ]]; then
|
||||
echo "apps/demos-static/web-app.yaml registry endpoint (${demos_registry_endpoint}) must match app registry endpoint (${registry_endpoint})" >&2
|
||||
|
|
@ -6374,6 +6387,10 @@ apps() {
|
|||
echo "apps/website/web-app.yaml must use an immutable php-website image tag, not latest." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$(image_ref_tag "${demos_image_ref}")" == "latest" ]]; then
|
||||
echo "apps/demos-static/web-app.yaml must use an immutable demos-static image tag, not latest." >&2
|
||||
exit 1
|
||||
fi
|
||||
ensure_website_image_tag_not_reused "${website_image_state_file}" "${website_source_hash}" "${website_image_ref}"
|
||||
|
||||
echo "Deploying homelab applications..."
|
||||
|
|
|
|||
Loading…
Reference in New Issue