Skip to content

zainasr/platform-ops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Platform Operations - GitOps Repository

GitOps Kubernetes Helm Prometheus Grafana

Production-ready Kubernetes infrastructure managed through GitOps principles with comprehensive observability

This repository serves as the single source of truth for the entire platform infrastructure. It defines the desired state of all Kubernetes resources and is automatically reconciled by Argo CD. All changes to the cluster are driven exclusively through Git commitsβ€”no manual kubectl apply commands.


πŸ“‹ Table of Contents


🎯 Philosophy & Purpose

Core Question

"What should be running in the cluster right now?"

This repository provides the definitive answer through declarative configuration.

GitOps Principles

βœ… Git as Single Source of Truth
βœ… Declarative Infrastructure
βœ… Automated Reconciliation
βœ… Immutable Deployments
βœ… Auditable Change History
βœ… Self-Healing Capabilities

Design Principles

  • Separation of Concerns: Application code lives in platform repository
  • Environment Parity: Same patterns work across dev, staging, and production
  • Disposable Infrastructure: Clusters can be recreated from scratch in minutes
  • Progressive Delivery: Controlled rollouts with automated rollback capabilities
  • Observability First: Built-in monitoring, metrics, and visualization

πŸ“‚ Repository Structure

platform-ops/
β”‚
β”œβ”€β”€ helm/                          # Helm charts for all services
β”‚   β”œβ”€β”€ api-node/
β”‚   β”‚   β”œβ”€β”€ Chart.yaml            # Chart metadata
β”‚   β”‚   β”œβ”€β”€ values.yaml           # Default configuration
β”‚   β”‚   └── templates/            # Kubernetes manifests
β”‚   β”‚       β”œβ”€β”€ deployment.yaml
β”‚   β”‚       β”œβ”€β”€ service.yaml
β”‚   β”‚       β”œβ”€β”€ ingress.yaml
β”‚   β”‚       β”œβ”€β”€ hpa.yaml          # Horizontal Pod Autoscaler
β”‚   β”‚       β”œβ”€β”€ pdb.yaml          # Pod Disruption Budget
β”‚   β”‚       └── servicemonitor.yaml
β”‚   β”‚
β”‚   β”œβ”€β”€ core-go/
β”‚   β”‚   β”œβ”€β”€ Chart.yaml
β”‚   β”‚   β”œβ”€β”€ values.yaml
β”‚   β”‚   └── templates/
β”‚   β”‚       └── ...
β”‚   β”‚
β”‚   └── worker-python/
β”‚       β”œβ”€β”€ Chart.yaml
β”‚       β”œβ”€β”€ values.yaml
β”‚       └── templates/
β”‚           └── ...
β”‚
β”œβ”€β”€ argocd/                        # Argo CD Application definitions
β”‚   β”œβ”€β”€ api-node.yaml             # Application CRD for api-node
β”‚   β”œβ”€β”€ core-go.yaml              # Application CRD for core-go
β”‚   └── worker-python.yaml        # Application CRD for worker-python
β”‚
β”œβ”€β”€ observability/                 # Monitoring and observability stack
β”‚   β”œβ”€β”€ prometheus/               # Prometheus metrics collection
β”‚   β”‚   β”œβ”€β”€ namespace.yaml        # Dedicated namespace
β”‚   β”‚   β”œβ”€β”€ rbac.yaml             # ServiceAccount + ClusterRole
β”‚   β”‚   β”œβ”€β”€ configMap.yml         # Scrape configs & rules
β”‚   β”‚   β”œβ”€β”€ deployment.yaml       # Prometheus deployment
β”‚   β”‚   └── service.yaml          # Prometheus service
β”‚   β”‚
β”‚   └── grafana/                  # Grafana dashboards
β”‚       β”œβ”€β”€ deployment.yaml       # Grafana deployment
β”‚       β”œβ”€β”€ service.yaml          # Grafana service
β”‚       β”œβ”€β”€ configmap-dashboards.yaml
β”‚       └── configmap-datasources.yaml
β”‚
β”œβ”€β”€ ingress/                       # Ingress controller (NGINX)
β”‚   └── ingress-nginx.yaml
β”‚
└── README.md                      # This file

πŸ› οΈ Technology Stack

Component Technology Version Purpose
Orchestration Kubernetes 1.28+ Container orchestration
GitOps Argo CD 2.9+ Continuous deployment
Package Manager Helm 3.13+ Templating & versioning
Ingress NGINX Ingress 1.9+ External traffic routing
Metrics Prometheus 2.48+ Metrics collection
Visualization Grafana 10.2+ Dashboards & alerting
Container Registry GHCR Latest Image storage
Local Cluster Kind 0.20+ Local K8s cluster

βš™οΈ Helm Charts

Chart Structure

Each service has a dedicated Helm chart following best practices:

helm/service-name/
β”œβ”€β”€ Chart.yaml              # Chart metadata & versioning
β”œβ”€β”€ values.yaml            # Default values (overridable)
β”œβ”€β”€ values-dev.yaml        # Development overrides
β”œβ”€β”€ values-prod.yaml       # Production overrides
└── templates/
    β”œβ”€β”€ deployment.yaml    # Main workload
    β”œβ”€β”€ service.yaml       # Service definition
    β”œβ”€β”€ ingress.yaml       # External routing
    β”œβ”€β”€ hpa.yaml          # Autoscaling config
    β”œβ”€β”€ pdb.yaml          # Disruption budget
    β”œβ”€β”€ configmap.yaml    # Configuration data
    β”œβ”€β”€ secret.yaml       # Sensitive data (sealed)
    └── servicemonitor.yaml # Prometheus scraping

