练习 Kubernetes。
是否可以仅通过 Bash
创建 YAML
部署对象及其配置?
我试过这个:
kubectl create -f deployment.yaml
创建一个 yaml,以便我稍后可以编辑。然而它只是显示
error: the path "deployment.yaml" does not exist
最佳答案
到目前为止,所有答案都提倡实际部署到集群,然后检索正在运行的部署。
使用--dry-run
,您可以在不实际部署任何东西的情况下获取对象的 YAML 格式。例如:
kubectl create deployment nginx --image=nginx --dry-run -o yaml
将部署 YAML 输出到标准输出:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}
关于bash - 如何仅使用 bash(无编辑器)创建 Kubernetes YAML 部署对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55691110/