不多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