Skip to content

This project demonstrates microservices orchestration using Kubernetes, enabling seamless deployment, scaling, and management of multiple microservices. It includes Spring Boot microservices deployed in a Kubernetes cluster using Config Server, Service Discovery (Eureka), and Load Balancing.

Notifications You must be signed in to change notification settings

AkashBhuiyan/microservice-container-orchestration-kubernetes

Repository files navigation

Kubernetes Dashboard

This image shows the Kubernetes Dashboard with deployed microservices.

Kubernetes Dashboard

Kubernetes Dashboard Documentation

K8s Dashboard Documentation

Helm Installation

Helm Installation Guide

Dashboard Installation

helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard

Port Forwarding for Dashboard Access

kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443

Create Dashboard Admin User

kubectl apply -f dashboard-adminuser.yaml

Role Binding for Admin User

kubectl apply -f dashboard-rolebinding.yaml

Create Secret for Admin User

kubectl apply -f secret.yml

Create Token for Admin User

kubectl -n kubernetes-dashboard create token admin-user

Create Bearer Token for Access by a Single Token

kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath="{.data.token}" | base64 -d

Kubernetes Commands

kubectl get deployments
kubectl get services
kubectl get replicaset
kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl get pods -o wide

Create Docker Images from the Git Project

Follow the steps mentioned in this link repository to create Docker images for this Kubernetes project from the Git repository: microservice-architecture-java.

Create Environment Variable in Kubernetes Cluster

kubectl apply -f configmaps.yml

Order of Deployment

To ensure services are deployed in a structured manner, the following order should be followed:

  1. Keycloak - Identity and access management service.
  2. ConfigMaps - Configuration for environment variables and other settings.
  3. ConfigServer - Centralized configuration management service.
  4. EurekaServer - Service registry for microservices.
  5. accountsdb - Database for microservices.
  6. cardsdb - Database for microservices.
  7. loandb - Database for microservices.
  8. Accounts - Microservice handling account-related operations.
  9. Loan - Microservice managing loan-related functionalities.
  10. Cards - Microservice handling card-related processes.
  11. Gateway - API Gateway for routing requests to services.

Deploying Applications in Kubernetes

To deploy microservices and applications in a Kubernetes cluster, the appropriate YAML manifest files should be created and applied. Each microservice and configuration must be properly defined before deployment.

Deployment Commands

kubectl apply -f keycloak.yml
kubectl apply -f configserver.yml
kubectl apply -f eurekaserver.yml
kubectl apply -f accountsdb.yml
kubectl apply -f cardsdb.yml
kubectl apply -f loandb.yml
kubectl apply -f accounts.yml
kubectl apply -f loan.yml
kubectl apply -f cards.yml
kubectl apply -f gateway.yml

Scale Deployments

kubectl scale deployment accounts-deployment --replicas=2

Retrieves detailed information about the specified Pod and Displays its status, events, conditions, logs, and resource usage.

kubectl describe pod <pod-name>

Updates the container image and Triggers a rolling update

kubectl set image deployment/<deployment-name> <container-name>=<new-image-name>:<new-image-tag>

Example:

kubectl set image deployment gatewayserver-deployment gatewayserver=akash9229/gatewayserver:v2

Rolling Update

kubectl rollout restart deployment <deployment-name>

Check if the new image is being used:

kubectl get deployment gatewayserver-deployment -o wide

Retrieves and displays Kubernetes events in the default namespace, sorted by creation time (oldest first), helping debug issues and track cluster activities and events.

kubectl get events -n default --sort-by=.metadata.creationTimestamp

Delete a Pod

kubectl delete pod <pod-name>

Delete a Deployment

kubectl delete deployment <deployment-name>

Delete a Service

kubectl delete service <service-name>

View Logs for a Pod Continuously

kubectl logs -f <pod-name>

View Resource Utilization of Pods

kubectl top pod

View Resource Utilization of Nodes

kubectl top node

Check Running Namespaces

kubectl get namespaces

Get All Resources in a Namespace

kubectl get all -n <namespace>

Apply All Configurations in a Directory

kubectl apply -f ./k8s/

Troubleshooting: Debug a Failing Pod

kubectl exec -it <pod-name> -- /bin/sh

Restart a Pod

kubectl delete pod <pod-name> --grace-period=0 --force

Check the Current Context

kubectl config current-context

Switch Kubernetes Contexts

kubectl config use-context <context-name>

List Available Kubernetes Contexts

kubectl config get-contexts

Create a New Kubernetes Context

kubectl config set-context <context-name> --cluster=<cluster-name> --user=<user-name> --namespace=<namespace-name>

Delete a Kubernetes Context

kubectl config delete-context <context-name>

Delete All Kubernetes Contexts

kubectl config delete-context <context-name>

List All Kubernetes Contexts

kubectl config get-contexts

Create a New Kubernetes Cluster

kubectl config set-cluster <cluster-name> --server=<cluster-server> --certificate-authority=<path-to-ca-cert>

About

This project demonstrates microservices orchestration using Kubernetes, enabling seamless deployment, scaling, and management of multiple microservices. It includes Spring Boot microservices deployed in a Kubernetes cluster using Config Server, Service Discovery (Eureka), and Load Balancing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published