首页 > 解决方案 > traefik 入口:服务无法访问

问题描述

我刚刚部署了 traefik:

$ helm install traefik traefik/traefik --set dashboard.ingressRoute=true

我正在使用一个k3d有 2 个工作人员的集群。

安装 traefik 后,我意识到有几个类似入口的资源:

$ kubectl api-resources | grep ingress
NAME               SHORTNAMES   APIGROUP               NAMESPACED   KIND
ingresses          ing          extensions             true         Ingress
ingresses          ing          networking.k8s.io      true         Ingress
ingressroutes                   traefik.containo.us    true         IngressRoute
ingressroutetcps                traefik.containo.us    true         IngressRouteTCP

第一个问题是:为什么会有这么多类似 ingress 的资源?

我可以访问我刚刚部署的 traefik 仪表板localhost/dashboard

尽管如此,我安装了一个简单的服务,我无法弄清楚为什么它无法访问。

这里,graylog.localhost入口描述:

$ kubectl describe ingresses.networking.k8s.io graylog-web
Name:             graylog-web
Namespace:        graylog
Address:          
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host               Path  Backends
  ----               ----  --------
  graylog.localhost  
                     /gelf   graylog-tcp:gelf (10.42.0.24:12201,10.42.1.33:12201)
                             graylog-web:graylog (10.42.0.24:9000,10.42.1.33:9000)
Annotations:
Events:  <none>

但是,当我尝试访问时graylog.localhost

$ curl graylog.localhost
404 page not found

这是已部署的 traefik 部署:

$ kubectl describe deployments.apps traefik
Name:                   traefik
Namespace:              kube-system
CreationTimestamp:      Sun, 08 Mar 2020 20:51:09 +0100
Labels:                 app=traefik
                        chart=traefik-4.0.0
                        heritage=Helm
                        release=traefik
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=traefik,release=traefik
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 1 max surge
Pod Template:
  Labels:           app=traefik
                    chart=traefik-4.0.0
                    heritage=Helm
                    release=traefik
  Service Account:  traefik
  Containers:
   traefik:
    Image:       traefik:2.1.3
    Ports:       9000/TCP, 8000/TCP, 8443/TCP
    Host Ports:  0/TCP, 0/TCP, 0/TCP
    Args:
      --global.checknewversion=true
      --global.sendanonymoususage=true
      --entryPoints.traefik.address=:9000
      --entryPoints.web.address=:8000
      --entryPoints.websecure.address=:8443
      --api.dashboard=true
      --ping=true
      --providers.kubernetescrd
      --log.level=WARN
    Liveness:     http-get http://:9000/ping delay=10s timeout=2s period=10s #success=1 #failure=3
    Readiness:    http-get http://:9000/ping delay=10s timeout=2s period=10s #success=1 #failure=1
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   traefik-6c6c896889 (1/1 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  4d11h  deployment-controller  Scaled up replica set traefik-6c6c896889 to 1

在这里你有traefik服务描述:

$ kubectl describe services traefik
Name:                     traefik
Namespace:                kube-system
Labels:                   app=traefik
                          chart=traefik-4.0.0
                          heritage=Helm
                          release=traefik
Annotations:              <none>
Selector:                 app=traefik,release=traefik
Type:                     LoadBalancer
IP:                       10.43.215.222
LoadBalancer Ingress:     172.20.0.2
Port:                     web  80/TCP
TargetPort:               web/TCP
NodePort:                 web  31000/TCP
Endpoints:                10.42.1.12:8000
Port:                     websecure  443/TCP
TargetPort:               websecure/TCP
NodePort:                 websecure  31856/TCP
Endpoints:                10.42.1.12:8443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

有任何想法吗?

标签: traefiktraefik-ingressk3s

解决方案


不知道完整的答案,但是 k3s 预装了 traefik,所以这可能就是你得到这么多的原因。


推荐阅读