Fam*_*ani 11 deployment docker kubernetes
我是 DevOps 的新手。我为刚刚在 Digital Oceans 上创建的 Kubernetes 集群编写了一个 deployment.yaml 文件。创建部署不断出现我现在无法解码的错误。这只是一个测试部署,为我公司的 Web 应用程序迁移到 kubernetes 做准备。
我尝试编辑部署的内容,使其看起来像我发现的常规示例。我什至无法让这个简单的例子起作用。您可以在下面找到 deployment.yaml 内容。
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: testit-01-deployment
spec:
replicas: 4
#number of replicas generated
selector:
#assigns labels to the pods for future selection
matchLabels:
app: testit
version: v01
template:
metadata:
Labels:
app: testit
version: v01
spec:
containers:
-name: testit-container
image: teejayfamo/testit
ports:
-containerPort: 80
Run Code Online (Sandbox Code Playgroud)
我在文件夹容器中的 cmd 上运行了这一行:
kubectl apply -f deployment.yaml --validate=false
来自服务器的错误(BadRequest):创建“deployment.yaml”时出错:版本“v1”中的部署不能作为部署处理:v1.Deployment.Spec:v1.DeploymentSpec.Template:v1.PodTemplateSpec.Spec:v1.PodSpec .Containers: []v1.Container: decode slice: expect [ or n, but found {, error found in #10 byte of ...|tainers":{"-name":"t|...,更大的上下文...|:"testit","version":"v01"}},"spec":{"containers":{"-name":"testit-container","image":"teejayfamo/tes|。 ..
我什至无法从搜索中获得任何有关此的信息。我不能只是创建部署。请问,谁理解并可以让我通过?
Pan*_*kaj 44
由于这是搜索的最高结果,因此我认为应该在可能发生这种情况时添加另一种情况。就我而言,它的出现是因为数字环境中没有双引号。变种 日志确实提供了微妙的提示,但帮助不大。
日志
..., bigger context ...|c-server-service"},{"name":"SERVER_PORT","value":80}]
Run Code Online (Sandbox Code Playgroud)
环境变量- 的值SERVER_PORT需要用双引号引起来。
env:
- name: SERVER_HOST
value: grpc-server-service
- name: SERVER_PORT
value: "80"
Run Code Online (Sandbox Code Playgroud)
Kubernetes问题供参考。
mch*_*wre 11
您的 yaml 文件中存在语法错误。
这应该有效。
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: testit-01-deployment
spec:
replicas: 4
#number of replicas generated
selector:
#assigns labels to the pods for future selection
matchLabels:
app: testit
version: v01
template:
metadata:
labels:
app: testit
version: v01
spec:
containers:
- name: testit-container
image: teejayfamo/testit
ports:
- containerPort: 80
Run Code Online (Sandbox Code Playgroud)
问题是:
Labels 应该 labels- name:和的语法- containerPort格式不正确spec.containers。希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
14574 次 |
| 最近记录: |