Skip to content

Instantly share code, notes, and snippets.

@tab1293
Last active October 15, 2019 00:55
Show Gist options
  • Save tab1293/904533da5618ca4dd94a939d742cc668 to your computer and use it in GitHub Desktop.
Save tab1293/904533da5618ca4dd94a939d742cc668 to your computer and use it in GitHub Desktop.
Failed Kubernetes job node pool selector
j := &batch.Job{
Spec: batch.JobSpec{
Template: core.PodTemplateSpec{
Spec: core.PodSpec{
Affinity: &core.Affinity{
NodeAffinity: &core.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &core.NodeSelector{
NodeSelectorTerms: []core.NodeSelectorTerm{
{
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: "cloud.google.com/gke-nodepool",
Values: []string{"dl-pool"},
Operator: core.NodeSelectorOpIn,
},
},
},
},
},
},
},
},
},
},
}
jobSpec := &batch.Job{
Spec: batch.JobSpec{
Selector: &meta.LabelSelector{
MatchLabels: map[string]string{
"cloud.google.com/gke-nodepool": "dl-pool",
},
},
},
}
j, err := k8.jobclient.Create(jobSpec)
if err != nil {
fmt.Print(err)
return nil, err
}
// Job.batch "dl-a4206a2b-f88d-4cac-9c83-5a7b446b7499-geyjteey9pp" is invalid:
// [
// spec.selector: Invalid value: v1.LabelSelector{
// MatchLabels:map[string]string{"cloud.google.com/gke-nodepool":"dl-pool", "controller-uid":"f364be13-eedb-11e9-8c5c-42010a960113"},
// MatchExpressions:[]v1.LabelSelectorRequirement(nil)
// }: `selector` not auto-generated,
// spec.template.metadata.labels: Invalid value: map[string]string{
// "job-name":"dl-a4206a2b-f88d-4cac-9c83-5a7b446b7499-geyjteey9pp",
// "controller-uid":"f364be13-eedb-11e9-8c5c-42010a960113",
// "jobName":"dl-a4206a2b-f88d-4cac-9c83-5a7b446b7499-geyjteey9pp",
// "podType":"download-job"
// }: `selector` does not match template `labels`
// ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment