Skip to content

Commit 37ec991

Browse files
authored
chore: non embedding certs for kubeconfig file generation (#238)
1 parent 36124d2 commit 37ec991

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ bin
2424
*~
2525

2626
**/*.kubeconfig
27+
**/*.crt
28+
**/*.key
2729
.DS_Store
2830

hack/create-user.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ GROUP=capsule.clastix.io
3737
TMPDIR=$(mktemp -d)
3838
echo "creating certs in TMPDIR ${TMPDIR} "
3939

40-
openssl genrsa -out ${TMPDIR}/tls.key 2048
41-
openssl req -new -key ${TMPDIR}/tls.key -subj "/CN=${USER}/O=${GROUP}" -out ${TMPDIR}/${USER}-${TENANT}.csr
40+
openssl genrsa -out ${USER}-${TENANT}.key 2048
41+
openssl req -new -key ${USER}-${TENANT}.key -subj "/CN=${USER}/O=${GROUP}" -out ${TMPDIR}/${USER}-${TENANT}.csr
4242

4343
# Clean any previously created CSR for the same user.
4444
kubectl delete csr ${USER}-${TENANT} 2>/dev/null || true
@@ -64,7 +64,7 @@ kubectl apply -f ${TMPDIR}/${USER}-${TENANT}-csr.yaml
6464

6565
# Approve and fetch the signed certificate
6666
kubectl certificate approve ${USER}-${TENANT}
67-
kubectl get csr ${USER}-${TENANT} -o jsonpath='{.status.certificate}' | base64 --decode > ${TMPDIR}/tls.crt
67+
kubectl get csr ${USER}-${TENANT} -o jsonpath='{.status.certificate}' | base64 --decode > ${USER}-${TENANT}.crt
6868

6969
# Create the kubeconfig file
7070
CONTEXT=$(kubectl config current-context)
@@ -90,8 +90,8 @@ preferences: {}
9090
users:
9191
- name: ${USER}
9292
user:
93-
client-certificate-data: $(cat ${TMPDIR}/tls.crt | base64 | tr -d '\n')
94-
client-key-data: $(cat ${TMPDIR}/tls.key | base64 | tr -d '\n')
93+
client-certificate: ${USER}-${TENANT}.crt
94+
client-key: ${USER}-${TENANT}.key
9595
EOF
9696

9797
echo "kubeconfig file is:" ${USER}-${TENANT}.kubeconfig

0 commit comments

Comments
 (0)