Feedback

Chat Icon

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

Stand Up the Lab: Two Servers, a Cluster, and an App to Deploy
27%

The Registry

The most popular container registry is Docker Hub, but it is not the only one. If you are using GitLab to host your projects, the most convenient way to store your Docker images is in GitLab Container Registry. In GitLab, every project has its own container registry, which is private by default. The advantage of using GitLab Container Registry is obvious: you can store your Docker images in the same place where your code is stored. However, this could be a disadvantage as well, because you may want to keep your Docker images separate from your code, or you may want to centralize all your Docker images in a single registry.

For us, GitLab is just a tool among many others, and our focus is on learning how to integrate Argo CD with a Git repository and a container registry. We are not going to dive into all the details of GitLab and its container registry, but since we are using it, some basic configurations are required.

In the following few steps, we will configure GitLab Container Registry and push a Docker image to it.

You can use your GitLab username and password to authenticate with GitLab Container Registry, but it is not recommended. Instead, you should use a personal access token (PAT). To create one, go to your profile page, click on Preferences and then on Access Tokens. You can also use the following URL to directly access the access tokens page:

https://gitlab.com/-/user_settings/personal_access_tokens

GitLab offers two kinds of personal access token: classic scoped tokens and fine-grained tokens. Create a classic token.

Give your token a name (for example, Learning), set an expiration date, and select the api scope. Then click on Create personal access token and copy the token to your clipboard.

Export the token as an environment variable. Example:

cat << EOF >> $HOME/.bashrc && source $HOME/.bashrc
export GITLAB_TOKEN="glpat-suqzcKXzgvo3TJCjC4-e"
EOF

To log in to GitLab Container Registry, use the following command:

docker login registry.gitlab.com \
  -u $GITLAB_USERNAME \
  -p $GITLAB_TOKEN

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

Enroll now to unlock all content and receive all future updates for free.