从远程主机访问Kubertnetes群集当前是一个不同的网络

时间:2018-02-18 14:48:43

标签: kubernetes kubeadm

我已经在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被称为“server: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

1 个答案:

答案 0 :(得分:0)

您需要在远程主机中安装kubectl并复制该文档中提到的conf文件。使用kubectl proxy进行从集群到运行kubernetes的实例的端口转发。完成后,请确保将conf中的clusterIp修改为公共IP。您引用的同一文档具有详细信息