说明 https://docs.k3s.io/zh/networking/networking-services?_highlight=trae#traefik-ingress-controller
默认配置文件位于/var/lib/rancher/k3s/server/manifests/traefik.yaml
traefik.yaml文件不应手动编辑,因为K3将在启动时用默认值替换该文件。
可以通过在/var/lib/rancher/k3s/server/manifests中创建一个额外的HelmChartConfig清单来定制Traefik。有关更多详细信息和示例,请参阅使用HelmChartConfig自定义打包组件。有关可能的配置值的更多信息,请参阅官方的Traefik Helm配置参数
https://docs.k3s.io/zh/helm#customizing-packaged-components-with-helmchartconfig
vi /var/lib/rancher/k3s/server/manifests/traefik-config.yaml
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
additionalArguments:
- "--entryPoints.web.proxyProtocol.insecure" # 80
- "--entryPoints.web.forwardedHeaders.insecure"
- "--entryPoints.websecure.proxyProtocol.insecure" # 443
- "--entryPoints.websecure.forwardedHeaders.insecure"
- "--entryPoints.web.forwardedHeaders.trustedIPs=127.0.0.1/32,10.0.0.0/8,172.16.0.0/16"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=127.0.0.1/32,10.0.0.0/8,172.16.0.0/16"
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0" # prometheus监控
- "--metrics.prometheus.addEntryPointsLabels=true"
- "--metrics.prometheus.addrouterslabels=true"
- "--metrics.prometheus.addServicesLabels=true"
- "--certificatesResolvers.letse.acme.dnsChallenge.provider=alidns" #自动签名证书letse配置,使用aliyun
- "--certificatesResolvers.letse.acme.email=xxxxx@qq.com"
- "--certificatesResolvers.letse.acme.storage=/data/acme.json"
- "--certificatesresolvers.letse.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.letse.acme.dnschallenge=true"
- "--certificatesresolvers.letse.acme.dnschallenge.provider=alidns"
deployment: # 映射地址
additionalVolumes:
- name: traefikconfig
hostPath:
path: /dataN/ingress/config
- name: traefiklogs
hostPath:
path: /dataN/ingress/logs
additionalVolumeMounts:
- name: traefikconfig
mountPath: "/etc/traefik"
- name: traefiklogs
mountPath: "/var/log/traefik"
env:
- name: "ALICLOUD_ACCESS_KEY"
value: "xxxx"
- name: "ALICLOUD_SECRET_KEY"
value: "xxxxx"