Multi-Stage Continuous Deployment with GitLab, Helm and Kubernetes
Creating a Helm Repository
We have different options to host our Helm repository. We can use GitHub Pages, Amazon S3, Google Cloud Storage, an OCI registry like Harbor, or even a simple web server.
GitLab also provides a built-in package registry that can be used to store charts that's what we are going to use in this guide.
We need to have the following variables defined in our environment:
GITLAB_USERNAME: Your GitLab username - we already defined it earlier.GITLAB_TOKEN: This can be a personal access token with theapiscope - we already defined it earlier too.
We have to define more variables:
PROJECT_ID: The GitLab project ID where we want to store the Helm chart. You can find the project ID in the project settings (Settings>General).
GitLab Project ID
HELM_CHANNEL: The channel where the chart will be stored. The channel can bestable,alpha,beta, or any other name you want.
Here is an example - make sure to replace the project ID with your own:
# Change the values accordingly
cat <> $HOME/.bashrc && source $HOME/.bashrc
export PROJECT_ID=61109779
export HELM_CHANNEL="stable"
EOF
We also need to define the URL where the Helm chart will be stored. This URL is generated by GitLab and it looks like this:
https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/helm/$HELM_CHANNEL/charts
Let's export this URL to our bash environment:
cat <> $HOME/.bashrc && source $HOME/.bashrc
export HELM_CHARTS_URL="https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/helm/api/$HELM_CHANNEL/charts"
EOF
Now, we can upload the Helm chart to the GitLab Package Registry:
cd $HOME/todo/app/manifests/helm/todo && \
curl \
--request POST \
--form 'chart=@todo-0.1.0.tgz' \
--user $GITLAB_USERNAME:$GITLAB_TOKEN \
$HELM_CHARTS_URL
This will upload the Helm chart to the GitLab Package Registry. You can view the index of the repository where the uploaded chart is referenced by visiting URL generated by the following command:
echoCloud Native CI/CD with GitLab
From Commit to Production ReadyEnroll now to unlock all content and receive all future updates for free.

