Включение модуля

Для использования модуля operator-argo в Deckhouse Kubernetes Platform, его необходимо включить. Это можно сделать одним из способов, описанных далее.

Способ 1: Включение с применением ModuleConfig

Для включения модуля создайте ресурс ModuleConfig:

1apiVersion: deckhouse.io/v1alpha1
2kind: ModuleConfig
3metadata:
4  name: operator-argo
5spec:
6  enabled: true

Способ 2: Включение с использованием deckhouse-controller

Для включения модуля выполните команду:

1kubectl -n d8-system exec deploy/deckhouse -c deckhouse -it -- deckhouse-controller module enable operator-argo

Выключение модуля

При отключении модуля будет удалён оператор ArgoCD (все ресурсы из пространства имен d8-operator-argo). Развёрнутые инсталляции ArgoCD и приложения останутся нетронутыми.

Если вам необходимо отключить модуль operator-argo, вы можете сделать это одним из способов, описанных далее.

Способ 1: Выключение с применением ModuleConfig

Для выключения модуля установите значение enabled в false в конфигурации ModuleConfig:

1apiVersion: deckhouse.io/v1alpha1
2kind: ModuleConfig
3metadata:
4  name: operator-argo
5spec:
6  enabled: false

Способ 2: Выключение с использованием deckhouse-controller

Для выключения модуля выполните следующую команду:

1kubectl -n d8-system exec deploy/deckhouse -c deckhouse -it -- deckhouse-controller module disable operator-argo

Установка ArgoCD и развертывание ArgoCD Application

Разверните ArgoCD, который будет доступен через Ingress:

1---
2apiVersion: v1
3kind: Namespace
4metadata:
5  name: argocd
6---
7apiVersion: argoproj.io/v1beta1
8kind: ArgoCD
9metadata:
10  name: argocd
11  namespace: argocd
12spec:
13  server:
14    host: <argocd-domain>
15    ingress:
16      enabled: true
17      tls:
18      - hosts:
19        - <argocd-domain>
20        secretName: argocd-ingress-tls
21    # To avoid internal redirection loops from HTTP to HTTPS, the API server should be run with TLS disabled.
22    # https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/#disable-internal-tls
23    insecure: true
24---
25apiVersion: cert-manager.io/v1
26kind: Certificate
27metadata:
28  name: argocd-ingress
29  namespace: argocd
30spec:
31  dnsNames:
32  - <argocd-domain>
33  issuerRef:
34    kind: ClusterIssuer
35    name: letsencrypt
36  secretName: argocd-ingress-tls

Создайте пространство имен для приложения:

1apiVersion: v1
2kind: Namespace
3metadata:
4  name: demo
5  labels:
6    argocd.argoproj.io/managed-by: argocd

Разверните ArgoCD Application:

1apiVersion: argoproj.io/v1alpha1
2kind: Application
3metadata:
4  name: demo
5  namespace: argocd
6spec:
7  destination:
8    namespace: demo
9    server: https://kubernetes.default.svc
10  project: default
11  source:
12    path: helm-guestbook
13    repoURL: https://github.com/argoproj/argocd-example-apps
14    targetRevision: HEAD
15  syncPolicy:
16    automated:
17      prune: true
18      selfHeal: true

Использование единой системы аутентификации Deckhouse Kubernetes Platform для аутентификации в ArgoCD

Создайте OAuth2-клиента для аутентификации в ArgoCD:

1apiVersion: deckhouse.io/v1
2kind: DexClient
3metadata:
4  name: argocd
5  namespace: argocd
6spec:
7  redirectURIs:
8    - https://<argocd-domain>/api/dex/callback
9    - https://<argocd-domain>/api/dex/callback-reserve

После создания ресурса DexClient, DKP зарегистрирует клиента с идентификатором (clientID) dex-client-argocd@argocd (используя шаблон dex-client-<name>@<namespace>).

Дождитесь, пока Deckhouse Kunernetes Platform создаст Secret с секретным ключом для клиента:

1kubectl -n argocd get secret/dex-client-argocd

Настройте ArgoCD для использования системы аутентификации DKP:

1apiVersion: argoproj.io/v1beta1
2kind: ArgoCD
3metadata:
4  name: argocd
5  namespace: argocd
6spec:
7  sso:
8    dex:
9      config: |
10        connectors:
11          - type: oidc
12            id: deckhouse
13            name: deckhouse
14            config:
15              issuer: "https://dex.<cluster-domain>/"
16              clientID: "dex-client-argocd@argocd"
17              clientSecret: "$dex-client-argocd:clientSecret"
18    provider: dex
19  server:
20    host: <argocd-domain>
21    ingress:
22      enabled: true
23      tls:
24        - hosts:
25            - <argocd-domain>
26          secretName: argocd-ingress-tls
27    # To avoid internal redirection loops from HTTP to HTTPS, the API server should be run with TLS disabled.
28    # https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/#disable-internal-tls
29    insecure: true

Перезапустите сервер ArgoCD:

1kubectl -n argocd rollout restart deploy/argocd-server

Если не перезапустить сервер ArgoCD, то попытка входа не удастся, а в логе сервера ArgoCD появится сообщение об ошибке (issue о проблеме).

Пример сообщения об ошибке... time="2024-10-16T14:12:59Z" level=warning msg="Failed to verify token: failed to verify token: token verification failed for all audiences: error for aud "argo-cd": Failed to query provider "https://argocd./api/dex": Get "https://argocd./api/dex/.well-known/openid-configuration": tls: failed to verify certificate: x509: certificate is valid for ingress.local, not argocd., error for aud "argo-cd-cli": Failed to query provider "https://argocd./api/dex": Get "https://argocd./api/dex/.well-known/openid-configuration": tls: failed to verify certificate: x509: certificate is valid for ingress.local, not argocd."

Предоставление ArgoCD доступа к ресурсам кластера

Для предоставления доступа ArgoCD к кластерным (cluster-wide) ресурсам используйте параметр clusterConfigNamespaces в настройках модуля:

1apiVersion: deckhouse.io/v1alpha1
2kind: ModuleConfig
3metadata:
4  name: operator-argo
5spec:
6  enabled: true
7  settings:
8    clusterConfigNamespaces: <list of namespaces of cluster-scoped Argo CD instances>
9  version: 1

Использование собственного доменного имени кластера вместо cluster.local

Чтобы настроить ArgoCD для работы с другим FQDN кластера (например, prod.local), укажите его в параметре clusterDomain:

1apiVersion: argoproj.io/v1beta1
2kind: ArgoCD
3metadata:
4  name: argocd
5  namespace: argocd
6spec:
7  ...
8  clusterDomain: "prod.local"
9  ...