一个基于 k3s 和 Traefik 的 entryPoints 案例可以是:
- 首先,在 k3s 中安装 Traefik 并启用 ingress controller。在这个例子中,我们使用 Helm 来安装 Traefik。
helm repo add traefik https://helm.traefik.io/traefik
helm install traefik traefik/traefik --set serviceType=LoadBalancer --namespace kube-system
- 接下来,我们将配置 Traefik 的 entryPoints。在这个例子中,我们要创建两个 entryPoints:HTTP 和 HTTPS。
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: tcp-entrypoints
spec:
entryPoints:
- name: http
protocol: http
port: 80
- name: https
protocol: tcp
port: 443
- 然后,我们可以使用 ingress 路由规则将流量从入口点路由到我们的应用程序。
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: my-app
spec:
entryPoints:
- http
routes:
- match: Host(`example.com`) && PathPrefix(`/`)
kind: Rule
services:
- name: my-app-service
port: 8080
- 最后,我们可以将 ingress 负载均衡器绑定到 entryPoints 上,以便流量能够正确地路由到我们的应用程序。
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: tcp-entrypoints
spec:
entryPoints:
- name: http
protocol: http
port: 80
- name: https
protocol: tcp
port: 443
routes:
- match: HostSNI(`*.example.com`)
kind: Rule
services:
- name: my-app-service
port: 8080
这个例子中的 entryPoints 配置为允许 HTTP 和 HTTPS 流量,并将流量转发到我们的应用程序服务。该服务绑定到规则,以便入站请求被路由到正确的端口。最后,负载均衡器绑定到 entryPoints 上,以便流量能够正确地路由到我们的应用程序。