Day 33 Task: Working with Namespaces and Services in Kubernetes
Anand Raval
CSE Undergraduate | AWS Certified Cloud Practitioner | Aspiring Cloud and DevOps | Docker | Kubernetes | Linux | Git, GitHub & GitLab | Jenkins | GCP | Application Testing & Deployment | Content Writer
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. Namespaces are intended for use in environments with many users spread across multiple teams, or projects. Services are used to expose your Pods and Deployments to the network. Read more about Namespace Here
Today's task:
Task 1:
kubectl create namespace <namespace-name>
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-deployment
namespace: deploy
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: anandraval12/django-todo-app:latest
ports:
- containerPort: 8000
kubectl apply -f deployment.yml -n <namespace-name>
kubectl get namespaces
Task 2: Read about Services, Load Balancing, and Networking in Kubernetes
In Kubernetes, a Service is an abstraction that defines a logical set of Pods and a policy by which to access them. Services provide a stable IP address and DNS name, enabling reliable communication between different parts of an application. They also facilitate load balancing traffic across the Pods, ensuring even distribution of network traffic.
Key Points:
Thank you for reading!