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

skaffold render with Kustomize and --set fails for inline patches #9731

Closed
coperni opened this issue Feb 23, 2025 · 0 comments · Fixed by #9732
Closed

skaffold render with Kustomize and --set fails for inline patches #9731

coperni opened this issue Feb 23, 2025 · 0 comments · Fixed by #9732

Comments

@coperni
Copy link
Contributor

coperni commented Feb 23, 2025

Kustomize supports inline patching. I noticed this issue while I was deploying a Kustomization w/ GCP Cloud Deploy

Expected behavior

Given the following input: https://github.com/coperni/skaffold-kustomize-issue

# skaffold.yaml
apiVersion: skaffold/v4beta7
kind: Config
profiles:
  - name: dev
    manifests:
      kustomize:
        paths:
          - overlays/dev
  - name: prod
    manifests:
      kustomize:
        paths:
          - overlays/prod

With overlay

# ./overlays/dev/kustomization.yaml
resources:
  - ../../base

patches:
  - target:
      kind: Pod
    patch: |-
      - op: replace
        path: /spec/containers/0/image
        value: nginx:latest
# ./overlays/prod/kustomization.yaml
resources:
  - ../../base
namePrefix: prod-
patches:
  - target:
      kind: Pod
    patch: |-
      - op: replace
        path: /spec/containers/0/image
        value: nginx:123

I would expect the following output when running skaffold render -p dev --set="foo=bar" or skaffold render -p dev

apiVersion: v1
data:
  foo: bar!
kind: ConfigMap
metadata:
  name: example-map
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: myapp-pod
spec:
  containers:
    - image: nginx:latest
      name: nginx

and running skaffold render -p prod --set="foo=bar" or skaffold render -p prod

apiVersion: v1
data:
  foo: bar!
kind: ConfigMap
metadata:
  name: prod-example-map
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: prod-myapp-pod
spec:
  containers:
    - image: nginx:123
      name: nginx

Actual behavior

skaffold render -p dev

apiVersion: v1
data:
  foo: bar!
kind: ConfigMap
metadata:
  name: example-map
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: myapp-pod
spec:
  containers:
    - image: nginx:latest
      name: nginx

skaffold render -p dev --set="foo=bar"

read /Users/REDACTED/tmp/kustomize_example/overlays/prod: is a directory

Information

  • Skaffold version: v2.14.0
  • Operating system: macOS 15.3.1 (24D70)
  • Installed via: curl w/ latest stable binary

Steps to reproduce

Checkout https://github.com/coperni/skaffold-kustomize-issue

  • skaffold render -p dev --set="foo=bar"
  • skaffold render -p prod --set="foo=bar"

Current workarounds

A mitigation would be to omit the --set flags since I don't have anything templated in the inline patch but our CI/CD pipeline injects build parameters into skaffold when we render our manifests. We are able to workaround this by placing the patches in dedicated patch files which are referenced in the kustomization.yaml overrlay.

# example 
# ./overlays/dev/kustomization.yaml
resources:
  - ../../base

patches:
  - target:
      kind: Pod
    path: patch.yaml

But I would prefer to not to have to create additional files for the amount of overlays we use.

I will submit a fix for this issue.

coperni added a commit to coperni/skaffold that referenced this issue Feb 23, 2025
coperni added a commit to coperni/skaffold that referenced this issue Feb 23, 2025
Darien-Lin pushed a commit that referenced this issue Feb 24, 2025
fix: kustomize render inline patches with set

Fixes: #9731
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant