apiVersion: v1 kind: Service metadata: name: traefik spec: ports: - name: web port: 80 - name: websecure port: 443 - name: admin port: 8080 selector: app: traefik --- apiVersion: apps/v1 kind: DaemonSet metadata: name: traefik-ingress-controller labels: app: traefik spec: selector: matchLabels: app: traefik template: metadata: name: traefik labels: app: traefik spec: serviceAccountName: traefik-ingress-controller terminationGracePeriodSeconds: 1 containers: - image: traefik:v2.0.5 name: traefik-ingress-lb ports: - name: web containerPort: 80 hostPort: 80 #hostPort方式,将端口暴露到集群节点 - name: websecure containerPort: 443 hostPort: 443 #hostPort方式,将端口暴露到集群节点 - name: admin containerPort: 8080 resources: limits: cpu: 2000m memory: 1024Mi requests: cpu: 1000m memory: 1024Mi securityContext: capabilities: drop: - ALL add: - NET_BIND_SERVICE args: - --configfile=/config/traefik.yaml volumeMounts: - mountPath: "/config" name: "config" volumes: - name: config configMap: name: traefik-config tolerations: #设置容忍所有污点,防止节点被设置污点 - operator: "Exists" nodeSelector: #设置node筛选器,在特定label的节点上启动 IngressProxy: "true"