Application Deployment with ArgoCD¶
This document explains how applications are defined, deployed, and managed using ArgoCD in this project.
Application Definition¶
In ArgoCD, applications are defined using the Application
custom resource. This project includes two sample applications:
- A Helm-based application (
0-application.yaml
) - A Kubernetes manifest-based application (
1-application.yaml
)
Example Application Definition¶
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myargoapp-0
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/sean-njela/argocd-demo.git
targetRevision: HEAD
path: environments/dev/helm/myargoapp-chart
helm:
valueFiles:
- values.yaml
destination:
server: https://kubernetes.default.svc
namespace: myapp-0
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Key Components of an Application Definition¶
Metadata¶
- name: Unique identifier for the application
- namespace: The namespace where the ArgoCD Application resource is created (typically
argocd
)
Spec¶
- project: The ArgoCD project this application belongs to (default or custom)
- source: Where to find the application manifests:
- repoURL: Git repository URL
- targetRevision: Git revision (branch, tag, commit)
- path: Path within the repository
- helm: Helm-specific configuration (if using Helm)
- destination: Where to deploy the application:
- server: Target Kubernetes cluster
- namespace: Target namespace for the application
- syncPolicy: How ArgoCD should handle synchronization:
- automated: Settings for automatic synchronization
- syncOptions: Additional sync options
Application Types¶
Helm-Based Applications¶
For applications packaged as Helm charts:
source:
repoURL: https://github.com/sean-njela/argocd-demo.git
targetRevision: HEAD
path: environments/dev/helm/myargoapp-chart
helm:
valueFiles:
- values.yaml
parameters:
- name: replicaCount
value: "2"
Kubernetes Manifest Applications¶
For applications defined with plain Kubernetes manifests:
source:
repoURL: https://github.com/sean-njela/argocd-demo.git
targetRevision: HEAD
path: environments/dev/apps/myapp
directory:
recurse: true
jsonnet: {}
Kustomize Applications¶
For applications using Kustomize:
source:
repoURL: https://github.com/sean-njela/argocd-demo.git
targetRevision: HEAD
path: environments/dev/kustomize
kustomize:
namePrefix: dev-
images:
- myapp:latest
Sync Policies¶
Manual Sync¶
Applications can be configured for manual synchronization:
With manual sync, changes must be applied explicitly through the UI or CLI.
Automated Sync¶
For automatic synchronization when changes are detected:
syncPolicy:
automated:
prune: true # Remove resources that no longer exist in Git
selfHeal: true # Revert manual changes made to the cluster
Sync Options¶
Additional synchronization options:
syncPolicy:
syncOptions:
- CreateNamespace=true # Create namespace if it doesn't exist
- PruneLast=true # Remove resources last during sync
- ApplyOutOfSyncOnly=true # Only apply resources that are out of sync
Application Health¶
ArgoCD monitors the health of deployed applications based on:
- Kubernetes resource status
- Custom health checks
- Resource-specific health assessments (e.g., Deployments, StatefulSets)
Health status is displayed in the UI and available via the API and CLI.
Deploying Applications¶
Using kubectl¶
Using ArgoCD CLI¶
# Create application from a manifest
argocd app create -f 0-application.yaml
# Create application with CLI parameters
argocd app create myapp \
--repo https://github.com/sean-njela/argocd-demo.git \
--path environments/dev/apps/myapp \
--dest-server https://kubernetes.default.svc \
--dest-namespace myapp
Using the ArgoCD UI¶
- Navigate to the ArgoCD UI at http://localhost:8080
- Click "New App" in the top left
- Fill in the application details
- Click "Create"
Managing Applications¶
Viewing Application Status¶
# Using kubectl
kubectl get applications -n argocd
kubectl describe application myapp -n argocd
# Using ArgoCD CLI
argocd app get myapp
argocd app list
Syncing Applications¶
# Using ArgoCD CLI
argocd app sync myapp
# Force sync (overwrite live state)
argocd app sync myapp --force
Deleting Applications¶
# Using kubectl
kubectl delete application myapp -n argocd
# Using ArgoCD CLI
argocd app delete myapp
Best Practices¶
- Use Declarative Definitions: Store Application manifests in Git
- Environment Separation: Use separate paths or values for different environments
- Resource Limits: Set appropriate CPU and memory limits
- Health Checks: Implement proper readiness and liveness probes
- Namespace Isolation: Use separate namespaces for different applications
- Sync Windows: Configure sync windows for controlled updates
- Progressive Delivery: Use canary or blue-green deployments for critical applications