mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #95209 from benhxy/gke/kubeconfig
Use host IP instead of localhost for GKE control plane kubeconfig
This commit is contained in:
commit
e850fa6a6c
@ -529,3 +529,6 @@ export ENABLE_CSI_PROXY="${ENABLE_CSI_PROXY:-true}"
|
|||||||
# in addition to listening to 127.0.0.1, and whether kube-apiserver should connect to etcd servers
|
# in addition to listening to 127.0.0.1, and whether kube-apiserver should connect to etcd servers
|
||||||
# through host IP.
|
# through host IP.
|
||||||
export ETCD_LISTEN_ON_HOST_IP="${ETCD_LISTEN_ON_HOST_IP:-false}"
|
export ETCD_LISTEN_ON_HOST_IP="${ETCD_LISTEN_ON_HOST_IP:-false}"
|
||||||
|
|
||||||
|
# Use host IP instead of localhost in control plane kubeconfig files.
|
||||||
|
export KUBECONFIG_USE_HOST_IP="${KUBECONFIG_USE_HOST_IP:-false}"
|
||||||
|
@ -576,3 +576,6 @@ export ENABLE_CSI_PROXY="${ENABLE_CSI_PROXY:-true}"
|
|||||||
# in addition to listening to 127.0.0.1, and whether kube-apiserver should connect to etcd servers
|
# in addition to listening to 127.0.0.1, and whether kube-apiserver should connect to etcd servers
|
||||||
# through host IP.
|
# through host IP.
|
||||||
export ETCD_LISTEN_ON_HOST_IP="${ETCD_LISTEN_ON_HOST_IP:-false}"
|
export ETCD_LISTEN_ON_HOST_IP="${ETCD_LISTEN_ON_HOST_IP:-false}"
|
||||||
|
|
||||||
|
# Use host IP instead of localhost in control plane kubeconfig files.
|
||||||
|
export KUBECONFIG_USE_HOST_IP="${KUBECONFIG_USE_HOST_IP:-false}"
|
||||||
|
@ -1265,11 +1265,18 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create kubeconfig files for control plane components.
|
||||||
function create-kubeconfig {
|
function create-kubeconfig {
|
||||||
local component=$1
|
local component=$1
|
||||||
local token=$2
|
local token=$2
|
||||||
echo "Creating kubeconfig file for component ${component}"
|
echo "Creating kubeconfig file for component ${component}"
|
||||||
mkdir -p "/etc/srv/kubernetes/${component}"
|
mkdir -p "/etc/srv/kubernetes/${component}"
|
||||||
|
|
||||||
|
local kube_apiserver="localhost"
|
||||||
|
if [[ ${KUBECONFIG_USE_HOST_IP:-} == "true" ]] ; then
|
||||||
|
kube_apiserver=$(hostname -i)
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF >"/etc/srv/kubernetes/${component}/kubeconfig"
|
cat <<EOF >"/etc/srv/kubernetes/${component}/kubeconfig"
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
@ -1281,7 +1288,7 @@ clusters:
|
|||||||
- name: local
|
- name: local
|
||||||
cluster:
|
cluster:
|
||||||
insecure-skip-tls-verify: true
|
insecure-skip-tls-verify: true
|
||||||
server: https://localhost:443
|
server: https://${kube_apiserver}:443
|
||||||
contexts:
|
contexts:
|
||||||
- context:
|
- context:
|
||||||
cluster: local
|
cluster: local
|
||||||
|
Loading…
Reference in New Issue
Block a user