Microservices K8 Ready
- Anand Nerurkar
- Jul 14, 2022
- 1 min read
Updated: Sep 13, 2023
How To Make Microservices Kubernetes Ready
Prerequisite
· Kubernetes
· Docker
· K8 cluster-will make use of GCP K8 cluster

Sample Microservices Architecture
· K8 Deployment
· K8 services
· K8 loadbalancer type for exposing services
·

kubectl comand
---
kubectl cluster-info
kubectl get node
kubectl create deployment deployment-name --image=image name --port=8080
kubectl get deployment
kubectl describe deployment deployment-name
kubectl get pods
kubectl logs nameofpod
# in a namespace
kubectl api-resource --namespaced=true
#not in a namespace
kubctl api-resource --namespaced=falseV
expose deployment
==
kubectl get deployments
kubectl expose deployment deployment-name --type=NodePort
kubectl get service
Kubenetes Namespaces
===
default namespace is virtual cluster withinh k8 cluster. It is normally for system realted work, we should not store our application in this namespace.

Better Approach
==

Below are the k8 default namespaces
kubectl get namespaces

Namespace type
====
deafult
if namepace is not defined,then all resources will be tagged to default namespace.
kube-system
This is reseved for k8 resources while creating k8 cluster
for eg: Master Node- API Server,Controller Manager,Schedular,ETCD
Worker Node - Kubelet,kubeproxy
It is not recommended to use this namespace for our application resources like pod,deployment,service etc....
kube-public
This is open for all, it has all cluster information.Everyone can read and access this namespace.
kube-node-lease
This is associated with lease object for each node and improve the performance of node and heartbeats.

We can create our namespace and application resources will be tagged to that namespace.


#to create namespace
kubectl create namespace my-namespace
# to deploy resources in my-namespace
kubectl apply -f deploy.yml --namespace=my-namespace
# to get resources in my-namespace
kubectl get deployment -n my-namespace
kubectl get pods -n my-namespace

Comments