Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

8.3.4.2.2. 手动添加源克隆 secret

通过将 sourceSecret 字段添加到 BuildConfig 内的 source 部分,并将它设置为您要创建的 secret 的名称(本例中为 basicsecret),您可以手动将源克隆 secret 添加到构建配置中。

apiVersion: "v1"
kind: "BuildConfig"
metadata:
  name: "sample-build"
spec:
  output:
    to:
      kind: "ImageStreamTag"
      name: "sample-image:latest"
  source:
    git:
      uri: "https://github.com/user/app.git"
    sourceSecret:
      name: "basicsecret"
  strategy:
    sourceStrategy:
      from:
        kind: "ImageStreamTag"
        name: "python-33-centos7:latest"
注意

您还可以使用 oc set build-secret 命令在现有构建配置上设置源克隆 secret:

$ oc set build-secret --source bc/sample-build basicsecret

在 BuildConfig 中定义 Secret 提供了有关此主题的更多信息。