Skip to content

cjanowski/k8s-python-argocd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Python App with Argo CD on AWS

This boilerplate provides a complete setup for deploying a Python Flask application on Kubernetes using Argo CD for GitOps on AWS.

Structure

k8s-python-argocd/
├── app/
│   └── app.py              # Python Flask application
├── manifests/              # Kubernetes manifests
│   ├── namespace.yaml
│   ├── deployment.yaml
│   ├── service.yaml
│   ├── ingress.yaml
│   ├── serviceaccount.yaml
│   └── secret.yaml
├── argocd/                 # Argo CD configurations
│   ├── application.yaml
│   └── project.yaml
├── Dockerfile
├── requirements.txt
├── aws-iam-policy.json
└── README.md

Prerequisites

  • EKS cluster running on AWS
  • Argo CD installed on the cluster
  • AWS Load Balancer Controller installed
  • ECR repository for container images
  • Proper IAM roles and policies

Setup Instructions

1. Build and Push Docker Image

# Build the Docker image
docker build -t python-app .

# Tag for ECR
docker tag python-app:latest YOUR_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/python-app:latest

# Push to ECR
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin YOUR_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com
docker push YOUR_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/python-app:latest

2. Create IAM Role for Service Account

# Create IAM policy
aws iam create-policy \
    --policy-name python-app-policy \
    --policy-document file://aws-iam-policy.json

# Create IAM role for service account
eksctl create iamserviceaccount \
    --name python-app-sa \
    --namespace python-app \
    --cluster YOUR_CLUSTER_NAME \
    --attach-policy-arn arn:aws:iam::YOUR_ACCOUNT:policy/python-app-policy \
    --approve

3. Update Configuration

  1. Update argocd/application.yaml with your Git repository URL
  2. Update manifests/deployment.yaml with your ECR image URL
  3. Update manifests/serviceaccount.yaml with your AWS account ID
  4. Update manifests/secret.yaml with actual base64 encoded AWS credentials (or use AWS IAM roles)

4. Deploy with Argo CD

# Apply Argo CD project
kubectl apply -f argocd/project.yaml

# Apply Argo CD application
kubectl apply -f argocd/application.yaml

Features

  • Flask Application: Simple Python web app with health checks and AWS integration
  • Kubernetes Manifests: Complete set of K8s resources including deployment, service, ingress
  • Argo CD GitOps: Automated deployment with sync policies
  • AWS Integration: IAM roles, ECR, ALB ingress controller
  • Security: Service accounts, RBAC, secrets management
  • Health Checks: Liveness and readiness probes

Endpoints

  • / - Root endpoint with app info
  • /health - Health check endpoint
  • /aws-info - AWS connectivity test

Customization

  • Modify app/app.py for your application logic
  • Update manifests/deployment.yaml for scaling and resource requirements
  • Adjust argocd/application.yaml for sync policies and source configuration
  • Modify aws-iam-policy.json for required AWS permissions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published