sách gpt4 ai đã đi

Lỗi khi tạo "deployment.yaml": Triển khai trong phiên bản "v1" không thể được xử lý như một Triển khai

In lại 作者:行者123 更新时间:2023-12-02 11:27:59 32 4
mua khóa gpt4 Nike

我是 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
cổng:
-containerPort: 80

我在文件夹容器中的 cmd 上运行了这一行:
kubectl apply -f deployment.yaml --validate=false

Error from server (BadRequest): error when creating "deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment: 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|..., bigger context ...|:"testit","version":"v01"}},"spec":{"containers":{"-name":"testit-container","image":"teejayfamo/tes|...



我什至无法从搜索中获得任何有关此的信息。我不能只是创建部署。请问,谁理解并可以让我通过?

1 Câu trả lời

您的 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
cổng:
- containerPort: 80

问题是:
  • Labels应该是 labels
  • - tên: 的语法和 - containerPorthiện hữu spec.containers 中未正确格式化部分。

  • 希望这可以帮助。

    关于docker - 创建 "deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57233686/

    32 4 0
    行者123
    Hồ sơ cá nhân

    Tôi là một lập trình viên xuất sắc, rất giỏi!

    Nhận phiếu giảm giá Didi Taxi miễn phí
    Mã giảm giá Didi Taxi
    Giấy chứng nhận ICP Bắc Kinh số 000000
    Hợp tác quảng cáo: 1813099741@qq.com 6ren.com