当前位置:  首页>> 技术小册>> Kubernets合辑6-服务发现

配置Ingress配置http代理:

  1. # ingree-demo-http.yaml
  2. apiVersion: networking.k8s.io/v1
  3. kind: Ingress
  4. metadata:
  5. name: slb-s1
  6. namespace: default
  7. annotations:
  8. # 因为安装traefik时候创建了 ingressClass 资源,因此不需要依赖注释中的 kubernetes.io/ingress.class
  9. # kubernetes.io/ingress.class: traefik
  10. traefik.ingress.kubernetes.io/router.entrypoints: web
  11. spec:
  12. ingressClassName: traefik
  13. rules:
  14. - host: slb-s1-http.huanle.com
  15. http:
  16. paths:
  17. - path: /
  18. pathType: Prefix
  19. backend:
  20. service:
  21. name: slb-s1
  22. port:
  23. name: http

测试

  1. # 通过LB的VIP 10.0.160.252 去访问测试的ingress域名
  2. [root@maxiaoke yaml]# curl -L http://10.0.160.252/info -H 'Host: slb-s1-http.huanle.com'
  3. 2021-10-13T06:40:02+00:00|v1.0.3|nginx-deploy-699fdd685d-mqw4m|ok
  4. [root@maxiaoke yaml]# curl -Lk https://10.0.160.252/info -H 'Host: slb-s1-http.huanle.com'
  5. 2021-10-13T06:40:24+00:00|v1.0.3|nginx-deploy-699fdd685d-mqw4m|ok

该分类下的相关小册推荐: