IKS Deployment Patterns #3: Multi-Zone Cluster, App exposed via LoadBalancer Using In-zone Backends Only

How can I deploy and expose my application in my IBM Cloud Kubernetes Service (IKS) directly with the LoadBalancer service in a multi-zone cluster, but only use local endpoints that live in the same availability zone?

Example Deployment Pattern

In this article we are going to go through the steps to deploy an example application with the following deployment pattern bellow:

Steps

  1. Sign up and create a multi-zone IKS cluster using the IBM Cloud Console. Documentation on deploying a cluster and specifically how multi-zone clusters work. Important: you have to use the paid tier.
  2. Download and apply the the following example Deployment and Service resource yaml, which will expose the echoserver application via the LoadBalancer service on port 1884 in three availability zones you specify in the yaml.
    $ kubectl apply -f iks_multi-zone_cluster_app_via_LoadBalancer_using_local_endpoints_only.yaml Note: do not forget to edit the lines marked with NEED TO EDIT!
  3. Check the IP address of the LoadBalancer service:

Test the App

  1. To test load the IP:port you specified in your browser or initiate curl commands (like my example): 
    $ curl http://{your IP here}:1884/
  2. You shall see a response like the following. (Run it for each LoadBalancer IP address.)

You can see the source IP address in the client_address field because we applied the externalTrafficPolicy: Local in the LoadBalancer Service resource.

Summary

As you learn more about your workload you can adjust and even switch between patters as needed. Different applications will require different patterns; please let us help you with your pattern! To read about other patterns follow this link to the IBM Cloud Blog or this on Medium.com.

Contact us

If you have questions, engage our team via Slack by registering here and join the discussion in the #general channel on our public IBM Cloud Kubernetes Service Slack.