DEV Community

K@zuki.
K@zuki.

Posted on

Trying Argo CD's Multiple sources

Introduction

Argo CD has a feature called Multiple sources.

This feature is in beta, but it allows you to build an application by retrieving configuration elements from different sources such as Helm Chart and Kustomize.

In this article, we will look at how Multiple sources can be useful and how to use it for deploying WordPress.

Benefits of Multiple sources

Multiple sources are useful in the following cases:

Separation of Helm Chart and values.yaml

You can separate the reference to Helm Chart and values.yaml into different repositories or directories.

This makes version management of the application easier.

Managing multiple Helm Charts in one Application

Using Multiple sources, you can manage multiple Helm Charts in one Application.

This allows for more flexible management of the application's configuration.

Deploying WordPress using Multiple sources

Why WordPress?

Bitnami's WordPress Chart has a problem where the DB password is regenerated when the pod is restarted. Therefore, it is necessary to separate the DB from the WordPress Chart, which is perfect for Multiple sources.

Defining an Application for WordPress

Let's use Multiple sources to deploy WordPress.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: wordpress
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  sources:
    # Make corrupt952/home-apps available for $manfiest
    - ref: manifest
      repoURL: https://github.com/corrupt952/home-apps

    # Load resources defined in corrupt952/home-apps/wordpress/base
    # Manage secrets such as passwords used by mariadb and wordpress
    - path: wordpress/base
      repoURL: https://github.com/corrupt952/home-apps

    # Load bitnami/mariadb Chart and corrupt952/home-apps/values/mariadb.yaml
    - chart: mariadb
      repoURL: https://charts.bitnami.com/bitnami
      targetRevision: 12.1.5
      helm:
        releaseName: mariadb
        valueFiles:
        - $manifest/values/mariadb.yaml

    # Load bitnami/wordpress Chart and corrupt952/home-apps/values/wordpress.yaml
    - chart: wordpress
      repoURL: https://charts.bitnami.com/bitnami
      targetRevision: 16.0.4
      helm:
        releaseName: wordpress
        valueFiles:
        - $manifest/values/wordpress.yaml

  ...
Enter fullscreen mode Exit fullscreen mode

By defining the previously source definition as sources, you can define multiple sources.

ref: manifest

The first definition is to refer to values.yaml in corrupt952/home-apps in the second and third sources.

In the case of ref, resources in the repository are not loaded, so it is important to remember to define it when referring to a file.

- ref: manifest
  repoURL: <https://github.com/corrupt952/home-apps>
Enter fullscreen mode Exit fullscreen mode

path: wordpress/base

The second definition is a source that manages resources with kustomize.

Since MariaDB and WordPress need to share passwords, Sealed Secret is used to manage them, and this definition is added to load and create resources.

- path: wordpress/base
  repoURL: <https://github.com/corrupt952/home-apps>
Enter fullscreen mode Exit fullscreen mode

chart: mariadb

The third definition is a source that loads the MariaDB Helm Chart.

valueFiles is defined to refer to values/mariadb.yaml in corrupt952/home-apps.

In the era before Multiple sources, such definitions were not possible, and it was necessary to define Chart.yaml in the same repository as values.yaml.

- chart: mariadb
  repoURL: <https://charts.bitnami.com/bitnami>
  targetRevision: 12.1.5
  helm:
    releaseName: mariadb
    valueFiles:
    - $manifest/values/mariadb.yaml
Enter fullscreen mode Exit fullscreen mode
# values/mariadb.yaml
global:
  storageClass: nfs-client

auth:
  username: wordpress
  database: wordpress
  existingSecret: wordpress-credentials
Enter fullscreen mode Exit fullscreen mode

chart: wordpress

The fourth definition is a source that loads the WordPress Helm Chart.

Like MariaDB, it refers to values/wordpress.yaml in corrupt952/home-apps.

- chart: wordpress
  repoURL: <https://charts.bitnami.com/bitnami>
  targetRevision: 16.0.4
  helm:
    releaseName: wordpress
    valueFiles:
    - $manifest/values/wordpress.yaml
Enter fullscreen mode Exit fullscreen mode
# values/wordpress.yaml
global:
  storageClass: nfs-client

allowEmptyPassword: false
existingSecret: wordpress-credentials

mariadb:
  enabled: false

memcached:
  enabled: false

externalDatabase:
  host: mariadb.wordpress.svc.cluster.local
  user: wordpress
  database: wordpress
  existingSecret: wordpress-credentials

...
Enter fullscreen mode Exit fullscreen mode

Conclusion

We have seen an example of deploying WordPress using Multiple sources. While it is still in beta, using Multiple sources effectively can lead to appropriate separation and commonization of manifests and settings.

Top comments (0)