惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
Know Your Adversary
Know Your Adversary
K
Kaspersky official blog
人人都是产品经理
人人都是产品经理
IT之家
IT之家
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
D
DataBreaches.Net
C
CXSECURITY Database RSS Feed - CXSecurity.com
U
Unit 42
博客园 - 【当耐特】
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
H
Help Net Security
L
LangChain Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
The GitHub Blog
The GitHub Blog
博客园_首页
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
The Register - Security
The Register - Security
Engineering at Meta
Engineering at Meta
T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
C
Cybersecurity and Infrastructure Security Agency CISA
T
Troy Hunt's Blog
罗磊的独立博客
腾讯CDC
Simon Willison's Weblog
Simon Willison's Weblog
Security Latest
Security Latest
Last Week in AI
Last Week in AI
P
Privacy & Cybersecurity Law Blog
Latest news
Latest news
The Cloudflare Blog
Jina AI
Jina AI
小众软件
小众软件
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
F
Full Disclosure
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
De Cero a Kubernetes Parte 2: Bootstrap del Cluster — Namespaces, Ingress, cert-manager y Storage
jesus manriq · 2026-05-20 · via DEV Community

K8s Terraform ArgoCD — Header

Serie: De Cero a Kubernetes — Parte 1 · Parte 2 · Parte 3 · Parte 4 · Parte 5


En la Parte 1 construimos un cluster Kubernetes con Terraform y kubeadm. Tres nodos listos pero vacíos. Hoy lo convertimos en una plataforma utilizable: tráfico externo con TLS automático, storage para bases de datos, namespaces que separan entornos, y permisos que evitan que un deploy en staging borre producción.

Todo con Terraform. Cero kubectl apply manual.


¿Por qué Terraform para el bootstrap y no ArgoCD?

Esta es una pregunta que recibimos mucho. La respuesta está en el orden de dependencias:

┌─────────────────────────────────────────┐
│  Terraform (infraestructura + bootstrap) │
│  VMs, redes, kubeadm, namespaces,       │
│  ingress, cert-manager, storage, RBAC   │
│  ↓                                      │
│  Terraform instala ArgoCD               │
│  ↓                                      │
│  ArgoCD maneja las aplicaciones         │
│  (backend, frontends, DB)               │
└─────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

Terraform gestiona lo que ArgoCD necesita para existir. Una vez que ArgoCD está corriendo, le pasamos el control de las aplicaciones. Si intentas usar ArgoCD para bootstrappear el ingress controller que necesita ArgoCD para exponer su propia UI, tienes un problema circular. Terraform rompe ese ciclo.


Lo que construiremos hoy

┌──────────────────────────────────────────────┐
│                 INTERNET                      │
│                    │                          │
│         ┌──────────▼──────────┐               │
│         │  nginx ingress      │               │
│         │  (NodePort 30080)   │               │
│         │  + cert-manager     │               │
│         │  + Let's Encrypt    │               │
│         └──────────┬──────────┘               │
│                    │                          │
│    ┌───────────────┼───────────────┐          │
│    ▼               ▼               ▼          │
│ ┌────────┐  ┌──────────┐  ┌──────────┐       │
│ │production│ │ staging  │  │infrastructure│    │
│ │namespace │ │namespace │  │ namespace  │    │
│ └────────┘  └──────────┘  └──────────┘       │
│                                                │
│ Storage: local-path-provisioner (PVC)          │
│ RBAC: ServiceAccounts + Roles                 │
└──────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode


Paso 1: Conectar Terraform al cluster

Necesitamos el provider de Kubernetes apuntando al cluster que creamos en la Parte 1:

# providers.tf (agregar al main.tf de la Parte 1)
provider "kubernetes" {
  host                   = "https://${hcloud_server.control_plane.ipv4_address}:6443"
  client_certificate     = base64decode(data.local_file.kubeconfig.content)
  client_key             = base64decode(data.local_file.kubeconfig.content)
  cluster_ca_certificate = base64decode(data.local_file.kubeconfig.content)
  # ⚠️ En producción: usar data source apropiado para extraer
  # cada campo del kubeconfig. Aquí simplificamos con un
  # provisioner que copia el archivo del control-plane.
}

