GitOps on Kubernetes. Managing services with ArgoCD Dmytro Kudriavtsev
whoiam Over9000 20y in IT: Devops 5y Admin 13y Java/Python dev 2y
Typical pipeline
deploy-dev-qa..: sed -i "s~latest~$BRANCH-$SHORT_COMMIT~g" deployment.yaml kubectl apply -f deployment.yaml #wrong cluster credentials #kubectl apply -f deployment.yaml -n wrong_ns #kubectl delete ns qa
What is GitOps
Principles of GitOps ● The entire system described declaratively. ● The canonical desired system state versioned in Git. ● Approved changes that can be automatically applied to the system.
GitOps
Key benefits of GitOps ● Deploy faster and more often. ● Easy and fast error recovery. ● Easier credential management. ● Self-documenting deployments. ● Shared knowledge in teams.
ArgoCD Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Argo CD is implemented as a kubernetes controller which continuously monitors running applications and compares the current, live state against the desired target state (as specified in the Git repo).
ArgoCD Features ● Web UI which provides real-time view of application activity ● Automated deployment of applications to specified target environments ● Support for multiple config management/templating tools (Kustomize, Helm, Ksonnet, Jsonnet, plain-YAML) ● Ability to manage and deploy to multiple clusters ● Rollback/Roll-anywhere to any application configuration committed in Git repository ● Health status analysis of application resources
ArgoCD Features ● Webhook integration (GitHub, BitBucket, GitLab) ● SSO Integration (OIDC, OAuth2, LDAP, SAML 2.0, GitHub, GitLab, Microsoft, LinkedIn) ● Automated or manual syncing of applications to its desired state ● CLI for automation and CI integration ● Multi-tenancy and RBAC policies for authorization ● Automated configuration drift detection and visualization ● Access tokens for automation ● PreSync, Sync, PostSync hooks to support complex application rollouts (e.g.blue/green & canary upgrades) ● Audit trails for application events and API calls ● Prometheus metrics ● Parameter overrides for overriding ksonnet/helm parameters in Git
Input Kubernetes manifests can be specified in several ways: ● Plain directory of YAML/json manifests ● helm charts ● kustomize applications ● ksonnet applications ● jsonnet files
UI
Kustomize Kustomize is a standalone tool to customize Kubernetes objects through a kustomization file. kubectl apply -k <kustomization_directory>
The three roots dev, prod and staging all refer to the base root. One would have to inspect the kustomization.yaml files to be sure. An overlay is a kustomization that depends on another kustomization. The kustomizations an overlay refers to (via filepath, URI or other method) bases.An overlay is unusable without its bases. An overlay may act as a base to another overlay. ├── base │ ├── deployment.yaml │ ├── kustomization.yaml │ └── service.yaml └── overlays ├── dev │ ├── kustomization.yaml │ └── patch.yaml ├── prod │ ├── kustomization.yaml │ └── patch.yaml └── staging ├── kustomization.yaml └── patch.yaml Kustomize
=>
To start with Kustomize, you need to have your original yaml files describing any resources you want to deploy into your cluster. Those files will be stored for this example in the folder ./k8s/base/ . In this example, we will work with a service , deployment resources and kustomization.yaml
The result of kustomize build k8s/base command will be the following, which is for now only the two files previously seen, concatenated:
A kustomization file contains fields falling into four categories: ● resources - what existing resources are to be customized. Example fields: resources, crds. ● generators - what new resources should be created. Example fields: configMapGenerator (legacy), secretGenerator (legacy). ● transformers - what to do to the aforementioned resources. Example fields: namePrefix, nameSuffix, images, commonLabels, patchesJson6902, etc. and the more general transformers. ● meta - fields which may influence all or some of the above. Example fields: vars, namespace, apiVersion, kind, etc.
Why kustomize? ● Purely declarative ● Template-free customization via overlays ● Easy customization for common use-cases ● Flexible tooling
Demo time! Svc: - Logging - Monitoring - Redis - Rabbitmq - Postgresql - kafka App: - app
Install k create namespace argocd k apply -n argocd -f https://../argo-cd/stable/manifests/install.yaml Download Argo CD CLI Login Using The CLI: k get po -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2 argocd login <ARGOCD_SERVER>
more: https://argoproj.github.io/argo-cd/ https://github.com/argoproj/argocd-example-apps https://kustomize.io/ https://www.weave.works/technologies/gitops/ https://www.weave.works/blog/kubernetes-anti-patterns-let-s-do-gitops-not-ciops https://www.gitops.tech/#why-should-i-use-gitops https://www.youtube.com/watch?v=LKOa2vMoy44 https://cluster.dev/
Tnx to all мамі за то шо я такий класний Соні :3 ЗСУ/Добробатам youtube Ukrops Cluster.dev Send pm to demoontz*

