4

I'm just learning Kubernetes and I'd like to avoid spending money on Elastic Load Balancing while running it on AWS.

Here's the command I use to install Kubernetes:

kops create cluster \
    --cloud aws \
    --name ${MY_KUBE_NAME}.k8s.local \
    --state s3://${MY_KUBE_NAME} \
    --master-count 1 \
    --master-size ${MY_KUBE_MASTER_AWS_INSTANCE_SIZE} \
    --master-volume-size ${MY_KUBE_MASTER_AWS_VOLUME_SIZE} \
    --master-zones ${MY_KUBE_AWS_ZONE} \
    --zones ${MY_KUBE_AWS_ZONE} \
    --node-count 1 \
    --node-size ${MY_KUBE_WORKER_AWS_INSTANCE_SIZE} \
    --node-volume-size ${MY_KUBE_WORKER_AWS_VOLUME_SIZE}

After running that command I can see a load balancer gets created through Amazon's ELB service.

Generally, that all worked well for me and then I could use kubectl to monitor and manage my cluster and also install Kubernetes Dashboard with its help. But one thing I don't like is that kops makes use of ELB. That was ok in the beginning and I used the URL provided by the load balancer to access the dashboard. Now I believe I can avoid using ELB to cut down my expenses on AWS. Could you please tell me how I can use kops create cluster without any ELB but still be able to connect to my cluster and dashboard from my local machine?

Susha
  • 65
  • 6

1 Answers1

1

The LB is needed to talk to the kube-apiserver which runs on the master. You can bypass that by deleting the ELB from the AWS console and modifying your configs to talk directly to the public or private IP of your master. You might have to re-issue your certificates on the master so that you can talk to the new IP address. Kops creates an ELB because that's more a standard 'production' ready type of practice and also it's compatible if you have more than one master. In other words, it's still recommended to have that ELB.

As far as the dashboard, generally, the dashboard is exposed as a Kubernetes LoadBalancer Service in AWS that creates an ELB. You can simply delete the service and the load balancer should be deleted.

$ kubectl delete svc <your-dashboard-svc>

Now if you want to avoid creating a load balancer on a service you just create a service with a ClusterIP or a NodePort. Then you can access your service using something like kubectl proxy.

Rico
  • 58,485
  • 12
  • 111
  • 141
  • But even if I don't add the dashboard to Kubernetes at all `kops` is still making use of ELB to create the cluster itself using the `kops create cluster` command. So, that is not the dashboard that creates ELB in my case. It is `kops` that does it. – Susha Jan 11 '19 at 02:11
  • I've just edited my question a bit to emphasize on that. – Susha Jan 11 '19 at 02:39
  • I suppose it's the elb to access the kube-apiserver from the outside, added more details – Rico Jan 11 '19 at 06:07
  • Yeah, I understand. `kops` is just not meant to run a production-grade cluster without a load balancer. I would need to implement a hack around it or look for another tool for that matter. I stumbled upon a similar issue when I wanted to use `kops` to run a cluster on a single host and it turned out that `kops create cluster` with `--node-count=0` gets reset to its default value of `2`. So, I needed to use `--dry-run --output=yaml` to save the config to a file and edit values for `minSize`/`maxSize` with the `sed` command, and only after that use `kops create -f` to actually start the cluster. – Susha Jan 12 '19 at 06:27