5.2.2 访问该应用

  为了经由一个固定的IP地址来访问该应用,甚至从集群外部来访问它,我们需要Kubernetes Service对象。

示例:

apiVersion: v1
kind: Service
metadata:
  name: hello-svc
  labels:
    app: hello-world
spec:
  type: NodePort
  ports:
  - port: 8080
    nodePort: 30001
    protocol: TCP
  selector:
    app: hello-world

kubectl apply -f svc.yml

posted @ 2024-06-30 10:22  ~技术小白  阅读(20)  评论(0)    收藏  举报