暴露HTTP服务是咱们常使用的,首先配置ingressroute。
    ingress-route.yaml

    1. apiVersion: traefik.containo.us/v1alpha1
    2. kind: IngressRoute
    3. metadata:
    4. name: foo
    5. spec:
    6. entryPoints:
    7. - web
    8. routes:
    9. - match: Host(`foo.rookieops.top`)
    10. kind: Rule
    11. services:
    12. - name: foo
    13. port: 8080

    然后在traefik中添加entrypoint:

    1. kind: Deployment
    2. apiVersion: extensions/v1beta1
    3. metadata:
    4. name: traefik
    5. namespace: kube-system
    6. labels:
    7. k8s-app: traefik-ingress-lb
    8. spec:
    9. selector:
    10. matchLabels:
    11. k8s-app: traefik-ingress-lb
    12. template:
    13. metadata:
    14. labels:
    15. k8s-app: traefik-ingress-lb
    16. name: traefik-ingress-lb
    17. spec:
    18. serviceAccountName: traefik-ingress-controller
    19. tolerations:
    20. - operator: "Exists"
    21. nodeSelector:
    22. kubernetes.io/hostname: 172.16.0.33
    23. containers:
    24. - image: traefik:v2.0
    25. name: traefik-ingress-lb
    26. ports:
    27. - name: web
    28. containerPort: 80
    29. - name: websecure
    30. containerPort: 443
    31. - name: admin
    32. containerPort: 8080
    33. - name: redis
    34. containerPort: 6379
    35. args:
    36. - --entrypoints.web.Address=:80
    37. - --entrypoints.websecure.Address=:443
    38. - --entrypoints.redis.Address=:6379
    39. - --api.insecure=true
    40. - --providers.kubernetescrd
    41. - --api
    42. - --api.dashboard=true
    43. - --accesslog

    然后创建配置清单就可以了。