This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
контроллер_argocd [2024/01/07 10:20] val |
контроллер_argocd [2026/02/13 09:13] (current) val [Контроллер ArgoCD] |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| * [[https://www.digitalocean.com/community/tutorials/how-to-deploy-to-kubernetes-using-argo-cd-and-gitops|How to Deploy to Kubernetes using Argo CD and GitOps]] | * [[https://www.digitalocean.com/community/tutorials/how-to-deploy-to-kubernetes-using-argo-cd-and-gitops|How to Deploy to Kubernetes using Argo CD and GitOps]] | ||
| * [[https://habr.com/ru/companies/otus/articles/544370/|Argo CD: готов к труду и обороне в Kubernetes]] | * [[https://habr.com/ru/companies/otus/articles/544370/|Argo CD: готов к труду и обороне в Kubernetes]] | ||
| + | * [[https://habr.com/ru/articles/674704/|Рабочий пример использования ArgoCD]] | ||
| + | * [[https://developers.redhat.com/articles/2023/05/25/3-patterns-deploying-helm-charts-argocd|3 patterns for deploying Helm charts with Argo CD]] | ||
| + | * [[https://medium.com/globant/using-multiple-sources-for-a-helm-chart-deployment-in-argocd-cf3cd2d598fc|Using multiple sources for a Helm Chart deployment in ArgoCD]] | ||
| + | |||
| + | * [[https://habr.com/ru/articles/674704/|Рабочий пример использования ArgoCD]] | ||
| + | |||
| + | * [[https://argo-cd.readthedocs.io/en/stable/operator-manual/secret-management/|argo-cd secret management]] | ||
| + | * [[https://itnext.io/integrating-sops-in-argocd-to-handle-kubernetes-secrets-e797b167d791|Integrating SOPS in ArgoCD to handle Kubernetes Secrets]] | ||
| + | * [[https://vieitesss.github.io/posts/ArgoCD-and-SOPS/|ArgoCD & SOPS]] | ||
| + | * [[https://medium.com/@stylishavocado/managing-sops-secrets-for-kubernetes-deployments-ft-argocd-84fff20d882d|Managing SOPS secrets for Kubernetes deployments ft. ArgoCD]] | ||
| ===== Развертывание и подключение к контроллеру ArgoCD ===== | ===== Развертывание и подключение к контроллеру ArgoCD ===== | ||
| <code> | <code> | ||
| Line 11: | Line 21: | ||
| kube1:~# watch kubectl get pods -n argocd | kube1:~# watch kubectl get pods -n argocd | ||
| + | </code> | ||
| + | * [[Система Kubernetes#Инструмент командной строки kubectl]] | ||
| + | <code> | ||
| cmder$ kubectl port-forward svc/argocd-server -n argocd 8080:443 | cmder$ kubectl port-forward svc/argocd-server -n argocd 8080:443 | ||
| - | student@kube1:~$ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo | + | kube1:~# kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo |
| </code> | </code> | ||
| * [[https://localhost:8080/]] | * [[https://localhost:8080/]] | ||
| - | ===== Установка, подключение и управление приложениями через утилиту argocd ===== | + | ===== Развертывание приложений ===== |
| + | |||
| + | ==== Установка, подключение и управление приложениями через утилиту argocd ==== | ||
| <code> | <code> | ||
| Line 57: | Line 71: | ||
| </code> | </code> | ||
| - | ===== Управление приложениями через kubectl ===== | + | ==== Управление приложениями через kubectl ==== |
| + | |||
| + | * [[https://argo-cd.readthedocs.io/en/release-1.8/user-guide/private-repositories/#managing-tls-certificates-using-the-argocd-web-ui|Managing TLS certificates using the ArgoCD web UI]] | ||
| <code> | <code> | ||
| - | student@server:~/argocd$ cat application.yaml | + | kube1# cat application.yaml |
| </code><code> | </code><code> | ||
| apiVersion: argoproj.io/v1alpha1 | apiVersion: argoproj.io/v1alpha1 | ||
| Line 66: | Line 83: | ||
| name: my-webd | name: my-webd | ||
| namespace: argocd | namespace: argocd | ||
| + | finalizers: | ||
| + | - resources-finalizer.argocd.argoproj.io/background | ||
| spec: | spec: | ||
| project: default | project: default | ||
| source: | source: | ||
| - | repoURL: 'http://server.corp13.un/student/gowebd-k8s.git' | + | repoURL: 'https://server.corpX.un/student/gowebd-k8s.git' |
| path: webd-chart | path: webd-chart | ||
| + | # repoURL: 'https://gitlab.corpX.un/student/webd-k8s.git' | ||
| + | # path: uni-webd-chart | ||
| + | |||
| + | # helm: | ||
| + | # valuesObject: | ||
| + | # replicaCount: 2 | ||
| + | # image: | ||
| + | # tag: "ver1.2" | ||
| + | # env: | ||
| + | # SECRET: "strongpassword2" | ||
| + | # valueFiles: | ||
| + | # - ../apps/gowebd/values.yaml | ||
| + | # - ../env.yaml | ||
| + | |||
| + | |||
| destination: | destination: | ||
| server: 'https://kubernetes.default.svc' | server: 'https://kubernetes.default.svc' | ||
| Line 79: | Line 113: | ||
| - CreateNamespace=true | - CreateNamespace=true | ||
| </code><code> | </code><code> | ||
| - | student@server:~/argocd$ kubectl apply -f application.yaml | + | kube1# kubectl apply -f application.yaml #--dry-run=client #-o yaml |
| + | |||
| + | kube1# kubectl get Application -n argocd -o yaml | less | ||
| + | |||
| + | kube1# ### kubectl delete -f application.yaml | ||
| </code> | </code> | ||
| - | ===== Тестирование приложения ===== | + | |
| + | ==== Тестирование приложения ==== | ||
| <code> | <code> | ||
| - | $ curl http://gowebd.corpX.un | + | $ curl http://kube1 -H "Host: gowebd.corpX.un" |
| gitlab-runner@server:~/gowebd-k8s$ cat webd-chart/Chart.yaml | gitlab-runner@server:~/gowebd-k8s$ cat webd-chart/Chart.yaml | ||
| Line 90: | Line 129: | ||
| appVersion: "ver1.N" | appVersion: "ver1.N" | ||
| </code><code> | </code><code> | ||
| - | $ curl http://gowebd.corpX.un | + | ИЛИ |
| + | |||
| + | Gitlab | ||
| + | gowebd-k8s | ||
| + | values.yaml | ||
| + | replicaCount: 3 | ||
| + | Chart.yaml | ||
| + | appVersion: "ver1.N" | ||
| + | </code> | ||
| + | |||
| + | ==== Развертывание множества приложений через ApplicationSet ==== | ||
| + | <code> | ||
| + | kube1:~/webd-k8s# cat argocd/application-s.yaml | ||
| + | </code><code> | ||
| + | apiVersion: argoproj.io/v1alpha1 | ||
| + | kind: ApplicationSet | ||
| + | metadata: | ||
| + | name: my-webd-s | ||
| + | namespace: argocd | ||
| + | spec: | ||
| + | generators: | ||
| + | - git: | ||
| + | repoURL: 'https://gitlab.corpX.un/student/webd-k8s.git' | ||
| + | revision: main | ||
| + | directories: | ||
| + | - path: apps/* | ||
| + | |||
| + | template: | ||
| + | metadata: | ||
| + | name: '{{path.basename}}' | ||
| + | labels: | ||
| + | name: apps | ||
| + | finalizers: | ||
| + | - resources-finalizer.argocd.argoproj.io/background | ||
| + | spec: | ||
| + | project: default | ||
| + | sources: | ||
| + | - repoURL: 'https://gitlab.corpX.un/student/webd-k8s.git' | ||
| + | targetRevision: main | ||
| + | path: uni-webd-chart | ||
| + | helm: | ||
| + | valueFiles: | ||
| + | - $values/apps/{{path.basename}}/values.yaml | ||
| + | - $values/env.yaml | ||
| + | - repoURL: 'https://gitlab.corpX.un/student/webd-k8s.git' | ||
| + | targetRevision: main | ||
| + | ref: values | ||
| + | |||
| + | destination: | ||
| + | server: 'https://kubernetes.default.svc' | ||
| + | namespace: my-ns | ||
| + | syncPolicy: | ||
| + | automated: | ||
| + | prune: true | ||
| + | selfHeal: true | ||
| + | |||
| + | syncOptions: | ||
| + | - CreateNamespace=true | ||
| </code> | </code> | ||
| ===== Дополнительные материалы ===== | ===== Дополнительные материалы ===== | ||
| + | |||
| + | ==== Добавление корпоративного корневого сертификата ==== | ||
| + | |||
| + | * [[Решение FreeIPA#Корневой сертификат]] | ||
| + | |||
| + | <code> | ||
| + | Settings-> | ||
| + | Repository certificates and known hosts-> | ||
| + | ADD TLS CERTIFICATE | ||
| + | Repository Server Name: gitlab.corpX.un | ||
| + | TLS Certificate (PEM format): cat /usr/local/share/ca-certificates/ca.crt | ||
| + | | ||
| + | kube1:~/webd-k8s# kubectl -n argocd get configmaps argocd-tls-certs-cm -o yaml | less | ||
| + | </code> | ||
| + | ==== Доступ к не публичному git репозиторию ==== | ||
| + | |||
| + | <code> | ||
| + | Settings -> Repositories + CONNECT REPO | ||
| + | |||
| + | student@server:~/argocd$ kubectl -n argocd get secrets | ||
| + | |||
| + | student@server:~/argocd$ kubectl -n argocd get secret repo-nnnnnnnnn -o yaml > gowebd-k8s-argocd-repo-cred.yaml | ||
| + | |||
| + | student@server:~/argocd$ cat gowebd-k8s-argocd-repo-cred.yaml | ||
| + | </code><code> | ||
| + | apiVersion: v1 | ||
| + | data: | ||
| + | password: UGEkJHcwcmQ= | ||
| + | project: ZGVmYXVsdA== | ||
| + | type: Z2l0 | ||
| + | url: aHR0cDovL3NlcnZlci5jb3JwMTMudW4vc3R1ZGVudC9nb3dlYmQtazhzLmdpdA== | ||
| + | username: YXJnb2Nk | ||
| + | kind: Secret | ||
| + | metadata: | ||
| + | annotations: | ||
| + | managed-by: argocd.argoproj.io | ||
| + | labels: | ||
| + | argocd.argoproj.io/secret-type: repository | ||
| + | name: gowebd-k8s-argocd-repo-cred | ||
| + | namespace: argocd | ||
| + | type: Opaque | ||
| + | </code> | ||
| + | |||
| + | ==== Обновление, при появлении новой версии образа ==== | ||
| * https://stackoverflow.com/questions/73616877/argocd-what-need-be-done-after-build-a-new-image | * https://stackoverflow.com/questions/73616877/argocd-what-need-be-done-after-build-a-new-image | ||