Feedback

Chat Icon

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

Your First Argo CD Application: From CLI to Declarative Manifests
40%

Creating an Application With the argocd CLI

We will use the GitLab repository we created earlier to store our application manifests. If you have not created it yet, do so. Our repository hosts a simple application that we will deploy using Argo CD.

Clone the repository, or cd into its directory:

cd $HOME/todo/app

As a reminder, this is our file tree:

$HOME/todo/app
├── Dockerfile
├── app.py
├── .dockerignore
├── .git
├── requirements.txt
└── tests
    └── test_app.py

We also pushed our Docker image to the GitLab registry and exported the image name to $IMAGE_NAME.

Example:

registry.gitlab.com/learning9042634/todo:v0

To deploy the application, we need to create the Kubernetes resources that define it. We will create a Deployment and a Service (NodePort). Our application will live in the default namespace. Here is the manifest:

mkdir -p $HOME/todo/app/manifests/plain && \
cat < $HOME/todo/app/manifests/plain/app.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: todo-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: todo-app
  template:
    metadata:
      labels:
        app: todo-app
    spec:
      imagePullSecrets:
      - name: gitlab-registry
      containers:
      - image: ${IMAGE_NAME}
        name: todo-app
        ports:
        - containerPort: 5000
        resources:
          limits:
            cpu: 100m
            memory: 128Mi
          requests:
            cpu: 100m
            memory: 128Mi
        readinessProbe:
          httpGet:
            path: /tasks
            port: 5000
          initialDelaySeconds: 5
          periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

Enroll now to unlock all content and receive all future updates for free.