Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

Argo CD E2E

 Refer Doc:

Using Azure Devops CI CD Code For AKS:-

https://github.com/shivscloud/azure-devops-aks/tree/main

https://github.com/mabusaa/argocd-course-issues-tracker/blob/main/slides.pdf

AKS login to the AKS Cluster

az aks get-credentials --resource-group rajesh-aks-deploy --name dev-rajesh-aks

What is GitOps:-

GitOps is a methodology for implementing and managing cloud-native infrastructure and applications. It leverages Git as a single source of truth for declarative infrastructure and application code. The core idea of GitOps is to use Git repositories as the canonical source for defining and versioning the desired state of the entire system, including infrastructure configuration, application code, and deployment manifests.

Key principles of GitOps include:

  1. Declarative Configuration: Infrastructure and application configuration are declared in a human-readable format (e.g., YAML) and stored in Git repositories. This declarative approach defines the desired state of the system rather than relying on imperative scripts or commands.

  2. Version Control: Git repositories serve as a version-controlled history of changes to infrastructure and application code. This enables easy rollback to previous configurations, auditability, and collaboration among team members.

  3. Continuous Delivery: Changes to the Git repository trigger automated workflows for deployment and reconciliation of the actual state of the system with the desired state. Continuous integration/continuous delivery (CI/CD) pipelines automate the deployment process based on changes to the Git repository.

  4. Observability and Control: GitOps platforms typically provide monitoring and observability tools to track the state of the system in real-time. Operators have full visibility into changes, deployments, and system health. GitOps also emphasizes the importance of applying Git-based access controls to manage who can make changes to the system.

  5. Self-Healing and Reconciliation: GitOps systems continuously monitor the actual state of the system and automatically reconcile any deviations from the desired state. If the actual state diverges from the desired state due to manual changes or external factors, the system automatically applies the necessary corrections to bring the system back to the desired state.

By adopting GitOps practices, organizations can achieve greater reliability, repeatability, and scalability in managing their cloud-native infrastructure and applications. GitOps simplifies deployment workflows, enhances collaboration among development and operations teams, and promotes a culture of automation and continuous improvement. Popular tools for implementing GitOps include ArgoCD, Flux, and Jenkins X.

Why GitOPS:

Easy rollbacks:

If bad version got deployed we can revert using git revert.



GitOps follows pull model:
It will have Controller it will pull the code from source and applies the changes in destination.

ArgoCD is the GitOps based CD tool with pull model design.(When ever changes happen in git will apply in destination i.e K8)

It will track your manifest versions.ArgoCD is not CI tool we have CI tools like azuredevops,GitLAB & Github actions



Argo always sync the git changes.

Core Components:

It support 
Helm Charts and Kustomize application and Directory of yaml files and Jsonnet 
  1. Application Controller: ArgoCD's application controller is responsible for reconciling the desired state of applications defined in Git repositories with the actual state of applications running in Kubernetes clusters. It continuously monitors the Git repositories for changes and applies those changes to the target clusters, ensuring that the applications are deployed and configured correctly. It will define source and destination deploy group of k8 resource

  2. Project : It will provide logical grouping of applications

  3. Application CRDs: ArgoCD uses Custom Resource Definitions (CRDs) to define applications and their associated configuration in Kubernetes. Users define applications as custom resources (e.g., Application or AppProject) in YAML format, specifying details such as the Git repository URL, target cluster, sync policy, and other parameters.

  4. API Server: ArgoCD provides an API server that exposes RESTful endpoints for managing applications, repositories, and other resources. The API server allows users to interact with ArgoCD programmatically via HTTP requests, enabling automation and integration with other tools and systems.

  5. Web UI: ArgoCD includes a web-based user interface (UI) that provides a graphical interface for managing applications and clusters. The UI allows users to view the status of applications, compare the desired and actual states, trigger manual syncs, view logs, and perform other administrative tasks.

  6. CLI Tool: In addition to the web UI, ArgoCD provides a command-line interface (CLI) tool (argocd) for interacting with the ArgoCD API and performing administrative tasks from the command line. The CLI tool allows users to manage applications, repositories, clusters, and other resources using simple commands.

  7. Repository Server: ArgoCD includes a repository server component that manages Git repositories containing application manifests and configuration files. The repository server periodically polls Git repositories for changes and synchronizes them with the internal state of ArgoCD, triggering application deployments as needed.

  8. Health Monitoring and Metrics: ArgoCD includes built-in health monitoring and metrics collection capabilities to track the health and performance of the system. Metrics such as application sync status, repository sync status, and resource utilization are exposed via Prometheus-compatible endpoints for monitoring and alerting purposes.

