我在 kubeadm 的帮助下在谷歌云上部署了一个 2 节点 1 主 k8s 集群。
root@ubuntu-vm-1404:~/ansible/Kubernetes# kubectl --kubeconfig kubernetes.conf get nodes
NAME STATUS ROLES AGE VERSION
kubernetes-node1 Ready 1h v1.9.3
kubernetes-node2 Ready 1h v1.9.3
master-kubernetes Ready master 1h v1.9.3
[sujeetkp@master-kubernetes ~]$ kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"clean", BuildDate:"2018-02-07T12:22:21Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was
有人可以帮助我如何从我的本地机器或来自不同网络中的远程主机访问集群。
root@ubuntu-vm-1404:~/ansible/Kubernetes# kubectl --kubeconfig kubernetes.conf config view
apiVersion: v1
clusters:
cluster:
certificate-authority-data: REDACTED
server: https://10.142.0.3:6443
name: kubernetes
contexts:
context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
name: kubernetes-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
在配置文件中,私有 IP 被称为“服务器:https ://10.142.0.3:6443 ”。所以我怀疑我可以从不同的网络访问它。
我已遵循以下文档。
https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/
我执行的命令是
kubeadm init --pod-network-cidr=10.244.0.0/16
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
kubeadm join --token b9cd48.c4b0d860b9b530f7 10.142.0.3:6443 --discovery-token-ca-cert-hash sha256:5c15e951dcca92f5877cd2dab8a4383accadedc37233b68d8c33451768dc03e3