CodeBlanks Logo Icon CodeBlanks

Cluster registry

Learn the cluster registry concept.

Cluster registry

On a multi-cluster platform, the question "which clusters exist, where, at which version, which environment" must have a single answer: a cluster registry (inventory). In Argo CD, clusters are kept as labelled Secrets; the ApplicationSet's cluster generator deploys by these labels:

apiVersion: v1
kind: Secret
metadata:
  name: uretim-tr
  namespace: argocd
  labels:
    argocd.argoproj.io/secret-type: cluster
    ortam: uretim
    bolge: tr
stringData:
  name: uretim-tr
  server: https://tr.k8s.sirket.com

Deploying by label

The ApplicationSet cluster generator produces an Application for each registered cluster matching the labels:

spec:
  generators:
    - clusters:
        selector:
          matchLabels:
            ortam: uretim
  template:
    metadata:
      name: 'magaza-{{name}}'
    spec:
      destination:
        server: '{{server}}'
        namespace: magaza

That way which application runs on which clusters is documented in Git and in the labels.

Practice A cluster record

Write a Secret YAML: name uretim-tr, namespace argocd; labels argocd.argoproj.io/secret-type: cluster, ortam: uretim; under stringData, name: uretim-tr and server: https://tr.k8s.sirket.com.

Starter code

terminal
# buraya yaz

Sample solution

terminal
apiVersion: v1
kind: Secret
metadata:
  name: uretim-tr
  namespace: argocd
  labels:
    argocd.argoproj.io/secret-type: cluster
    ortam: uretim
stringData:
  name: uretim-tr
  server: https://tr.k8s.sirket.com

Expected output

secret/uretim-tr created
$ argocd cluster list
SERVER                      NAME       STATUS
https://tr.k8s.sirket.com   uretim-tr  Successful

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the benefit of the cluster generator's label selector?

  • It encrypts labels
  • It isn't needed
  • When a new production cluster is labelled, applications are deployed to it automatically Correct answer
  • It deletes clusters

Explanation: Adding a cluster becomes the same as adding a Secret.

2 Mark the Secret as an Argo CD cluster record.

Question
  labels:
    argocd.argoproj.io/secret-type: ____
Answer
  labels:
    argocd.argoproj.io/secret-type: cluster

Explanation: secret-type: cluster is Argo CD's cluster record.

3 Match.

Term Meaning
cluster registration Inventory
secret-type: cluster Argo CD cluster
clusters generator Deploy by label
{{server}} Cluster address

All lessons in Expert