K8s-创建一套deploy,svc,ingress资源清单

2021-02-19 14:27:25 浏览数 (1)

不多BB,直接上yaml

代码语言:javascript复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-dm
spec:
  selector:
    matchLabels:
      name: nginx
  replicas: 2
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.18
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    name: nginx
apiVersion: extensions/v1beta1   #api版本
kind: Ingress   #清单类型
metadata:   #元数据
  name: nginx-test   #ingress的名称
spec:   #规格
  rules:  #定义后端转发的规则
    - host: ingress.myit.icu  #通过域名进行转发
      http:
        paths:
          - backend:  #配置后端服务
              serviceName: nginx-svc
              servicePort: 80

0 人点赞