1 – If you delete cluster then all data get deleted?
No, the Persistent Volume is not deleted because it is stored separately from the Pod. This is one of the main purposes of using a Persistent Volume — to retain data even if the Pod is deleted or recreated.
2 .Difference Between kubectl apply
vs kubectl create
Command | Description | Use Case |
---|---|---|
kubectl create | Creates a new resource | Use only when the resource does not exist |
kubectl apply | Creates or updates a resource | Use when you may modify configs and want to re-apply |
✅ kubectl create
– One-time creation
kubectl create -f deployment.yaml
- Creates the resource from
deployment.yaml
- ❌ Will fail if the resource already exists: pgsqlCopyEdit
Error from server (AlreadyExists): deployments.apps "my-app" already exists
kubectl apply
– Declarative & idempotent
bashCopyEditkubectl apply -f deployment.yaml
- If the resource doesn’t exist, it creates it
- If it exists, it updates it based on the changes in the YAML
- Supports declarative configuration (preferred in GitOps, CI/CD)
Best Practice
Use
kubectl apply
for all YAML-based deployments in production and CI/CD pipelines — it’s declarative, idempotent, and update-friendly.
why we dont use replication controller in aks
We don’t use ReplicationController in AKS (Azure Kubernetes Service) or modern Kubernetes clusters because it is deprecated and replaced by more advanced controllers like Deployments and ReplicaSets.
Here’s a breakdown of why ReplicationController is not used in AKS or modern Kubernetes environments:
🔄 1. ReplicationController is Obsolete
- ReplicationController (RC) is the original controller to manage the number of pod replicas.
- It is now replaced by ReplicaSet, which offers more features and better support in current Kubernetes versions.
🚀 2. Deployment is the Standard Way
- In AKS (and all modern Kubernetes setups), we use Deployments which manage:
- Rolling updates
- Rollbacks
- Declarative pod updates
- Deployments automatically use ReplicaSet internally to manage pod replicas.
⚙️ 3. Advanced Features Missing in RC
ReplicationController does not support:
- Rollback of versions
- Canary or blue/green deployments
- Strategies for zero-downtime upgrades
- Label selectors as flexible as ReplicaSet
✅ Summary: Use Deployment Instead
Feature | ReplicationController | ReplicaSet | Deployment |
---|---|---|---|
Manages pod replicas | ✅ | ✅ | ✅ |
Rolling updates | ❌ | ❌ | ✅ |
Rollbacks | ❌ | ❌ | ✅ |
Recommended in AKS | ❌ | ⚠️ (used by Deployment) | ✅ |
What is an Annotation?
Annotations are key-value pairs, like labels.
Unlike labels, they are not used for selection (e.g., no selector.matchAnnotations
).
Instead, they are used to store extra metadata that might be:
- Used by tools
- Referenced by controllers or policies
- Just informational
🆚 Labels vs Annotations
Feature | Labels | Annotations |
---|---|---|
Used for selecting/filtering | ✅ Yes | ❌ No |
Max size | Small (~63 chars per key/value) | Larger (up to ~256KB) |
Purpose | Identify objects | Store metadata/config for tools |
Used by controllers/tools | ✅ Sometimes | ✅ Frequently |
🛠️ How to Add an Annotation
Example in YAML:
yamlCopyEditapiVersion: v1
kind: Pod
metadata:
name: my-pod
annotations:
example.com/maintainer: "team@example.com"
spec:
containers:
- name: nginx
image: nginx