bitnami / kube-libsonnet

Bitnami's jsonnet library for building Kubernetes manifests
https://bitnami.com
Apache License 2.0
174 stars 50 forks source link

spec.selector is breaking JobSpec for latest GKE #5

Closed borg286 closed 5 years ago

borg286 commented 6 years ago

https://github.com/bitnami-labs/kube-libsonnet/blob/master/kube.libsonnet#L525 This selector is unnecessary, as kubernetes fills in the selector for you when you leave it out. By specifying it kubernetes complains that it isn't auto-generated but user generated.

kupson commented 5 years ago

Versions (minikube server):

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0", GitCommit:"0ed33881dc4355495f623c6f22e7dd0b7632b7c0", GitTreeState:"clean", BuildDate:"2018-09-27T17:05:32Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:30:26Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}

Test yaml (from test-simple-validate.json):

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  annotations: {}
  labels: {name: foo-cronjob}
  name: foo-cronjob
  namespace: default
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 20
  jobTemplate:
    spec:
      completions: 1
      parallelism: 1
      selector:
        matchLabels: {name: foo-cronjob}
      template:
        metadata:
          labels: {name: foo-cronjob}
        spec:
          containers:
          - args: []
            env: []
            image: busybox
            imagePullPolicy: IfNotPresent
            name: foo
            ports: []
            stdin: false
            tty: false
            volumeMounts: []
          imagePullSecrets: []
          initContainers: []
          restartPolicy: OnFailure
          terminationGracePeriodSeconds: 30
          volumes: []
  schedule: 0 * * * *
  successfulJobsHistoryLimit: 10

Error:

The CronJob "foo-cronjob" is invalid: spec.jobTemplate.spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"name":"foo-cronjob"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: `selector` will be auto-generated