Skip to content

Commit

Permalink
fix: deprecated API usage for k8s 1.25+ (#126) (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm3brian authored Jul 21, 2023
1 parent 34a29ba commit bb9dc81
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions charts/k8s-image-swapper/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: k8s-image-swapper
description: Mirror images into your own registry and swap image references automatically.
type: application
version: 1.6.1
version: 1.6.2
appVersion: 1.4.1
home: https://github.com/estahn/charts/tree/main/charts/k8s-image-swapper
keywords:
Expand All @@ -15,7 +15,7 @@ maintainers:
name: estahn
annotations:
artifacthub.io/changes: |
- "Allow to set custom name for serviceAccount"
- "Fixes deprecated policy api usage for pdb"
artifacthub.io/images: |
- name: k8s-image-webhook
image: ghcr.io/estahn/k8s-image-swapper:1.4.1
3 changes: 2 additions & 1 deletion charts/k8s-image-swapper/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# k8s-image-swapper

![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)
![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)

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

Expand Down Expand Up @@ -39,6 +39,7 @@ Mirror images into your own registry and swap image references automatically.
| image.repository | string | `"ghcr.io/estahn/k8s-image-swapper"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| kubeVersionOverride | string | `""` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| patch.enabled | bool | `true` | |
Expand Down
18 changes: 18 additions & 0 deletions charts/k8s-image-swapper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,21 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Return the appropriate apiVersion for pod disruption budget
*/}}
{{- define "k8s-image-swapper.podDisruptionBudget.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "k8s-image-swapper.kubeVersion" $) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the target Kubernetes version
*/}}
{{- define "k8s-image-swapper.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/k8s-image-swapper/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.pdb.enabled }}
apiVersion: policy/v1beta1
apiVersion: {{ template "k8s-image-swapper.podDisruptionBudget.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "k8s-image-swapper.fullname" . }}
Expand Down
2 changes: 2 additions & 0 deletions charts/k8s-image-swapper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ image:

containerPort: 8443

kubeVersionOverride: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
Expand Down

0 comments on commit bb9dc81

Please # to comment.