同步 · dev.to / @markyu
A practical Kubernetes guide for developers: pods, deployments, services, config, scaling, and when not to introduce Kubernetes too early.
- 发布日期
- May 4 '24
- 阅读时长
- 2 min read
- 点赞
- 6
kubernetesdevopscontainerscloud
Kubernetes is not the first tool I reach for.
That may sound strange in 2026, but I still think many teams adopt Kubernetes before their deployment pain is real enough.
Kubernetes helps when you need orchestration. It hurts when you just wanted a place to run one container.
What Kubernetes Actually Gives You
Kubernetes helps manage:
- container scheduling
- restarts
- scaling
- service discovery
- rollout strategy
- configuration
- workload isolation
The basic shape:
Deployment
|
v
ReplicaSet
|
v
Pods
|
v
ContainersMost beginner confusion comes from mixing up those layers.
The Smallest Useful Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 2
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: nginx:1.27
ports:
- containerPort: 80Apply it:
kubectl apply -f deployment.yaml
kubectl get podsThis does not expose the app yet. It only runs pods.
Add a Service
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
selector:
app: api
ports:
- port: 80
targetPort: 80
type: ClusterIPThe service gives stable networking inside the cluster.
client -> service -> matching podsPods can die and come back with different IPs. The service keeps the route stable.
The Debug Commands I Use First
kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl get events --sort-by=.lastTimestamp
kubectl rollout status deployment/apiIf a pod is stuck in CrashLoopBackOff, I look at logs first.
If it is stuck in Pending, I look at describe/events because it may be scheduling, resources, or image pulling.
Config and Secrets
Do not bake environment-specific config into images.
Use ConfigMaps for normal config:
apiVersion: v1
kind: ConfigMap
metadata:
name: api-config
data:
LOG_LEVEL: "info"Use Secrets for sensitive values, but remember: Kubernetes Secrets are not magic encryption by default. Treat cluster access seriously.
When Kubernetes Is Worth It
I would consider Kubernetes when:
- you run many services
- rollouts need control
- autoscaling matters
- workloads need scheduling
- multiple teams share a platform
- you already have observability
I would avoid it when:
- one app can run fine on managed PaaS
- nobody owns cluster operations
- logs and metrics are weak
- the team has no deployment discipline yet
Cloud-native 3.0 is making Kubernetes more platform-like, especially with internal developer portals and AI-assisted operations. Still, the fundamentals have not changed: a confusing cluster is not a platform.
Final Thought
Kubernetes is powerful because it standardizes operational patterns. It is painful because it exposes every weak operational habit your team already had.
What was your first Kubernetes failure: image pull, config, networking, or resources?
相关阅读
Cloud Architecture Choices I Would Not Overcomplicate
A practical 2026 cloud architecture guide for developers choosing between client-server, distributed systems, microservices, serverless, and cloud-native platforms.
cloud
Sustainable Cloud Design Starts With Boring Cost Signals
A practical cloud sustainability guide for developers: right-sizing, autoscaling, regions, storage lifecycle, carbon-aware thinking, and cost visibility.
cloud
Docker Containers: The Commands That Prove Isolation
A practical Docker container guide focused on the commands that show image layers, process isolation, networking, volumes, and debugging.
docker
原文发布
本文首发于 dev.to,评论与点赞保留在原站。
在 dev.to 继续阅读