provider "helm" {
  kubernetes {
    host                   = "https://${hcloud_server.control_plane.ipv4_address}:6443"
    client_certificate     = base64decode(var.k8s_client_cert)
    client_key             = base64decode(var.k8s_client_key)
    cluster_ca_certificate = base64decode(var.k8s_ca_cert)
  }
}

Enter fullscreen mode Exit fullscreen mode

Nota práctica: Para este tutorial, extraemos los certificados del kubeconfig con un local_file data source. En producción, usarías un backend de secretos (Vault, AWS Secrets Manager) y los inyectarías como variables de entorno.


Paso 2: Namespaces — la base de todo

Los namespaces son la unidad de aislamiento lógico en Kubernetes. Sin ellos, todos los recursos viven en default y el desorden es garantía de problemas:

resource "kubernetes_namespace" "production" {
  metadata {
    name = "production"
    labels = {
      environment = "production"
      managed-by  = "terraform"
    }
  }
}

resource "kubernetes_namespace" "staging" {
  metadata {
    name = "staging"
    labels = {
      environment = "staging"
      managed-by  = "terraform"
    }
  }
}

resource "kubernetes_namespace" "infrastructure" {
  metadata {
    name = "infrastructure"
    labels = {
      environment = "infrastructure"
      managed-by  = "terraform"
    }
  }
}

