Created
July 2, 2026 15:40
-
-
Save tedkulp/16aca7fbcada87a15233c93632cbf805 to your computer and use it in GitHub Desktop.
Workaround for freelens proxy issues. See https://github.com/freelensapp/freelens/issues/766#issuecomment-4864299578
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| REAL_KUBECTL=/usr/bin/kubectl | |
| if [[ -n "$KUBECONFIG" && -f "$KUBECONFIG" ]]; then | |
| # Extract cluster name and server from the Freelens temp kubeconfig | |
| export CLUSTER_NAME | |
| CLUSTER_NAME=$(yq '.clusters[0].name' "$KUBECONFIG") | |
| temp_server=$(yq '.clusters[0].cluster.server' "$KUBECONFIG") | |
| # Only modify if the server points to the Freelens local proxy | |
| if [[ "$temp_server" =~ ^https://127\.0\.0\.1:[0-9]+/ ]]; then | |
| export REAL_SERVER REAL_USER | |
| REAL_SERVER=$(yq '.clusters[] | select(.name == env(CLUSTER_NAME)) | .cluster.server' ~/.kube/config) | |
| if [[ -n "$REAL_SERVER" && "$REAL_SERVER" != "null" ]]; then | |
| REAL_USER=$(yq '.contexts[] | select(.context.cluster == env(CLUSTER_NAME)) | .context.user' ~/.kube/config) | |
| # Replace server and remove Freelens proxy CA/TLS settings | |
| yq -i ' | |
| .clusters[0].cluster.server = env(REAL_SERVER) | | |
| del(.clusters[0].cluster.certificate-authority-data) | | |
| del(.clusters[0].cluster.insecure-skip-tls-verify) | |
| ' "$KUBECONFIG" | |
| # Update context to reference the correct user | |
| yq -i '.contexts[0].context.user = env(REAL_USER)' "$KUBECONFIG" | |
| # Replace users section with the matching user from real config | |
| user_tmp=$(mktemp) | |
| yq '.users[] | select(.name == env(REAL_USER))' ~/.kube/config >"$user_tmp" | |
| yq -i ".users = [load(\"${user_tmp}\")]" "$KUBECONFIG" | |
| rm -f "$user_tmp" | |
| fi | |
| fi | |
| fi | |
| $REAL_KUBECTL "$@" |
Author
Great! I'm glad you figured it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Codex, I fixed the x509 TLS errors on my side: