If you are annoyed, as myself, about renewing the kubeconfig every 24 hours, i’ve created a simple script that generates a permanent kubeconfig file without expiration.
This script makes sense, obviously, if you have more than 1 karbon cluster to manage.
#!/bin/bash
if f -n "$1" ]; then
echo Cluster name: $1.
else
echo "No cluster name has been specified. "
exit 1
fi
kubectl create serviceaccount --namespace kube-system superuser
kubectl create clusterrolebinding superuser-rule --clusterrole=cluster-admin --serviceaccount=kube-system:superuserA=$(kubectl -n kube-system describe secret/$(kubectl -n kube-system get sa/superuser -o jsonpath='{.secretst0].name}')|awk '{for(i=1;i<=NF;i++)if($i=="token:")print $(i+1)}')
B=$(kubectl config view --flatten --minify|awk '{for(i=1;i<=NF;i++)if($i=="certificate-authority-data:")print $(i+1)}')
C=$(kubectl config view --flatten --minify|awk '{for(i=1;i<=NF;i++)if($i=="server:")print $(i+1)}')
D=$(kubectl config view --flatten --minify|awk '{for(i=1;i<=NF;i++)if($i=="name:")print $(i+1)}'|head -1)cat <<EOF >kubeconfig.$1
apiVersion: v1
kind: Config
users:
- name: superuser
user:
token: $A
clusters:
- cluster:
certificate-authority-data: $B
server: $C
name: $D
contexts:
- context:
cluster: $D
user: superuser
name: $D-context
current-context: $D-context
EOF
The script can be improved in many ways so keep it as is and do whatever you want , don’t ask for support :)
Hope it helps