compliance-policies icon indicating copy to clipboard operation
compliance-policies copied to clipboard

configureMinimumReplicaCount ignores setting in HorizontalPodAutoscaler

Open nwittstruck opened this issue 1 year ago • 1 comments

What happened?

Currently, the policy that validates the minimum replica count only checks the configuration of the ReplicaSet. This works fine for simple use cases when you just use a ReplicaSet.

However, when you use a HorizontalPodAutoscaler, the Kubernetes docs discourage using a ReplicaSet.

When an HPA is enabled, it is recommended that the value of spec.replicas of the Deployment and / or StatefulSet be removed from their [manifest(s)](https://kubernetes.io/docs/reference/glossary/?all=true#term-manifest).

Since the policy only checks the ReplicaSet, but not the HorizontalPodAutoscaler, the policy gives a false warning. The policy should also check the minReplicas in HorizontalPodAutoscaler configuration.

Example

Use a HorizontalPodAutoscaler instead of a ReplicaSet to configure the minium amount of replicas.

Output of pulumi about

pulumi about doesn't seem to work in policy packages: Pulumi: Version 3.95.0 Packages:

        "@pulumi/kubernetes-compliance-policies": "0.1.1",
        "@pulumi/compliance-policy-manager": "0.1.2",
        "@pulumi/policy": "^1.7.0",
        "@pulumi/pulumi": "^3.0.0"

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

nwittstruck avatar Dec 10 '23 16:12 nwittstruck