ArgoCDStorage#

class phalanx.storage.argocd.ArgoCDStorage(context=None)#

Bases: object

Interface to Argo CD operations.

Calls the argocd command-line client. Used by the installer and for cluster recovery.

Parameters:

context (Optional[str], default: None) – The kubectl context to specify for all argocd commands. If this is None, then the current context will be used.

Methods Summary

create_environment(environment, ...)

Manually create an Argo CD application.

list_applications_except_nublado_users(...)

List any ArgoCD applications except nublado-users.

login(username, password)

Authenticate to Argo CD.

set_helm_value(application, key, value)

Set a helm value for an ArgoCD project.

set_project(application, project)

Set the Argo CD project of an application.

sync(application, *[, timeout, kind])

Sync all or part of a specific Argo CD application.

sync_all(app_of_apps_name, *[, timeout])

Sync all or part of all Argo CD applications under an app of apps.

unset_helm_value(application, key)

Unset a helm value for an ArgoCD project.

Methods Documentation

create_environment(environment, app_of_apps_name, *, git_url, git_branch)#

Manually create an Argo CD application.

Used only by the installer for installing the app of apps to bootstrap the environment.

Parameters:
  • environment (str) – Name of the environment.

  • app_of_apps_name (str) – Name of the app of apps Argo CD application.

  • git_url (str) – URL to the Phalanx Git repository.

  • git_branch (str) – Name of the branch in that repository from which to pull the Argo CD configuration.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

list_applications_except_nublado_users(app_of_apps_name)#

List any ArgoCD applications except nublado-users.

We don’t care about nublado-users because ArgoCD doesn’t provision any resources in it, and most functionality that uses this method expect there to be resources in the app.

Parameters:

app_of_apps_name (str) – Name of the parent app of apps.

Raises:
  • CommandFailedError – Raised if Argo CD fails.

  • CommandTimedOutError – Raised if the command timed out. The timeout is also passed to Argo CD as an option, so normally the command should fail and raise CommandFailedError instead. This exception means the Argo CD timeout didn’t work for some reason.

Return type:

ApplicationList

login(username, password)#

Authenticate to Argo CD.

Authenticates using username and password authentication with port forwarding. This normally must be done before any other Argo CD operations.

Parameters:
  • username (str) – Username for authentication. (Usually this will be admin.)

  • password (SecretStr) – Password for that user.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

set_helm_value(application, key, value)#

Set a helm value for an ArgoCD project.

This is only used in the cluster recovery process, where we want to change some helm values the first time we sync an application, after the app-of-apps has already been synced.

Parameters:
  • application (str) – Application to change.

  • key (str) – The helm key to change.

  • value (str) – The Helm value to set.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

set_project(application, project)#

Set the Argo CD project of an application.

Parameters:
  • application (str) – Application to change.

  • project (Project) – Project to move it into.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

sync(application, *, timeout=datetime.timedelta(seconds=120), kind=None)#

Sync all or part of a specific Argo CD application.

Parameters:
  • application (str) – Name of the application.

  • timeout (timedelta, default: datetime.timedelta(seconds=120)) – How long to wait for the sync to complete.

  • kind (Optional[str], default: None) – If given, only this kind of resource will be synced.

Raises:
  • CommandFailedError – Raised if Argo CD fails.

  • CommandTimedOutError – Raised if the command timed out. The timeout is also passed to Argo CD as an option, so normally the command should fail and raise CommandFailedError instead. This exception means the Argo CD timeout didn’t work for some reason.

Return type:

None

sync_all(app_of_apps_name, *, timeout=datetime.timedelta(seconds=30))#

Sync all or part of all Argo CD applications under an app of apps.

Parameters:
  • app_of_apps_name (str) – Name of the parent app of apps.

  • timeout (timedelta, default: datetime.timedelta(seconds=30)) – How long to wait for the sync to complete.

Raises:
  • CommandFailedError – Raised if Argo CD fails.

  • CommandTimedOutError – Raised if the command timed out. The timeout is also passed to Argo CD as an option, so normally the command should fail and raise CommandFailedError instead. This exception means the Argo CD timeout didn’t work for some reason.

Return type:

None

unset_helm_value(application, key)#

Unset a helm value for an ArgoCD project.

This is only used in the cluster recovery process, where we want to change some helm values the first time we sync an application, after the app-of-apps has already been synced.

Parameters:
  • application (str) – Application to change.

  • key (str) – The helm key to change.

  • value – The Helm value to set.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None