Extend K8S and RIC installation instructions
[it/dep.git] / ci / tiller-secret-gen / bin / tls-secrets.sh
1 #!/bin/sh
2
3 #   Copyright (c) 2019 AT&T Intellectual Property.
4 #   Copyright (c) 2019 Nokia.
5 #
6 #   Licensed under the Apache License, Version 2.0 (the "License");
7 #   you may not use this file except in compliance with the License.
8 #   You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #   Unless required by applicable law or agreed to in writing, software
13 #   distributed under the License is distributed on an "AS IS" BASIS,
14 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #   See the License for the specific language governing permissions and
16 #   limitations under the License.
17
18 set -x
19
20 export ENTITIES=${ENTITIES:-helm tiller}
21 export KUBECONFIG=${KUBECONFIG:-/kubeconfig}
22 export CA_DIR=${CA_DIR:-/pki}
23 if [ ! -z ${TARGET_NAMESPACE} ]; then
24   SECRET_NS="--namespace ${TARGET_NAMESPACE}"
25 else
26   SECRET_NS=''
27 fi
28
29 if [ ! -f ${KUBECONFIG} ]; then
30   export SVCACCT_NAME=${SVCACCT_NAME:-tiller}
31   /bin/svcacct-to-kubeconfig.sh
32 fi    
33
34 if [ ! -f ${CA_DIR}/helm.key.pem -o \
35      ! -f ${CA_DIR}/tiller.key.pem ]; then
36  /bin/cert-gen.sh
37 fi    
38
39 # i'm assuming we can just lose the CA key.
40 for entity in ${ENTITIES}; do
41  kubectl create secret generic \
42   --from-file=ca.crt=/pki/ca.cert.pem \
43   --from-file=tls.crt=/pki/${entity}.cert.pem \
44   --from-file=tls.key=/pki/${entity}.key.pem \
45   ${SECRET_NS} ${entity}
46  
47  kubectl label secret \
48   ${SECRET_NS} ${entity} \
49   app=helm \
50   name=${entity}
51 done