Skip to content

Commit 7fdabf0

Browse files
authored
feat: allow test to be optional and specify image for test; fix HPA; increase app version to 1.5.10 (#138)
1 parent 72ba190 commit 7fdabf0

File tree

10 files changed

+78
-23
lines changed

10 files changed

+78
-23
lines changed

charts/k8s-image-swapper/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ 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.8.0
6-
appVersion: 1.4.1
5+
version: 1.9.0
6+
appVersion: 1.5.10
77
home: https://github.com/estahn/charts/tree/main/charts/k8s-image-swapper
88
keywords:
99
- kubernetes
@@ -15,7 +15,7 @@ maintainers:
1515
name: estahn
1616
annotations:
1717
artifacthub.io/changes: |
18-
- "Allow configure AWS secret and deploy extraManifests"
18+
- "Allow test to be optional and specify image for test; fix HPA"
1919
artifacthub.io/images: |
2020
- name: k8s-image-webhook
21-
image: ghcr.io/estahn/k8s-image-swapper:1.4.1
21+
image: ghcr.io/estahn/k8s-image-swapper:1.5.10

charts/k8s-image-swapper/README.md

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

3-
![Version: 1.8.0](https://img.shields.io/badge/Version-1.8.0-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.9.0](https://img.shields.io/badge/Version-1.9.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.10](https://img.shields.io/badge/AppVersion-1.5.10-informational?style=flat-square)
44

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

@@ -25,7 +25,9 @@ Mirror images into your own registry and swap image references automatically.
2525
| awsSecretKeys.accessKeyID | string | `"aws_access_key_id"` | If using Hashicorp Vault Operator w/ AWS engine, use `access_key` |
2626
| awsSecretKeys.secretAccessKey | string | `"aws_secret_access_key"` | If using Hashicorp Vault Operator w/ AWS engine, use `secret_key` |
2727
| awsSecretName | string | `""` | If set, the secret will be used as environment variables, see awsSecretKeys. |
28+
| cacheVolume | object | `{"emptyDir":{}}` | The type of volume to be used for caching images |
2829
| certmanager.enabled | bool | `false` | |
30+
| clusterSuffix | string | `"cluster.local"` | The DNS suffix of cluster addresses |
2931
| commonLabels | object | `{}` | Labels that will be added on all the resources (not in selectors) |
3032
| config.dryRun | bool | `true` | |
3133
| config.logFormat | string | `"console"` | |
@@ -73,6 +75,11 @@ Mirror images into your own registry and swap image references automatically.
7375
| serviceAccount.annotations | object | `{}` | |
7476
| serviceAccount.create | bool | `true` | |
7577
| serviceAccount.name | string | `""` | |
78+
| test.affinity | object | `{}` | Set affinity for the test pod |
79+
| test.enabled | bool | `true` | Should the test be included with the release |
80+
| test.image | string | `"busybox"` | The image to use for running the test |
81+
| test.nodeSelector | object | `{}` | Set a node selector for the test pod |
82+
| test.tolerations | list | `[]` | Set tolerations for the test pod |
7683
| tolerations | list | `[]` | |
7784
| webhook.failurePolicy | string | `"Ignore"` | |
7885
| webhook.namespaceSelector | object | `{}` | |

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ Create the name of the service account to use
7171
{{- end }}
7272
{{- end }}
7373

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-
8574
{{/*
8675
Return the target Kubernetes version
8776
*/}}

charts/k8s-image-swapper/templates/cert-manager-cert.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ metadata:
77
{{- include "k8s-image-swapper.labels" . | nindent 4 }}
88
spec:
99
secretName: {{ include "k8s-image-swapper.fullname" . }}-cert
10+
commonName: {{ printf "%s.%s.svc" (include "k8s-image-swapper.fullname" .) .Release.Namespace }}
1011
dnsNames:
11-
- {{ include "k8s-image-swapper.fullname" . }}.{{ .Release.Namespace }}.svc
12+
- {{ printf "%s.%s.svc.%s" (include "k8s-image-swapper.fullname" .) .Release.Namespace .Values.clusterSuffix }}
13+
- {{ printf "%s.%s.svc" (include "k8s-image-swapper.fullname" .) .Release.Namespace }}
14+
- {{ printf "%s.%s" (include "k8s-image-swapper.fullname" .) .Release.Namespace }}
15+
- {{ include "k8s-image-swapper.fullname" . }}
1216
issuerRef:
1317
name: {{ include "k8s-image-swapper.fullname" . }}-issuer
1418
{{- end -}}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ spec:
9090
subPath: config.yaml
9191
mountPath: /.k8s-image-swapper.yaml
9292
readOnly: true
93+
- mountPath: /tmp
94+
name: tmp
9395
{{- if or .Values.patch.enabled .Values.certmanager.enabled }}
9496
- name: webhook-cert
9597
mountPath: "/usr/local/certificates/"
@@ -99,6 +101,8 @@ spec:
99101
- name: {{ include "k8s-image-swapper.fullname" . }}
100102
configMap:
101103
name: {{ include "k8s-image-swapper.fullname" . }}
104+
- name: tmp
105+
{{- toYaml .Values.cacheVolume | nindent 10 }}
102106
{{- if .Values.patch.enabled }}
103107
- name: webhook-cert
104108
secret:

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.autoscaling.enabled }}
2-
apiVersion: autoscaling/v2beta1
2+
apiVersion: {{ .Capabilities.APIVersions.Has "autoscaling/v2" | ternary "autoscaling/v2" "autoscaling/v2beta2" }}
33
kind: HorizontalPodAutoscaler
44
metadata:
55
name: {{ include "k8s-image-swapper.fullname" . }}
@@ -17,12 +17,16 @@ spec:
1717
- type: Resource
1818
resource:
1919
name: cpu
20-
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
2123
{{- end }}
2224
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
2325
- type: Resource
2426
resource:
2527
name: memory
26-
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
2731
{{- end }}
2832
{{- 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: {{ template "k8s-image-swapper.podDisruptionBudget.apiVersion" . }}
2+
apiVersion: {{ .Capabilities.APIVersions.Has "policy/v1" | ternary "policy/v1" "policy/v1beta1" }}
33
kind: PodDisruptionBudget
44
metadata:
55
name: {{ include "k8s-image-swapper.fullname" . }}

charts/k8s-image-swapper/templates/tests/test-connection.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.test.enabled }}
12
apiVersion: v1
23
kind: Pod
34
metadata:
@@ -9,7 +10,23 @@ metadata:
910
spec:
1011
containers:
1112
- name: wget
12-
image: busybox
13+
image: {{ .Values.test.image }}
1314
command: ['wget']
14-
args: ['{{ include "k8s-image-swapper.fullname" . }}:{{ .Values.service.port }}']
15+
args:
16+
- --no-check-certificate
17+
- -O-
18+
- 'https://{{ include "k8s-image-swapper.fullname" . }}:{{ .Values.service.port }}'
1519
restartPolicy: Never
20+
{{- with .Values.test.nodeSelector }}
21+
nodeSelector:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
{{- with .Values.test.affinity }}
25+
affinity:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
{{- with .Values.test.tolerations }}
29+
tolerations:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
{{- end }}

charts/k8s-image-swapper/values.schema.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,17 @@
295295
}
296296
}
297297
},
298+
"test": {
299+
"type": "object",
300+
"properties": {
301+
"enabled": {
302+
"type": "boolean"
303+
},
304+
"image": {
305+
"type": "string"
306+
}
307+
}
308+
},
298309
"tolerations": {
299310
"type": "array",
300311
"items": {}

charts/k8s-image-swapper/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,22 @@ extraManifestsTemplated: []
171171
# name: "{{ .Release.Name }}-extra-config"
172172
# data:
173173
# key: value
174+
175+
# -- The DNS suffix of cluster addresses
176+
clusterSuffix: cluster.local
177+
178+
test:
179+
# -- Should the test be included with the release
180+
enabled: true
181+
# -- Set affinity for the test pod
182+
affinity: {}
183+
# -- The image to use for running the test
184+
image: busybox
185+
# -- Set a node selector for the test pod
186+
nodeSelector: {}
187+
# -- Set tolerations for the test pod
188+
tolerations: []
189+
190+
# -- The type of volume to be used for caching images
191+
cacheVolume:
192+
emptyDir: {}

0 commit comments

Comments
 (0)