how to work with Ingress not IngressRoute

it has been work fine with IngressRoute, but when change to Ingress then not work, shows 404

IngressRoute

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingr-hello
  namespace: hello
  labels:
    app: app-hello
spec:
  entryPoints:
    - web
  routes:
  - match: Host(\`mydomain.com\`)
    kind: Rule
    services:
    - name: svc-hello
      port: 80

Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ing-hello
  namespace: hello
  labels:
    app: app-hello
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: mydomain.com
    http:
      paths:
      - backend:
          serviceName: svc-hello
          servicePort: 80

show

[root@i-qoy2h7fd ~]# kubectl logs ing/ing-hello -nhello
error: cannot get the logs from *v1beta1.Ingress: selector for *v1beta1.Ingress not implemented

or as https://doc.traefik.io/traefik/routing/providers/kubernetes-ingress/, also fail

kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
  name: myingress
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: web

spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /bar
            backend:
              serviceName: whoami
              servicePort: 80
          - path: /foo
            backend:
              serviceName: whoami
              servicePort: 80

Hi @dulm,

Did you define the needed RBAC ?

For the ingress, you would need something like

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
rules:
  - apiGroups:
      - ""
    resources:
      - services
      - endpoints
      - secrets
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
      - networking.k8s.io
    resources:
      - ingresses
      - ingressclasses
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses/status
    verbs:
      - update

Get the dep of traefik, only find --providers.kubernetescrd, no --providers.kubernetesingress.

  1. Dose it mean only crd work?
  2. If i add --providers.kubernetescrd and --providers.kubernetesingress both into dep, will k8s ingress and crd work together?
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: traefik
    manager: k3s
  name: traefik
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: traefik
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: traefik
    spec:
      containers:
      - args:
        - --api.insecure
        - --accesslog
        - --entrypoints.web.Address=:80
        - --entrypoints.websecure.Address=:443
        - --providers.kubernetescrd
        - --certificatesresolvers.myresolver.acme.tlschallenge
        - --certificatesresolvers.myresolver.acme.email=foo@you.com
        - --certificatesresolvers.myresolver.acme.storage=acme.json
        image: traefik:v2.2
        imagePullPolicy: IfNotPresent
        name: traefik
        ports:
        - containerPort: 80
          name: web
          protocol: TCP
        - containerPort: 443
          name: websecure
          protocol: TCP
        - containerPort: 8080
          name: admin
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: traefik-ingress-controller
      serviceAccountName: traefik-ingress-controller
      terminationGracePeriodSeconds: 30

With add --providers.kubernetescrd and --providers.kubernetesingress both, it finnally work fine now.