Introduction

In this lecture, we’ll containerize and deploy a RESTful Go microservice to a Kubernetes cluster. We’ll also learn about some important building blocks of our cluster such as Deployments, Services, ConfigMaps, Secrets, Ingresses, and the like.

Lecture

Deploying a Microservice to Kubernetes

Below, you’ll find the source code of the projects that we used in this video, links, resources, and other reference material for you learn and practice even further.

Read the Source

Below, you’ll find the zip archives of the projects and other related artifacts that we’ve covered in this article.

The Contents of the .netrc File

machine github.com
login your_github_username_comes_here
password ghp_your_github_api_key_comes_here
machine api.github.com
login your_github_username_comes_here
password ghp_your_github_api_key_comes_here

The Environment Variables

Here are the environment variables of interest that our builder script uses:

ECR_REPO=112233445566.dkr.ecr.us-west-2.amazonaws.com
ECR_IMAGE_FIZZ_CRYPTO=fizz-crypto
ECR_TAG_FIZZ_CRYPTO=0.0.15

ECR Login Script

Here’s the login script I used in the video:

aws ecr get-login-password --region us-west-2 | \
docker login --username AWS --password-stdin \
1122334455667788.dkr.ecr.us-west-2.amazonaws.com
Note

To use the above script, you need to install and configure AWS CLI first.

Resources and Additional Reading

Services We Used in the Video

Kubernetes

Kubernetes API Objects That We Saw in the Video

Containers

Container Images We Used

Building Images

Best Practices

GitHub Access Tokens

Linux

Conclusion

That was how you can containerize and deploy a Go-based microservice to a Kubernetes cluster.

We’ll have more Go programming and Kubernetes deployments in the upcoming future.

Until next time… May the source be with you 🦄.