使用Kubernetes的Deployment功能可以方便地管理应用的部署和扩展。以下是一个简单的使用示例:
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
通过这样的方式,可以很方便地创建和管理Deployment,实现应用的快速部署和扩展。