File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ chmod 600 "${TMP_KUBECONFIG}"
5353# Merge into existing kubeconfig (or create it if it doesn't exist)
5454if [[ -f " ${TARGET} " ]]; then
5555 log_info " Merging into existing ${TARGET} ..."
56+ # Remove stale context/cluster/user first so the new credentials always win
57+ # (re-installs generate a new CA — old creds cause x509/Unauthorized errors)
58+ kubectl config --kubeconfig=" ${TARGET} " delete-context " ${CONTEXT_NAME} " 2> /dev/null || true
59+ kubectl config --kubeconfig=" ${TARGET} " delete-cluster " ${CONTEXT_NAME} " 2> /dev/null || true
60+ kubectl config --kubeconfig=" ${TARGET} " delete-user " ${CONTEXT_NAME} " 2> /dev/null || true
5661 KUBECONFIG=" ${TARGET} :${TMP_KUBECONFIG} " kubectl config view --flatten > " ${TARGET} .merged"
5762 mv " ${TARGET} .merged" " ${TARGET} "
5863else
You can’t perform that action at this time.
0 commit comments