Chapter 1: Argo Introduction and Environment Setup

Understanding the Argo ecosystem, core concepts, installation, and environment configuration for Argo CD, Argo Workflows, Argo Rollouts, and Argo Events

作者
14min

Argo Introduction and Environment Setup

Chapter 1: Getting Started with the Argo Ecosystem

This chapter will introduce the four core projects of the Argo ecosystem and guide you through setting up a complete Argo development environment.

1.1 Argo Ecosystem Overview

1.1.1 What is Argo?

Argo is a collection of open-source tools for Kubernetes that helps you implement:

  • GitOps-based continuous deployment (Argo CD)
  • Cloud-native workflow orchestration (Argo Workflows)
  • Progressive delivery (Argo Rollouts)
  • Event-driven automation (Argo Events)

All Argo projects are part of the CNCF (Cloud Native Computing Foundation) ecosystem and are widely used in production environments.

1.1.2 Argo Family

🔄 正在渲染 Mermaid 图表...

1.1.3 Component Responsibilities

ComponentPurposeUse Cases
Argo CDDeclarative GitOps continuous deployment tool- Automated deployment
- Configuration management
- Multi-environment management
Argo WorkflowsKubernetes-native workflow engine- CI/CD pipelines
- Data processing
- Machine learning tasks
Argo RolloutsKubernetes progressive delivery controller- Blue-green deployment
- Canary releases
- Automated rollback
Argo EventsEvent-driven workflow automation framework- Event listening
- Automated triggering
- Complex event processing

1.2 Core Concepts

1.2.1 GitOps Principles

GitOps is a way to implement continuous delivery that uses Git as the single source of truth for declarative infrastructure and applications:

🔄 正在渲染 Mermaid 图表...

GitOps Core Principles:

  1. Declarative: The system state is described declaratively
  2. Versioned: Canonical desired system state versioned in Git
  3. Automatically Pulled: Software agents automatically pull the desired state declarations from Git
  4. Continuously Reconciled: Software agents continuously observe actual system state and attempt to apply desired state

1.2.2 Workflow DAG Pattern

Argo Workflows supports DAG (Directed Acyclic Graph) workflow definitions:

🔄 正在渲染 Mermaid 图表...

1.2.3 Progressive Delivery Strategies

Argo Rollouts supports multiple deployment strategies:

🔄 正在渲染 Mermaid 图表...

1.3 Environment Preparation

1.3.1 Prerequisites

Before starting, ensure you have the following tools installed:

# 1. kubectl - Kubernetes CLI
kubectl version --client

# 2. Kind - Local Kubernetes cluster (or use Minikube, k3s)
kind version

# 3. Git client
git --version

# 4. (Optional) Helm
helm version

# 5. (Optional) Docker
docker version

1.3.2 Creating a Kubernetes Cluster

Use Kind to create a local Kubernetes cluster:

# kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: argo-demo
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
- role: worker
- role: worker

Create the cluster:

# Create cluster using config file
kind create cluster --config kind-config.yaml

# Verify cluster is running
kubectl cluster-info
kubectl get nodes

1.3.3 Installing Ingress Controller

Install NGINX Ingress Controller for external access:

# Install NGINX Ingress
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

# Wait for Ingress Controller to be ready
kubectl wait --namespace ingress-nginx \
  --for=condition=ready pod \
  --selector=app.kubernetes.io/component=controller \
  --timeout=90s

1.4 Installing Argo CD

1.4.1 Installing Argo CD

# Create namespace
kubectl create namespace argocd

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

# Wait for all pods to be ready
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s

# View all resources
kubectl get all -n argocd

1.4.2 Accessing Argo CD UI

# Method 1: Port forwarding (for quick testing)
kubectl port-forward svc/argocd-server -n argocd 8080:443

# Method 2: Configure Ingress (recommended for production)
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argocd-server-ingress
  namespace: argocd
  annotations:
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  ingressClassName: nginx
  rules:
  - host: argocd.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: argocd-server
            port:
              number: 443
EOF

# Add to /etc/hosts
echo "127.0.0.1 argocd.local" | sudo tee -a /etc/hosts

1.4.3 Getting Initial Password

# Get initial admin password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

# Login credentials
# Username: admin
# Password: (output from above command)

1.4.4 Installing Argo CD CLI

# macOS
brew install argocd

# Linux
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x /usr/local/bin/argocd

# Windows
# Download from: https://github.com/argoproj/argo-cd/releases/latest

