Home > Software engineering >  Is there any method to set nodeselector for pod using golang api
Is there any method to set nodeselector for pod using golang api

Time:12-07

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

CodePudding user response:

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"
  • Related