AKS Architecture Diagram

Production-Grade AKS Cluster with Terraform

🎯 Problem Statement Organizations moving to Kubernetes often struggle with: Manual cluster provisioning leading to configuration drift Lack of security hardening and compliance controls No standardized approach to cluster lifecycle management Difficulty reproducing environments consistently πŸ’‘ Solution Overview I designed and implemented a fully automated AKS deployment pipeline using Terraform that provisions production-grade Kubernetes clusters with built-in security, monitoring, and networking configurations. πŸ—οΈ Architecture β”Œ β”‚ β”œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ ─ ─ β”Œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ β”Œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ A I C ─ ─ A + ─ ─ ─ ─ ─ ─ ─ β”Œ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”” ─ ─ p n o ─ ─ z ─ ─ ─ ─ ─ ─ ─ A ─ ─ ─ ─ ─ ─ p g n ─ ─ u L ─ ─ ─ ─ ─ ─ ─ z ─ S ( ─ ─ S ( ─ ─ ─ r t ─ ─ r o ─ ─ ─ ─ ─ ─ ─ u ─ u A ─ ─ u A ─ ─ ─ G e r ─ ─ e g ─ ─ ─ ─ ─ ─ ─ r ─ b K ─ ─ b p ─ ─ ─ a s o ─ ─ ─ ─ ─ ─ ─ ─ ─ e ─ n S ─ ─ n p ─ ─ ─ t s l ─ ─ M A ─ ─ ─ ─ ─ ─ ─ ─ e ) ─ ─ e G ─ ─ ─ e l ─ ─ o n ─ ─ ─ ─ ─ ─ ─ V ─ t ─ ─ t W ─ ─ ─ w e ─ ─ n a ─ ─ ─ ─ ─ ─ ─ N ─ ─ ─ ) ─ ─ ─ a r ─ ─ i l ─ ─ ─ ─ ─ ─ ─ e ─ 1 ─ ─ 2 ─ ─ ─ y ─ ─ t y ─ ─ ─ ─ ─ ─ ─ t ─ ─ ─ ─ ─ ─ ─ ─ o t ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ r i ─ ─ ─ ─ ─ ─ ─ ┐ β”‚ β”‚ β”˜ ┐ β”‚ β”‚ β”˜ ─ ─ ─ ─ c ─ ─ ─ ─ ─ ─ ─ β—„ ─ ─ ─ ─ s ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ R ┐ β”‚ β”‚ β”Ό β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ ┐ β”‚ β”‚ β”‚ β”˜ ┐ β”‚ β”‚ β”˜ ─ ─ ─ A ─ ─ e ─ β—„ ─ ─ ─ z ─ ─ s ─ ─ ─ ─ ─ u ─ ─ o β”Œ β”‚ β”‚ β”Ό β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Ό β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”” ─ ─ ─ r ─ ─ u ─ ─ ─ ─ ─ ─ ─ ─ ─ e ─ ─ r ─ β–Ί β–Ί ─ ─ ─ ─ ─ ─ ─ ─ c ─ β”Œ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”” β”Œ β”‚ β”” β”Œ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ S ─ ─ e ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ C ( ─ ─ ─ ─ u ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ o A ─ ─ ─ ─ b ─ ─ G ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ n C ─ ─ ─ ─ s ─ ─ r ─ ─ S ( ─ ─ U ( ─ ─ A ─ ─ A ( ─ ─ ─ t R ─ ─ ─ ─ c ─ ─ o ─ ─ y 3 ─ ─ s s ─ ─ z ─ ─ z s ─ ─ ─ a ) ─ ─ ─ ─ r ─ ─ u ─ A ─ s ─ ─ e p ─ ─ u ─ ─ u e ─ ─ ─ i ─ ─ ─ ─ i ─ ─ p ─ K ─ t n ─ ─ r o ─ ─ r ─ ─ r c ─ ─ ─ n ─ ─ ─ ─ p ─ ─ ─ S ─ e o ─ ─ t ─ ─ e ─ ─ e r ─ ─ ─ e ─ ─ ─ ─ t ─ ─ ─ ─ m d ─ ─ N ─ ─ ─ ─ e ─ ─ ─ r ─ ─ ─ ─ i ─ ─ ─ C ─ e ─ ─ o i ─ ─ C ─ ─ K t ─ ─ ─ ─ ─ ─ ─ o ─ ─ ─ l ─ N s ─ ─ d n ─ ─ N ─ ─ e s ─ ─ ─ R ─ ─ ─ ─ n ─ ─ ─ u ─ o , ─ ─ e s ─ ─ I ─ ─ y ─ ─ ─ e ─ ─ ─ ─ ─ ─ ─ s ─ d ─ ─ t ─ ─ ─ ─ m ─ ─ ─ g ─ ─ ─ ─ ─ ─ ─ t ─ e a ─ ─ P a ─ ─ + ─ ─ V g ─ ─ ─ i ─ ─ ─ ─ ─ ─ ─ e ─ u ─ ─ o n ─ ─ ─ ─ a m ─ ─ ─ s ─ ─ ─ ─ ─ ─ ─ r ─ P t ─ ─ o c ─ ─ C ─ ─ u t ─ ─ ─ t ─ ─ ─ ─ ─ ─ ─ ─ o o ─ ─ l e ─ ─ a ─ ─ l ) ─ ─ ─ r ─ ─ ─ ─ ─ ─ ─ ─ o s ─ ─ s ─ ─ l ─ ─ t ─ ─ ─ y ─ ─ ─ ─ ─ ─ ─ ─ l c ─ ─ ) ─ ─ i ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ a ─ ─ ─ ─ c ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ l ─ ─ ─ ─ o ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ e ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ) ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ β”‚ β”‚ ─ ─ β”‚ β”‚ ─ ─ ─ ─ β”‚ β”‚ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ β”˜ ┐ β”˜ ┐ β”‚ β”˜ ┐ β”˜ ─ ─ ─ ─ ─ ─ ─ ─ ─ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ ─ ─ β”‚ β”‚ ─ ─ ─ ─ ─ ─ ┐ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ ┐ β”˜ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ ─ ─ ─ ─ ┐ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ ─ ─ ─ β”‚ ─ ─ ─ ─ ─ ─ ─ ─ ─ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ ─ ┐ ─ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ β”‚ β”‚ πŸ› οΈ Technologies Used Category Technology IaC Terraform 1.5+ Cloud Provider Microsoft Azure Container Orchestration Azure Kubernetes Service (AKS) Networking Azure CNI, Calico Network Policies Ingress Application Gateway Ingress Controller Secrets Management Azure Key Vault + CSI Driver Monitoring Azure Monitor, Prometheus, Grafana CI/CD GitHub Actions State Management Azure Storage Backend πŸ“ Project Structure a β”œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”œ β”‚ β”‚ β”‚ β”œ β”œ β”œ β”” k ─ ─ ─ ─ ─ ─ s ─ ─ ─ ─ ─ ─ - t m β”œ β”‚ β”‚ β”‚ β”‚ β”œ β”œ β”” e β”œ β”œ β”” m v o t e o ─ ─ ─ ─ n ─ ─ ─ a a u e r d ─ ─ ─ ─ v ─ ─ ─ i r t r r u i n i p r a l a β”œ β”œ β”œ β”” n m s r d s p . a u a f e k ─ ─ ─ ─ e o e o e t r t b t f o s s ─ ─ ─ ─ t n c n v a o f l s o r / / w i u m / g d e . r m m v o v o t r e i / s t m / a a u e r o i n n . f . i r t r k r t t g t t n i p s i i y s / f f . a u i n n / / v t b t o g g a f l s n / / r e . s s s t . . . f t e t f x f a m p l e πŸ” Security Features Azure AD Integration - RBAC with Azure Active Directory Pod Security Standards - Enforced baseline policies Network Policies - Calico for micro-segmentation Private Cluster - API server with private endpoint Key Vault Integration - Secrets injected via CSI driver Defender for Containers - Runtime threat protection πŸ“Š Key Metrics Achieved Metric Result Deployment Time < 20 minutes Configuration Drift 0% (enforced via GitOps) Security Compliance 100% CIS Benchmark Cost Optimization 35% savings with spot nodes πŸ”‘ Key Learnings Module Reusability - Designing Terraform modules for reuse across environments saves significant time State Management - Remote state with locking is critical for team collaboration Security First - Building security into the infrastructure from day one prevents costly retrofits Documentation - Self-documenting code with clear variable descriptions improves maintainability πŸ”— Resources GitHub Repository: github.com/yourusername/aks-terraform Related Blog Post: Best Practices for Production AKS Clusters Want to discuss this project? Get in touch! ...

