Skip to content

Commit 6be29be

Browse files
authored
Modernize chart (#66)
1 parent 7cc8b24 commit 6be29be

File tree

10 files changed

+116
-59
lines changed

10 files changed

+116
-59
lines changed

charts/amazon-eks-pod-identity-webhook/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: amazon-eks-pod-identity-webhook
33
description: A Kubernetes webhook for pods that need AWS IAM access
4-
version: 2.3.2
4+
version: 2.4.0
55
type: application
66
# renovate: image=amazon/amazon-eks-pod-identity-webhook
77
appVersion: "v0.6.1"

charts/amazon-eks-pod-identity-webhook/templates/_helpers.tpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ helm.sh/chart: {{ include "amazon-eks-pod-identity-webhook.chart" . }}
5050
{{- if .Chart.AppVersion }}
5151
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
5252
{{- end }}
53-
app.kubernetes.io/managed-by: {{ .Release.Service }}
5453
{{- end }}
5554

5655
{{/*
@@ -72,8 +71,8 @@ Create the name of the service account to use
7271
{{- end }}
7372
{{- end }}
7473

75-
{{/*
76-
Get PodDisruptionBudget API Version
74+
{{/*
75+
Get PodDisruptionBudget API Version
7776
*/}}
7877
{{- define "amazon-eks-pod-identity-webhook.pdb.apiVersion" -}}
7978
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
{{- if .Values.pki.certManager.enabled }}
2+
{{- $fullName := include "amazon-eks-pod-identity-webhook.fullname" . }}
23
apiVersion: cert-manager.io/v1
34
kind: Certificate
45
metadata:
5-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
6+
name: {{ $fullName }}
67
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
78
spec:
8-
secretName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}-cert"
9-
commonName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}"
9+
secretName: "{{ $fullName }}-cert"
10+
commonName: "{{ $fullName }}"
1011
dnsNames:
11-
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}"
12-
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}"
13-
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc"
14-
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc.local"
12+
- "{{ $fullName }}"
13+
- "{{ $fullName }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}"
14+
- "{{ $fullName }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc"
15+
- "{{ $fullName }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc.local"
1516
duration: "{{ .Values.pki.certManager.certificate.duration }}"
1617
renewBefore: "{{ .Values.pki.certManager.certificate.renewBefore }}"
1718
issuerRef:
1819
{{- if .Values.pki.certManager.existingIssuer.enabled }}
1920
name: {{ .Values.pki.certManager.existingIssuer.name }}
2021
kind: {{ .Values.pki.certManager.existingIssuer.kind }}
2122
{{- else }}
22-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
23+
name: {{ $fullName }}
2324
kind: Issuer
2425
{{- end }}
2526
{{- end }}

charts/amazon-eks-pod-identity-webhook/templates/clusterrole.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ rules:
1414
- get
1515
- watch
1616
- list
17+
- apiGroups:
18+
- certificates.k8s.io
19+
resources:
20+
- certificatesigningrequests
21+
verbs:
22+
- create
23+
- get
24+
- list
25+
- watch

