apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd
spec:
  selector:
    matchLabels:
      run: httpd
  replicas: 1
  template:
    metadata:
      labels:
        run: httpd
    spec:
      containers:
      - name: httpd
        image: httpd
        ports:
        - containerPort: 80
---
apiVersion: v1 # v1是service的apiversion
kind: Service # 当前资源的类型为 Service。
metadata:
  name: httpd-svc # Service 的名字为 httpd-svc。
spec:
  type: NodePort
  selector: # elector 指明挑选那些 label 为 run: httpd 的 Pod 作为 Service 的后端。
    run: httpd
  ports: # 将 Service 的 8080 端口映射到 Pod 的 80 端口,使用 TCP 协议。
  - protocol: TCP
    port: 8080
    targetPort: 80

 

 

引用 https://www.cnblogs.com/wuchangblog/p/14031074.html

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-11-12
  • 2021-09-17
  • 2021-07-10
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-01-24
  • 2022-03-03
相关资源
相似解决方案