警告
本文最后更新于 2020-07-31 15:17,文中内容可能已过时。
方式1:helm安装
1.给node添加标签,方便pod调度到指定节点
| 1
 | kubectl label nodes k8s-node04 traefik=true
 | 
2.自定义资源清单配置
vim my_values.yaml
|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 | # 使用hostNetwork,service就不需要了
service:
  enabled: false
# traefik是dashboard的配置,web和websecure是入口的配置
ports:
  traefik:
    expose: false
    port: 9000
  web:
    expose: false
    port: 80
  websecure:
    expose: false
    port: 443
# 监听1024以下的端口需要修改traefik默认的安全上下文配置
securityContext:
  capabilities:
    drop: []
  readOnlyRootFilesystem: false
  runAsGroup: 0
  runAsNonRoot: false
  runAsUser: 0
# 使用hostNetwork
hostNetwork: true
# 控制pod调度
nodeSelector:
  traefik: "true"
 | 
3.安装traefik
| 1
 | helm install traefik traefik/traefik --version=8.9.1 -f my_values.yaml
 | 
4.获取hostIP
| 1
 | kubectl get pod -l app.kubernetes.io/name=traefik  -o jsonpath={.items[0].status.hostIP};echo
 | 
5.做好解析后访问
| 1
2
3
4
5
6
7
8
 | http入口:
http://traefik.my.com/
https入口:
https://traefik.my.com/
dashboard:
http://traefik.my.com:9000/dashboard/
 |