Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb api version switching #1696

Merged
merged 1 commit into from
Apr 19, 2022
Merged

pdb api version switching #1696

merged 1 commit into from
Apr 19, 2022

Conversation

bwagner5
Copy link
Contributor

@bwagner5 bwagner5 commented Apr 19, 2022

1. Issue, if available:
N/A

2. Description of changes:

  • Use PDB v1 api on clusters >= 1.21 if < 1.21 then use v1beta1

3. How was this change tested?

  • helm template charts/karpenter

Kind 1.20:

$ kind create cluster --image kindest/node:v1.20.70@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9 --kubeconfig /tmp/kubeconfig
$ export KUBECONFIG=/tmp/kubeconfig
$ make apply
$ kg pdb karpenter -n karpenter -o yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  annotations:
    meta.helm.sh/release-name: karpenter
    meta.helm.sh/release-namespace: karpenter
  creationTimestamp: "2022-04-19T16:06:57Z"
  generation: 1
  labels:
    app.kubernetes.io/managed-by: Helm
  name: karpenter
  namespace: karpenter
  resourceVersion: "1004"
  uid: b794ed80-9030-489b-8663-1dd5a3772d96
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: karpenter
      app.kubernetes.io/name: karpenter
status:
  currentHealthy: 0
  desiredHealthy: 0
  disruptionsAllowed: 0
  expectedPods: 1
  observedGeneration: 1

Kind 1.21

$  kind create cluster --image kindest/node:v1.21.2@sha256:9d07ff05e4afefbba983fac311807b3c17a5f36e7061f6cb7e2ba756255b2be4 --kubeconfig /tmp/kubeconfig --name kind-121
$ export KUBECONFIG=/tmp/kubeconfig
$ make apply
$ kg pdb karpenter -n karpenter -o yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  annotations:
    meta.helm.sh/release-name: karpenter
    meta.helm.sh/release-namespace: karpenter
  creationTimestamp: "2022-04-19T16:15:26Z"
  generation: 1
  labels:
    app.kubernetes.io/managed-by: Helm
  name: karpenter
  namespace: karpenter
  resourceVersion: "675"
  uid: e43a67a9-1554-4206-b2aa-e4fc0c9cf389
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: karpenter
      app.kubernetes.io/name: karpenter
status:
  conditions:
  - lastTransitionTime: "2022-04-19T16:15:26Z"
    message: ""
    observedGeneration: 1
    reason: InsufficientPods
    status: "False"
    type: DisruptionAllowed
  currentHealthy: 0
  desiredHealthy: 0
  disruptionsAllowed: 0
  expectedPods: 1
  observedGeneration: 1

4. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bwagner5 bwagner5 requested a review from a team as a code owner April 19, 2022 15:59
@bwagner5 bwagner5 requested a review from njtran April 19, 2022 15:59
@netlify
Copy link

netlify bot commented Apr 19, 2022

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit 387b837
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/625edc54232580000914171a

@bwagner5 bwagner5 merged commit 7b74e70 into aws:main Apr 19, 2022
@bwagner5 bwagner5 deleted the pdb-fix branch April 19, 2022 16:19
tzneal pushed a commit to tzneal/karpenter that referenced this pull request Apr 19, 2022
tzneal pushed a commit that referenced this pull request Apr 19, 2022

{{/* Get PodDisruptionBudget API Version */}}
{{- define "karpenter.pdb.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this was possible. 👍 Thanks for fixing this

@suket22 suket22 mentioned this pull request May 23, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants