NodePort是否可在Azure容器服务(Kubernetes)上运行 [英] Does NodePort work on Azure Container Service (Kubernetes)

查看:193
本文介绍了NodePort是否可在Azure容器服务(Kubernetes)上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Kubernetes仪表板提供了以下服务

I have got the following service for Kubernetes dashboard

Name:               kubernetes-dashboard
Namespace:          kube-system
Labels:             k8s-app=kubernetes-dashboard
                    kubernetes.io/cluster-service=true
Annotations:        kubectl.kubernetes.io/last-applied-configuration={"kind":"Service","apiVersion":"v1","metadata":{"name":"kubernetes-dashboard","namespace":"kube-system","creationTimestamp":null,"labels":{"k8s-app":"k...
Selector:           k8s-app=kubernetes-dashboard
Type:               NodePort
IP:                 10.0.106.144
Port:               <unset> 80/TCP
NodePort:           <unset> 30177/TCP
Endpoints:          10.244.0.11:9090
Session Affinity:   None
Events:             <none>

根据文档,我跑了

az acs kubernetes browse

,它可用于 http://localhost:8001/ui

但是我也想在集群外部访问它. describe输出说它是使用端口30177上的NodePort公开的.

But I want to access it outside the cluster too. The describe output says that it is exposed using NodePort on port 30177.

但是我无法在http://<any node IP>:30177

推荐答案

我们知道,将服务公开到Internet,我们可以使用nodeportLoadBalancer.

As we know, expose the service to internet, we can use nodeport and LoadBalancer.

据我所知,Azure现在不支持节点端口类型.

As far as I know, Azure does not support nodeport type now.

但是我也想在集群外部访问它.

But I want to access it outside the cluster too.

我们可以使用LoadBalancer重新创建kubernetes仪表板,这是我的步骤:

we can use LoadBalancer to re-create the kubernetes dashboard, here are my stpes:

    通过kubernetes UI
  1. 删除 kubernetes-dashboard:选择命名空间 kube-system ,然后选择服务,然后将其删除:
  2. 修改kubernets-dashboard-service.yaml:SSH主VM,然后将更改类型从nodeport更改为 LoadBalancer :

  1. Delete kubernetes-dashboard via kubernetes UI: select Namespace to kube-system, then select services, then delete it:
  2. Modify kubernets-dashboard-service.yaml: SSH master VM, then change type from nodeport to LoadBalancer:

root @ k8s-master-47CAB7F6-0:/etc/kubernetes/addons#vi kubernetes-dashboard-service.yaml

root@k8s-master-47CAB7F6-0:/etc/kubernetes/addons# vi kubernetes-dashboard-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    kubernetes.io/cluster-service: "true"
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 9090
  selector:
    k8s-app: kubernetes-dashboard
  type: LoadBalancer

  • 开始 kubernetes从CLI 2.0浏览:

  • start kubernetes browse from CLI 2.0:

    C:\ Users> az acs kubernetes browse -g k8s -n containerservice-k8s

    C:\Users>az acs kubernetes browse -g k8s -n containerservice-k8s

    然后使用SSH来主控VM来检查状态:

    Then SSH to master VM to check the status:

    现在,我们可以通过公共IP地址浏览用户界面:

    Now, we can via the Public IP address to browse the UI:

    更新:
    下图显示了Azure容器服务集群(Kubernetes)的体系结构,我们应该使用Load Balancer将服务公开到Internet.

    Update:
    The following image shows the architecture of azure container service cluster(Kubernetes), we should use Load Balancer to expose the service to internet.

    这篇关于NodePort是否可在Azure容器服务(Kubernetes)上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