Chart Components

1. Deployment

  • Container specifications
  • Resource limits and requests
  • Security context (non-root)
  • Health probes (liveness/readiness)
  • Environment variables
  • Volume mounts

2. Service

  • ClusterIP service type
  • Port definitions
  • Selector labels
  • Session affinity (if needed)

3. Ingress

  • Path-based routing
  • TLS termination
  • SSL certificates
  • Rate limiting annotations

4. Horizontal Pod Autoscaler (HPA)

  • CPU-based scaling
  • Memory-based scaling
  • Custom metrics (optional)

5. Pod Disruption Budget (PDB)

  • Minimum available pods
  • Maximum unavailable pods
  • High availability guarantees

Key Benefits

βœ… Reusability: Same chart across dev/staging/prod
βœ… Versioning: Semantic versioning for charts
βœ… Templating: DRY principle with Go templates
βœ… Rollback: Built-in rollback capabilities
βœ… Testing: helm template and helm lint
βœ… GitOps Compatible: Declarative and deterministic

Example Values (api-node)

# values.yaml
replicaCount: 3

image:
  repository: ghcr.io/org/api-node
  tag: "a1b2c3d"
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 3000

ingress:
  enabled: true
  className: nginx
  hosts:
    - host: api.example.com
      paths:
        - path: /
          pathType: Prefix

resources:
  requests:
    cpu: 100m
    memory: 128Mi
  limits:
    cpu: 500m
    memory: 512Mi

autoscaling:
  enabled: true
  minReplicas: 3
  maxReplicas: 10
  targetCPUUtilizationPercentage: 70

πŸ” GitOps with Argo CD

Argo CD is responsible for continuous reconciliation.

Responsibilities

Watch this repository

Render Helm charts

Apply Kubernetes manifests

Enforce desired state continuously

Enabled Features

Automated sync

Drift correction (self-heal)

Resource pruning

❌ No kubectl apply is used for application workloads.

πŸ”„ CI β†’ GitOps Image Promotion Flow

This repository does not build images.

Flow

CI builds images in the platform repository

Images are tagged with Git commit SHA

CI updates image.repository and image.tag in Helm values.yaml

Changes are committed to this repository

Argo CD detects the change and deploys automatically

Rollback = Git revert

🌐 Networking

Service-to-service communication via Kubernetes DNS

External access via NGINX Ingress

TLS termination at Ingress (local / self-signed for Kind)

πŸ” Security Posture

Containers run as non-root

Read-only root filesystems

Least-privilege security context

No secrets committed to Git

Registry access via imagePullSecrets

πŸ“Š Observability (Manual Prometheus Setup)

Observability is intentionally installed manually (no Helm) to deeply understand Prometheus internals.

What is monitored

Application metrics (/metrics)

HTTP request counters and latency

Background worker metrics

What is NOT included (yet)

node-exporter

kube-state-metrics

Alertmanager

πŸ” Prometheus Architecture (Manual)

Prometheus is deployed as a Deployment and discovers applications using:

Kubernetes API

kubernetes_sd_configs

Label-based relabeling

Prometheus pulls metrics from:

api-node

core-go

worker-python

Each application exposes /metrics.

πŸ“‚ Prometheus Manifests

Located at:

observability/prometheus/

Includes:

Namespace

ServiceAccount

RBAC

ConfigMap (prometheus.yml)

Deployment

Service

Prometheus runs in the observability namespace and scrapes apps in default.

πŸš€ Running the Platform Locally (Clean Start) 1️⃣ Prerequisites

Docker

Kind

kubectl

GitHub account (GHCR access)

2️⃣ Create a Kind Cluster kind create cluster --name kind-cluster-1 kubectl config use-context kind-kind-cluster-1

3️⃣ Install Argo CD (Fresh) kubectl create namespace argocd

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

Verify:

kubectl get pods -n argocd

All pods must be Running, especially argocd-repo-server.

4️⃣ Configure GHCR Access (Required)

Create image pull secret:

kubectl create secret docker-registry ghcr-cred
--docker-server=ghcr.io
--docker-username=
--docker-password=
--docker-email=unused@example.com
-n default

Attach to default ServiceAccount:

kubectl patch serviceaccount default
-n default
-p '{"imagePullSecrets":[{"name":"ghcr-cred"}]}'

5️⃣ Register Applications in Argo CD kubectl apply -n argocd -f argocd/

Verify:

kubectl get applications -n argocd

Apps should move to:

Synced

Healthy

6️⃣ Install Prometheus (Manual) kubectl apply -f observability/prometheus/

Access Prometheus:

kubectl port-forward -n observability svc/prometheus 9090:9090

Open:

http://localhost:9090

Check:

Status β†’ Targets

All app targets should be UP

🧹 Cleaning the Cluster (Reset Everything) Remove Applications kubectl delete applications -n argocd --all

Remove Workloads kubectl delete namespace default kubectl create namespace default

Remove Prometheus kubectl delete namespace observability

Remove Argo CD (Full Reset) kubectl delete namespace argocd

🧠 Design Philosophy

GitOps-first

Immutable images

CI β‰  CD separation

Kubernetes-native patterns

Minimal but production-aligned

Learning-focused observability (manual first, Helm later)

πŸ“„ Related Repository Application Source & CI

➑️ https://github.com/zainasr/platform

About

GitOps infrastructure repository managing Kubernetes deployments via Argo CD, with Helm charts, Prometheus/Grafana observability, and automated reconciliation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors