Skip to content

Commit bb9dc81

Browse files
authored
fix: deprecated API usage for k8s 1.25+ (#126) (#127)
1 parent 34a29ba commit bb9dc81

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

charts/k8s-image-swapper/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: k8s-image-swapper
33
description: Mirror images into your own registry and swap image references automatically.
44
type: application
5-
version: 1.6.1
5+
version: 1.6.2
66
appVersion: 1.4.1
77
home: https://github.com/estahn/charts/tree/main/charts/k8s-image-swapper
88
keywords:
@@ -15,7 +15,7 @@ maintainers:
1515
name: estahn
1616
annotations:
1717
artifacthub.io/changes: |
18-
- "Allow to set custom name for serviceAccount"
18+
- "Fixes deprecated policy api usage for pdb"
1919
artifacthub.io/images: |
2020
- name: k8s-image-webhook
2121
image: ghcr.io/estahn/k8s-image-swapper:1.4.1

charts/k8s-image-swapper/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# k8s-image-swapper
22

3-
![Version: 1.6.1](https://img.shields.io/badge/Version-1.6.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.4.1](https://img.shields.io/badge/AppVersion-1.4.1-informational?style=flat-square)
3+
![Version: 1.6.2](https://img.shields.io/badge/Version-1.6.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.4.1](https://img.shields.io/badge/AppVersion-1.4.1-informational?style=flat-square)
44

55
Mirror images into your own registry and swap image references automatically.
66

@@ -39,6 +39,7 @@ Mirror images into your own registry and swap image references automatically.
3939
| image.repository | string | `"ghcr.io/estahn/k8s-image-swapper"` | |
4040
| image.tag | string | `""` | |
4141
| imagePullSecrets | list | `[]` | |
42+
| kubeVersionOverride | string | `""` | |
4243
| nameOverride | string | `""` | |
4344
| nodeSelector | object | `{}` | |
4445
| patch.enabled | bool | `true` | |

charts/k8s-image-swapper/templates/_helpers.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,21 @@ Create the name of the service account to use
7070
{{- default "default" .Values.serviceAccount.name }}
7171
{{- end }}
7272
{{- end }}
73+
74+
{{/*
75+
Return the appropriate apiVersion for pod disruption budget
76+
*/}}
77+
{{- define "k8s-image-swapper.podDisruptionBudget.apiVersion" -}}
78+
{{- if semverCompare "<1.21-0" (include "k8s-image-swapper.kubeVersion" $) -}}
79+
{{- print "policy/v1beta1" -}}
80+
{{- else -}}
81+
{{- print "policy/v1" -}}
82+
{{- end -}}
83+
{{- end -}}
84+
85+
{{/*
86+
Return the target Kubernetes version
87+
*/}}
88+
{{- define "k8s-image-swapper.kubeVersion" -}}
89+
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride }}
90+
{{- end -}}

charts/k8s-image-swapper/templates/pdb.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.pdb.enabled }}
2-
apiVersion: policy/v1beta1
2+
apiVersion: {{ template "k8s-image-swapper.podDisruptionBudget.apiVersion" . }}
33
kind: PodDisruptionBudget
44
metadata:
55
name: {{ include "k8s-image-swapper.fullname" . }}

charts/k8s-image-swapper/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ image:
1212

1313
containerPort: 8443
1414

15+
kubeVersionOverride: ""
16+
1517
imagePullSecrets: []
1618
nameOverride: ""
1719
fullnameOverride: ""

0 commit comments

Comments
 (0)