Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helm
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
to be continuous...
Helm
Commits
fcd186e8
Commit
fcd186e8
authored
2 years ago
by
Pierre Smeyers
Browse files
Options
Downloads
Patches
Plain Diff
refactor: manage Helm config and cache with env
parent
698111e6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/gitlab-ci-helm.yml
+15
-23
15 additions, 23 deletions
templates/gitlab-ci-helm.yml
with
15 additions
and
23 deletions
templates/gitlab-ci-helm.yml
+
15
−
23
View file @
fcd186e8
...
...
@@ -325,10 +325,6 @@ stages:
done
}
function get_helm_opts() {
echo "${TRACE+--debug} --registry-config $CI_PROJECT_DIR/.config/helm/registry.json --repository-cache $CI_PROJECT_DIR/.cache/helm/repository --repository-config $CI_PROJECT_DIR/.config/helm/repositories.yaml"
}
function setup_kubeconfig() {
if [ -n "$1" ]; then
export KUBECONFIG="$CI_PROJECT_DIR/.kubeconfig"
...
...
@@ -345,10 +341,6 @@ stages:
# Use cacheable folders
mkdir -p "$CI_PROJECT_DIR/.config/helm/"
mkdir -p "$CI_PROJECT_DIR/.cache/helm/repository/"
ln -s "$CI_PROJECT_DIR/.cache" ~/.cache
ln -s "$CI_PROJECT_DIR/.config" ~/.config
helm_opts=$(get_helm_opts)
# Install helm repositories
for repo in $HELM_REPOS
...
...
@@ -367,7 +359,7 @@ stages:
log_info "--- login to OCI-registry \\e[32m${repo_name}\\e[0m: \\e[33;1m${registry_host}\\e[0m"
export HELM_EXPERIMENTAL_OCI=1
# shellcheck disable=SC2086
echo "$repo_password" | helm $
helm_opts
registry login "$registry_host" --username "$repo_user" --password-stdin
echo "$repo_password" | helm $
{TRACE+--debug}
registry login "$registry_host" --username "$repo_user" --password-stdin
else
log_warn "--- OCI-registry \\e[32m${repo_name}\\e[0m (\\e[33;1m${repo_url}\\e[0m) defined, but no credentials found (\$HELM_REPO_${repo_name_ssc}_USER/\$HELM_REPO_${repo_name_ssc}_PASSWORD)"
fi
...
...
@@ -376,17 +368,17 @@ stages:
then
log_info "--- add repository \\e[32m${repo_name}\\e[0m: \\e[33;1m${repo_url}\\e[0m (with user/password auth)"
# shellcheck disable=SC2086
echo "$repo_password" | helm $
helm_opts
repo add "$repo_name" "$repo_url" --username "$repo_user" --password-stdin
echo "$repo_password" | helm $
{TRACE+--debug}
repo add "$repo_name" "$repo_url" --username "$repo_user" --password-stdin
else
log_info "--- add repository \\e[32m${repo_name}\\e[0m: \\e[33;1m${repo_url}\\e[0m (unauthenticated)"
# shellcheck disable=SC2086
helm $
helm_opts
repo add "$repo_name" "$repo_url"
helm $
{TRACE+--debug}
repo add "$repo_name" "$repo_url"
fi
fi
done
# shellcheck disable=SC2086
helm $
helm_opts
repo update
helm $
{TRACE+--debug}
repo update
}
function awkenvsubst() {
...
...
@@ -438,7 +430,7 @@ stages:
log_info "--- \\e[32mpre-deploy hook\\e[0m (\\e[33;1m${prescript}\\e[0m) not found: skip"
fi
helm_opts=$
(get_helm_opts)
helm_opts=$
{TRACE+--debug}
helm_opts="$helm_opts --set ${HELM_ENV_VALUE_NAME}=$environment_type"
helm_opts="$helm_opts --set ${HELM_HOSTNAME_VALUE_NAME}=$hostname"
...
...
@@ -517,7 +509,7 @@ stages:
log_info "--- \\e[32mpre-delete hook\\e[0m (\\e[33;1m${prescript}\\e[0m) not found: skip"
fi
helm_opts=$
(get_helm_opts)
helm_opts=$
{TRACE+--debug}
if [ -f "$CI_PROJECT_DIR/.kubeconfig" ]; then
log_info "--- using \\e[32mkubeconfig\\e[0m: \\e[33;1m$CI_PROJECT_DIR/.kubeconfig\\e[0m"
...
...
@@ -553,7 +545,7 @@ stages:
log_info "--- \$environment_name: \\e[33;1m${environment_name}\\e[0m"
log_info "--- \$environment_type: \\e[33;1m${environment_type}\\e[0m"
helm_opts=$
(get_helm_opts)
helm_opts=$
{TRACE+--debug}
if [ -f "$CI_PROJECT_DIR/.kubeconfig" ]; then
log_info "--- using \\e[32mkubeconfig\\e[0m: \\e[33;1m$CI_PROJECT_DIR/.kubeconfig\\e[0m"
...
...
@@ -584,16 +576,13 @@ stages:
fi
add_helm_repositories
helm_opts=$(get_helm_opts)
# helm package
# shellcheck disable=SC2086
helm $
helm_opts
$HELM_PACKAGE_ARGS $helm_version_opts $HELM_CHART_DIR --destination helm_packages
helm $
{TRACE+--debug}
$HELM_PACKAGE_ARGS $helm_version_opts $HELM_CHART_DIR --destination helm_packages
}
function helm_publish() {
helm_opts=$(get_helm_opts)
helm_package=$(ls -1 ./helm_packages/*.tgz 2>/dev/null || echo "")
if [[ -z "$helm_package" ]]; then
log_error "No package found to deploy"
...
...
@@ -633,17 +622,17 @@ stages:
then
registry_host=$(echo "$HELM_PUBLISH_URL" | awk -F[/:] '{print $4}')
# shellcheck disable=SC2086
echo "$password" | helm $
helm_opts
registry login "$registry_host" --username "$username" --password-stdin
echo "$password" | helm $
{TRACE+--debug}
registry login "$registry_host" --username "$username" --password-stdin
# enable OCI support prior to v3.8.0
export HELM_EXPERIMENTAL_OCI=1
# shellcheck disable=SC2086
helm $
helm_opts
push "$helm_package" "$HELM_PUBLISH_URL"
helm $
{TRACE+--debug}
push "$helm_package" "$HELM_PUBLISH_URL"
else
log_info "Installing cm-push plugin (version ${HELM_CM_PUSH_PLUGIN_VERSION:-latest})..."
# shellcheck disable=SC2086
helm $
helm_opts
plugin install ${HELM_CM_PUSH_PLUGIN_VERSION:+--version "$HELM_CM_PUSH_PLUGIN_VERSION"} https://github.com/chartmuseum/helm-push || true
helm $
{TRACE+--debug}
plugin install ${HELM_CM_PUSH_PLUGIN_VERSION:+--version "$HELM_CM_PUSH_PLUGIN_VERSION"} https://github.com/chartmuseum/helm-push || true
# shellcheck disable=SC2086
helm $
helm_opts
cm-push --username "$username" --password "$password" "$helm_package" "$HELM_PUBLISH_URL"
helm $
{TRACE+--debug}
cm-push --username "$username" --password "$password" "$helm_package" "$HELM_PUBLISH_URL"
fi
;;
post)
...
...
@@ -683,6 +672,9 @@ stages:
services
:
-
name
:
"
$TBC_TRACKING_IMAGE"
command
:
[
"
--service"
,
"
helm"
,
"
3.3.2"
]
variables
:
HELM_CACHE_HOME
:
$CI_PROJECT_DIR/.cache/helm
HELM_CONFIG_HOME
:
$CI_PROJECT_DIR/.config/helm
before_script
:
-
*helm-scripts
-
install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment