How to access multiple services deployed (Spring boot app) in google Kubernetes?

10/29/2018

I created 2 simple spring boot application and deployed in Google Kubernetes using a docker container by referring this link : Deploy spring boot in Kubernetes

Now when I run kubectl get services i can see 2 services(Spring boot applications) listed!

I understand that using expose I can reserve a static IP for the services! But What I need is ** I need to access two services using Single IP** (Similar to routing) so that end-user need only be known about one IP address for the multiservices! How could I achieve that? I am very new to this! Please help..

-- Dillz
google-kubernetes-engine
kubernetes
spring-boot

2 Answers

10/29/2018

The easiest way to access your services publicly, using the same IP address, would be to use the ingress-controller and Ingress resource. This will allow you to use dns based hostnames and/or path matching to access each service individually.

I have an easy to use starter repository that I recommend you use to get started. Simply run the following commands:

Install the ingress-controller:

$ git clone https://github.com/mateothegreat/k8-byexamples-ingress-controller
$ cd k8-byexamples-ingress-controller
$ git submodule update --init

$ make install LOADBALANCER_IP=<your static ip here>

Create your Ingress resource:

$ make issue HOST=<your dns hostname> SERVICE_NAME=<your service> SERVICE_PORT=<the service port>

You can repeat this last step as many times as you need. For additional information you can go to https://github.com/mateothegreat/k8-byexamples-ingress-controller.

-- yomateo
Source: StackOverflow

10/31/2018

You can use GCE Ingress resource so that both services are used as backends.

As mentioned in Patrick's comment above, convert both services to type: NodePort instead of LB. Verify that a node port was allocated.

kubectl get service web

and then create ingress with 2 host paths.

The following documentation will help you get started:

-- arp-sunny.
Source: StackOverflow