List all available ingress controllers on Kubernetes - kubernetes

I have a GKE cluster with Traefik being used as an ingress controller.
I want to create a GKE ingress, but I can't find anywhere which kubernetes.io/ingress.class to use.
I tried to use kubernetes.io/ingress.class: gce, but nothing happened... it's almost like the ingress was completely ignored.
Is there a way to list all available ingress controllers/classes? Or, at least, which kubernetes.io/ingress.class should I use to create a GKE Ingress? (I'll still use traefik for other ingresses).

Run describe on the Ingress. If you see create/add events, you have an Ingress controller running in the cluster, otherwise, you probably have the HttpLoadBalancing(GKE Ingress Controller) add-on disabled on your GKE cluster.

On GKE, The kubernetes.io/ingress.class: gce is the default ingress class, if there is no an annotation defined under the metadata section, the Ingress Resource uses the GCP GCLB L7 load balancer to serve traffic. So have you tried setting the annotation to an empty string?
Being said that, answering the following questions it will help me to understand the contest:
Could you please define you use case? Are you trying to define two
ingress for the same service or convert to curren Traefik to a GCE
ingress?
Could you please attach your GKE ingress definition to see
if there is a sintaxis error ?

Related

Kubernetes with route fanout - Basic understanding of Service setup

I have questions about my basic understanding about the setup of my k8s cluster.
I have a K8s running on Hetzner-cloud and allocated a "physical" Loadbalancer (which can be controlled via annotations on a Service.)
I use a nginx (or traefik) as my ingress-controller.
Please correct me if I am wrong:
I create the service Loadbalancer with the annotations in the same namespace of my ingress-controller right?
Then I create an ingress with label kubernetes.io/ingress-controller=nginx in my default namespace with the settings to point to my services in the default namespace (one for frontend, one for backend)
Is this the correct way to set this up?
1.- No. Ingress Controller and your workload doesn't have to be in the same namespace. In fact, you will have the Ingress Controller running in a separate namespace than your workload.
2.-Yes. Generally speaking your Ingress rules, meaning your Ingress object, meaning your Ingress yaml and your Service must be in the same namespace. So Ingress can't transpass a namespace.
Note: There is a way to have an Ingress object to send trafffic to a Service in a different namespace.
I create the service Loadbalancer with the annotations in the same
namespace of my ingress-controller right?
No ideally your ingress controller will be running in different namespace in which your workload must not be running.
You should be keeping only the Nginx service with type : Loadbalancer other services of your workload should be ClusterIP.
So all your traffic comes inside the cluster from one point. Your flow will be something like
DNS > LB > Ingress > Service > Pods > Container
Then I create an ingress with label
kubernetes.io/ingress-controller=nginx in my default namespace with
the settings to point to my services in the default namespace (one for
frontend, one for backend)
You mentioned label ideally, it should be an annotation kubernetes.io/ingress-controller=nginx.
Yes, it's perfect. You can create different ingress with different annotation rules as per requirements for different services that you want to expose publicly.
Keep your workload in default namespace for the controller you can use different namespaces like ingress-controller in future also if you have any requirement of setting up the Monitoring tools also you can create namespace and use it for monitoring only.

Internal working and connection of Kubernetes Ingress Object and Ingress Controller

I was trying to understand the relation between Kubernetes Ingress Resource and Ingress Controller.
I read that Ingress resource is mainly the rules and controller Pods route the traffic actually for Ingress rules.
I'm confused, like other Objects why Ingress resource can not spin up PODs on its own by specifying the image.
Secondly, how Ingress Object connects to actual Ingress Controller Pods to get its work done ( or say other way round). I don't see specifying any selector in the Ingress Object.
Thirdly, if the Ingress Resource gets its own IP address ( internal or external) then why Ingress Controller needs external IP address.
thanks
PS: I do not have a great knowledge of Kubernetes, please pardon if the questions sound silly.
Details with diagram are posted in GKE tutorial
Ingress with NGINX controller on Google Kubernetes Engine

K8s - Unable to reach application from outside the cluster

I am learning to deploy applications on private clusters. The application is up and running in a pod and is reachable from the node itself. I have created an ingress controller service as well, but I am not sure what's going wrong. The external IP of the nginx-ingress service always returns 404. Any ideas on the fix ?
Services running :
Application service :
Nginx service :
Application ingress :
Ingress yaml :
Looks like the Ingress is not being served by your Nginx Ingress controller at the moment. If the Ingress is served by a controller, it should have at least one IP Address under its status.loadBalancer (which should be the external IP used by the Ingress Controller which is serving it), while in your case, looks empty like this:
status:
loadBalancer: {}
The most common problem on this regard is that the Ingress does not define an Ingress Class or there is no default Ingress Class in the cluster.
First of all, do a k get IngressClass and see if there's any Ingress Class defined. in your cluster. Depending on the Kubernetes version and Ingress Controller version, it could make use of IngressClass objects or simply use annotations (or both).
I would try simply adding the annotation kubernetes.io/ingress.class: nginx under the Ingress metadata as the nginx class is usually the one defined by the Nginx Ingress Controller. Or, if your Ingress Controller is using a different Ingress Class, I'd try specify that in the annotation, then your setup should work.
If you are curious on what is the purpose of an Ingress Class, it can mostly be used to associate an Ingress resource definition, with an ingress controller. On a Kubernetes cluster, there may be more than one Ingress Controller, each one with its own ingress class and Ingress resources are associated to one of them by matching the requested ingress class.
If an ingress class is not specified, the Ingress uses the default one, which means that the IngressClass annotated to be the default one of the cluster is automatically used.
For more info, check the documentation here ( https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class )

what is an ingress controller and how do I create it?

Good morning guys, so I took down a staging environment for a product on GCP and ran the deployment scripts again, the backend and frontend service have been setup. I have an ingress resource and a load balancer up, however, the service is not running. A look at the production app revealed there was something like an nginx-ingress-controller. I really don't understand all these and how it was created. Can someone help me understand because I have not seen anything online that makes it clear for me. Am I missing something?
loadBalancer: https://gist.github.com/davidshare/5a571e56febe7dacd580282b373f3095
Ingress Resource: https://gist.github.com/davidshare/d0f53912bc7da8310ec3d64f1c8a44f1
Ingress allows access to your Kubernetes services from outside the Kubernetes cluster. There are different kubernetes aka K8 resources alternatively you can use like (Node Port / Loadbalancer) which you can use to expose.
Ingress is independent resource to your service , you can specify routing rules declaratively, so each url with some context can be mapped to different services.
This makes it decoupled and isolated from the services you want to expose.
So to work ingress it needs an Ingress Controller for your cluster.
Like deployment resource in K8, ingress can be created simply by
kubectl create -f ingress.yaml
First, you have to implement Ingress Controller in order to apply Ingress resource, as described in #Shubhu answer. Ingress controller, as an edge router, applies specific logical structure with aim to route external traffic to your Kubernetes cluster underlying services via basic pattern routing rules defined in Ingress resource.
If you select Nginx Ingress Controller then it might be useful to proceed with installation guide approaching some specific prerequisites based on cloud provider environment. In order to simplify Nginx Ingress controller installation procedure it is also possible to use Helm package manager and install appropriate stable/nginx-ingress Helm chart.

Kubernetes GCE Internal Ingress

I'm looking for a way to to create an internal HTTPs L7 ingress controller in GCE, but there doesn't seem to be any documentation in regards to how this can be done. I see that there is a way to create an internal a L4 LoadBalancer, but not an L7 ingress. Why is this the case and what are possible solutions or workarounds?
If you want an "internal" ingress-controller setup you simply do not need to expose your Service as type `LoadBalancer. Your ingress-controller will be accessible via the node port.'
If you're wanting an actual load balancer in front of your ingress you'll have to roll your own such as HAproxy.