使用Kubernetes的Deployment功能可以方便地管理應(yīng)用的部署和擴(kuò)展。以下是一個(gè)簡單的使用示例:
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 3
selector:
matchLabels:
app: example-app
template:
metadata:
labels:
app: example-app
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
kubectl apply -f deployment.yaml
kubectl get deployments
kubectl scale --replicas=5 deployment/example-deployment
通過這樣的方式,可以很方便地創(chuàng)建和管理Deployment,實(shí)現(xiàn)應(yīng)用的快速部署和擴(kuò)展。