DevOps Fest 2020. Дмитрий Кудрявцев. Реализация GitOps на Kubernetes. ArgoCD

  • 1.
    GitOps on Kubernetes. Managingservices with ArgoCD Dmytro Kudriavtsev
  • 2.
    whoiam Over9000 20y inIT: Devops 5y Admin 13y Java/Python dev 2y
  • 3.
  • 4.
    deploy-dev-qa..: sed -i "s~latest~$BRANCH-$SHORT_COMMIT~g"deployment.yaml kubectl apply -f deployment.yaml #wrong cluster credentials #kubectl apply -f deployment.yaml -n wrong_ns #kubectl delete ns qa
  • 5.
  • 6.
    Principles of GitOps ●The entire system described declaratively. ● The canonical desired system state versioned in Git. ● Approved changes that can be automatically applied to the system.
  • 7.
  • 8.
    Key benefits ofGitOps ● Deploy faster and more often. ● Easy and fast error recovery. ● Easier credential management. ● Self-documenting deployments. ● Shared knowledge in teams.
  • 9.
    ArgoCD Argo CD isa declarative, GitOps continuous delivery tool for Kubernetes. Argo CD is implemented as a kubernetes controller which continuously monitors running applications and compares the current, live state against the desired target state (as specified in the Git repo).
  • 10.
    ArgoCD Features ● WebUI which provides real-time view of application activity ● Automated deployment of applications to specified target environments ● Support for multiple config management/templating tools (Kustomize, Helm, Ksonnet, Jsonnet, plain-YAML) ● Ability to manage and deploy to multiple clusters ● Rollback/Roll-anywhere to any application configuration committed in Git repository ● Health status analysis of application resources
  • 11.
    ArgoCD Features ● Webhookintegration (GitHub, BitBucket, GitLab) ● SSO Integration (OIDC, OAuth2, LDAP, SAML 2.0, GitHub, GitLab, Microsoft, LinkedIn) ● Automated or manual syncing of applications to its desired state ● CLI for automation and CI integration ● Multi-tenancy and RBAC policies for authorization ● Automated configuration drift detection and visualization ● Access tokens for automation ● PreSync, Sync, PostSync hooks to support complex application rollouts (e.g.blue/green & canary upgrades) ● Audit trails for application events and API calls ● Prometheus metrics ● Parameter overrides for overriding ksonnet/helm parameters in Git
  • 12.
    Input Kubernetes manifests canbe specified in several ways: ● Plain directory of YAML/json manifests ● helm charts ● kustomize applications ● ksonnet applications ● jsonnet files
  • 13.
  • 15.
    Kustomize Kustomize is astandalone tool to customize Kubernetes objects through a kustomization file. kubectl apply -k <kustomization_directory>
  • 16.
    The three rootsdev, prod and staging all refer to the base root. One would have to inspect the kustomization.yaml files to be sure. An overlay is a kustomization that depends on another kustomization. The kustomizations an overlay refers to (via filepath, URI or other method) bases.An overlay is unusable without its bases. An overlay may act as a base to another overlay. ├── base │ ├── deployment.yaml │ ├── kustomization.yaml │ └── service.yaml └── overlays ├── dev │ ├── kustomization.yaml │ └── patch.yaml ├── prod │ ├── kustomization.yaml │ └── patch.yaml └── staging ├── kustomization.yaml └── patch.yaml Kustomize
  • 17.
  • 18.
    To start withKustomize, you need to have your original yaml files describing any resources you want to deploy into your cluster. Those files will be stored for this example in the folder ./k8s/base/ . In this example, we will work with a service , deployment resources and kustomization.yaml
  • 19.
    The result ofkustomize build k8s/base command will be the following, which is for now only the two files previously seen, concatenated:
  • 20.
    A kustomization filecontains fields falling into four categories: ● resources - what existing resources are to be customized. Example fields: resources, crds. ● generators - what new resources should be created. Example fields: configMapGenerator (legacy), secretGenerator (legacy). ● transformers - what to do to the aforementioned resources. Example fields: namePrefix, nameSuffix, images, commonLabels, patchesJson6902, etc. and the more general transformers. ● meta - fields which may influence all or some of the above. Example fields: vars, namespace, apiVersion, kind, etc.
  • 21.
    Why kustomize? ● Purelydeclarative ● Template-free customization via overlays ● Easy customization for common use-cases ● Flexible tooling
  • 22.
    Demo time! Svc: - Logging -Monitoring - Redis - Rabbitmq - Postgresql - kafka App: - app
  • 23.
    Install k create namespaceargocd k apply -n argocd -f https://../argo-cd/stable/manifests/install.yaml Download Argo CD CLI Login Using The CLI: k get po -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2 argocd login <ARGOCD_SERVER>
  • 24.
  • 25.
    Tnx to all мамі зато шо я такий класний Соні :3 ЗСУ/Добробатам youtube Ukrops Cluster.dev Send pm to demoontz*