gokubernetesnodeselector

Is there any method to set nodeselector for pod using golang api


Basically need a way to set nodeselector for Pod using GoLang API

Pod.Spec.NodeSelector["failure-domain.beta.kubernetes.io/zone"] = zone is giving out error


Solution

  • You should initialize the map before setting it. something like this

    pod.Spec.NodeSelector = make(map[string]string)
    pod.Spec.NodeSelector["failure-domain.beta.kubernetes.io/zone"] = "zone1"