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 does not respect templating deploy.helm.releases.name #5671

Closed
netaskd opened this issue Apr 13, 2021 · 7 comments · Fixed by #5751
Closed

skaffold render does not respect templating deploy.helm.releases.name #5671

netaskd opened this issue Apr 13, 2021 · 7 comments · Fixed by #5751

Comments

@netaskd
Copy link

netaskd commented Apr 13, 2021

Actual behavior

In the doc (https://skaffold.dev/docs/environment/templating/):

List of fields that support templating:

build.artifacts.[].docker.buildArgs (see builders)
build.tagPolicy.envTemplate.template (see envTemplate tagger)
deploy.helm.releases.setValueTemplates (see Deploying with helm)
deploy.helm.releases.name (see Deploying with helm)    <-----------------------------------------------
deploy.helm.releases.namespace (see Deploying with helm)
deploy.kubectl.defaultNamespace
deploy.kustomize.defaultNamespace

My skaffold.yaml contains:

profiles:
- name: deploy
  deploy:
    helm:
      releases:
      - name: "app-{{.PROJECT_VERSION}}"
        artifactOverrides:
          image: app
...

where PROJECT_VERSION is "0.0.1" (sourced from dev-env file to the current shell env)

So, when I run skaffold render it does not fill variable and shows it as is in the skaffold.yaml. For example, ConfigMap contains:

$ skaffold render
---
# Source: app/templates/configmap/env.yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: app-{{.PROJECT_VERSION}}-env
  namespace: dev-01
data:
...

This behavior affects all points where I use {{ .Release.Name }} in helm chart. Source ConfigMap looks like this:

kind: ConfigMap
apiVersion: v1
metadata:
  name: {{ .Release.Name }}-env
  namespace: {{ .Values.stand }}
data:
...

Information

  • Skaffold version: 1.21
  • Operating system: Centos7
  • Installed via: skaffold.dev
@briandealwis
Copy link
Member

There are a few different forms of templating, and in this situation is referring to Go templating in the skaffold.yaml, not Helm templating. So you can refer to environment variables, but not values from the Helm deployer valuesFiles.

@GoogleContainerTools/skaffold-team thoughts? Are there any dangers in loading the valuesFiles and making them available for templating within Helm templated fields?

@briandealwis briandealwis added the triage/discuss Items for discussion label Apr 23, 2021
@briandealwis
Copy link
Member

@netaskd could you clarify:

where PROJECT_VERSION is "0.0.1" (sourced from dev-env file to the current shell env)

Did you mean you were providing PROJECT_VERSION from the environment, or were you looking to retrieve the value from the values files?

@netaskd
Copy link
Author

netaskd commented Apr 27, 2021

@briandealwis, PROJECT_VERSION providing from environment.

In this example:
The dev-env file contains

export PROJECT_VERSION=0.0.1

then

$ source ./dev-env
$ skaffold render

@briandealwis
Copy link
Member

So that should be supported. Could you please run Skaffold with -vdebug to enable debug-level logging, and attach the output here (eliding any confidential information)?

@netaskd
Copy link
Author

netaskd commented Apr 28, 2021

@netaskd
Copy link
Author

netaskd commented Apr 28, 2021

@netaskd
Copy link
Author

netaskd commented Apr 28, 2021

@briandealwis looks like the issue exists when set

build.tagPolicy.envTemplate.template: "{{.PROJECT_VERSION}}"

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

Successfully merging a pull request may close this issue.

3 participants