Foudel
Foudel

Reputation: 277

How to set values in helm_release

Good day!

I am trying to set values of the NVIDIA helm chart using helm terraform provider but I am not able to define the name of the variable correctly, some of the .tf file looks like the below:

set {
name  = "nvidiaInstaller.driverVersion"
value = "${var.driverVersion}"
}
set {
name  = "nvidiaInstaller.tag"
value = "${var.tag}"
}
set {
name  = "nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key[0]"
value = "${var.nvidiaInstallerNodeAffinityKey}"
}
set {
name  = "nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator[1]"
value = "${var.nvidiaInstallerNodeAffinityOperator}"
}

Example of defining the values:

variable "driverVersion" {default = 440.31}
variable "tag" {default = "ae3f1b937f784b9e0d18f9dd03b67829381799c9" }
variable "nvidiaInstallerNodeAffinityKey" {default = "gpu"}
variable "nvidiaInstallerNodeAffinityOperator" {default = "In"}
variable "nvidiaInstallerNodeAffinityValues" {default = "nvidia-tesla-t4"}

But when applying, I got the below issue:

1 error occurred:
* module.bocr-applications.helm_release.nvidia-gpu-installer: 1 error occurred:
* helm_release.nvidia-gpu-installer: rpc error: code = Unknown desc = release gpu-installer 
failed: DaemonSet in version "v1" cannot be handled as a DaemonSet: v1.DaemonSet.Spec: 
v1.DaemonSetSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Affinity: 
v1.Affinity.NodeAffinity: v1.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution: 
v1.NodeSelector.NodeSelectorTerms: []v1.NodeSelectorTerm: 
v1.NodeSelectorTerm.MatchExpressions: []v1.NodeSelectorRequirement: 
v1.NodeSelectorRequirement.Key: ReadString: expects " or n, but found [, error found in #10 
byte of ...|:[{"key":["gpu",null|..., bigger context ...|"nodeSelectorTerms": 
[{"matchExpressions":[{"key":["gpu",null,"nvidia-tesla-t4"],"operator":[null,"In|...

Can Someone help me resolve this issue?

Upvotes: 1

Views: 18418

Answers (2)

Foudel
Foudel

Reputation: 277

Actually the above issue is due to bad overwriting of key, operator and values in values.yaml file. helm release set array for the below example:

set {
name  = "nvidiaInstaller.tag"
value = "${var.tag}"
}
set {
name  = "nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key[0]"
value = "${var.nvidiaInstallerNodeAffinityKey}"
}
set {
name  = "nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator[1]"
value = "${var.nvidiaInstallerNodeAffinityOperator}"
}

should be defined as below:

set_string {
name  = "nvidiaInstaller.tag"
value = "${var.tag}"
}

set {
name  ="nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key"
value = "${var.nvidiaInstallerNodeAffinityKey}"
}
set {
name  ="nvidiaInstaller.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator"
  value = "${var.nvidiaInstallerNodeAffinityOperator}"
 }

Upvotes: 3

DanF
DanF

Reputation: 364

That error could be a handful of things, a character that is non-ascii, null, or a bad indentation.

  • Verify that you have no extra characters at the end of any given values.
  • Do a helm template and verify that all fields have non null values rendered on the output.
  • When you do a helm template verify that your blocks are aligned, I had an error liked the one you posted where my blocks weren't aligned and/or was using spaces/tabs and it tirggered that error

Upvotes: 0

Related Questions