k8s deployment 清单
时间: 2023-07-22 20:15:01 浏览: 104
当您创建一个Kubernetes Deployment时,您需要提供一个清单(manifest)来定义Deployment的配置。以下是一个示例清单,展示了如何创建一个简单的Deployment:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-deployment
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: my-app-image:latest
ports:
- containerPort: 80
```
这个清单定义了一个名为"my-app-deployment"的Deployment,它包含了3个副本,使用了一个名为"my-app"的标签选择器来选择Pod,以及一个包含了一个容器的Pod模板。容器使用名为"my-app-container"的镜像,并且将容器的80端口暴露出来。
您可以将上述清单保存为一个名为"my-app-deployment.yaml"的文件,并使用`kubectl apply`命令来创建该Deployment:
```
kubectl apply -f my-app-deployment.yaml
```
请注意,这只是一个示例,您可以根据您的应用程序的需求进行调整和扩展。
阅读全文
相关推荐
















