其他分享
首页 > 其他分享> > k8s service直接暴露外部访问配置

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

作者:互联网

# 例如
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

标签:service,kubernetes,app,暴露,dashboard,k8s,10.43
来源: https://www.cnblogs.com/freefei/p/14489754.html