Create an Application
Table of Contentsβ
1 - Via the Web interfaceβ
Stepsβ
- Open the Argo CD UI (https://localhost:8080)
- Click + NEW APP
- Fill in the form:
| Field | Value |
|---|---|
| Application Name | guestbook |
| Project | default |
| Sync Policy | Manual |
| Repository URL | https://github.com/argoproj/argocd-example-apps.git |
| Path | guestbook |
| Cluster URL | https://kubernetes.default.svc |
| Namespace | default |
- Click CREATE
- Click SYNC to deploy
Workflow snapshotβ
π Back to table of contentsβ
2 - Via the CLIβ
Create an applicationβ
# Application simple
argocd app create guestbook \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
# VΓ©rifier
argocd app list
# Synchroniser
argocd app sync guestbook
Common optionsβ
# Avec auto-sync
argocd app create my-app \
--repo https://github.com/org/gitops.git \
--path apps/my-app \
--dest-server https://kubernetes.default.svc \
--dest-namespace production \
--sync-policy automated \
--auto-prune \
--self-heal
# Avec une branche spΓ©cifique
argocd app create my-app \
--revision main \
...
# Avec un tag
argocd app create my-app \
--revision v1.2.3 \
...
Useful commandsβ
# Voir le dΓ©tail
argocd app get guestbook
# Voir les ressources
argocd app resources guestbook
# Voir l'historique
argocd app history guestbook
# Supprimer
argocd app delete guestbook
π Back to table of contentsβ
3 - Via declarative YAMLβ
Basic Applicationβ
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: guestbook
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: HEAD
path: guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
Application with Sync Policyβ
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/org/gitops.git
targetRevision: main
path: apps/my-app
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- PruneLast=true
Applyβ
kubectl apply -f application.yaml
Best practicesβ
metadata:
# Finalizer pour cleanup propre
finalizers:
- resources-finalizer.argocd.argoproj.io
# Labels pour organisation
labels:
app.kubernetes.io/name: my-app
team: backend
env: production
π Back to table of contentsβ
4 - With Helmβ
From a Helm repositoryβ
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nginx
namespace: argocd
spec:
project: default
source:
repoURL: https://charts.bitnami.com/bitnami
chart: nginx
targetRevision: 15.0.0
helm:
values: |
replicaCount: 3
service:
type: ClusterIP
resources:
requests:
memory: 128Mi
cpu: 100m
destination:
server: https://kubernetes.default.svc
namespace: web
From a Git repo containing the chartβ
spec:
source:
repoURL: https://github.com/org/gitops.git
path: charts/my-app
targetRevision: HEAD
helm:
valueFiles:
- values.yaml
- values-prod.yaml
parameters:
- name: image.tag
value: v1.2.3
Helm with external valuesβ
spec:
source:
repoURL: https://github.com/org/gitops.git
path: charts/my-app
helm:
valueFiles:
- values.yaml
# Fichier depuis un autre path
- $values/environments/prod/values.yaml
sources:
- repoURL: https://github.com/org/config.git
ref: values
π Back to table of contentsβ
5 - With Kustomizeβ
Typical structureβ
apps/my-app/
βββ base/
β βββ kustomization.yaml
β βββ deployment.yaml
β βββ service.yaml
βββ overlays/
βββ dev/
β βββ kustomization.yaml
βββ prod/
βββ kustomization.yaml
Kustomize Applicationβ
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app-prod
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/org/gitops.git
path: apps/my-app/overlays/prod
targetRevision: HEAD
kustomize:
images:
- name: my-app
newTag: v1.2.3
destination:
server: https://kubernetes.default.svc
namespace: production
Image overridesβ
spec:
source:
kustomize:
images:
- name: nginx
newName: my-registry/nginx
newTag: custom-tag
namePrefix: prod-
nameSuffix: -v2
commonLabels:
env: production
π Back to table of contentsβ
6 - Hands-on exercisesβ
Exercise 1: Deploy guestbookβ
# CrΓ©er l'application
argocd app create guestbook \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
# Synchroniser
argocd app sync guestbook
# VΓ©rifier
kubectl get pods -n default
argocd app get guestbook
Exercise 2: Deploy with YAMLβ
# my-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: helm-guestbook
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
path: helm-guestbook
targetRevision: HEAD
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
kubectl apply -f my-app.yaml
Quizβ
Q1. What is the difference between path and chart in source?
Answer
- path: Path to a folder in a Git repo
- chart: Name of a chart in a Helm repository
You use path for local manifests (YAML, Kustomize, local chart) and chart for charts from a Helm registry.
π Back to table of contentsβ
Key takeawaysβ
- 3 methods: UI, CLI, declarative YAML
- Always specify source and destination
- Helm: registry repoURL + chart + version
- Kustomize: path to the overlay
- Use labels for organization