Sock-shop on GCP with Loadbalancer

11/19/2018

I am trying to deploy and access Sock-shop on Google Cloud Platform. https://github.com/microservices-demo/microservices-demo

I was able to deploy it using the deployment script https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml

Based on the tutorial here https://www.weave.works/docs/cloud/latest/tasks/deploy/sockshop-deploy/ It says Display the Sock Shop in the browser using:

<master-node-IP>:<NodePort>

But on GCP master node is hidden from the user.

So I changed the type from NodePort to LoadBalancer.

And I was able to get an external IP.

But it says the page cannot be found. enter code here

Do I need to set up more stuff for LoadBalancer?

-- Jae Kim
google-cloud-platform
kubernetes
load-balancing

2 Answers

11/19/2018

I would recommend to return back for NodePort in the corresponded Service and create Ingress resource in your GCP cluster.

If you desire to access the related application from outside the cluster, Kubernetes provides Ingress mechanism to expose HTTP and HTTPS routes to your internal services.

Basically, HTTP(S) Load Balancer is created by default in GKE once Ingress resource has been implemented successfully, therefore it will take care for routing all the external HTTP/S traffic to the nested Kubernetes services.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: basic-ingress
spec:
  backend:
    serviceName: web
    servicePort: 8080

You can check the External IP address for Load Balancer by the following command:

kubectl get ingress basic-ingress

I found this Article would be very useful in your common research.

-- mk_sta
Source: StackOverflow

12/11/2018

I dont know If you solve the issue but I did it so I would like to share with you my solution that works for me. You can do it through two ways:

1st) By creating a Load Balancer, where you expose the front-end service. I assume that you have already created a namespace called sock-shop so any further command should specify and referred to that namespace. If you type and execute the command: kubectl get services --namespace=sock-shop you should be able to see a list with all the services included a service called "front-end". So now you want to expose that service not as NodePort but as LoadBalancer. So, execute the command: kubectl expose service front-end --name=front-end-lb --port=80 --target-port=8079 --type=LoadBalancer --namespace=sock-shop After this give some time and you will able to access the Front end of the Sock Shop via public IP address (ephimeral)

2nd) More advanced way is by configuring an Ingress Load Balancer. You need to configure another yaml file and put this code inside and run it as you did with the previous .yaml file.

nano basic-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace : sock-shop
  name: basic-ingress
spec:
  backend:
    serviceName: front-end
    servicePort: 80

kubectl apply -f basic-ingress.yaml --namespace=sock-shop

Locate the Public IP address through this command and after maximun 15mins you should be able to access the Sock Shop.

kubectl get ingress --namespace=sock-shop
-- Ab.avramidis
Source: StackOverflow