gpt4 book ai didi

kubernetes - 云构建kubectl-如何将上一步的输出应用于Kubernetes集群

转载 作者:行者123 更新时间:2023-12-02 11:51:50 25 4
gpt4 key购买 nike

我有一个运行Bazel命令的简单cloudbuild.yaml文件。该命令以日志输出形式返回Kubernetes配置。

我的目标是取得第一步的输出,并将其应用于我的Kubernetes集群。

steps:
- name: gcr.io/cloud-builders/bazel
args: ["run", "//:kubernetes"]

- name: "gcr.io/cloud-builders/kubectl"
args: ["apply", "<log output of previous step>"]
env:
- "CLOUDSDK_COMPUTE_ZONE=europe-west3-a"
- "CLOUDSDK_CONTAINER_CLUSTER=cents-ideas"

更新资料

我尝试了以下方法:
- name: gcr.io/cloud-builders/bazel
entrypoint: /bin/bash
args:
[
"bazel",
"run",
"//:kubernetes",
" > kubernetes.yaml",
]

- name: "gcr.io/cloud-builders/kubectl"
args: ["apply", "-f", "kubernetes.yaml"]
env:
- "CLOUDSDK_COMPUTE_ZONE=europe-west3-a"
- "CLOUDSDK_CONTAINER_CLUSTER=cents-ideas"

但是然后我得到这个错误:
Running: kubectl apply -f kubernetes.yaml
error: the path "kubernetes.yaml" does not exist

最佳答案

正如大家已经在这里建议使用volumes

像这样调整您的cloudbuild.yaml文件:

- name: gcr.io/cloud-builders/bazel
entrypoint: /bin/bash
args:
[
"bazel",
"run",
"//:kubernetes",
" > /workspace/kubernetes.yaml",
]

- name: "gcr.io/cloud-builders/kubectl"
args: ["apply", "-f", "/workspace/kubernetes.yaml"]
env:
- "CLOUDSDK_COMPUTE_ZONE=europe-west3-a"
- "CLOUDSDK_CONTAINER_CLUSTER=cents-ideas"

关于kubernetes - 云构建kubectl-如何将上一步的输出应用于Kubernetes集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60028532/

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