resource "kubernetes_namespace" "argocd" {
  metadata {
    name = "argocd"
    labels = {
      environment = "infrastructure"
      managed-by  = "terraform"
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

La convención: production para cargas de trabajo reales, staging para pruebas pre-producción, infrastructure para componentes del sistema (ingress, cert-manager, storage), argocd para la herramienta GitOps.


Paso 3: Storage — local-path-provisioner

Kubernetes necesita un StorageClass que cree PersistentVolumes dinámicamente cuando un pod pide un PVC. En Hetzner usamos local-path-provisioner (de Rancher), que crea volúmenes en el disco local del nodo:

resource "helm_release" "local_path_provisioner" {
  name       = "local-path-provisioner"
  namespace  = kubernetes_namespace.infrastructure.metadata[0].name
  repository = "https://rancher.github.io/local-path-provisioner"
  chart      = "local-path-provisioner"
  version    = "0.0.28"

  set {
    name  = "storageClass.defaultClass"
    value = "true"
  }

  set {
    name  = "nodePathMap[0].node"
    value = "DEFAULT_PATH_FOR_NON_LISTED_NODES"
  }

  set {
    name  = "nodePathMap[0].paths[0]"
    value = "/var/local-path-provisioner"
  }
}

Enter fullscreen mode Exit fullscreen mode

¿Por qué no Rook/Ceph? Para un cluster de 3 nodos modestos, Ceph es sobreingeniería. local-path-provisioner es perfecto: los datos viven en /var/local-path-provisioner del nodo donde corre el pod. La limitación es que si ese nodo muere, el volumen se pierde. Para producción seria, más adelante migras a Longhorn (replicación) o usas volúmenes de cloud (Hetzer volumes).


Paso 4: nginx ingress controller — la puerta de entrada

El ingress controller es el reverse proxy que recibe tráfico externo y lo rutea a los Services correctos dentro del cluster. Usamos nginx, el más probado del ecosistema:

resource "helm_release" "ingress_nginx" {
  name       = "ingress-nginx"
  namespace  = kubernetes_namespace.infrastructure.metadata[0].name
  repository = "https://kubernetes.github.io/ingress-nginx"
  chart      = "ingress-nginx"
  version    = "4.11.2"

  set {
    name  = "controller.service.type"
    value = "NodePort"
  }

  set {
    name  = "controller.service.nodePorts.http"
    value = "30080"
  }

  set {
    name  = "controller.service.nodePorts.https"
    value = "30443"
  }

  set {
    name  = "controller.config.proxy-body-size"
    value = "50m"
  }

  set {
    name  = "controller.config.proxy-read-timeout"
    value = "60"
  }

  set {
    name  = "controller.config.proxy-send-timeout"
    value = "60"
  }
}

Enter fullscreen mode Exit fullscreen mode

Detalles importantes:

  • Usamos NodePort porque Hetzner no tiene LoadBalancer nativo. El ingress escucha en el puerto 30080 (HTTP) y 30443 (HTTPS) de cada nodo
  • proxy-body-size: 50m permite uploads de archivos
  • Los timeouts de proxy en 60s evitan que requests largos (migraciones, backups) se corten

En producción real: apuntas un balanceador de carga (Hetzner Load Balancer, Cloudflare Tunnel, o un nginx externo) al NodePort 30080/30443 de los workers. También puedes instalar hcloud-cloud-controller-manager para que Hetzner cree Load Balancers automáticamente.


Paso 5: cert-manager — TLS automático con Let's Encrypt

Nadie debería manejar certificados TLS a mano en 2026. cert-manager los crea, renueva 30 días antes de expirar, y los inyecta como Secrets:

resource "helm_release" "cert_manager" {
  name       = "cert-manager"
  namespace  = kubernetes_namespace.infrastructure.metadata[0].name
  repository = "https://charts.jetstack.io"
  chart      = "cert-manager"
  version    = "1.16.1"

  set {
    name  = "installCRDs"
    value = "true"
  }

  set {
    name  = "prometheus.enabled"
    value = "false"
  }
}

Enter fullscreen mode Exit fullscreen mode

Después de instalar cert-manager, creamos los ClusterIssuers:

# Staging — para pruebas, sin rate limits fuertes
resource "kubernetes_manifest" "cluster_issuer_staging" {
  manifest = {
    apiVersion = "cert-manager.io/v1"
    kind       = "ClusterIssuer"
    metadata = {
      name = "letsencrypt-staging"
    }
    spec = {
      acme = {
        server  = "https://acme-staging-v02.api.letsencrypt.org/directory"
        email   = var.letsencrypt_email
        privateKeySecretRef = {
          name = "letsencrypt-staging-account-key"
        }
        solvers = [{
          http01 = {
            ingress = {
              class = "nginx"
            }
          }
        }]
      }
    }
  }
}

# Production — certificados de verdad
resource "kubernetes_manifest" "cluster_issuer_production" {
  manifest = {
    apiVersion = "cert-manager.io/v1"
    kind       = "ClusterIssuer"
    metadata = {
      name = "letsencrypt-production"
    }
    spec = {
      acme = {
        server  = "https://acme-v02.api.letsencrypt.org/directory"
        email   = var.letsencrypt_email
        privateKeySecretRef = {
          name = "letsencrypt-production-account-key"
        }
        solvers = [{
          http01 = {
            ingress = {
              class = "nginx"
            }
          }
        }]
      }
    }
  }

  depends_on = [helm_release.cert_manager]
}

Enter fullscreen mode Exit fullscreen mode

La diferencia staging vs production: Let's Encrypt tiene rate limits estrictos en producción (50 certificados por dominio por semana). Si estás probando configuraciones de ingress, usas staging. Cuando todo funciona, cambias a production.


Paso 6: RBAC mínimo viable

Para este tutorial necesitamos un ServiceAccount que las aplicaciones usarán:

resource "kubernetes_service_account" "apps" {
  metadata {
    name      = "apps-sa"
    namespace = kubernetes_namespace.production.metadata[0].name
  }
}

resource "kubernetes_role" "apps" {
  metadata {
    name      = "apps-role"
    namespace = kubernetes_namespace.production.metadata[0].name
  }

  rule {
    api_groups = [""]
    resources  = ["pods", "services", "configmaps", "secrets"]
    verbs      = ["get", "list", "watch"]
  }

  rule {
    api_groups = ["apps"]
    resources  = ["deployments"]
    verbs      = ["get", "list", "watch"]
  }
}

resource "kubernetes_role_binding" "apps" {
  metadata {
    name      = "apps-rolebinding"
    namespace = kubernetes_namespace.production.metadata[0].name
  }

  role_ref {
    api_group = "rbac.authorization.k8s.io"
    kind      = "Role"
    name      = kubernetes_role.apps.metadata[0].name
  }

  subject {
    kind      = "ServiceAccount"
    name      = kubernetes_service_account.apps.metadata[0].name
    namespace = kubernetes_namespace.production.metadata[0].name
  }
}

Enter fullscreen mode Exit fullscreen mode

Esto es intencionalmente restrictivo: las apps pueden leer recursos pero no modificarlos ni crear nuevos. En la Parte 4 configuraremos un ServiceAccount específico para el backend con permisos de lectura de Secrets.


Paso 7: Verificación — probar TLS real

Creamos un ingress de prueba con TLS:

resource "kubernetes_manifest" "test_ingress" {
  manifest = {
    apiVersion = "networking.k8s.io/v1"
    kind       = "Ingress"
    metadata = {
      name      = "test-ingress"
      namespace = "production"
      annotations = {
        "cert-manager.io/cluster-issuer"            = "letsencrypt-staging"
        "nginx.ingress.kubernetes.io/ssl-redirect"  = "true"
      }
    }
    spec = {
      ingressClassName = "nginx"
      tls = [{
        hosts      = ["test.tudominio.com"]
        secretName = "test-tls"
      }]
      rules = [{
        host = "test.tudominio.com"
        http = {
          paths = [{
            path     = "/"
            pathType = "Prefix"
            backend = {
              service = {
                name = "echo-service"
                port = { number = 80 }
              }
            }
          }]
        }
      }]
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

Después de terraform apply, apuntas el DNS test.tudominio.com a la IP pública de cualquier nodo y verificas:

curl -v https://test.tudominio.com:30443
# < HTTP/2 200
# < SSL certificate verified: CN = test.tudominio.com
# (Fake LE Intermediate X1) ← staging, esperado

Enter fullscreen mode Exit fullscreen mode

Cuando confirmas que funciona, cambias el annotation a letsencrypt-production y obtienes un certificado real. cert-manager lo renovará automáticamente cada 60 días.


Estructura final de Terraform hasta ahora

infra/
├── main.tf                    # Providers + recursos principales
├── variables.tf
├── outputs.tf
├── terraform.tfvars
├── versions.tf
├── cloud-init/
│   ├── control-plane.yaml
│   └── worker.yaml
├── modules/
│   ├── kubernetes-core/       # (opcional — refactor futuro)
│   │   ├── namespaces.tf
│   │   ├── storage.tf
│   │   ├── ingress.tf
│   │   ├── cert-manager.tf
│   │   └── rbac.tf
└── .gitignore

Enter fullscreen mode Exit fullscreen mode


Qué aprendiste en esta parte

  • Namespaces como capa de aislamiento entre entornos
  • Por qué Terraform maneja el bootstrap y ArgoCD maneja las apps
  • nginx ingress controller expuesto vía NodePort
  • cert-manager + Let's Encrypt para TLS automático con renovación
  • local-path-provisioner como StorageClass dinámica
  • RBAC mínimo viable con ServiceAccounts, Roles y RoleBindings
  • El flujo ClusterIssuerIngress annotationSecret TLS → certificado listo

En la Parte 3, desplegaremos ArgoCD, configuraremos GitOps con el patrón app-of-apps, y tendremos nuestro primer despliegue automático desde GitHub.


En Guayoyo Tech no solo escribimos tutoriales — diseñamos y desplegamos arquitecturas como esta para empresas reales. Kubernetes, Terraform, ArgoCD, pipelines CI/CD, y todo el ecosistema cloud-native: lo armamos contigo, sin humo y sin vendor lock-in. Si quieres que tu infraestructura se parezca a lo que acabas de leer, hablemos gratis 15 minutos. Tu cluster, tu nube, tus reglas — nosotros ponemos la ingeniería.