-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-smallstep.sh
executable file
·51 lines (38 loc) · 1.57 KB
/
install-smallstep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -eo pipefail
# Automates wildcard ClusterIssuer, Certificate and Secret generation on a K8s cluster where cert-manager is already installed.
if [ -z "$1" ]; then
echo "Usage: install-smallstep.sh {domain}"
exit 1
fi
DOMAIN="$1"
## Create namespace where cert and tls secret will reside
kubectl create namespace contour-tls --dry-run=client -o yaml | kubectl apply -f -
## Install step-certificates and step-issuer Helm charts
helm repo add smallstep https://smallstep.github.io/helm-charts
helm repo update
helm install step-certificates smallstep/step-certificates --namespace small-step --create-namespace --wait
helm install step-issuer smallstep/step-issuer --namespace small-step --create-namespace --wait
## Get step-certificates root certificate
ROOT_CERT=$(kubectl get -o jsonpath="{.data['root_ca\.crt']}" configmaps/step-certificates-certs -n small-step | base64 -w 0)
## Get the step-certificate provisioner information
KID=$(kubectl get -o jsonpath="{.data['ca\.json']}" configmaps/step-certificates-config -n small-step | jq .authority.provisioners | jq '.[0].key.kid' | tr -d '"')
## Create StepClusterIssuer
cat > step-cluster-issuer.yaml <<EOF
---
apiVersion: certmanager.step.sm/v1beta1
kind: StepClusterIssuer
metadata:
name: step-cluster-issuer
spec:
url: https://step-certificates.small-step.svc.cluster.local
caBundle: ${ROOT_CERT}
provisioner:
name: admin
kid: ${KID}
passwordRef:
namespace: small-step
name: step-certificates-provisioner-password
key: password
EOF
kubectl apply -f step-cluster-issuer.yaml