apisix-helm-chart icon indicating copy to clipboard operation
apisix-helm-chart copied to clipboard

Add IngressClass To Chart

Open amartincolby opened this issue 2 years ago • 10 comments

I am trying to configure APISIX and the apisix-ingress-controller. This is not working because the ingress-controller does not create a new ingressClass. I cannot tell if I missing something in the basic configuration and setup. If it is not creating a new IngressClass, can it be configured to do so?

amartincolby avatar Sep 11 '22 05:09 amartincolby

IngressClass resource is not required.

You can continue whether or not the resource exists. Also, you can create this resource by yourself

tao12345666333 avatar Sep 11 '22 06:09 tao12345666333

However, I think maybe we can add this configuration as well. Would you like to submit a PR to add this resource?

tao12345666333 avatar Sep 11 '22 07:09 tao12345666333

I thought that IngressClass was required from 1.19 forward?

Regardless, I will open a PR with the template. Happy to help.

amartincolby avatar Sep 11 '22 23:09 amartincolby

Thanks! If you could submit a PR, I'd be happy to merge it.

To be precise, the IngressClass resource was added since v1.18. But this resource is not mandatory. Whether this resource is required depends on the implementation of the ingress controller.

tao12345666333 avatar Sep 12 '22 11:09 tao12345666333

Ah, ok. I am not sure where I read this, because I cannot find it now, but I thought that IngressClass was required after 1.19.

amartincolby avatar Sep 13 '22 03:09 amartincolby

IngressClass resource is not required.

You can continue whether or not the resource exists. Also, you can create this resource by yourself

can give me a example config that set apisix-ignress as deafult ingressclass in cluster ? thank you every mutch . I find the k8s guid, have the config example,but the key sepc.controller have no idea. 可以给个defaulingressclass的样例配置吗,我找了k8s手册和apisix的手册,还有测试用例,发现都是通过注解或者指定ingressClassName 指定apisix的,但是我想把apisix配置成默认的ingress-controller 。找了下官方的default ingress class的样例,里面的spec.controller 不知道该如何配置.


apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  labels:
    app.kubernetes.io/component: controller
  name: nginx-example
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
spec:
  controller: k8s.io/ingress-nginx

lkad avatar Nov 21 '22 02:11 lkad

@tao12345666333

I was looking into this and how other ingress controllers manage IngressClasses and it seems to me the standard way of doing it (to be able to support multiple classes via the same controller, i.e. the Kubernetes way) is for the controller to get/list all IngressClasses registered on the cluster where spec.controller is set to a unique identifier, e.g.

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: apisix-custom-1
spec:
  controller: apisix.apache.org/ingress-controller

From that point on, the controller would watch for new Ingresses where the ingressClassName matches the metadata.name of the IngressClass, in this case, apisix-custom-1. I believe currently the only supported class is apisix, which is hard-coded here.

You can see how traefik is doing it https://github.com/traefik/traefik/blob/56f7515ecd8572c6a4c73f35e54b33414e6efb79/pkg/provider/kubernetes/ingress/client.go#L483-L492

The spec.controller value that it searches for https://github.com/traefik/traefik/blob/c57876c116ebc375becaff476fbcf6f25c4db7f3/pkg/provider/kubernetes/ingress/kubernetes.go#L35

So I guess this needs a counterpart issue on https://github.com/apache/apisix-ingress-controller, only then would it make sense to add the IngressClass template to this chart.

macmiranda avatar Dec 02 '22 16:12 macmiranda

I have the same problem, I can't create my ingresses this way: https://apisix.apache.org/docs/ingress-controller/tutorials/proxy-the-httpbin-service-with-ingress/

I have this error message when I apply the ingress manifest: "admission webhook "vingress.elbv2.k8s.aws" denied the request: invalid ingress class: IngressClass.networking.k8s.io "apisix".

I'm on EKS 1.23

ecoupal-believe avatar Feb 08 '23 07:02 ecoupal-believe

I am experiencing a similar issue while trying to create ingress when the AWS ALB Controller is running.

Here's the error message that I receive:

error when creating "ingress.yaml": admission webhook "vingress.elbv2.k8s.aws" denied the request: invalid ingress class: IngressClass.networking.k8s.io "apisix" not found

meong1234 avatar Jul 14 '23 04:07 meong1234

For people reporting being blocked by this issue, you can just create an Ingress Class resource called apisix even though it won't be used by the controller. It will nevertheless fix the problem with the admission webhook.

macmiranda avatar Jul 14 '23 06:07 macmiranda