Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot template numbers through kustomize #3095

Open
nbrns opened this issue Oct 14, 2024 · 0 comments
Open

Cannot template numbers through kustomize #3095

nbrns opened this issue Oct 14, 2024 · 0 comments

Comments

@nbrns
Copy link

nbrns commented Oct 14, 2024

Environment

Device and OS: Windows 11 / WSL2
App version: v0.41.0
Kubernetes distro being used: EKS / kind

Steps to reproduce

  1. Define a zarf package that tries to template a integer value through kustomize, e.g. deployment spec replica count

zarf.yaml

kind: ZarfPackageConfig
metadata:
  name: podinfo
  version: 1.0.0
variables:
  - name: DEPLOYMENT_REPLICAS
    default: "3"
components:
  - name: podinfo
    required: true
    manifests:
      - name: podinfo
        kustomizations:
          - manifests

manifests/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - podinfo.yaml

manifests/podinfo.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: podinfo-deployment
spec:
  replicas: ###ZARF_VAR_DEPLOYMENT_REPLICAS###
  selector:
    matchLabels:
      app: podinfo
  template:
    metadata:
      labels:
        app: podinfo
    spec:
      containers:
      - name: podinfo
        image: ghcr.io/stefanprodan/podinfo:latest
        ports:
        - containerPort: 9898

Expected result

podinfo is running with 3 replicas.

Actual Result

podinfo is running with 1 replica.

The reason for this is because Zarf first applies the kustomize build. The kustomize build eliminates the Zarf variables, as they are treated as comments. Thus, the replica property is set to null. This results in the default value of 1 for deployments. While this results in deployments not being scaled, with some CRDs, where the replica property is required, this even breaks packages.

EDIT: The general behaviour of Zarf variables just vanishing can be avoided by quoting the variables. However, this results in typing errors when trying to set actual ints/numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triage
Development

No branches or pull requests

1 participant