1、nginx_deployment文件

[root@k8s-master ~]# cat nginx.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

2、nginx_svc文件

[root@k8s-master ~]# cat nginx_svc.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
  name: nginx
spec:
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: NodePort

3、nginx_ingress文件

[root@k8s-master ~]# cat nginx_ingress.yaml 
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  namespace: default
spec:
  rules:
  - host: nginx.qq.com
    http:
      paths:
      - backend:
          serviceName: nginx
          servicePort: 80
        path: /
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