June 15, 2024 Β· 9 min Β· 1775 words Β· Elmi Abdullahi
GitOps Architecture Diagram

GitOps with ArgoCD and Kubernetes

🎯 Problem Statement Traditional deployment approaches often suffer from: Manual deployments leading to human errors Configuration drift between environments Lack of audit trail for changes Slow rollback processes during incidents No single source of truth for cluster state πŸ’‘ Solution Overview I implemented a GitOps-based continuous deployment pipeline using ArgoCD that treats Git as the single source of truth for declarative infrastructure and application definitions. πŸ—οΈ Architecture β”Œ β”‚ β”” β”Œ β”‚ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”‚ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ G ( - - - ─ ─ ─ ─ A S R ─ ─ i C ─ ─ ─ ─ p o e ─ ─ t I B T P ─ ─ ─ ─ p u p ─ ─ H u e u ─ ─ ─ ─ l r o ─ ─ u P i s s ─ ─ ─ ─ i c s ─ ─ b i l t h ─ ─ ─ β”‚ β–Ό ─ c e i ─ β”‚ β”‚ β–Ό ─ p d ─ β”Œ β”‚ β”‚ β”‚ β”‚ β”‚ β”” ─ ─ ─ a t ─ ─ A e I ─ ─ ─ ─ ─ ─ t C o ─ ─ c l m ─ ─ ─ ─ ─ ─ i o r ─ ─ t i a ─ ─ β”Œ β”‚ β”‚ β”” ─ ─ ─ ─ o d y ─ ─ i n g ─ ─ ─ N ─ ─ ─ ─ ─ n e ─ ─ o e e ─ ─ ─ a ─ ─ ─ ─ ─ ─ ─ n ) ─ ─ ─ m ─ ─ ─ ─ ─ ─ ─ s ─ ─ ─ D e ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ e s ─ ─ ─ ─ ┐ β”‚ β”‚ β”‚ β”˜ ┐ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ ─ ─ v p ─ ─ ─ ─ ─ ─ ─ ─ ─ a ─ ─ ─ ─ ─ ─ ─ ─ ─ c ─ ─ ─ ─ ─ ─ ─ ─ K ─ e ─ ─ ─ ─ ─ ─ ─ ─ u ┐ β”‚ β”‚ β”˜ ─ ─ ─ β–Ί β–Ί ─ ─ b ─ ─ D ─ β”Œ β”‚ β”‚ β”‚ β”” β”Œ β”‚ β”‚ β”‚ β”‚ β”Ό β”‚ β”” ─ e β”Œ β”‚ β”‚ β”” ─ ─ e ─ ─ ─ ─ ─ ─ ─ r ─ N ─ ─ ─ v ─ ─ ─ ─ ─ ─ ─ n ─ S a ─ ─ ─ e ─ ─ ─ ─ ( - - ─ - ─ ─ e ─ t m ─ ─ ─ l ─ ─ C ( ─ ─ C ─ ─ ─ t ─ a e ─ ─ ─ o ─ ─ o K ─ ─ D S H ─ R ─ ─ e ─ g s ─ ─ ─ p ─ ─ n 8 ─ ─ A y e ─ o ─ ─ s ─ i p ─ ─ ─ e ─ ─ f s ─ ─ r P n a ─ l ─ ─ ─ n a ─ ─ ─ r ─ ─ i ─ ─ g l c l ─ l ─ ─ C ─ g c ─ ─ ─ ─ ─ g Y ─ β”‚ β”‚ β–Ό ─ o a t ─ b ─ β”‚ β–Ό ─ l ─ e ─ ─ ─ W ─ ─ A ─ ─ C t h ─ a ─ ─ u ┐ β”‚ β”‚ β”˜ ─ ─ o ─ ─ R M ─ ─ D f ─ c ─ ─ s ─ ─ r ─ ─ e L ─ ─ o C ─ k ─ ─ t β”Œ β”‚ β”‚ β”” ─ ─ k ─ ─ p ) ─ ─ r h ─ ─ ─ e ─ N ─ ─ ─ f ─ ─ o ─ ─ m e ─ ─ ─ r ─ a ─ ─ ─ l ─ ─ ─ ─ ) c ─ ─ ─ ─ P m ─ ─ ─ o ─ ─ ─ ─ k ─ ─ ─ ─ r e ─ ─ ─ w ─ ─ ─ ─ ─ ─ ─ ─ o s ─ ─ ─ ─ ┐ β”‚ β”‚ β”‚ β”˜ ┐ β”‚ β”‚ β”‚ β”‚ β”Ό β”‚ β”˜ ─ ─ d p ─ ─ ─ ─ ─ ─ ─ a ─ ─ ─ ─ ─ ─ ─ c ─ ─ ─ ─ ─ ─ ─ e ─ ─ ─ ─ ─ ─ ┐ β”‚ β”‚ β”˜ ─ ─ ─ ─ ─ ─ ─ ─ β”Œ β”‚ β”‚ β”‚ β”” ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ C R ( ─ ─ ─ β”‚ β”‚ β”‚ β”‚ ─ ─ ─ ─ o e A ─ ─ ┐ β”‚ β”˜ ─ ─ ─ n g C ─ ─ ─ ─ ─ t i R ─ ─ ─ ─ ─ a s / ─ β”‚ β”‚ β”‚ β”‚ β”‚ β”˜ ─ ─ ─ i t G ─ β–² β”‚ β”‚ ─ ─ ─ n r C ─ ─ ─ ─ e y R ─ ─ ─ ─ r ) ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ β”˜ ┐ β”‚ β”‚ β”‚ β”˜ β”‚ πŸ› οΈ Technologies Used Category Technology GitOps Platform ArgoCD 2.8+ CI Platform GitHub Actions Container Registry Azure Container Registry Kubernetes AKS / GKE Secrets Management Sealed Secrets / External Secrets Notifications Slack, Microsoft Teams Metrics Prometheus + ArgoCD Metrics πŸ“ Repository Structure # a β”œ β”œ β”œ β”‚ β”‚ β”” # g β”œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”œ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”” p ─ ─ ─ ─ i ─ ─ ─ A p ─ ─ ─ ─ G t ─ ─ ─ p - i o p r s D . β”” R t p a β”œ β”‚ β”‚ β”‚ β”‚ β”” a β”œ β”‚ β”‚ β”‚ β”” i β”œ β”œ β”” l e r o g ─ E O s p ─ ─ r ─ ─ n ─ ─ ─ i p c c i ─ A p - p ─ ─ g ─ ─ f ─ ─ ─ c o k t D s r s o r a e h w β”” M e / b β”œ β”œ β”œ β”” β”œ β”œ β”” c a β”œ β”œ β”” p β”” a c i m t r u o ─ E C p a ─ ─ ─ ─ v ─ ─ ─ d p ─ ─ ─ r ─ s e n o i f b r ─ . o o s ─ ─ ─ ─ e ─ ─ ─ / p ─ ─ ─ o ─ t r g n o i / k m n / e r l j r t r i n l f c d f / d s i k l d s p i a a a e m u - e t e l i i e e n u a e t r c p p p c y c m s o R o . g p r g s y v a o a p p p t - t a s r e w y u l v r t s g d t - - - s p u n - i p s a r o i e o i / i d s p / r r a n n o / m a y c s m n o e t r o e g g g s l t m e s i g n v a o j / e i / i i e . . z / s . g d e r n t o n y y a y i . c / x o n t a a t a n y t / r . m m i m g a . y R y l l o l . m y e a n y l a p m . a m o l y m l s a l i m t l o r y πŸ”„ GitOps Workflow CI Pipeline (GitHub Actions) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 name: CI Pipeline on: push: branches: [main] pull_request: branches: [main] jobs: build-and-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Build and test run: | docker build -t app:${{ github.sha }} . docker run app:${{ github.sha }} npm test - name: Push to ACR uses: azure/docker-login@v1 with: login-server: ${{ secrets.ACR_LOGIN_SERVER }} username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} - run: | docker tag app:${{ github.sha }} ${{ secrets.ACR_LOGIN_SERVER }}/app:${{ github.sha }} docker push ${{ secrets.ACR_LOGIN_SERVER }}/app:${{ github.sha }} update-manifests: needs: build-and-push runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: repository: org/gitops-repo token: ${{ secrets.GH_PAT }} - name: Update image tag run: | cd apps/overlays/dev kustomize edit set image app=${{ secrets.ACR_LOGIN_SERVER }}/app:${{ github.sha }} - name: Commit and push run: | git config user.name "github-actions" git config user.email "github-actions@github.com" git add . git commit -m "Update dev image to ${{ github.sha }}" git push ArgoCD Application Definition 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: my-app-dev namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io spec: project: default source: repoURL: https://github.com/org/gitops-repo.git targetRevision: HEAD path: apps/overlays/dev destination: server: https://kubernetes.default.svc namespace: dev syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true retry: limit: 5 backoff: duration: 5s maxDuration: 3m0s factor: 2 πŸ” Security Implementation RBAC - Role-based access control for ArgoCD users SSO Integration - Azure AD / GitHub OAuth Sealed Secrets - Encrypted secrets in Git Network Policies - ArgoCD namespace isolation Audit Logging - Complete audit trail of all changes πŸ“Š Results & Metrics Metric Before After Deployment Frequency Weekly Multiple per day Lead Time for Changes 2-3 days < 1 hour Mean Time to Recovery 4 hours < 15 minutes Change Failure Rate 15% < 2% πŸ”‘ Key Learnings Separation of Concerns - Keeping app code and configuration in separate repos provides clear boundaries Progressive Delivery - Promoting changes through environments (dev β†’ staging β†’ prod) catches issues early Self-Healing - ArgoCD’s self-heal feature ensures the cluster always matches the desired state Observability - ArgoCD’s built-in dashboard provides excellent visibility into deployment status πŸ”— Resources GitHub Repository: github.com/yourusername/gitops-argocd Related Blog Post: Getting Started with GitOps Interested in implementing GitOps? Let’s discuss! ...

