github.com/verrazzano/verrazzano@v1.7.1/ci/scripts/update_lre_kubeconfig.sh (about)

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