how to setup loaderbalancer service of kubernetes in AWS

8/14/2015

i try to use AWS to setup kubernetes(version 1.0.1) and deploy a few services and pods there.

but i have got stuck with LoadBalancer service. According to the docs i just need to setup correct type of service and open ports in firewall

But service doesn't receive external IP. (ingress is empty)

Do i need to create LoadBalancer manually in AWS console? maybe some another actions?

Thanks,

-- hamsterksu
amazon-ec2
amazon-web-services
kubernetes

2 Answers

6/27/2016

This step is different whether you are using kubernetes over google cloud (where External IP is shown by issuing kubectl get svc ) or over amazon aws. After launching your cluster (aws or gcloud) then deploying your app using kubectl create -f some-deployment.yaml you issue

kubectl expose rs your-pod-name  --type="LoadBalancer"

to expose your app ... then chill a few minutes until command

kubectl get pods

responds back with column STATUS has value Running ... only then issue

kubectl get svc

which after a few minutes will show EXTERNAL-IP on gcloud as per

NAME                       CLUSTER-IP       EXTERNAL-IP       PORT(S)                   AGE
kubernetes                 10.123.240.1     <none>            443/TCP                   10m
loudspeed-deployment-210   10.123.247.54    104.196.113.166   3000/TCP,80/TCP,443/TCP   1m
mongo                      10.123.244.245   <none>            27017/TCP                 5m

whereas on aws the EXTERNAL-IP will partially display the URL of your LoadBalancer Ingress ... to see the full URL just issue

kubectl describe svc

typical output would be

Labels:         app=my-cool-app,pod-template-hash=494629853
Selector:       app=my-cool-app,pod-template-hash=494629853
Type:           LoadBalancer
IP:         10.0.154.138
LoadBalancer Ingress:   a53bigscarystring33e-20075.us-east-1.elb.amazonaws.com
Port:           port-1  80/TCP
NodePort:       port-1  30487/TCP
Endpoints:      10.244.0.3:80
Port:           port-2  443/TCP
NodePort:       port-2  32698/TCP
Endpoints:      10.244.0.3:443
Session Affinity:   None
Events:
  FirstSeen LastSeen    Count   From            SubobjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  14m       14m     1   {service-controller }           Normal      CreatingLoadBalancer    Creating load balancer
  13m       13m     1   {service-controller }           Normal      CreatedLoadBalancer Created load balancer


Name:           mongo
Labels:         name=mongo
Selector:       name=mongo
Type:           ClusterIP
IP:         10.0.63.81
Port:           <unset> 27017/TCP
Endpoints:      10.244.0.4:27017
Session Affinity:   None
No events.

note in above value of

    LoadBalancer Ingress:   a53bigscarystring33e-20075.us-east-1.elb.amazonaws.com

that is your External URL which is visible from command line using

curl a53bigscarystring33e-20075.us-east-1.elb.amazonaws.com

and is typically mapped to your publicly visible domain in your aws Route 53 console on the Resource Type A auto refreshed picklist

See details like ( we do not automatically open NodePort services in the AWS firewall) https://github.com/kubernetes/kubernetes/blob/release-1.3/docs/design/aws_under_the_hood.md

-- Scott Stensland
Source: StackOverflow

8/17/2015

The LoadBalancer should be getting created automatically.

There might be IAM policy issues preventing the load balancer from being created (see Issue #10692).

If that isn't the problem, looking for errors in /var/log/kube-controller-manager.log on the master VM may give you an idea of what is going wrong.

-- CJ Cullen
Source: StackOverflow