Skip to content

[BUG] no-rolling-update-strategy does not account for the default Strategy being RollingUpdate #824

@meganwalker-ibm

Description

@meganwalker-ibm

Describe the bug
The no-rolling-update-strategy rule is looking for a DeploymentLike object to have a strategy.type field matching RollingUpdate|Rolling.

However the default value for this field is RollingUpdate making specifying it redundant: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy

However the rule is useful for ensuring we don't set a type of Recreate.

I think this rule would be better revised to consider a missing value as being a pass.

To Reproduce
Enable no-rolling-update-strategy.
Lint two deploymentLike objects. One that does not set a strategy. One that sets RolllingUpdate explicitly.
They are equivalent in effect, and so should be treated the same.

Sample YAML input
.kube-linter.yaml

checks:
  doNotAutoAddDefaults: true
  include:
    - no-rolling-update-strategy

sample.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1
spec:
  strategy:
    type: Other
---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  name: app2
spec:
---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  name: app3
spec:
  strategy:
    type: RollingUpdate

Expected behavior
Only app1 should be identifies as violating this linting rule. app2 and app3 are directly equivalent to each other.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions