请求流程示意图

用户 DNS SLB(负载均衡) Ingress(工作节点上) Service Pod Container App 1 访问域名 2 DNS解析到负载均衡 3 分发到Ingress 4 Ingress找到service 5 6 7 用户 DNS SLB(负载均衡) Ingress(工作节点上) Service Pod Container App

yml示例文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: docker-demo
  namespace: nero
spec:
  selector:
    matchLabels:
      app: docker-demo
  replicas: 1 # tells deployment to run 4 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      labels:
        app: docker-demo
    spec:
      containers:
      - name: docker-demo
        image: registry.cn-hangzhou.aliyuncs.com/zhangnero/docker-demo:v1.0
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          name: server
      imagePullSecrets:
      - name: aliyun-account
---
kind: Service
apiVersion: v1
metadata:
  name: docker-demo
  namespace: nero
spec:
  selector:
    app: docker-demo
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: docker-demo
  namespace: nero
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "100m"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "100s"
spec:
  rules:
  - host: www.nero.com
    http:
      paths:
      - path: /* 
        backend:
          serviceName: docker-demo
          servicePort: 8080
Logo

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

更多推荐