AliyunContainerService / k8s-for-docker-desktop

为Docker Desktop for Mac/Windows开启Kubernetes和Istio。
https://yq.aliyun.com/articles/672675
4.97k stars 1.13k forks source link

dashboard 如何通过ip访问,不用localhost #38

Open china8chen opened 5 years ago

china8chen commented 5 years ago

k8s 的dashboard,如何通过ip访问,而不是localhost

khs1994 commented 5 years ago

https://github.com/AliyunContainerService/k8s-for-docker-desktop#%E9%85%8D%E7%BD%AE-kubeconfig-%E5%8F%AF%E8%B7%B3%E8%BF%87

$ kubectl get all --all-namespaces 获取到端口,IP:端口 访问即可

khs1994 commented 5 years ago

https://github.com/AliyunContainerService/k8s-for-docker-desktop/blob/master/kubernetes-dashboard.yaml 这个文件加一个 type: NodePort

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
    - port: 443
      targetPort: 8443
  selector:
k8s-app: kubernetes-dashboard
JamesYing commented 4 years ago

为什么这些cluster-ip都无法ping通呢?

khs1994 commented 4 years ago

外部访问不到 cluster-ip (k8s 运行在虚拟机,windows 不能ping 通虚拟机内部地址)