GitOps
GitOps setup with ArgoCD
Last updated
Was this helpful?
GitOps setup with ArgoCD
Last updated
Was this helpful?
This page provides a detailed overview of how to set up the GitOps functionality for Seldon Enterprise Platform. Setting up GitOps is highly recommended.
Seldon Enterprise Platform leverages to implement GitOps in your cluster. You can read more about Seldon Enterprise Platform's GitOps integration in the and sections.
This documentation page will walk you through the different steps required to set up ArgoCD and GitOps in your cluster. Note that this guide assumes a fresh cluster without ArgoCD, thus it must only be treated as a general reference. Feel free to adapt these steps to your particular infrastructure.
Download the .
Verify the .
Install .
Install .
Since this guide assumes that you currently don't have ArgoCD installed in your cluster, the first step will be on installing and configuring it. You can treat these steps as a quick way to get started with ArgoCD. Therefore, it is highly encouraged to check for further configuration.
To install and configure ArgoCD we will first install their official K8s manifest into our cluster. For version v2.6.7
of ArgoCD, this can be done as follows:
Now that we have ArgoCD installed in our cluster, the next step will involve configuring it so that:
The admin user credentials get changed.
SSL termination is disabled in ArgoCD.
ArgoCD gets exposed under the /argocd/
path of our load balancer.
This command requires htpasswd
that can be installed on Ubuntu, Debian and Mint systems with:
As a general choice, we recommend to handle SSL termination at the ingress / load balancer level. This simplifies the components setup within the cluster.
Following this approach, we will need to disable the SSL termination in ArgoCD. Otherwise, ArgoCD will expect to receive SSL traffic by default. To do this, we can ask ArgoCD to run in insecure
mode by running the command below:
There are different ways to access ArgoCD. However, the most convenient is usually to expose it through our ingress layer so that it can be accessed as a different subpath (/argocd/
). This will make the ArgoCD API and UI reachable as http(s)://<load-balancer-domain>/argocd/
.
This will need to be configured in a couple of places.
On one hand, we need to tell ArgoCD to expect its static assets to be served under the /argocd/
path. This can be done by running the following command:
Create a VirtualService
that maps the /argocd/
path to ArgoCD's service. To expose ArgoCD as a VirtualService, you can create the file argocd-vs.yaml
file:
Apply the configuration: kubectl apply -f argocd-vs.yaml
After configuring ArgoCD, we should now be able to reach ArgoCD under:
In a standard setup, you should be able to obtain your load balancer domain by checking the Istio resources created in your cluster:
Alternatively, if your ingress layer doesn't expose an external IP address or domain, it's also possible to port-forward a local port into ArgoCD. For example, you can access ArgoCD locally at localhost:8080
or localhost:8080/argocd/
if you defined the rootpath
above by running:
Once we know our load balancer domain, we can then access ArgoCD through its UI or API. For the latter, we will leverage ArgoCD's CLI, called argocd
. Below, you can find instructions on how to set up and access both of them.
ArgoCD ships with a CLI tool called argocd
.
This tool allows you to interact with ArgoCD from the command line. The rest of this guide will provide command examples that can be used to configure ArgoCD using their `argocd` tool.
However, it's also possible to perform the same actions from the ArgoCD UI.
To use the `argocd` CLI, we will need to:
1. Install the argocd
CLI locally.
This can be achieved by running the following commands:
2. Authenticate the CLI against our ArgoCD instance.
Assuming that our load balancer domain can be found under $INGRESS
, it should be enough to run the command below.
This section walks you through how to create a new GitOps-tracked environment for a namespace with name $namespace
. The GitOps repository which acts as the source of truth for this environment exists under $GIT_REPO_URL
.
The only requirements for the Git repository are:
It contains a non-empty folder named as the namespace (./$namespace
).
It is accessible from within the cluster. Assuming you have already set the shell variables $GIT_USER
and $GIT_TOKEN
, this can be verified using this one-liner command:
If you are using a private repository and see an error the reads: fatal: repository 'YOUR GIT REPOSITORY' not found
, it is likely your `$GIT_TOKEN` has insufficient permissions.
You can create an ArgoCD project by creating the following AppProject
resource named argocd-project.yaml
Similarly create the ArgoCD Application
resource:
To use a namespace with GitOps, you need to annotate it with the Git repository URL using key git-repo
and enable it for GitOps access by adding the seldon.gitops
label. As an example, to enable a namespace named $namespace
, you could run the following commands:
The last required step is to provide the relevant Git credentials to access our GitOps repository. Note that these credentials need to be set at both the ArgoCD and Seldon Enterprise Platform levels.
You can configure your GitOps repository access in ArgoCD using either SSH or user / password credentials. These credentials can be provided using the argocd
CLI tool, or directly through the ArgoCD UI.
Seldon Enterprise Platform also requires access to the repository. This access is used to monitor the status of the current resources in the cluster, as well as to create new ones.
To configure our Git credentials in Seldon Enterprise Platform, follow these steps:
Create a Kubernetes secret containing our credentials, either as a SSH key or a User / Password combination. This secret can have any arbitrary name, but must live in the same namespace as Seldon Enterprise Platform.
If the private key is present under $GIT_SSH_PATH
, you can create the credentials secret using:
The `passphrase` field can be left empty if they SSH key doesn't have a passphrase.
Update Seldon Enterprise Platform's configuration to point to the newly created secret. In particular, you need to modify the gitops
section of the values of the Seldon Enterprise Platform Helm chart. Here, you need to set the gitops.argocd.enabled
flag to true
, and point the gitops.git.secret
field to the right secret name git-creds
.
By default, the resource synchronisation against the GitOps repository happens on a poll basis. That is, Seldon Enterprise Platform checks the repo periodically for updates.
The main caveat of this approach is that there may be a small delay between taking an action and seeing it reflected in the cluster or UI. To work around this, you can configure a set of webhooks in the cluster that gets pinged everytime there is a change in the cluster.
You can find these instructions on how to set up these webhooks for common Git providers.
1. Configure the webhook that sends updates to the Seldon Enterprise Platform endpoint:
Set $ARGOCDURL
and create the webhook that sends the updates to ArgoCD:
After following the preceding steps, further namespaces can be enabled for GitOps by doing the following:
Create the namespace, if it does not already exist
You should see one application per gitops namespace when running the following:
You can check the status of an argocd app with kubectl get application -n argocd seldon-gitops-<namespace_name> -o yaml
.
You can also use the ArgoCD UI to inspect applications. You can trigger a manual sync from there. If a particular application is missing or in error try running its setup again in order to debug.
Note that these steps must be treated just as a guideline. Therefore, you may need to adapt them to your infrastructure. For more information on ArgoCD's configuration, we suggest checking .
Upon the initial installation of ArgoCD, it is recommended to change its user and password. This guideline will show how to change ArgoCD's default admin user as an example. However, it's also possible to hook . This could be the same as , providing a Single Sign-On across your entire stack.
The following command will assume that we want to set the admin credentials as admin
// $ARGOCDINITIALPASS
. ArgoCD requires the password to be . With this in mind, we can set those credentials as:
Assuming that you have followed the guidelines, this UI should be accessible under the /argocd/
path of your load balancer domain. After accessing the UI, you should be prompted with a login form asking for the admin credentials. You should be able to access this UI by using ArgoCD's user or password combination admin
and $ARGOCDINITIALPASS
by default, respectively. You can learn more about how to navigate ArgoCD's UI in the .
The request logger is an infrastructure component that runs in the , seldon-logs
by default. Alongside this, Triggers can also be created for detectors and these tied to particular models. Thus is good to back them through a GitOps environment.
With this goal in mind, it's encouraged to create a system-level GitOps environment to track these infrastructure resources. To do this, you can follow the , using the seldon-logs
namespace as the target.
Now that ArgoCD has been , you can proceed to create a new GitOps environment. This environment provides a Kubernetes namespace to deploy our machine learning models, which is backed by a GitOps repository.
For GitHub, your token needs the repo
scope for full control of private repositories. For more information, see . For other providers, check the relevant docs for token-based repository access.
In order for ArgoCD to keep track of our new environment, it's necessary to configure a and an . These are concepts native to ArgoCD. We suggest checking the for more information about them.
ArgoCD projects and applications can be created via the ArgoCD UI, argocd
CLI tool and through CRDs. As the approach guarantees the best reproducibility, this is the approach that we recommend.
If you intend to use Batch jobs on the namespace then you'll need additional config. You can visit the of the docs for more details.
Ensure that the argocd
CLI tool is already , and that ${GIT_USER}
and ${GIT_TOKEN
represent GitOps repository user and password, run the following:
Ensure that the argocd
CLI tool is already , and that $GIT_SSH_PATH
represents the path to an SSH private key with access to GitOps repository, run the following:
ArgoCD exposes a UI that can be used to configure your GitOps repository. After you have followed the , this UI should be accessible under the /argocd/
path. You should be able to access this UI by using ArgoCD's user or password combination it is admin
and 12341234
by default, respectively. For more details, see .
to the appropriate AppProject
to deploy into that namespace, if required
for Enterprise Platform to use it
Further context is provided in.