Fork me on GitHub
代码改变世界

k8s service直接暴露外部访问配置

2021-03-06 10:28  freefei  阅读(579)  评论(0编辑  收藏  举报
# 例如
kubectl edit service kubernetes-dashboard -n kubernetes-dashboard


apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2021-03-05T09:17:16Z"
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
  resourceVersion: "45245"
  uid: 5e618b58-a093-4bc4-ac96-c7ba71a13b01
spec:
  clusterIP: 10.43.9.56
  clusterIPs:
  - 10.43.9.56
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 30008 #增加访问端口
    port: 443
    protocol: TCP
    targetPort: 8443 
  selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort  # 修改类型
status:
  loadBalancer: {}


最后直接访问ip:30008

@ https://github.com/ranmufei

校友通微信小程序

校友通微信小程序