Skip to content

HPA minReplicas vs PDB minAvailable check #202

@nissessenap

Description

@nissessenap

There is already a basic config for checking deployment replicas vs PDB.
https://github.com/open-policy-agent/gatekeeper-library/tree/master/library/general/poddisruptionbudget

But what happens if we add HPA to the mix. Instead of setting replicas in a deployment we do it using HPA.
In PDB setting minAvailable: 2 and in HPA setting minReplicas: 1 will potentially lock a node from draining when cordoned thanks to the PDB rule.

Below we can find a example that is okay. But lowering HPA minReplicas: 1 and we would get issues if the application didn't have any load.

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: app
spec:
  minReplicas: 2
  maxReplicas: 4
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: app
  metrics:
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 80
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: app
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app: app
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: app
          image: nginx:latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions