Before you begin | Прежде чем начать |
This section describes how Argo CD works when bundled with Deckhouse and assumes you have basic understanding or prior knowledge of Argo CD. | Раздел описывает особенности работы Argo CD в поставке с Deckhouse и предполагает наличие базовых знаний или предварительного знакомства с Argo CD. |
The following details are used in the examples below:
| Данные, которые используются в примерах ниже:
|
The concept | Концепция |
The module implements a method of deploying applications using a combination of werf bundles and OCI-based registries. | Модуль предлагает способ развертывания приложений с помощью связки werf bundle и OCI-based registries. |
The advantage of this approach is that there is a single place to deliver the artifact — the container registry. The artifact contains both container images and the Helm chart. It is used both for the initial deployment of the application and for pull model auto-updates. | Преимущество этого подхода заключается в том, что есть единое место доставки артефакта — container registry. Артефакт содержит в себе как образы контейнеров, так и Helm-чарт. Он используется как для первичного деплоя приложения, так и для автообновлений по pull-модели. |
The following components are used: | Используемые компоненты: |
|
|
To use the OCI registry as a repository, you have to enable the | Чтобы использовать OCI-registry как репозиторий, в параметрах репозитория Argo CD нужно использовать
флаг |
Argo CD Image Updater automatically updates applications in the cluster once the artifact has been delivered. Argo CD Image Updater has been modified to work with werf bundles. | Чтобы автоматически обновлять приложения в кластере после доставки артефакта, используется Argo CD Image Updater. В Argo CD Image Updater внесены изменения, позволяющие ему работать с werf-бандлами. |
The examples below use the «Application of Applications» pattern, which implies that there are two git repositories — a dedicated repository for the application, and a dedicated repository for the infrastructure: | В примерах используется схема с шаблоном «Application of Applications», подразумевающая два git-репозитория — отдельный репозиторий для приложения и отдельный репозиторий для инфраструктуры: |
The use of the Application of Applications pattern and a separate infrastructure repository is not necessary if you are allowed to create Application resources manually. For the sake of simplicity, in the examples below we will manage Application resources manually. | Использование шаблона Application of Applications и отдельного репозитория для инфраструктуры не обязательно, если допускается создавать ресурсы Application вручную. Для простоты в примерах ниже мы будем придерживаться ручного управления ресурсами Application. |
WerfSource CRD-based configuration | Конфигурация с WerfSource CRD |
All you need to do to use Argo CD and Argo CD Image Updater is to configure the Application object and access to the registry. Access to the registry is required for the Argo CD repository and Argo CD Image Updater. Thus, you have to configure: | Чтобы использовать Argo CD и Argo CD Image Updater, достаточно настроить объект Application и доступ к registry. Доступ к registry нужен в двух местах — в репозитории Argo CD и в конфигурации Argo CD Image Updater. Для этого нужно сконфигурировать: |
|
|
The | Модуль |
|
|
Thus, three objects need to be created for deploying from the OCI repository. Note that all namespaced objects must be created in the | Таким образом, для деплоя из OCI-репозитория нужно создать три объекта. Все объекты, предполагающие
область видимости namespace, должны быть созданы в namespace |
Example: | Пример: |
yamlapiVersion: deckhouse.io/v1alpha1 kind: WerfSource metadata: name: example spec: imageRepo: cr.example.io/myproject # bundle and image repository pullSecretName: example-registry # Secret with the credentials required for access — apiVersion: v1 kind: Secret metadata: namespace: d8-delivery # namespace of the module name: example-registry type: kubernetes.io/dockerconfigjson # only this Secret type is supported data: .dockerconfigjson: … — apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 0.0 name: myapp namespace: d8-delivery # namespace of the module spec: destination: namespace: myapp server: https://kubernetes.default.svc project: default source: chart: mychart # bundle — cr.example.com/myproject/mychart helm: {} repoURL: cr.example.com/myproject # Argo CD repository from WerfBundle targetRevision: 1.0.0 syncPolicy: automated: prune: true selfHeal: true syncOptions:
| yamlapiVersion: deckhouse.io/v1alpha1 kind: WerfSource metadata: name: example spec: imageRepo: cr.example.io/myproject # Репозиторий бандлов и образов. pullSecretName: example-registry # Secret с доступом. — apiVersion: v1 kind: Secret metadata: namespace: d8-delivery # Namespace модуля. name: example-registry type: kubernetes.io/dockerconfigjson # Поддерживается только этот тип Secret’ов. data: .dockerconfigjson: … — apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 0.0 name: myapp namespace: d8-delivery # Namespace модуля. spec: destination: namespace: myapp server: https://kubernetes.default.svc project: default source: chart: mychart # Бандл — cr.example.com/myproject/mychart. helm: {} repoURL: cr.example.com/myproject # Репозиторий Argo CD из WerfBundle. targetRevision: 1.0.0 syncPolicy: automated: prune: true selfHeal: true syncOptions:
|
Publishing an artifact to the registry | Публикация артефакта в registry |
The Helm OCI chart requires that the chart name in | OCI-чарт Helm требует, чтобы имя чарта в |
sh werf bundle publish –repo cr.example.com/myproject/mychart –tag 1.0.0 | sh werf bundle publish –repo cr.example.com/myproject/mychart –tag 1.0.0 |
For more information about bundles, see the werf documentation. | Подробнее о бандлах — в документации werf. |
Bundle auto-updating | Автообновление бандла |
As part of the pull model, Argo CD Image Updater automatically updates the Application using a published werf bundle. Image Updater scans the OCI repository at set intervals and updates | Argo CD Image Updater используется для автоматического обновления Application из опубликованного
werf-бандла в pull-модели. Image Updater сканирует OCI-репозиторий с заданным интервалом и обновляет
|
The rules for updating images | Правила обновлений образов |
You have to add an annotation to the Application object containing the rules governing image updates (see the werf documentation for details). | В Application нужно добавить аннотацию с правилами обновления образа (подробнее — в документации werf). |
Here is an example of a rule that updates a patch version of an application ( | Пример правила, обновляющего патч-версии приложения ( |
yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 | yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 |
Access settings for the registry | Настройки доступа к registry |
The | У сервис-аккаунта |
Per-Application configuration | Индивидуальная настройка для Application |
You can refer access credentials individually in each Application using the | Сослаться на параметры доступа можно индивидуально в каждом Application с помощью аннотации |
Example: | Пример: |
yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 argocd-image-updater.argoproj.io/pull-secret: pullsecret:d8-delivery/example-registry | yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 argocd-image-updater.argoproj.io/pull-secret: pullsecret:d8-delivery/example-registry |
How to authenticate using the
| Особенности аутентификации командной утилиты
|
Argo CD user | Пользователь Argo CD |
Set | Задайте |
To do so: | Чтобы включить пользователя |
|
|
sh kubectl edit mc delivery | sh kubectl edit mc delivery |
|
|
yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: delivery (…) spec: enabled: true settings: argocd: admin: enabled: true version: 1 | yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: delivery (…) spec: enabled: true settings: argocd: admin: enabled: true version: 1 |
kubectl | kubectl |
If external access to Kubernetes API is configured, | Если настроен внешний доступ к Kubernetes API, |
sh argocd login argocd.example.com –core | sh argocd login argocd.example.com –core |
The | Утилита |
Use the following command to set | Выполните следующую команду для выбора namespace |
sh kubectl config set-context –current –namespace=d8-delivery | sh kubectl config set-context –current –namespace=d8-delivery |
Dex | Dex |
The Dex-based authorization does not work for the CLI, but it does in the web interface. | Авторизация через Dex не работает для CLI, но работает в веб-интерфейсе. |
That is, you cannot authorize via SSO because Dex Client in Deckhouse does not support public clients, in this case Argo CD: | Вот так не работает, потому нет возможности зарегистрировать публичного клиента для DexClient, в роли которого выступает Argo CD: |
sh argocd login argocd.example.com –sso | sh argocd login argocd.example.com –sso |
Partial WerfSource CRD usage scenarios | Частичное использование WerfSource CRD |
No Argo CD repository | Без репозитория Argo CD |
WerfSource creates a repository on the Argo CD and adds registry information to the Image Updater configuration. However, it also allows you to skip the repository creation. To do so, set the | WerfSource отвечает за создание репозитория в Argo CD и внесение registry в конфигурацию
Image Updater. От создания репозитория можно отказаться в WerfSource, для этого нужно установить
параметр |
yamlapiVersion: deckhouse.io/v1alpha1 kind: WerfSource metadata: name: example spec: … argocdRepoEnabled: false | yamlapiVersion: deckhouse.io/v1alpha1 kind: WerfSource metadata: name: example spec: … argocdRepoEnabled: false |
How to manually create an Argo CD repository for the OCI registry | Как самостоятельно создать репозиторий Argo CD для OCI-registry |
The registry acts as a repository for the bundles. To use it, you will have to enable OCI mode in the repository. Unfortunately, the web interface does not allow you to set the | Registry играет роль репозитория бандлов. Чтобы это работало, нужно в репозитории включить режим
OCI. Однако веб-интерфейс не позволяет установить флаг |
Using the Argo CD CLI | Argo CD CLI |
The | Утилита |
sh
$ argocd repo add cr.example.com/myproject | sh
$ argocd repo add cr.example.com/myproject |
Using the web interface and kubectl | Веб-интерфейс и kubectl |
The missing flag can be added manually to an existing repository: | В существующий репозиторий недостающий флаг можно добавить вручную: |
sh kubectl -n d8-delivery edit secret repo-…. | sh kubectl -n d8-delivery edit secret repo-…. |
yaml apiVersion: v1 kind: Secret stringData: # <—– add enableOCI: “true” # <—– and save data: (…) metadata: (…) name: repo-…. namespace: d8-delivery type: Opaque | yaml apiVersion: v1 kind: Secret stringData: # <—– Добавить enableOCI: “true” # <—– и сохранить. data: (…) metadata: (…) name: repo-…. namespace: d8-delivery type: Opaque |
No registry for Image Updater | Без registry для Image Updater |
The registries in | Registry в |
yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 argocd-image-updater.argoproj.io/pull-secret: pullsecret:d8-delivery/example-registry | yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: annotations: argocd-image-updater.argoproj.io/chart-version: ~ 1.0 argocd-image-updater.argoproj.io/pull-secret: pullsecret:d8-delivery/example-registry |