Skip to content

Commit

Permalink
Initial commit of amazon-eks-pod-identity-webhook (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Mar 31, 2022
1 parent 40f0f23 commit 5f72b9e
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
with:
version: v0.12.0
kubectl_version: v1.23.5

- name: Run chart-testing (install)
run: ct install --config charts/ct.yaml --excluded-charts keycloak-config-cli
run: ct install --debug --config charts/ct.yaml --excluded-charts amazon-eks-pod-identity-webhook,keycloak-config-cli
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
charts/*/charts/*.tgz
*.iml
23 changes: 23 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
10 changes: 10 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: amazon-eks-pod-identity-webhook
description: A Kubernetes webhook for pods that need AWS IAM access
version: 0.1.0
type: application
appVersion: "v0.4.0"
maintainers:
- name: jkroepke
email: [email protected]
url: https://github.com/jkroepke
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
pki:
certManager:
enabled: false

caBundle: |
-----BEGIN CERTIFICATE-----
MIID0TCCArmgAwIBAgIRAK7lo9vNaBdCxqZgWIBF6VwwDQYJKoZIhvcNAQELBQAw
NjE0MD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es: 73 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "amazon-eks-pod-identity-webhook.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "amazon-eks-pod-identity-webhook.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "amazon-eks-pod-identity-webhook.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "amazon-eks-pod-identity-webhook.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end }}

{{/*
Common labels
*/}}
{{- define "amazon-eks-pod-identity-webhook.labels" -}}
helm.sh/chart: {{ include "amazon-eks-pod-identity-webhook.chart" . }}
{{ include "amazon-eks-pod-identity-webhook.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "amazon-eks-pod-identity-webhook.selectorLabels" -}}
app.kubernetes.io/name: {{ include "amazon-eks-pod-identity-webhook.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "amazon-eks-pod-identity-webhook.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "amazon-eks-pod-identity-webhook.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/templates/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.pki.certManager.enabled }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
spec:
secretName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}-cert"
commonName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc"
dnsNames:
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}"
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}"
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc"
- "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}.{{ include "amazon-eks-pod-identity-webhook.namespace" . }}.svc.local"
duration: "{{ .Values.pki.certManager.certificate.duration }}"
renewBefore: "{{ .Values.pki.certManager.certificate.renewBefore }}"
issuerRef:
{{- if .Values.pki.certManager.existingIssuer.enabled }}
name: {{ .Values.pki.certManager.existingIssuer.name }}
kind: {{ .Values.pki.certManager.existingIssuer.kind }}
{{- else }}
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
kind: Issuer
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
labels:
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- watch
- list
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
labels:
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
89 changes: 89 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
labels:
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "amazon-eks-pod-identity-webhook.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "amazon-eks-pod-identity-webhook.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "amazon-eks-pod-identity-webhook.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /webhook
- --in-cluster=false
- --annotation-prefix={{ .Values.config.annotationPrefix }}
- --token-audience={{ .Values.config.tokenAudience }}
- --sts-regional-endpoint=true
- --port={{ .Values.config.ports.webhook }}
- --metrics-port={{ .Values.config.ports.metrics }}
- --aws-default-region={{ .Values.config.defaultAwsRegion }}
- --logtostderr
{{- if .Values.config.extraArgs }}
{{- toYaml .Values.config.extraArgs | nindent 12 }}
{{- end }}
volumeMounts:
- name: cert
mountPath: "/etc/webhook/certs"
readOnly: true
ports:
- name: https
containerPort: {{ .Values.config.ports.webhook }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.config.ports.metrics }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: cert
secret:
{{- if .Values.pki.existingSecret }}
secretName: {{ .Values.pki.existingSecret | quote }}
{{- else }}
secretName: "{{ include "amazon-eks-pod-identity-webhook.fullname" . }}-cert"
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/amazon-eks-pod-identity-webhook/templates/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
{{- if and .Values.pki.certManager.enabled (not .Values.pki.certManager.existingIssuer.enabled) }}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: {{ include "amazon-eks-pod-identity-webhook.fullname" . }}
namespace: {{ include "amazon-eks-pod-identity-webhook.namespace" . }}
labels:
{{- include "amazon-eks-pod-identity-webhook.labels" . | nindent 4 }}
spec:
selfSigned: {}
{{- end }}
Loading

0 comments on commit 5f72b9e

Please sign in to comment.