github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/config/scripts/update_oke_kubeconfig.sh (about) 1 #!/bin/bash 2 3 # 4 # Copyright (c) 2020, 2022, Oracle and/or its affiliates. 5 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 6 # 7 8 kubectl -n kube-system create serviceaccount kubeconfig-sa 9 kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:kubeconfig-sa 10 # In k8s 1.24 and later, secret is not created for service account. Create a service account token secret and get the 11 # token from the same. 12 TOKENNAME=kubeconfig-sa-token 13 kubectl -n kube-system apply -f <<EOF - 14 apiVersion: v1 15 kind: Secret 16 metadata: 17 name: ${TOKENNAME} 18 annotations: 19 kubernetes.io/service-account.name: kubeconfig-sa 20 type: kubernetes.io/service-account-token 21 EOF 22 TOKEN=`kubectl -n kube-system get secret $TOKENNAME -o jsonpath='{.data.token}'| base64 --decode` 23 kubectl config set-credentials kubeconfig-sa --token=$TOKEN 24 kubectl config set-context --current --user=kubeconfig-sa