-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkubeproxy
More file actions
executable file
·14 lines (11 loc) · 883 Bytes
/
kubeproxy
File metadata and controls
executable file
·14 lines (11 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash
# Creates kubecontext entry to access GKE Master via Istio Ingress Gateway
# So that access to GKE Master API can be allowed from peered VPC.
PROXIED_API_SERVER=${1:-'https://kubernetes.internal.gke.shared1.dev.gcp.testing'}
CURRENT_CONTEXT="$(kubectl config current-context)"
CURRENT_CONTEXT_USER="$(kubectl config view -o jsonpath="{.contexts[?(@.name == \"${CURRENT_CONTEXT}\")].context.user}")"
NAMESPACE="$(kubectl config view -o jsonpath="{.contexts[?(@.name == \"${CURRENT_CONTEXT}\")].context.namespace}")"
PROXIED_CONTEXT="proxied-${CURRENT_CONTEXT}"
kubectl config set-cluster "${PROXIED_CONTEXT}" --server="${PROXIED_API_SERVER}" --insecure-skip-tls-verify=true
kubectl config set-context "${PROXIED_CONTEXT}" --cluster="${PROXIED_CONTEXT}" --namespace="${NAMESPACE}" --user="${CURRENT_CONTEXT_USER}"
kubectl config use-context "${PROXIED_CONTEXT}"