charts/amazon-eks-pod-identity-webhook/templates/deployment.yaml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ spec:
3131
imagePullSecrets:
3232
{{- toYaml . | nindent 8 }}
3333
{{- end }}
34-
{{- if .Values.priorityClassName }}
35-
priorityClassName: "{{ .Values.priorityClassName }}"
34+
{{- with .Values.priorityClassName }}
35+
priorityClassName: {{ . | quote }}
3636
{{- end }}
3737
containers:
3838
- name: {{ .Chart.Name }}
39-
securityContext:
40-
{{- toYaml .Values.securityContext | nindent 12 }}
4139
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4240
imagePullPolicy: {{ .Values.image.pullPolicy }}
4341
command:
@@ -46,9 +44,10 @@ spec:
4644
- --aws-default-region={{ .Values.config.defaultAwsRegion }}
4745
- --in-cluster=false
4846
- --logtostderr
49-
- --namespace={{ include "amazon-eks-pod-identity-webhook.namespace" . }}
47+
- --namespace=$(POD_NAMESPACE)
5048
- --metrics-port={{ .Values.config.ports.metrics }}
5149
- --port={{ .Values.config.ports.webhook }}
50+
- --service-name={{ include "amazon-eks-pod-identity-webhook.fullname" . }}
5251
- --sts-regional-endpoint={{ .Values.config.stsRegionalEndpoint }}
5352
- --token-audience={{ .Values.config.tokenAudience }}
5453
- --token-expiration={{ .Values.config.tokenExpiration }}
@@ -61,27 +60,56 @@ spec:
6160
{{- if .Values.config.extraArgs }}
6261
{{- toYaml .Values.config.extraArgs | nindent 12 }}
6362
{{- end }}
64-
volumeMounts:
65-
- name: cert
66-
mountPath: "/etc/webhook/certs"
67-
readOnly: true
6863
ports:
6964
- name: https
7065
containerPort: {{ .Values.config.ports.webhook }}
7166
protocol: TCP
7267
- name: metrics
7368
containerPort: {{ .Values.config.ports.metrics }}
7469
protocol: TCP
70+
env:
71+
- name: POD_NAMESPACE
72+
valueFrom:
73+
fieldRef:
74+
fieldPath: metadata.namespace
75+
{{- with .Values.livenessProbe }}
7576
livenessProbe:
76-
{{- toYaml .Values.livenessProbe | nindent 12 }}
77+
{{- toYaml . | nindent 12 }}
78+
{{- end }}
79+
{{- with .Values.readinessProbe }}
7780
readinessProbe:
78-
{{- toYaml .Values.readinessProbe | nindent 12 }}
81+
{{- toYaml . | nindent 12 }}
82+
{{- end }}
83+
{{- with .Values.resources }}
7984
resources:
80-
{{- toYaml .Values.resources | nindent 12 }}
85+
{{- toYaml . | nindent 12 }}
86+
{{- end }}
87+
{{- with .Values.securityContext }}
88+
securityContext:
89+
{{- toYaml . | nindent 12 }}
90+
{{- end }}
91+
volumeMounts:
92+
- name: cert
93+
mountPath: "/etc/webhook/certs"
94+
readOnly: true
8195
hostNetwork: {{ .Values.hostNetwork }}
8296
serviceAccountName: {{ include "amazon-eks-pod-identity-webhook.serviceAccountName" . }}
97+
{{- with .Values.podSecurityContext }}
8398
securityContext:
84-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
99+
{{- toYaml . | nindent 8 }}
100+
{{- end }}
101+
{{- with .Values.nodeSelector }}
102+
nodeSelector:
103+
{{- tpl (toYaml .) $ | nindent 8 }}
104+
{{- end }}
105+
{{- with .Values.affinity }}
106+
affinity:
107+
{{- tpl (toYaml .) $ | nindent 8 }}
108+
{{- end }}
109+
{{- with .Values.tolerations }}
110+
tolerations:
111+
{{- tpl (toYaml .) $ | nindent 8 }}
112+
{{- end }}
85113
volumes:
86114
- name: cert
87115
secret:
@@ -90,15 +118,3 @@ spec:
90118
{{- else }}
91119
secretName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}-cert"
92120
{{- end }}
93-
{{- if .Values.nodeSelector }}
94-
nodeSelector:
95-
{{- tpl (toYaml .Values.nodeSelector) . | nindent 8 }}
96-
{{- end }}
97-
{{- if .Values.affinity }}
98-
affinity:
99-
{{- tpl (toYaml .Values.affinity ) . | nindent 8 }}
100-
{{- end }}
101-
{{- if .Values.tolerations }}
102-
tolerations:
103-
{{- tpl (toYaml .Values.tolerations) . | nindent 8 }}
104-
{{- end }}

charts/amazon-eks-pod-identity-webhook/templates/mutatingwebhook.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ webhooks:
3333
{{- end }}
3434
objectSelector:
3535
matchExpressions:
36+
- key: "eks.amazonaws.com/skip-pod-identity-webhook"
37+
operator: "DoesNotExist"
38+
values: []
3639
- key: "app.kubernetes.io/name"
3740
operator: "NotIn"
3841
values:
3942
- "{{ include "amazon-eks-pod-identity-webhook.name" . }}"
40-
{{- if .Values.mutatingWebhook.objectSelector.matchExpressions }}
41-
{{- toYaml .Values.mutatingWebhook.objectSelector.matchExpressions | nindent 8 }}
43+
{{- with .Values.mutatingWebhook.objectSelector.matchExpressions }}
44+
{{- toYaml . | nindent 8 }}
4245
{{- end }}
43-
{{- if .Values.mutatingWebhook.objectSelector.matchLabels }}
44-
matchLabels: {{- toYaml .Values.mutatingWebhook.objectSelector.matchLabels | nindent 8 }}
46+
{{- with .Values.mutatingWebhook.objectSelector.matchLabels }}
47+
matchLabels: {{- toYaml . | nindent 8 }}
4548
{{- end }}
4649
sideEffects: None
4750
admissionReviewVersions:
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
---
22
{{- if .Values.config.podIdentityWebhookMap.enabled }}
3+
{{- $fullName := include "amazon-eks-pod-identity-webhook.fullname" . }}
34
apiVersion: rbac.authorization.k8s.io/v1
45
kind: Role
56
metadata:
6-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
7+
name: {{ $fullName }}
78
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
89
labels:
910
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
1011
rules:
1112
- apiGroups:
1213
- ""
1314
resources:
14-
- configmaps
15+
- secrets
16+
verbs:
17+
- create
18+
- apiGroups:
19+
- ""
20+
resources:
21+
- secrets
1522
verbs:
1623
- get
17-
- watch
18-
- list
24+
- update
25+
- patch
26+
resourceNames:
27+
{{- /* This is the service account name, ref: https://github.com/aws/amazon-eks-pod-identity-webhook/blob/ac3554488585c1a35bea552f771ef3bd4e6e0ddd/pkg/handler/handler.go#L436 */}}
28+
- "{{ include "amazon-eks-pod-identity-webhook.serviceAccountName" . }}"
1929
---
2030
apiVersion: rbac.authorization.k8s.io/v1
2131
kind: RoleBinding
2232
metadata:
23-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
33+
name: {{ $fullName }}
2434
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
2535
labels:
2636
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
2737
roleRef:
2838
apiGroup: rbac.authorization.k8s.io
2939
kind: Role
30-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
40+
name: {{ $fullName }}
3141
subjects:
3242
- kind: ServiceAccount
33-
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
43+
name: {{ $fullName }}
3444
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
3545
{{- end }}

charts/amazon-eks-pod-identity-webhook/templates/service.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ metadata:
66
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
77
labels:
88
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
9-
{{- with .Values.serviceAnnotations }}
9+
{{- with .Values.service.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- with .Values.service.annotations }}
1013
annotations:
1114
{{- toYaml . | nindent 4 }}
1215
{{- end }}
@@ -16,9 +19,11 @@ spec:
1619
- port: {{ .Values.config.ports.webhook }}
1720
targetPort: https
1821
protocol: TCP
22+
appProtocol: https
1923
name: https
2024
- port: {{ .Values.config.ports.metrics }}
2125
targetPort: metrics
26+
appProtocol: http
2227
protocol: TCP
2328
name: metrics
2429
selector:

charts/amazon-eks-pod-identity-webhook/templates/servicemonitor.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ spec:
3030
{{- if .Values.metrics.serviceMonitor.honorLabels }}
3131
honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
3232
{{- end }}
33-
{{- if .Values.metrics.serviceMonitor.relabelings }}
34-
relabelings: {{- toYaml .Values.metrics.serviceMonitor.relabelings | nindent 6 }}
33+
{{- with .Values.metrics.serviceMonitor.relabelings }}
34+
relabelings: {{- toYaml . | nindent 6 }}
35+
{{- end }}
36+
{{- with .Values.metrics.serviceMonitor.endpointAdditionalProperties }}
37+
{{- toYaml . | nindent 6 }}
3538
{{- end }}
3639
{{- end -}}

charts/amazon-eks-pod-identity-webhook/values.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ metrics:
133133
honorLabels: false
134134
# -- RelabelConfigs to apply to samples before scraping.
135135
relabelings: []
136+
# -- More properties for the endpoint configuration of the service monitor.
137+
endpointAdditionalProperties: {}
136138

137139
readinessProbe:
138140
httpGet:
@@ -169,20 +171,33 @@ resources:
169171
requests: {}
170172

171173
securityContext:
172-
# -- Pod securityContext: Enable read-only root filesystem
174+
# -- Container securityContext: Allow privilege escalation
175+
allowPrivilegeEscalation: false
176+
# -- Container securityContext: Enable read-only root filesystem
173177
readOnlyRootFilesystem: true
174-
# -- Pod securityContext: Run primary group id
178+
# -- Container securityContext: Run primary group id
175179
runAsGroup: 1
176-
# -- Pod securityContext: Disable root user
180+
# -- Container securityContext: Disable root user
177181
runAsNonRoot: false
178-
# -- Pod securityContext: Run user id
182+
# -- Container securityContext: Run user id
179183
runAsUser: 65534
184+
# -- Container securityContext: Drop capabilities
185+
capabilities:
186+
drop: ["ALL"]
187+
188+
189+
podSecurityContext:
190+
# -- Pod securityContext: Seccomp profile
191+
seccompProfile:
192+
type: RuntimeDefault
180193

181194
service:
182195
# -- Service type
183196
type: ClusterIP
184197
# -- Service annotations
185198
annotations: {}
199+
# -- Service labels.
200+
labels: {}
186201

187202
serviceAccount:
188203
# -- Enable creation of ServiceAccount for nginx pod
@@ -202,10 +217,6 @@ podAnnotations: {}
202217
# prometheus.io/scheme: "http"
203218
# prometheus.io/scrape: "true"
204219

205-
# -- amazon-eks-pod-identity-webhook pods' Security Context.
206-
podSecurityContext: {}
207-
# fsGroup: 2000
208-
209220
# -- Affinity for pod assignment
210221
affinity: {}
211222

0 commit comments

Comments
 (0)