Add standalone R3 RIC platform helm charts and deployment scripts.
[ric-plt/ric-dep.git] / helm / appmgr / templates / bin / _svcacct-to-kubeconfig.sh.tpl
1 {{/*
2    Copyright (c) 2019 AT&T Intellectual Property.
3    Copyright (c) 2019 Nokia.
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 */}}
17 #!/bin/sh
18
19 # generate a kubconfig (at ${KUBECONFIG} file from the automatically-mounted
20 # service account token.
21 # ENVIRONMENT:
22 # SVCACCT_NAME: the name of the service account user.  default "default"
23 # CLUSTER_NAME: the name of the kubernetes cluster.  default "kubernetes"
24 # KUBECONFIG: where the generated file will be deposited.
25 SVCACCT_TOKEN=`cat /var/run/secrets/kubernetes.io/serviceaccount/token`
26 CLUSTER_CA=`base64 /var/run/secrets/kubernetes.io/serviceaccount/ca.crt|tr -d '\n'`
27
28 cat >${KUBECONFIG} <<__EOF__
29 ApiVersion: v1
30 kind: Config
31 users:
32 - name: ${SVCACCT_NAME:-default}
33   user:
34     token: ${SVCACCT_TOKEN}
35 clusters:
36 - cluster:
37     certificate-authority-data: ${CLUSTER_CA}
38     server: ${K8S_API_HOST:-https://kubernetes.default.svc.cluster.local/}
39   name: ${CLUSTER_NAME:-kubernetes}
40 contexts:
41 - context:
42     cluster: ${CLUSTER_NAME:-kubernetes}
43     user: ${SVCACCT_NAME:-default}
44   name: svcs-acct-context
45 current-context: svcs-acct-context
46 __EOF__