Kong Ingress order

I have a Kubernetes environment running. I have installed Kong Ingress on this and it works fine. I have a Yaml file which specifies the Ingress rules for creating services and routes to other containers that are running.

Now, if one of the containers don’t exist, Kong obviously is unable to create a mapping i.e. service and route objects for that container.

Now, if my container that was missing comes up later, will Kong listen to kubernetes logs and create a service and rule later? Or do I have to create the ingress again after the container is up ?

Hello @angelshila,

The Ingress Controller will take care of pods coming up and going away.

Kong Ingress controller can create routing rules even if the containers (or pods abstraction in k8s) are not healthy.

Kong Ingress Controller will create a Route object in Kong for your Ingress rule and then associate it with a Service and an Upstream object in Kong based on the backend service in your Ingress rule.

The pods are translated to Targets in Kong.
If there are no healthy pods for your service, there will not be any healthy Targets in Kong. As soon as the pods (or containers) are started and are registered with Kubernetes service discovery, the Kubernetes Ingress Controller will sync that information to Kong (controller is listening to all the pod activity happening inside the cluster).

Let me know if you have more questions or please mark this answer as accepted if it answers your questions.

1 Like

Let me know if I understand this correct.

So, if my container i.e. my backend service is missing at first and I have an Ingress resource mapped to this particular service, a route object is not created.

However, later when my service is up and running, Kong will automatically create a route object.

Yes, that is correct.

1 Like

I had a follow up question for this issue.

Suppose, I don’t use Kong as an Ingress Controller and I use it as a normal deployment object in K8s and I configure the routes and services initially using a script inside the Kong Yaml while bootstrapping.

Now, suppose some of the containers do not exist, but they come up later like I had mentioned before, will Kong later handle this issue and create routes and service objects just like it does when Kong is deployed as an Ingress? Or do I have to again call a script or issue curl commands to the Kong Admin Api once the containers are up?

Regards,
Anushila

Please make sure that your script is either idempotent, meaning, running it multiple times has the same effect or make sure that the script is executed only once and no one changes any configuration in Kong after that. Also, make sure that the script is not executed by multiple pods at the same time. A Job would be the way to go if you’re doing this.

Kong can be used without the Ingress controller and a lot of people configure it that way, so shor t answer is yes, it’s possible…

Or do I have to again call a script or issue curl commands to the Kong Admin Api once the containers are up?

If you’re using DNS record of your service in k8s, then you don’t need to configure anything additional in Kong.

Please note that using only Routes and Services, will not provide health-checking, circuit-breaking and load-balancing.
You will need to use Upstreams along with Routes and Services to get the advantage of these features in Kong.

Also, depending on the type of your service, the DNS record in k8s will differ and features that Kong supports will differ based on how you configure your Upstream and Targets in Kong.

Please make sure to read our docs on load-balancing and health-checks and k8s docs on how it handles DNS for various types of services if you care about those features in Kong.

1 Like