Setting Up an EXTERNAL-IP for Local LoadBalancer Service

Introduction

If you've used a LoadBalancer service from a Cloud Provider, you'll know how convenient it is to have an EXTERNAL-IP assigned automatically. However, when using local Kubernetes, the default setting doesn't provide an EXTERNAL-IP. Building on our previous discussion, this guide will show you how to use `cloud-provider-kind` to assign an EXTERNAL-IP to your local LoadBalancer service.

First, make sure you've set up your local Kubernetes using Kind as outlined in my previous guide. This is necessary to proceed with the next steps.

Installing cloud-provider-kind

Since this is a Go package, you'll need to install Go first. Then, you can install the package with the following steps:

go install sigs.k8s.io/cloud-provider-kind@latest


Then execute command to use:

cloud-provider-kind

Keep in mind that you need to keep the terminal running while using Kubernetes to create the EXTERNAL-IP.


Testing with local EXTERNAL-IP

Create a deployment and expose a LoadBalancer service to check if the EXTERNAL-IP has been generated.

kubectl create deploy whoami --image traefik/whoami
kubectl expose deploy whoami --port 80 --type LoadBalancer


The results will be as follows:


You can access the EXTERNAL-IP to use it locally.


Using cloud-provider-kind as a service

If you're on Ubuntu, there's a way to automatically run cloud-provider-kind when you start your machine as a service, so you don't have to manually start it every time you want to use it.

First, navigate to the directory /etc/systemd/system and create a file called cloud-provider-kind.service with the following content:

cd /etc/systemd/system
touch cloud-provider-kind.service


[Unit]
Description = Your description
After = docker.service

[Service]
Type = simple
ExecStart = {direction to cloud-provider-kind}
StandardOutput = journal
User = {user id}
Group = {group id}

[Install]
WantedBy=multi-user.target

  • ExecStart: Use the command `which cloud-provider-kind` to replace your directory.
  • User, Group: Use the command `id` to get the appropriate values.


To start the service:

sudo systemctl enable --now cloud-provider-kind


Then check status:


If you have any suggestions or questions regarding the content of the article, please don't hesitate to leave a comment below!

Comments

Popular posts from this blog

Kubernetes Practice Series

Docker Practice Series

NodeJS Practice Series

React Practice Series

Sitemap

Setting up Kubernetes Dashboard with Kind

Deploying a NodeJS Server on Google Kubernetes Engine

Create API Gateway with fast-gateway

Explaining Async/Await in JavaScript in 10 Minutes

A Handy Guide to Using Dynamic Import in JavaScript