首页 > 解决方案 > Trying to deploy traefik with kubernetes

问题描述

I'm trying to deploy traefik in Kubernetes with minikube. The deployment works well, the pod starts but when I look into pod logs, I get this :

Failed to list *v1beta1.Ingress: the server could not find the requested resource (get ingresses.extensions)

My current kubectl & kubernetes server versions are :

kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:45:37Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:39:34Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"

The version of traefik image that I try to deploy : traefik:v2.0

I set up all the RBAC resources and my current configuration for traefik is :

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: traefik-lb
spec:
  controller: traefik.io/ingress-controller
---
apiVersion: "networking.k8s.io/v1"
kind: "Ingress"
metadata:
  name: "example-ingress"
spec:
  ingressClassName: "traefik-lb"
  rules:
  - host: "*.example.com"
    http:
      paths:
      - path: "/example"
        pathType: Exact
        backend:
          service:
            name: "rabbitmq"
            port:
                number: 32666
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: traefik-ingress-controller
rules:
  - apiGroups: [""]
    resources: [services, endpoints]
    verbs: [list, watch]
  - apiGroups: [extensions]
    resources: [ingresses]
    verbs: [list]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: traefik-ingress-controller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
  name: {{ include "traefik.serviceAccountName" . }}
  namespace: default

The command api-versions result :

d3vpasha@d3vpasha-ZenBook-UX425EA-UX425EA ~/helm-charts/charts/traefik (dev)$ kubectl api-versions
admissionregistration.k8s.io/v1
apiextensions.k8s.io/v1
apiregistration.k8s.io/v1
apps/v1
authentication.k8s.io/v1
authorization.k8s.io/v1
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1
coordination.k8s.io/v1
discovery.k8s.io/v1
discovery.k8s.io/v1beta1
events.k8s.io/v1
events.k8s.io/v1beta1
flowcontrol.apiserver.k8s.io/v1beta1
networking.k8s.io/v1
node.k8s.io/v1
node.k8s.io/v1beta1
policy/v1
policy/v1beta1
rbac.authorization.k8s.io/v1
scheduling.k8s.io/v1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

I don't see what I do wrong :/ if someone can help me, thank you in advance

EDIT : I would like to add the fact that traefik:2.5 has not this problem so it's something related to the version 2.0 of traefik...

标签: kubernetesminikubetraefikrbac

解决方案


你可能想看看我在这里做的很多例子

试试这个。您可能需要将服务类型从 LoadBalancer 更改为 ClusterIP。

这可能也有帮助traefik-whoami

尝试使用 helm 生成资源。管理起来更方便。如果出现问题,您始终可以生成 k8s 清单。


推荐阅读