-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-cert.sh
43 lines (34 loc) · 1010 Bytes
/
create-cert.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
#!/bin/zsh
mkdir -p target/cert
cp csr.json target/cert
pushd target/cert
# Create private key and CSR
cfssl genkey csr.json | cfssljson -bare tenancy-fixer
# Create CSR k8s object
cat <<EOF | kubectl create -f -
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
name: tenancy-fixer
spec:
groups:
- system:authenticated
request: $(cat tenancy-fixer.csr | base64 | tr -d '\n')
usages:
- digital signature
- key encipherment
- server auth
EOF
# Approve certificate
kubectl certificate approve tenancy-fixer
sleep 5s
# Download public key
kubectl get csr tenancy-fixer -o jsonpath='{.status.certificate}' | base64 --decode > tenancy-fixer.crt
cp tenancy-fixer-key.pem tls.key
cp tenancy-fixer.crt tls.crt
kubectl create secret tls tenancy-fixer-tls -n kubeflow-extension --key ./tls.key --cert ./tls.crt
# Display public key content
openssl x509 -in tls.crt -text
#Propriétaire : CN=tenancy-fixer.kubeflow-extension.svc
#Emetteur : CN=kubernetes
popd