You typically need the following Kubernetes objects:
- Deployment
- Service
- Ingress (optional)
- ConfigMap
- Secret
- HorizontalPodAutoscaler (HPA)
- Namespace (optional)
1. Deployment (deployment.yaml)
Defines how your app is deployed (replicas, containers, image, etc.).

Why use: Ensures consistent rollout of your app with scaling and updates.
2. Service (service.yaml)
Exposes your app internally or externally.

Why use: Enables communication between pods or external access.
3. Ingress (ingress.yaml) (optional)
Handles routing and TLS termination.

Why use: Provides HTTP routing, TLS, and domain-based access.
This matches all paths that start with /. pathType: Prefix means any request starting with / (like /, /home, /about) will match.
The request is forwarded to the welcome-service on port 80.
4. ConfigMap (configmap.yaml)
Stores non-sensitive configuration.

Why use: Externalize environment variables for flexibility.
5. Secret (secret.yaml)
Stores sensitive data like passwords or API keys.

Why use: Securely manage sensitive configuration.
6. HorizontalPodAutoscaler (hpa.yaml)
Auto-scales pods based on CPU/memory.

Why use: Automatically adjusts resources based on load.
7. Namespace (namespace.yaml) (optional)
Isolates resources within the cluster.

Why use: Organizes and scopes resources for better management.
Summary of Differences & Usage
| Object | Purpose | Key Difference |
|---|---|---|
| Deployment | Manages app lifecycle | Controls replicas, updates |
| Service | Exposes app | Internal/external access |
| Ingress | Routes HTTP traffic | Domain-based routing |
| ConfigMap | Stores config | Non-sensitive data |
| Secret | Stores secrets | Sensitive data (base64) |
| HPA | Auto-scales pods | Based on metrics |
| Namespace | Logical grouping | Isolation & organization |
Leave a Reply