Day 9 : Deploying Microservices on Kubernetes - Project Journey
Tags: microservices, kubernetes, devops, beginners
Published: 2024-07-09 23:06:30

Hey guys, it's Day 9 of my SRE and Cloud Security journey, and I'm pumped to share what I accomplished today! I successfully deployed a three-microservice application on Kubernetes – it was definitely a challenge, but I tackled it head-on and learned a ton in the process.  Let's just say, I had more than a few "oh, no, not again" moments, but I emerged victorious, and that's what matters! 

I'm excited to share the challenges I faced, the solutions I implemented, and everything in between. Buckle up, because this journey is packed with valuable insights, and maybe even a few laughs along the way. I hope it inspires you as much as it inspired me to take on this project. Let's dive in! 


**Project Structure:**

- **bookstore/**
  - **deployments/** (deployment YAML files for each microservice)
  - **services/** (service YAML files for each microservice)
  - **ingress/** (`ingress.yaml` for external access)
  - **README.md** (setup and deployment instructions)

**Setting Up the Kubernetes Cluster:**

- Installed Minikube (`minikube start`) for a local single-node cluster. It was like setting up a mini-city for my microservices!
- Verified cluster status with `kubectl cluster-info`.  Just ensuring everything ran smoothly, like checking if the traffic lights were working in my Lagos city. 

**Deploying Microservices:**

- Applied deployment YAML files (`kubectl apply -f deployments/<file>`) for each microservice. It was like sending my microservices to their new homes in the Kubernetes city.
- Defined and applied service YAML files (`kubectl apply -f services/<file>`) for internal and external access.  Now my microservices could interact with each other and the outside world.

**Configuring Ingress:**

- Created and applied `ingress.yaml` to route external traffic using annotations and hostnames.  This was like building a grand entrance to my microservices city, making it easy for visitors to find their way around. 

**Challenges:**

- **Image Pull Issues:** Incorrect image names/tags led to `ImagePullBackOff` and `ErrImagePull` errors.  It was like finding the right address in a city with confusing street signs.
- **Networking Configuration:** Connectivity problems between microservices due to incorrect service configurations.  It was like trying to build a network of roads without a proper map. 
- **Ingress Setup:** Difficulties exposing microservices externally due to incorrect Ingress configuration.  It was like trying to build a grand entrance without knowing where the door should go.

**Solutions:**

- **Image Pull:** Verified image names/tags, corrected deployment files, and ensured images were available in the registry.  I finally found the right street signs and made sure the addresses were correct.
- **Networking:** Updated service configurations with appropriate service types (ClusterIP, LoadBalancer).  I got my hands on a proper map and built the roads correctly.
- **Ingress:** Configured Ingress with correct annotations, host definitions, and ensured the Ingress controller was properly set up.  I finally found the right spot for the door and built a grand entrance that everyone could admire.

**Additional Challenge:**

- **Host File Modification:** Since I didn't have a domain name, I had to manually add the generated IP address of my Kubernetes cluster to the host file on my Windows machine. This involved opening the host file (`C:\Windows\System32\drivers\etc\hosts`) as administrator, adding the IP address and desired domain name, and saving the changes.  It was like adding a new address to my own personal map to find my way to my microservices city.

**Conclusion:**

Day 9 involved deploying microservices on Kubernetes, overcoming image pull, networking, and Ingress configuration challenges. The host file modification was an additional step to access the cluster using a custom domain name. This project reinforced my understanding of Kubernetes deployments and the importance of thorough configuration and troubleshooting.  I'm feeling pretty confident now, like I've got the map to my microservices city memorized!