How to use variables with forward slash in kubernetes chart?

5/25/2018

I defined the following parameters in values.yaml

resources:
  nvidia.com/gpu: 1

and in templates, I'd like to add following logic in templates/deployment.yaml

{{- if .Values.resources.nvidia.com/gpu }}
 ****
{{- end}}

But it's failed, please help me to know how to use it in templates/deployment.yaml.

-- che yang
charts
kubernetes

1 Answer

5/25/2018

You can always use the function index:

  {{- if index .Values.resources "nvidia.com/gpu" }}
    x: {{ index .Values.resources "nvidia.com/gpu" }}
  {{- end}}
-- Ignacio Millán
Source: StackOverflow