# Setup domain, user and password first.$exportUSER=user$exportDOMAIN=ingress.feisky.xyz$htpasswd-cauth $USERNewpassword:Re-typenewpassword:Addingpasswordforuseruser$PASSWORD=$(catauth|awk-F:'{print $2}')# Deploy with helm.helminstallstable/traefik--name--namespacekube-system--setrbac.enabled=true,acme.enabled=true,dashboard.enabled=true,acme.staging=false,acme.email=admin@$DOMAIN,dashboard.domain=ui.$DOMAIN,ssl.enabled=true,acme.challengeType=http-01,dashboard.auth.basic.$USER=$PASSWORD
根据你自己环境中部署的 service 名称和端口自行修改,有新 service 增加时,修改该文件后可以使用kubectl replace -f traefik.yaml来更新。
测试
在集群的任意一个节点上执行。假如现在我要访问nginx的"/"路径。
$curl-HHost:traefik.nginx.iohttp://172.20.0.115/<!DOCTYPEhtml><html><head><title>Welcome to nginx!</title><style>body{width:35em;margin:0auto;font-family:Tahoma,Verdana,Arial,sans-serif; }</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking.Furtherconfigurationisrequired.</p><p>For online documentation and support please refer to<a href="http://nginx.org/">nginx.org</a>.<br/>Commercialsupportisavailableat<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>