简体   繁体   English

本地主机的 Kube.netes Traefik 入口规则

[英]Kubernetes Traefik ingress rule for local host

I am trying to connect to traefik dashboard to localhost.我正在尝试将 traefik 仪表板连接到本地主机。 My manifest below will bring up the localhost:port but I only get 404 errors.我下面的清单将显示 localhost:port 但我只收到 404 错误。 Now sure how to set the ingress to work locally.现在确定如何将入口设置为在本地工作。 The base code was set up to run on AWS NLB, I am trying to setup this to run locally.基本代码设置为在 AWS NLB 上运行,我正在尝试将其设置为在本地运行。 This manifest below contains the deployment and service for the traefik Kube.netes install.下面的清单包含 traefik Kube.netes 安装的部署和服务。

apiVersion: v1
kind: Namespace
metadata:
  name: traefik
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: traefik-ingress-lb
  namespace: kube-system
  labels:
    k8s-app: traefik-ingress-lb
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: traefik-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
    spec:
      # hostNetwork: true
      serviceAccountName: traefik-ingress-lb
      terminationGracePeriodSeconds: 60
      containers:
      - image: traefik:v2.5
        imagePullPolicy: IfNotPresent
        name: traefik-ingress-lb
        args:
        - --serversTransport.insecureSkipVerify=true
        - --providers.kubernetesingress=true
        - --providers.kubernetescrd
        - --entryPoints.traefik.address=:1080
        - --entryPoints.https.address=:443
        - --entrypoints.https.http.tls=true
        - --entryPoints.https.forwardedHeaders.insecure=true
        - --entryPoints.https2.address=:4443
        - --entrypoints.https2.http.tls=true
        - --entryPoints.https2.forwardedHeaders.insecure=true
        - --entryPoints.turn.address=:5349
        - --entrypoints.turn.http.tls=true
        - --entryPoints.turn.forwardedHeaders.insecure=true        
        - --api
        - --api.insecure
        - --accesslog
        - --log.level=INFO
        - --pilot.dashboard=false
        - --entryPoints.http.address=:80
        - --entrypoints.http.http.redirections.entryPoint.to=https
        - --entrypoints.http.http.redirections.entryPoint.scheme=https
        - --entrypoints.http.http.redirections.entrypoint.permanent=true
        resources:
          limits:
            memory: 3072Mi
            cpu: 1.5
          requests:
            memory: 1024Mi
            cpu: 1        
---
apiVersion: v1
kind: Service
metadata:
  name: lb
  namespace: kube-system
  annotations:
   
spec:
  type: LoadBalancer 
  externalTrafficPolicy: Local
  selector:
    k8s-app: traefik-ingress-lb
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 443   
  - name: https2
    port: 4443
    targetPort: 4443
  - name: turn
    port: 5349
    targetPort: 5349
---
apiVersion: v1
kind: Service
metadata:
  name: dashboard
  namespace: traefik
spec:
  selector:
    k8s-app: traefik-ingress-lb
  ports:
  - name: dashboard
    port: 1080
    targetPort: 1080
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik
  namespace: kube-system
  # annotations:
  #   ingress.kubernetes.io/whitelist-x-forwarded-for: "true"
spec:
  entryPoints:
    - https
    # - web
  routes:
  - kind: Rule
    match: "PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
    # middlewares:                    
    # - name: internal-ip-whitelist             
    #   namespace: traefik            
    services:                       
    - kind: Service
      name: dashboard
      namespace: kube-system
      passHostHeader: true
      port: 1080
,,,

Your IngressRoute points to the dashboard service in namespace 'kube-system', but the traefik dashboard service is deployed in namespace 'traefik'.您的 IngressRoute 指向命名空间“kube-system”中的仪表板服务,但 traefik 仪表板服务部署在命名空间“traefik”中。 Therefore the route is not working, leading to the 404 in traefik.因此,该路线不起作用,导致 traefik 中的 404。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM