This project is about kubernetes deployment for E-commerce backend.
The E-commerce backend project link (https://github.com/purbo75/E-Commerce-site-BackEnd-with-Node-js.git )
Basically this is beginner level project for kubernetes.One can hello with kubernetes by doing this project.
This is a simple project where a docker image run from kubernetes. A docker image named purbo75/backend from dockerhub run on a deployment file(server-deployment.ymal) .For this Deployment, A Service is exposed from server-cluster-service.yaml. To access this service, ingress-ngins is configured from ingress service.yaml.
To configured domain name edit /etc/hosts with the minikube ip.
The docker image return a list of json product list(/api/products).
- Docker
- Kubernetes
- Minikube
To install minikube :
sudo apt-get update
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start
The commands to run the deployment on Ubuntu -
To start minikube:
minikube start
To enable ingress-nginx:
kubectl addons enable ingress-nginx
or
minikube addons enable ingress-nginx
kubectl apply -f FileName
kubectl command-
To get the pods information
kubectl get pods
To get the service information
kubectl get services
To get all service regardless of all name-space
kubectl get svc -A
To edit ingress-nginx service type
kubectl edit service ingress-nginx-controller -n ingress-nginx
then edit the spec.type(as example one has to change it from Nodeport to Loadbalancer, just edit the type).
To get the namespace information
kubectl get ns
To get the pod's log
kubectl logs pod_name
To restart a pod:
kubectl rollout restart deployment pod_name
To get the logs of ingress- nginx controller:
kubectl logs -n ingress-nginx ingress-nginx-controller_name
To set service to a local port:
kubectl port-forward service/server-cluster-ip-service local_port:service's port
To execute command on pod's bash:
kubectl exec --stdin --tty pod_name -- sh