我尝试使用这个 .yml 进行部署
variables:
CHART_REPOSITORY: '' # URL de repositorio de Charts de Helm.
CHART_NAME: '' # Nombre del chart en el repositorio
CHART_VERSION: '' # Versión exacta del chart, si no se especifica, se usa la más reciente
HELM_UPGRADE_EXTRA_ARGS: '' # Argumentos arbitrarios adicionales añadidos al comando helm upgrade. Ref https://helm.sh/docs/helm/helm_upgrade/#options
RELEASE_NAME: $CHART_NAME
HELM_INSTALL_IMAGE: registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/3.5.3-kube-1.16.15-alpine-3.12
ENVIRONMENT_NAME: production
VALUES_FILE: 'values.y*ml'
stages:
deploy
deploy:
stage: deploy
only:
master
main
image: $HELM_INSTALL_IMAGE
environment:
name: $ENVIRONMENT_NAME
script:
values_path=$(find . -maxdepth 1 -name "$VALUES_FILE" | head -n1)
- |
helm upgrade "$RELEASE_NAME" "$CHART_NAME" \
--namespace "$KUBE_NAMESPACE" \
${CHART_REPOSITORY:+--repo $CHART_REPOSITORY} \
${CHART_VERSION:+--version $CHART_VERSION} \
${values_path:+-f $values_path} \
--install \
--create-namespace \
--wait \
--wait-for-jobs \
$HELM_UPGRADE_EXTRA_ARGS
这就是结果
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:b95732bb43121fede653c4095be0b47d06555480ea4511ab26094b9fda503266 for registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/3.5.3-kube-1.16.15-alpine- 3.12 with digest registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/3.5.3-kube- 1.16.15-alpine-3.12@sha256:5670adc971e8698b1cafb35110277993f6c35a80eb10653c8edb52918b282882 ...
export RANCHER_APP_EXTRA_ARGS="\ # collapsed multi-line command
values_path=$(find . -maxdepth 1 -name "$VALUES_FILE" | head -n1)
helm upgrade "$RELEASE_NAME" "$CHART_NAME" \ # collapsed multi-line command
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /builds/dgti/eaf/superset-dss.tmp/KUBECONFIG
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /builds/dgti/eaf/superset-dss.tmp/KUBECONFIG
Error: release name is invalid: `your text`
Cleaning up project directory and file based variables
0:00
ERROR: Job failed: exit code 1
我明白了:
Error: release name is invalid: `your text`
这应该意味着变量
RELEASE_NAME
未正确设置。RELEASE_NAME
被分配为 $CHART_NAME
,而这在您的初始 variables
部分中也是一个空字符串。
variables:
CHART_NAME: '' # Nombre del chart en el repositorio
...
RELEASE_NAME: $CHART_NAME
您需要正确指定
CHART_NAME
的值。在本例中,它应该是您要在 Kubernetes 上部署的 Superset 的 Helm 图表的名称。
例如,如果您的 helm 存储库中有 Superset 的 helm 图表,则
CHART_NAME
应该是该图表的名称。 CHART_REPOSITORY
应该是 Superset 图表所在的 helm 存储库的 URL。
那就是:
variables:
CHART_REPOSITORY: 'https://helm-repo-url/' # URL de repositorio de Charts de Helm.
CHART_NAME: 'superset' # Nombre del chart en el repositorio
CHART_VERSION: '1.0.0' # Versión exacta del chart, si no se especifica, se usa la más reciente
HELM_UPGRADE_EXTRA_ARGS: '' # Argumentos arbitrarios adicionales añadidos al comando helm upgrade. Ref https://helm.sh/docs/helm/helm_upgrade/#options
RELEASE_NAME: $CHART_NAME
HELM_INSTALL_IMAGE: registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/3.5.3-kube-1.16.15-alpine-3.12
ENVIRONMENT_NAME: production
VALUES_FILE: 'values.y*ml'
stages:
- deploy
deploy:
stage: deploy
only:
- master
- main
image: $HELM_INSTALL_IMAGE
environment:
name: $ENVIRONMENT_NAME
script:
- |
values_path=$(find . -maxdepth 1 -name "$VALUES_FILE" | head -n1)
helm upgrade "$RELEASE_NAME" "$CHART_NAME" \
--namespace "$KUBE_NAMESPACE" \
${CHART_REPOSITORY:+--repo $CHART_REPOSITORY} \
${CHART_VERSION:+--version $CHART_VERSION} \
${values_path:+-f $values_path} \
--install \
--create-namespace \
--wait \
--wait-for-jobs \
$HELM_UPGRADE_EXTRA_ARGS
您需要将
'https://helm-repo-url/'
替换为 Helm 存储库的实际 URL,将 superset
替换为 Superset 的实际 Helm 图表名称。KUBE_NAMESPACE
已在 CI/CD 管道中的某个位置定义。 values.y*ml
应该是您希望用于配置的 Superset Helm 图表值文件的路径。
假设设置 Kubernetes 权限是为了允许 GitLab 部署到您指定的命名空间。这通常涉及创建具有适当权限的服务帐户和角色,然后为您的 GitLab CI/CD 管道使用生成的 kubeconfig。
更多信息请参阅“将 GitLab CI/CD 与 Kubernetes 集群结合使用/授权代理访问您的项目”