gpt4 book ai didi

kubernetes - Bazel k8s_deploy不将Kubernetes资源应用于集群

转载 作者:行者123 更新时间:2023-12-02 11:53:17 27 4
gpt4 key购买 nike

我有多个用于部署Kubernetes的Bazel规则

  • deployments:
  • load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
    k8s_object(
    name = "k8s_deployment",
    kind = "deployment",
    cluster = "cents-ideas",
    template = ":ideas.deployment.yaml",
    images = {
    "gcr.io/cents-ideas/ideas:latest": ":image"
    },
    )
  • services:
  • k8s_object(
    name = "k8s_service",
    kind = "service",
    template = ":ideas.service.yaml",
    )

    然后将所有这些 k8s_object放到一个像 this这样的单一 k8s_objects中:
    load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")
    k8s_objects(
    name = "k8s",
    objects = [
    ":k8s_deployment",
    ":k8s_service"
    ]
    )

    最后,我有一个运行 cloudbuild.yaml规则的 k8s_objects 文件:
    steps:
    - id: 'push docker images and deploy changes to kubernetes'
    name: gcr.io/cloud-builders/bazel
    args: ['run', '//:kubernetes']

    但是,尽管Cloud Build成功,但Kubernetes资源并未应用于集群:
    cloud build

    Here是完整的构建日志。

    因此,基本上将图像推送到容器注册表,然后记录已修改的 .yaml文件,但是 而不是应用于我的Google Kubernetes Engine集群。

    最佳答案

    我认为您需要在目标后缀“.create”或“.replace”,请参见docs

    因此,您需要以下内容:

    bazel run //:k8s.create

    其中k8s是您的目标名称。

    关于kubernetes - Bazel k8s_deploy不将Kubernetes资源应用于集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60025908/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com