These core components work together to enable continuous delivery of applications to Kubernetes clusters using Git as the source of truth. ArgoCD automates the deployment and configuration of applications, enforces desired state management, and provides visibility and control over the deployment process.


***Sync:Actual state = desired state


Architecture of Argocd

Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/architecture/


API Server¶
Repository Server¶
Application Controller¶
=============================Setup Argo CD=======================
Ref:- https://techcommunity.microsoft.com/t5/apps-on-azure-blog/getting-started-with-gitops-argo-and-azure-kubernetes-service/ba-p/3288595

We need one running k8 cluster.
For HA we need atleast 3 worker nodes
Privilage options:
1.Cluster level options
2.Namespace level access

You need to create a namespace for argocd.

kubectl create ns argocd

and then choose one of the below options :

1. Non-HA:

a. cluster-admin privileges: https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

b. namespace level privileges: https://github.com/argoproj/argo-cd/raw/stable/manifests/namespace-install.yaml

2. HA:

a. cluster-admin privileges: https://github.com/argoproj/argo-cd/raw/stable/manifests/ha/install.yaml

b. namespace level privileges: https://github.com/argoproj/argo-cd/raw/stable/manifests/ha/namespace-install.yaml

3. Light installation "Core"

https://github.com/argoproj/argo-cd/raw/stable/manifests/core-install.yaml

4. Helm chart: https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd

Login to any EKS or AKS cluster:
az aks get-credentials --resource-group rajesh-aks-deploy --name dev-rajesh-aks


kubectl create ns argocd
kubectl get ns
NAME              STATUS   AGE
argocd            Active   7s
default           Active   47m
kube-node-lease   Active   47m
kube-public       Active   47m
kube-system       Active   47m

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Sample output:
raj [ ~ ]$ kubectl get pods -n argocd
NAME                                               READY   STATUS    RESTARTS   AGE
argocd-application-controller-0                    1/1     Running   0          41s
argocd-applicationset-controller-79c95f5d7-qb8gc   1/1     Running   0          45s
argocd-dex-server-f5d97b5b-rnc62                   1/1     Running   0          45s
argocd-notifications-controller-7f8d9dd7f-sdgpz    1/1     Running   0          44s
argocd-redis-69f8795dbd-hldrs                      1/1     Running   0          43s
argocd-repo-server-9cf5d5585-m2dst                 1/1     Running   0          43s
argocd-server-7574cff9df-bvcpl                     1/1     Running   0          42s


**Get the Admin intial password that set by argocd

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
 Exposing ArgoCD server:-
By default argoCD won't expose to any endpoint
Hot fix to access not recommended:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
kubectl port-forward svc/argocd-server -n argocd 8080:443

As of now going with 
Best practice :

Setup ingress 

https://learn.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-cli&WT.mc_id=opensource-52942-jessde
**https://rajesh-singamsetti.blogspot.com/2024/03/aks-ingress-setup.html

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

helm install ingress-nginx ingress-nginx/ingress-nginx \
  --create-namespace \
  --namespace ingress-basic \
  --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz \
  --set controller.service.externalTrafficPolicy=Local


kubectl get svc -n ingress-basic

Argo CD CLI Installation:-
https://argo-cd.readthedocs.io/en/stable/cli_installation/

IP: access argo cd
Username: admin
Password:kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo


=======================Argo CD Application========================
Its a k8 resource object


Repo url:https://github.com/shivscloud/azure-k8-manifest
Click on create after application created it will be like below






Post a Comment

0 Comments

Ad Code

Responsive Advertisement