Skip to content

rubensgomes/k8s-ms

Repository files navigation

k8s-playground-java

I created this playground project to experiment with running Kubernetes on my local laptop.

This project comprises the following tasks:

  • Set up an Ubuntu VM on Windows 10 using Hyper-V.
  • Install a single node Kubernetes MicroK8s on an Ubuntu VM. These steps create a default cluster named "microk8s-cluster".
  • Install Kubernetes kubectl CLI tools.
  • Develop a microservice to deploy and run on a single MicroK8s node.
  • Build a containerized image of the application.
  • Push containerized image to docker.io registry.
  • Create a Kubernetes deployment manifest file.
  • Create a Kubernetes service manifest file.
  • Ensure Kubernetes processes are running.
  • Ensure a cluster with 1 (one) node is created.
  • Deploy the application.
  • Set up the corresponding Kubernetes service for the application.

Set Up Ubuntu 22.04 LTS Linux VM Using Hyper-V

For further information about Hyper-V on Windows 10, refer to Hyper-V on Windows 10.

I have a 64-bit Windows 10 Enterprise laptop, which already comes with the Hyper-V technology installed. I had enabled Hyper-V following Install Hyper-V on Windows 10.

After Hyper-V was enabled, I ran the "Hyper-V Manager" Windows 10 GUI and followed prompts to install Ubuntu 22.04 LTS. There is online documentation on how to install an Ubuntu VM on Windows 10 using Hyper-V.

After the installation, I configured several tools on my Ubuntu VM. Also, I allocated extra disk space from Windows 10 to extend the size of one of the main file system partitions in Ubuntu. Because I was running low of disk space in the "/" file system after installing Kubernetes.

Installing Single Node Kubernetes MicroK8s

I followed the documentation at Install Kubernetes on Ubuntu to install a single-node MicroK8s Kubernetes on my Ubuntu 22.04 Linux VM Windows 10 Enterprise laptop. For further information about MicroK8s, refer to MicroK8s documentation. Noticed that a default cluster named "microk8s-cluster" is created as part of the installation.

Once MicroK8s is installed, it runs as a service backend process at the start of Ubuntu. To save my laptop battery or CPU cycles, I stopped/started MicroK8s as needed using the following commands:

sudo microk8s stop
sudo microk8s start

For handy Kubernetes "mkctl" CLI commands, refer to MicroK8s Commands.

Develop a Simple Microservice Application

I created a simple Java Spring Boot microservice to deploy and run on my single MicroK8s Kubernetes. I built a Docker containerized image using my own "build.sh" and Dockerfile. For more information about the application files, configuration and how the containerized image was created, refer to the folder APP.md.

In addition to developing a simple Spring Boot microservice application, I also wrote a build.sh shell script to create a containerized image. This containerized image is created by making use of a Dockerfile, which I wrote to make use of different layers for Spring Boot classes, dependency libraries, metadata files, and the application Java classes files.

Deploying Containerized Application Image

Once a containerized image is created from running build.sh as "./build.sh -b -c -d -p -r k8s-learning-ms" following the steps in Building Containerized Image, I then set up a deployment file to deploy the containerized application to Kubernetes.


Rubens Gomes

About

A sample Spring Boot microservice deployed to local Kubernetes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published