What are Namespaces and Services in k8s
In Kubernetes, Namespaces are used to create isolated environments for resources. Each Namespace is like a separate cluster within the same physical cluster. Services are used to expose your Pods and Deployments to the network.
💥Task 1:
Create a Namespace for your Deployment
Use the command
kubectl create namespace <namespace-name>
to create a Namespace
- Update the deployment.yml file to include the Namespace
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-todo-app
namespace: node-app-deployment
labels:
app: node-app
spec:
replicas: 3
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
containers:
- name : node-app
image: sarikak/node-app-batch-6
ports:
- containerPort: 8000
- Apply the updated deployment using the command:
kubectl apply -f deployment.yml -n <namespace-name>
- Verify that the Namespace has been created by checking the status of the Namespaces in your cluster.
💥Task-2: Services, LoadBalancing, Networking in K8s
Services
Service in K8s enables access to the external network to access Pods in K8. Services select Pods based on their labels. When a network request is made to the service, it selects all Pods in the cluster matching the service's selector, chooses one of them, and forwards the network request to it.
LoadBalancing
Load balancing is a key component of Kubernetes container management. A load balancer distributes network traffic among multiple Kubernetes services, allowing you to use your containers more efficiently and maximize the availability of your services.
Networking
The Kubernetes network model provides the foundation for understanding how containers, pods, and services within Kubernetes communicate with each other. Developed by Google, networking with Kubernetes allows administrators to move workloads across private, public, and hybrid cloud infrastructures. Developers use Kubernetes to package software applications with their required infrastructure and deploy new versions quickly.
Keep growing your Kubernetes knowledge💥🙌
📚Happy Learning! :)