kubernetes-sigs/kubectl-validate

Deployments with `.spec.strategy` specified fail validation

rahul-theorem opened this issue · 6 comments

When attempting to validate a simple deployment, kubectl-validate fails with the following error:

deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      service: my-service
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  template:
    metadata:
      labels:
        service: my-service
    spec:
       containers:
        - name: main
          image: my-service:latest
          imagePullPolicy: Always
          resources:
            limits:
              cpu: 100m
              memory: 100Mi
            requests:
              cpu: 100m
              memory: 100Mi
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP

Error:

$ kubectl-validate --version=1.24 ./deployment.yaml

deployment.yaml...ERROR
spec.strategy.rollingUpdate: Invalid value: value provided for unknown field
spec.strategy.type: Invalid value: value provided for unknown field

After removing .spec.strategy, validation succeeds. This happens for both RollingUpdate & Recreate strategies. This same issue appears to be impacting PDBs as well (specifically .spec.selector.matchLabels), but all other resources (CRDs or otherwise) are working as expected.

Version: https://pkg.go.dev/sigs.k8s.io/kubectl-validate@v0.0.0-20230531195345-5aee348b797c
Environment: MacOS (arm64)

ProductName:		macOS
ProductVersion:		13.4
BuildVersion:		22F66

@eddycharly Are there any more updates for this issue?

#60 solves this I believe. Will add a test case to verify

ykyr commented

We hit the same issue. The tool is great, but this bug is blocking pretty much all the validations, as Deployments are used everywhere.

Sweet - that PR fixed the issue I was just having. 🥇 - appreciate it!

/close

as fixed by #60

@alexzielenski: Closing this issue.

In response to this:

/close

as fixed by #60

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.