# Verify installation
argocd version

1.4.5 CLI Login

# Login to Argo CD
argocd login argocd.local --username admin --password $(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)

# Change password
argocd account update-password

1.5 Installing Argo Workflows

1.5.1 Installing Argo Workflows

# Create namespace
kubectl create namespace argo

# Install Argo Workflows
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/latest/download/install.yaml

# Wait for pods to be ready
kubectl wait --for=condition=Ready pods --all -n argo --timeout=300s

# View resources
kubectl get all -n argo

1.5.2 Configuring Access Permissions

# Create ServiceAccount for workflow execution
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  name: argo-workflow
  namespace: argo
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: argo-workflow-role
  namespace: argo
rules:
- apiGroups: [""]
  resources: ["pods", "pods/log"]
  verbs: ["get", "watch", "list"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["create"]
- apiGroups: ["argoproj.io"]
  resources: ["workflows", "workflowtemplates"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: argo-workflow-binding
  namespace: argo
subjects:
- kind: ServiceAccount
  name: argo-workflow
  namespace: argo
roleRef:
  kind: Role
  name: argo-workflow-role
  apiGroup: rbac.authorization.k8s.io
EOF

1.5.3 Accessing Workflows UI

# Port forwarding
kubectl -n argo port-forward svc/argo-server 2746:2746

# Configure Ingress
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argo-workflows-ingress
  namespace: argo
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
  ingressClassName: nginx
  rules:
  - host: argo-workflows.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: argo-server
            port:
              number: 2746
EOF

echo "127.0.0.1 argo-workflows.local" | sudo tee -a /etc/hosts

1.5.4 Installing Argo Workflows CLI

# macOS
brew install argo

# Linux
curl -sLO https://github.com/argoproj/argo-workflows/releases/latest/download/argo-linux-amd64.gz
gunzip argo-linux-amd64.gz
chmod +x argo-linux-amd64
sudo mv argo-linux-amd64 /usr/local/bin/argo

# Verify installation
argo version

1.6 Installing Argo Rollouts

1.6.1 Installing Argo Rollouts

# Create namespace
kubectl create namespace argo-rollouts

# Install Argo Rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml

# Verify installation
kubectl get pods -n argo-rollouts

1.6.2 Installing Kubectl Plugin

# macOS/Linux
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/')
chmod +x kubectl-argo-rollouts-*
sudo mv kubectl-argo-rollouts-* /usr/local/bin/kubectl-argo-rollouts

# Verify installation
kubectl argo rollouts version

1.6.3 Accessing Rollouts Dashboard

# Start dashboard
kubectl argo rollouts dashboard

# Visit http://localhost:3100

1.7 Installing Argo Events

1.7.1 Installing Argo Events

# Create namespace
kubectl create namespace argo-events

# Install Argo Events
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install.yaml

# Install event sources and sensors
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install-validating-webhook.yaml

# Verify installation
kubectl get pods -n argo-events

1.7.2 Creating EventBus

cat <<EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
  name: default
  namespace: argo-events
spec:
  nats:
    native:
      replicas: 3
      auth: token
EOF

# Verify EventBus status
kubectl -n argo-events get eventbus default

1.8 Verification and Testing

1.8.1 Complete Installation Check

# Check all namespaces
kubectl get pods -n argocd
kubectl get pods -n argo
kubectl get pods -n argo-rollouts
kubectl get pods -n argo-events

# Check services
kubectl get svc -n argocd
kubectl get svc -n argo
kubectl get svc -n argo-events

1.8.2 Creating First Workflow

cat <<EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-
  namespace: argo
spec:
  entrypoint: whalesay
  serviceAccountName: argo-workflow
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["Hello Argo!"]
EOF

# View workflow execution
argo list -n argo
argo logs @latest -n argo

1.8.3 Creating First Application (using Argo CD)

# Create a simple application
cat <<EOF | kubectl apply -f -
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
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
EOF

# Check application status
argocd app get guestbook

1.9 Chapter Summary

In this chapter, we’ve learned:

  1. Argo Ecosystem Overview: Understanding the four core projects and their relationships
  2. Environment Setup: Creating a Kubernetes cluster with Kind
  3. Installing Components: Installing and configuring Argo CD, Workflows, Rollouts, and Events
  4. Verification: Running simple tests to ensure everything works
🔄 正在渲染 Mermaid 图表...

In the next chapter, we’ll dive deeper into Argo CD basics and learn how to implement GitOps.