配置Ingress配置http代理:
# ingree-demo-http.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: slb-s1
namespace: default
annotations:
# 因为安装traefik时候创建了 ingressClass 资源,因此不需要依赖注释中的 kubernetes.io/ingress.class
# kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
ingressClassName: traefik
rules:
- host: slb-s1-http.huanle.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: slb-s1
port:
name: http
测试
# 通过LB的VIP 10.0.160.252 去访问测试的ingress域名
[root@maxiaoke yaml]# curl -L http://10.0.160.252/info -H 'Host: slb-s1-http.huanle.com'
2021-10-13T06:40:02+00:00|v1.0.3|nginx-deploy-699fdd685d-mqw4m|ok
[root@maxiaoke yaml]# curl -Lk https://10.0.160.252/info -H 'Host: slb-s1-http.huanle.com'
2021-10-13T06:40:24+00:00|v1.0.3|nginx-deploy-699fdd685d-mqw4m|ok