May 20, 2024 Β· 9 min Β· 1839 words Β· Elmi Abdullahi
Observability Stack Architecture

Kubernetes Observability Stack

🎯 Problem Statement Modern Kubernetes environments face observability challenges: Visibility Gap - No centralized view of cluster and application health Troubleshooting - Difficulty correlating metrics, logs, and traces Alert Fatigue - Too many false positives or missing critical alerts Cost - Expensive commercial APM solutions Scalability - Monitoring solution must scale with the cluster πŸ’‘ Solution Overview I designed and deployed a comprehensive open-source observability stack using Prometheus, Grafana, Loki, and Tempo, providing metrics, logs, traces, and alerting in a unified platform. ...

March 5, 2024 Β· 13 min Β· 2709 words Β· Elmi Abdullahi
GitOps Workflow Diagram

Getting Started with GitOps: A Practical Guide

What is GitOps? GitOps is a modern approach to continuous deployment that uses Git as the single source of truth for declarative infrastructure and applications. Coined by Weaveworks in 2017, GitOps extends the principles of Infrastructure as Code (IaC) to the entire deployment lifecycle. Core Principles Declarative Configuration - The entire system is described declaratively Version Controlled - The desired state is stored in Git Automated Delivery - Approved changes are automatically applied Continuous Reconciliation - Agents ensure actual state matches desired state Why GitOps? Traditional deployment approaches often suffer from several challenges: ...

November 15, 2024 Β· 7 min Β· 1296 words Β· Elmi Abdullahi
Kubernetes Troubleshooting

Kubernetes Troubleshooting: A Practical Guide

Introduction Troubleshooting Kubernetes can be challenging due to its distributed nature. This guide covers practical techniques I’ve used to debug production issues across dozens of clusters. The Troubleshooting Mindset When debugging Kubernetes, follow this systematic approach: Define the problem - What’s the expected vs actual behavior? Gather information - Collect logs, events, and metrics Form hypotheses - What could cause this behavior? Test hypotheses - Verify or eliminate causes Implement fix - Apply and validate the solution Essential kubectl Commands Pod Status and Events 1 2 3 4 5 6 7 8 9 10 11 # Get pod status with more details kubectl get pods -o wide # Describe pod for events and conditions kubectl describe pod <pod-name> # Get pods with specific status kubectl get pods --field-selector=status.phase=Pending # Watch pod status changes kubectl get pods -w Container Logs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # Get logs from a pod kubectl logs <pod-name> # Get logs from a specific container in multi-container pod kubectl logs <pod-name> -c <container-name> # Follow logs in real-time kubectl logs -f <pod-name> # Get logs from previous container instance (after restart) kubectl logs <pod-name> --previous # Get last N lines kubectl logs --tail=100 <pod-name> # Get logs with timestamps kubectl logs --timestamps <pod-name> Executing Commands in Containers 1 2 3 4 5 6 7 8 # Open a shell in a running container kubectl exec -it <pod-name> -- /bin/bash # Run a specific command kubectl exec <pod-name> -- cat /etc/config/app.yaml # Exec into a specific container kubectl exec -it <pod-name> -c <container-name> -- /bin/sh Common Issues and Solutions 1. Pod Stuck in Pending Symptoms: Pod stays in Pending state indefinitely ...

October 20, 2024 Β· 6 min Β· 1145 words Β· Elmi Abdullahi