kubernetes-orchestration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKubernetes Orchestration
Kubernetes编排
Deploy and manage containerized applications at scale with Kubernetes orchestration, services, and production patterns.
借助Kubernetes编排、服务和生产模式,大规模部署和管理容器化应用。
Core Resources
核心资源
Deployment
Deployment
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:1.0.0
ports:
- containerPort: 3000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: myapp-secrets
key: database-url
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:1.0.0
ports:
- containerPort: 3000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: myapp-secrets
key: database-url
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10Service
Service
yaml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalanceryaml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancerIngress
Ingress
yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp-ingress
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- myapp.example.com
secretName: myapp-tls
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp-service
port:
number: 80yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp-ingress
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- myapp.example.com
secretName: myapp-tls
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp-service
port:
number: 80ConfigMap
ConfigMap
yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp-config
data:
app.env: production
log.level: infoyaml
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp-config
data:
app.env: production
log.level: infoBest Practices
最佳实践
- Use namespaces for organization
- Implement resource limits
- Use liveness and readiness probes
- Manage secrets properly
- Use StatefulSets for stateful apps
- Implement network policies
- Use Helm for packaging
- Monitor with Prometheus
- 使用Namespace进行资源组织
- 配置资源限制
- 配置存活探针和就绪探针
- 妥善管理Secret
- 为有状态应用使用StatefulSet
- 配置网络策略
- 使用Helm进行应用打包
- 借助Prometheus进行监控