Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cert-manager-setup chart, make dex + traefik use cert-manager issued certificates #123

Merged
merged 14 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/dex/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: dex
version: 1.5.4
version: 1.6.0
appVersion: 2.17.0
description: CoreOS Dex
keywords:
Expand Down
19 changes: 19 additions & 0 deletions stable/dex/templates/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: dex
namespace: kubeaddons
timaa2k marked this conversation as resolved.
Show resolved Hide resolved
annotations:
"helm.sh/hook": pre-install
spec:
secretName: dex

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable too

issuerRef:
name: kubernetes-ca
kind: ClusterIssuer
commonName: dex
organization:
- Mesosphere
timaa2k marked this conversation as resolved.
Show resolved Hide resolved
dnsNames:
- dex-kubeaddons

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable, let's add it to values.yaml

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- dex-kubeaddons.kubeaddons
- dex-kubeaddons.kubeaddons.svc.cluster.local
22 changes: 22 additions & 0 deletions staging/cert-manager-setup/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
17 changes: 17 additions & 0 deletions staging/cert-manager-setup/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
name: cert-manager-setup
home: https://github.com/mesosphere/charts
version: 0.1.0
appVersion: 0.10.0
description: Install cert-manager and optionally add a ClusterIssuer
keywords:
- cert-manager
- issuer
- clusterissuer
sources:
- https://github.com/jetstack/cert-manager
- https://github.com/jetstack/cert-manager/tree/master/deploy/charts/cert-manager
maintainers:
- name: timaa2k
email: tweidner@d2iq.com
engine: gotpl
27 changes: 27 additions & 0 deletions staging/cert-manager-setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cert-manager-setup

cert-manager-setup installs [cert-manager](https://github.com/jetstack/cert-manager/blob/master/deploy/charts/cert-manager/README.md) which is a Kubernetes addon to automate the management and issuance of
TLS certificates from various issuing sources.

`cert-manager` will ensure certificates are valid and up to date periodically, and attempt
to renew certificates at an appropriate time before expiry.

`cert-manager-setup` deploys the cert-manager

In addition to installing `cert-manager`, `cert-manager-setup` provides the capability to specify a `ClusterIssuer` in the `values.yaml` file which will be applied directly after the `cert-manager` installation has completed. In order for this to happen, `cert-manager-setup` sets up an `Issuer` in the `cert-manager` namespace. It then creates an intermediate certificate from the secret `kubernetes-root-ca` which must already contain ideally the Kubernetes root CA. The `ClusterIssuer` then uses the intermediate certificate derived from the Kubernetes root CA.

# Supported values format

```yaml
clusterissuer:
name: clusterissuer-name
spec:
ca:
secretName: clusterissuer-secret
```

In the given example we create a `ClusterIssuer` named `clusterissuer-name` with the `ca` type. The `ca` type expects a secret that contains the Certificate Authority (CA) to be used by this `ClusterIssuer`. The spec follows the original `cert-manager` [spec](https://docs.cert-manager.io/en/latest/tasks/issuers/setup-ca.html#creating-an-issuer-referencing-the-secret).

# Notes

In order to submit the `ClusterIssuer` post installation, `cert-manager-setup` runs a post-install `Job` hook. In case that the hook fails the Job will not be cleaned up by Helm. This behavior is intended to ease debugging.
Binary file not shown.
6 changes: 6 additions & 0 deletions staging/cert-manager-setup/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: v0.10.0
digest: sha256:28e79a359d2563500962b1791ffb542092daf6a6ee73e58b9681d21b9955974e
generated: "2019-09-13T12:14:07.505937281+02:00"
4 changes: 4 additions & 0 deletions staging/cert-manager-setup/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
- name: cert-manager
version: 0.10.0
repository: https://charts.jetstack.io
1 change: 1 addition & 0 deletions staging/cert-manager-setup/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deploys cert-manager and submits the kubernetes-ca ClusterIssuer post installation.
45 changes: 45 additions & 0 deletions staging/cert-manager-setup/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cert-manager-setup.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 "cert-manager-setup.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 "cert-manager-setup.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "cert-manager-setup.labels" -}}
app.kubernetes.io/name: {{ include "cert-manager-setup.name" . }}
helm.sh/chart: {{ include "cert-manager-setup.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
8 changes: 8 additions & 0 deletions staging/cert-manager-setup/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: read-apiservices
rules:
- apiGroups: ["apiregistration.k8s.io"]
resources: ["apiservices"]
verbs: ["get", "watch", "list"]
13 changes: 13 additions & 0 deletions staging/cert-manager-setup/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-apiservices-rolebinding
namespace: cert-manager
timaa2k marked this conversation as resolved.
Show resolved Hide resolved
subjects:
- kind: ServiceAccount
namespace: cert-manager
timaa2k marked this conversation as resolved.
Show resolved Hide resolved
name: default
roleRef:
kind: ClusterRole
name: read-apiservices
apiGroup: rbac.authorization.k8s.io
Loading