diff options
| author | James Munnelly <munnerz@users.noreply.github.com> | 2019-04-29 18:48:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-29 18:48:04 +0100 |
| commit | f06ad32f094c0d8e4fe1801d0775771b5de19009 (patch) | |
| tree | 8638b1e79253b8fbca0623e4f6586b9e8bff1187 /deploy | |
| parent | 3935fd70e743931e6322bf088cd3e1c866f2e2cd (diff) | |
| parent | a598b0e12668be45d7346f761b0b00432e40fa11 (diff) | |
| download | cert-manager-webhook-hostinger-f06ad32f094c0d8e4fe1801d0775771b5de19009.tar.gz cert-manager-webhook-hostinger-f06ad32f094c0d8e4fe1801d0775771b5de19009.zip | |
Merge pull request #1 from munnerz/deployment-updates
Build and deployment fixes
Diffstat (limited to 'deploy')
| -rw-r--r-- | deploy/example-webhook/templates/NOTES.txt | 19 | ||||
| -rw-r--r-- | deploy/example-webhook/templates/_helpers.tpl | 16 | ||||
| -rw-r--r-- | deploy/example-webhook/templates/apiservice.yaml | 3 | ||||
| -rw-r--r-- | deploy/example-webhook/templates/deployment.yaml | 11 | ||||
| -rw-r--r-- | deploy/example-webhook/templates/pki.yaml | 76 | ||||
| -rw-r--r-- | deploy/example-webhook/values.yaml | 15 |
6 files changed, 106 insertions, 34 deletions
diff --git a/deploy/example-webhook/templates/NOTES.txt b/deploy/example-webhook/templates/NOTES.txt index 197e374..e69de29 100644 --- a/deploy/example-webhook/templates/NOTES.txt +++ b/deploy/example-webhook/templates/NOTES.txt @@ -1,19 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "example-webhook.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ include "example-webhook.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "example-webhook.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ include "example-webhook.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/deploy/example-webhook/templates/_helpers.tpl b/deploy/example-webhook/templates/_helpers.tpl index db3c5cd..d3c474b 100644 --- a/deploy/example-webhook/templates/_helpers.tpl +++ b/deploy/example-webhook/templates/_helpers.tpl @@ -30,3 +30,19 @@ Create chart name and version as used by the chart label. {{- define "example-webhook.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{- define "example-webhook.selfSignedIssuer" -}} +{{ printf "%s-selfsign" (include "example-webhook.fullname" .) }} +{{- end -}} + +{{- define "example-webhook.rootCAIssuer" -}} +{{ printf "%s-ca" (include "example-webhook.fullname" .) }} +{{- end -}} + +{{- define "example-webhook.rootCACertificate" -}} +{{ printf "%s-ca" (include "example-webhook.fullname" .) }} +{{- end -}} + +{{- define "example-webhook.servingCertificate" -}} +{{ printf "%s-webhook-tls" (include "example-webhook.fullname" .) }} +{{- end -}} diff --git a/deploy/example-webhook/templates/apiservice.yaml b/deploy/example-webhook/templates/apiservice.yaml index ddd7c75..504ab91 100644 --- a/deploy/example-webhook/templates/apiservice.yaml +++ b/deploy/example-webhook/templates/apiservice.yaml @@ -7,11 +7,12 @@ metadata: chart: {{ include "example-webhook.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + annotations: + certmanager.k8s.io/inject-ca-from: "{{ .Release.Namespace }}/{{ include "example-webhook.servingCertificate" . }}" spec: group: {{ .Values.groupName }} groupPriorityMinimum: 1000 versionPriority: 15 - insecureSkipTLSVerify: true service: name: {{ include "example-webhook.fullname" . }} namespace: {{ .Release.Namespace }} diff --git a/deploy/example-webhook/templates/deployment.yaml b/deploy/example-webhook/templates/deployment.yaml index fc0acbd..23e9064 100644 --- a/deploy/example-webhook/templates/deployment.yaml +++ b/deploy/example-webhook/templates/deployment.yaml @@ -24,6 +24,9 @@ spec: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --tls-cert-file=/tls/tls.crt + - --tls-private-key-file=/tls/tls.key env: - name: GROUP_NAME value: {{ .Values.groupName | quote }} @@ -41,8 +44,16 @@ spec: scheme: HTTPS path: /healthz port: https + volumeMounts: + - name: certs + mountPath: /tls + readOnly: true resources: {{ toYaml .Values.resources | indent 12 }} + volumes: + - name: certs + secret: + secretName: {{ include "example-webhook.servingCertificate" . }} {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | indent 8 }} diff --git a/deploy/example-webhook/templates/pki.yaml b/deploy/example-webhook/templates/pki.yaml new file mode 100644 index 0000000..89b6a23 --- /dev/null +++ b/deploy/example-webhook/templates/pki.yaml @@ -0,0 +1,76 @@ +--- +# Create a selfsigned Issuer, in order to create a root CA certificate for +# signing webhook serving certificates +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Issuer +metadata: + name: {{ include "example-webhook.selfSignedIssuer" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + app: {{ include "example-webhook.name" . }} + chart: {{ include "example-webhook.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selfSigned: {} + +--- + +# Generate a CA Certificate used to sign certificates for the webhook +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Certificate +metadata: + name: {{ include "example-webhook.rootCACertificate" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + app: {{ include "example-webhook.name" . }} + chart: {{ include "example-webhook.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + secretName: {{ include "example-webhook.rootCACertificate" . }} + duration: 43800h # 5y + issuerRef: + name: {{ include "example-webhook.selfSignedIssuer" . }} + commonName: "ca.example-webhook.cert-manager" + isCA: true + +--- + +# Create an Issuer that uses the above generated CA certificate to issue certs +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Issuer +metadata: + name: {{ include "example-webhook.rootCAIssuer" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + app: {{ include "example-webhook.name" . }} + chart: {{ include "example-webhook.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + ca: + secretName: {{ include "example-webhook.rootCACertificate" . }} + +--- + +# Finally, generate a serving certificate for the webhook to use +apiVersion: certmanager.k8s.io/v1alpha1 +kind: Certificate +metadata: + name: {{ include "example-webhook.servingCertificate" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + app: {{ include "example-webhook.name" . }} + chart: {{ include "example-webhook.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + secretName: {{ include "example-webhook.servingCertificate" . }} + duration: 8760h # 1y + issuerRef: + name: {{ include "example-webhook.rootCAIssuer" . }} + dnsNames: + - {{ include "example-webhook.fullname" . }} + - {{ include "example-webhook.fullname" . }}.{{ .Release.Namespace }} + - {{ include "example-webhook.fullname" . }}.{{ .Release.Namespace }}.svc diff --git a/deploy/example-webhook/values.yaml b/deploy/example-webhook/values.yaml index da3f9eb..31eb151 100644 --- a/deploy/example-webhook/values.yaml +++ b/deploy/example-webhook/values.yaml @@ -14,7 +14,7 @@ certManager: image: repository: mycompany/webhook-image - tag: stable + tag: latest pullPolicy: IfNotPresent nameOverride: "" @@ -24,19 +24,6 @@ service: type: ClusterIP port: 443 -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little |
