Extend K8S and RIC installation instructions
[it/dep.git] / ric-infra / 45-Tiller / docker / bin / svcacct-to-kubeconfig.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 # generate a kubconfig (at ${KUBECONFIG} file from the automatically-mounted
19 # service account token.
20 # ENVIRONMENT:
21 # SVCACCT_NAME: the name of the service account user.  default "default"
22 # CLUSTER_NAME: the name of the kubernetes cluster.  default "kubernetes"
23 # KUBECONFIG: where the generated file will be deposited.
24 SVCACCT_TOKEN=`cat /var/run/secrets/kubernetes.io/serviceaccount/token`
25 CLUSTER_CA=`base64 /var/run/secrets/kubernetes.io/serviceaccount/ca.crt|tr -d '\n'`
26
27 cat >${KUBECONFIG} <<__EOF__
28 ApiVersion: v1
29 kind: Config
30 users:
31 - name: ${SVCACCT_NAME:-default}
32   user:
33     token: ${SVCACCT_TOKEN}
34 clusters:
35 - cluster:
36     certificate-authority-data: ${CLUSTER_CA}
37     server: ${CLUSTER_SERVER:-https://kubernetes.default.svc.cluster.local/}
38   name: ${CLUSTER_NAME:-kubernetes}
39 contexts:
40 - context:
41     cluster: ${CLUSTER_NAME:-kubernetes}
42     user: ${SVCACCT_NAME:-default}
43   name: svcs-acct-context
44 current-context: svcs-acct-context
45 __EOF__