Skip to content

Latest commit

 

History

History
122 lines (106 loc) · 3.21 KB

README.md

File metadata and controls

122 lines (106 loc) · 3.21 KB

k8s-mongo-project

This is my first K8s project. I made this to get some hands-on experience in Kubernetes and expand my knowledge in container orchestration.

Prerequisites

  1. minikube
  2. kubectl
  3. docker

Kubernetes Architecture

k8s architecture

How to run

  1. Clone the repository
git clone https://github.com/0xt3j4s/k8s-mongo-project.git
  1. Start minikube
minikube start
  1. Create the secret
kubectl apply -f mongo-secret.yaml
  1. Create the mongodb deployment and the internal service
kubectl apply -f mongo.yaml
  1. Check the status
kubectl get all
  1. Create the configmap
kubectl apply -f mongo-configmap.yaml
  1. Create the mongo express pod and the external service
kubectl apply -f mongo-express.yaml
  1. Check the status
kubectl get all
kubectl get service
  1. Open the mongo express service
minikube service mongo-express-service

This is will generate the URL to access the mongo express service at the assigned nodePort (which is 30001 in this case).

  1. Open the URL in your browser and you will see the mongo express UI.

My outputs

  • Created the secret:

    $ kubectl apply -f mongo-secret.yaml
    secret/mongo-secret created
  • Confirmed using:

    $ kubectl get secret                
    NAME           TYPE     DATA   AGE
    mongo-secret   Opaque   2      15s
  • Creating the mongodb deployment

    $ kubectl apply -f mongo.yaml       
    deployment.apps/mongo-deployment created
  • Confirmed using:

    $ kubectl get pod         
    NAME                                READY   STATUS    RESTARTS   AGE
    mongo-deployment-845bcbf466-8v6bd   1/1     Running   0          48s
  • Creating the internal service

    $ kubectl apply -f mongo.yaml
    deployment.apps/mongo-deployment unchanged
    service/mongodb-service created

Similarly Created the configmap and the mongo express pod and the external service.

  • configmap:

    $ kubectl apply -f mongo-configmap.yaml
    configmap/mongodb-configmap created
  • Mongo express pod:

    $ kubectl apply -f mongo-express.yaml  
    deployment.apps/mongo-express created
  • External service:

    $ kubectl apply -f mongo-express.yaml    
    deployment.apps/mongo-express unchanged
    service/mongo-express-service created

Finally, opening the mongo express external service using minikube

minikube service mongo-express-service
|-----------|-----------------------|-------------|---------------------------|
| NAMESPACE |         NAME          | TARGET PORT |            URL            |
|-----------|-----------------------|-------------|---------------------------|
| default   | mongo-express-service |        8081 | http://192.168.49.2:30001 |
|-----------|-----------------------|-------------|---------------------------|
🎉  Opening service default/mongo-express-service in default browser...

The final service looks like this: mongo-express