Open v5tech opened 2 years ago
ingress.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: traefik-dashboard
spec:
entryPoints:
- web
- websecure
routes:
- match: Host(`traefik.example.com`)
kind: Rule
services:
- name: api@internal
kind: TraefikService
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
annotations:
ingress.kubernetes.io/ssl-redirect: "false"
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
# traefik.ingress.kubernetes.io/router.middlewares: default-stripprefix@kubernetescrd
spec:
rules:
- host: nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
- host: tomcat.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: tomcat
port:
number: 8080
Log Aggregation for Traefik and Kubernetes with the Elastic Stack https://traefik.io/blog/log-aggregation-for-traefik-and-kubernetes-with-the-elastic-stack/
Capture Traefik Metrics for Apps on Kubernetes with Prometheus https://traefik.io/blog/capture-traefik-metrics-for-apps-on-kubernetes-with-prometheus/
Application Request Tracing with Traefik and Jaeger on Kubernetes https://traefik.io/blog/application-request-tracing-with-traefik-and-jaeger-on-kubernetes/
HTTPS on Kubernetes Using Traefik Proxy https://traefik.io/blog/https-on-kubernetes-using-traefik-proxy/
Traefik Proxy 2.x and Kubernetes 101 https://traefik.io/blog/traefik-proxy-kubernetes-101/
From Zero to Hero: Getting Started with k0s and Traefik https://traefik.io/blog/from-zero-to-hero-getting-started-with-k0s-and-traefik/
Kubernetes Ingress & Service API Demystified https://traefik.io/blog/kubernetes-ingress-service-api-demystified/
Getting Started with Traefik and the New Kubernetes Gateway API https://traefik.io/blog/getting-started-with-traefik-and-the-new-kubernetes-gateway-api/
Rate limiting on Kubernetes applications with Traefik Proxy and Codefresh https://traefik.io/blog/rate-limiting-on-kubernetes-applications/
Integrating Consul Connect Service Mesh with Traefik 2.5 https://traefik.io/blog/integrating-consul-connect-service-mesh-with-traefik-2-5/
安装文档
https://k3d.io/ https://k3s.io/ https://doc.traefik.io/traefik/
安装k3d
创建集群
此处使用--registry-config配置镜像仓库认证。文档地址:https://k3d.io/v5.1.0/usage/registries/#registries-file
常用参数:
--k3s-arg : 文档地址:https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#k3s-server-cli-help
可选的组件有:coredns, servicelb, traefik, local-storage, metrics-server
如:--k3s-arg "--disable=traefik@server:0"
registries.yaml
注:"registry.cn-beijing.aliyuncs.com" 名字保持一致
不想使用默认flannel的可以选择其他网络组件.如:calico 参考:https://github.com/rancher/k3d/blob/main/docs/usage/advanced/calico.md
创建ingress
访问traefik dashboard
浏览器访问:http://localhost:9000/dashboard/
参考文档
Traefik 路由规则及中间件 Traefik Middlewares 的配置 https://doc.traefik.io/traefik/providers/overview/ https://doc.traefik.io/traefik/routing/providers/kubernetes-ingress/ https://doc.traefik.io/traefik/middlewares/overview/