Skip to content

Commit d5f353c

Browse files
authored
Merge pull request kosmos-io#808 from OrangeBao/main
Cherry-Pick: replace IP with a local domain name
2 parents a179790 + 12ed853 commit d5f353c

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

hack/k8s-in-k8s/kubelet_node_helper.sh

+16-8
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ EOL
572572
}
573573

574574
function install_lvscare_lb() {
575-
echo "exec(1/6): get port of apiserver...."
575+
echo "exec(1/7): get port of apiserver...."
576576

577577
PORT=$(grep 'server:' "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}" | awk -F '[:/]' '{print $NF}')
578578

@@ -584,7 +584,7 @@ function install_lvscare_lb() {
584584
fi
585585

586586
# Start generating kube-lvscare.yaml
587-
echo "exec(2/6): generate kube-lvscare.yaml...."
587+
echo "exec(2/7): generate kube-lvscare.yaml...."
588588

589589
cat <<EOL > $PATH_KUBERNETES/manifests/kube-lvscare.yaml
590590
apiVersion: v1
@@ -639,25 +639,33 @@ EOL
639639
status: {}
640640
EOL
641641

642-
echo "exec(3/6): restart static pod"
642+
echo "exec(3/7): restart static pod"
643643
mv "${PATH_KUBERNETES}/manifests/kube-lvscare.yaml" "${PATH_KUBERNETES}/kube-lvscare.yaml"
644644
sleep 2
645645
mv "${PATH_KUBERNETES}/kube-lvscare.yaml" "${PATH_KUBERNETES}/manifests/kube-lvscare.yaml"
646646

647-
echo "exec(4/6): wait lvscare ready"
647+
echo "exec(4/7): wait lvscare ready"
648648
if wait_api_server_proxy_ready; then
649649
echo "lvscare is ready"
650650
else
651651
echo "lvscare is not ready"
652652
exit 1
653653
fi
654654

655-
echo "exec(5/6): update kubelet.conf"
655+
echo "exec(5/7): update kubelet.conf"
656656
cp "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}" "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}.bak"
657-
sed -i "s|server: .*|server: https://${LOCAL_IP}:${LOCAL_PORT}|" "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}"
658-
sed -i 's|certificate-authority-data: .*|insecure-skip-tls-verify: true|' "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}"
657+
sed -i "s|server: .*|server: https://apiserver.virtual-cluster-system.svc:${LOCAL_PORT}|" "${PATH_KUBERNETES}/${KUBELET_KUBE_CONFIG_NAME}"
658+
659+
echo "exec(6/7): update /etc/hosts"
660+
local_record="${LOCAL_IP} apiserver.virtual-cluster-system.svc"
661+
if grep -qFx "$local_record" /etc/hosts; then
662+
echo "Record $local_record already exists in /etc/hosts."
663+
else
664+
sed -i "1i $local_record" /etc/hosts
665+
echo "Record $local_record inserted into /etc/hosts."
666+
fi
659667

660-
echo "exec(6/6): restart kubelet"
668+
echo "exec(7/7): restart kubelet"
661669
systemctl restart kubelet
662670
}
663671

pkg/kubenest/constants/constant.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
CertificateValidity = time.Hour * 24 * 365 * 100
4040
CaCertAndKeyName = "ca"
4141
VirtualClusterCertAndKeyName = "virtualCluster"
42-
VirtualClusterSystemNamespace = "virtualCluster-system"
42+
VirtualClusterSystemNamespace = "virtual-cluster-system"
4343
ApiserverCertAndKeyName = "apiserver"
4444
EtcdCaCertAndKeyName = "etcd-ca"
4545
EtcdServerCertAndKeyName = "etcd-server"

0 commit comments

Comments
 (0)