if [[ -z $SILENT ]]; then echo"====> Complete" echo"keys can be found in volume mapped to $(pwd)" echo echo"====> Output results as YAML" echo"---" echo"ca_key: |" cat $CA_KEY | sed 's/^/ /' echo echo"ca_cert: |" cat $CA_CERT | sed 's/^/ /' echo echo"ssl_key: |" cat $SSL_KEY | sed 's/^/ /' echo echo"ssl_csr: |" cat $SSL_CSR | sed 's/^/ /' echo echo"ssl_cert: |" cat $SSL_CERT | sed 's/^/ /' echo fi
if [[ -n $K8S_SECRET_NAME ]]; then
if [[ -n $K8S_SECRET_COMBINE_CA ]]; then [[ -z $SILENT ]] && echo"====> Adding CA to Cert file" cat ${CA_CERT} >> ${SSL_CERT} fi
if [[ -n $K8S_SECRET_SEPARATE_CA ]]; then kubectl create secret generic \ $K8S_SECRET_NAME \ --from-file="tls.crt=${SSL_CERT}" \ --from-file="tls.key=${SSL_KEY}" \ --from-file="ca.crt=${CA_CERT}" else kubectl create secret tls \ $K8S_SECRET_NAME \ --cert=${SSL_CERT} \ --key=${SSL_KEY} fi
if [[ -n $K8S_SECRET_LABELS ]]; then [[ -z $SILENT ]] && echo"====> Labeling Kubernetes secret" IFS=$' \n\t'# We have to reset IFS or label secret will misbehave on some systems kubectl label secret \ $K8S_SECRET_NAME \ $K8S_SECRET_LABELS fi fi