1、deployment的简单写法:  nginx-deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-depoly
  namespace: default
  labels:
    app: nginxapp
spec:
  replicas: 3
  selector:
     matchLabels:
       app: nginxpod
  template:
    metadata:
      labels:
         app: nginxpod
    spec:
     containers:
     - name: nginxpod
       image: nginx:latest
       imagePullPolicy: IfNotPresent
       ports:
       - containerPort: 80

2、写个对应的service文件 nginx-svc.yaml

apiVersion: v1
kind: Service
metadata:
   name: nginx-svc
   namespace: default
   labels:
     app: nginxsvcapp
spec:
  type: ClusterIP
  selector:
    app: nginxpod
  ports:
   - port: 81
     protocol: TCP
     targetPort: 80

 

相关文章:

  • 2021-12-09
  • 2021-09-18
  • 2022-01-07
  • 2021-08-30
  • 2021-08-10
  • 2021-05-16
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2022-02-13
  • 2021-11-17
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案