@@ -26,6 +26,8 @@ export SSL_IP=${SSL_IP}
26
26
export K8S_NAME=${K8S_NAME:- " omgwtfssl" }
27
27
export K8S_NAMESPACE=${K8S_NAMESPACE:- " default" }
28
28
export K8S_SAVE_CA_KEY=${K8S_SAVE_CA_KEY}
29
+ export K8S_SAVE_CA_CRT=${K8S_SAVE_CA_CRT}
30
+ export K8S_SHOW_SECRET=${K8S_SHOW_SECRET}
29
31
30
32
export OUTPUT=${OUTPUT:- " yaml" }
31
33
@@ -88,15 +90,8 @@ openssl req -new -key ${SSL_KEY} -out ${SSL_CSR} -subj "/CN=${SSL_SUBJECT}" -con
88
90
openssl x509 -req -in ${SSL_CSR} -CA ${CA_CERT} -CAkey ${CA_KEY} -CAcreateserial -out ${SSL_CERT} \
89
91
-days ${SSL_EXPIRE} -extensions v3_req -extfile ${SSL_CONFIG} > /dev/null || exit 1
90
92
91
- if [[ -z $SILENT ]]; then
92
- echo " ====> Complete"
93
- echo " keys can be found in volume mapped to $( pwd) "
94
- echo
95
-
96
- if [[ ${OUTPUT} == " k8s" ]]; then
97
- echo " ====> Output results as base64 k8s secrets"
98
- echo " ---"
99
- cat << EOM | tee /certs/secret.yaml
93
+ # create k8s secret file
94
+ cat << EOM > /certs/secret.yaml
100
95
apiVersion: v1
101
96
kind: Secret
102
97
metadata:
@@ -106,19 +101,31 @@ type: kubernetes.io/tls
106
101
data:
107
102
EOM
108
103
if [[ -n $K8S_SAVE_CA_KEY ]]; then
109
- echo -n " ca_key: " | tee -a /certs/secret.yaml
110
- cat $CA_KEY | base64 | tr ' \n' ' ,' | sed ' s/,//g' | tee -a /certs/secret.yaml
111
- echo | tee -a /certs/secret.yaml
104
+ echo -n " ca.key: " >> /certs/secret.yaml
105
+ cat $CA_KEY | base64 | tr ' \n' ' ,' | sed ' s/,//g' >> /certs/secret.yaml
106
+ echo >> /certs/secret.yaml
107
+ fi
108
+ if [[ -n $K8S_SAVE_CA_CRT ]]; then
109
+ echo -n " ca.crt: " >> /certs/secret.yaml
110
+ cat $CA_CERT | base64 | tr ' \n' ' ,' | sed ' s/,//g' >> /certs/secret.yaml
111
+ echo >> /certs/secret.yaml
112
112
fi
113
- echo -n " ca_crt: " | tee -a /certs/secret.yaml
114
- cat $CA_CERT | base64 | tr ' \n' ' ,' | sed ' s/,//g' | tee -a /certs/secret.yaml
115
- echo | tee -a /certs/secret.yaml
116
- echo -n " ssl_key: " | tee -a /certs/secret.yaml
117
- cat $SSL_KEY | base64 | tr ' \n' ' ,' | sed ' s/,//g' | tee -a /certs/secret.yaml
118
- echo | tee -a /certs/secret.yaml
119
- echo -n " ssl_crt: " | tee -a /certs/secret.yaml
120
- cat $SSL_CERT | base64 | tr ' \n' ' ,' | sed ' s/,//g' | tee -a /certs/secret.yaml
121
- echo | tee -a /certs/secret.yaml
113
+ echo -n " tls.key: " >> /certs/secret.yaml
114
+ cat $SSL_KEY | base64 | tr ' \n' ' ,' | sed ' s/,//g' >> /certs/secret.yaml
115
+ echo >> /certs/secret.yaml
116
+ echo -n " tls.crt: " >> /certs/secret.yaml
117
+ cat $SSL_CERT | base64 | tr ' \n' ' ,' | sed ' s/,//g' >> /certs/secret.yaml
118
+ echo >> /certs/secret.yaml
119
+
120
+ if [[ -z $SILENT ]]; then
121
+ echo " ====> Complete"
122
+ echo " keys can be found in volume mapped to $( pwd) "
123
+ echo
124
+
125
+ if [[ ${OUTPUT} == " k8s" ]]; then
126
+ echo " ====> Output results as base64 k8s secrets"
127
+ echo " ---"
128
+ cat /certs/secret.yaml
122
129
123
130
else
124
131
echo " ====> Output results as YAML"
0 commit comments