Kubernetes (K8s), container orchestration''ın endüstri standardıdır. Docker Compose tek sunucuya hitap ederken K8s onlarca sunucudan oluşan cluster''ı yönetir: otomatik ölçekleme, self-healing, rolling update, service discovery — hepsi built-in. Bu yazı temel kavramları pratik YAML örnekleriyle anlatır.

Temel Kavramlar

İlgili rehberler: DNS nedir, ayarları değiştirme · Domain adı ve WHOIS sorgulama · Hosting türleri rehberi · Nginx yapılandırma · Plesk panel yönetimi

  • Node: Cluster''daki fiziksel/sanal sunucu
  • Pod: Bir veya daha fazla container''ı içeren en küçük dağıtım birimi
  • Deployment: Pod''ları yönetir, replika sayısı tanımlar, rolling update sağlar
  • Service: Pod''lara stabil IP ve DNS verir
  • Ingress: Dış dünyadan HTTP(S) trafiği cluster''a yönlendirir
  • ConfigMap / Secret: Config ve hassas veri
  • Namespace: Cluster içinde mantıksal izolasyon

İlk Deployment

# app-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp
  labels: { app: webapp }
spec:
  replicas: 3
  selector:
    matchLabels: { app: webapp }
  template:
    metadata:
      labels: { app: webapp }
    spec:
      containers:
        - name: app
          image: ghcr.io/user/webapp:v1.2.0
          ports:
            - containerPort: 3000
          env:
            - name: NODE_ENV
              value: production
          resources:
            requests: { cpu: 100m, memory: 128Mi }
            limits:   { cpu: 500m, memory: 512Mi }
          livenessProbe:
            httpGet: { path: /health, port: 3000 }
            initialDelaySeconds: 15
            periodSeconds: 10
          readinessProbe:
            httpGet: { path: /ready, port: 3000 }
            periodSeconds: 5
kubectl apply -f app-deployment.yaml
kubectl get pods
kubectl logs -f deployment/webapp
kubectl describe deployment webapp

Service

Pod''ların IP''leri ephemeral''dır (yeniden oluşturulunca değişir). Service, label selector ile pod''ları seçer ve stabil bir erişim noktası sunar.

apiVersion: v1
kind: Service
metadata:
  name: webapp
spec:
  type: ClusterIP    # cluster içi; diğer: NodePort, LoadBalancer
  selector:
    app: webapp
  ports:
    - port: 80
      targetPort: 3000

Artık cluster içindeki diğer pod''lar http://webapp/ ile erişebilir.

Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: webapp
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  ingressClassName: nginx
  tls:
    - hosts: [example.com]
      secretName: webapp-tls
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: webapp
                port: { number: 80 }
Bilgi
cert-manager + ingress-nginx kombinasyonu otomatik Let''s Encrypt sertifikası alıp yeniler. Kurulum için helm install ile iki chart eklemek yeterli.

ConfigMap ve Secret

apiVersion: v1
kind: ConfigMap
metadata:
  name: webapp-config
data:
  NODE_ENV: production
  LOG_LEVEL: info
---
apiVersion: v1
kind: Secret
metadata:
  name: webapp-secret
type: Opaque
stringData:
  DATABASE_URL: postgres://user:pass@db/app
  JWT_SECRET: supersecret
# Deployment içinde kullanım
spec:
  containers:
    - name: app
      envFrom:
        - configMapRef: { name: webapp-config }
        - secretRef: { name: webapp-secret }
Uyarı
Secret default olarak base64 encode''lu (şifreli değil!). Production''da encryption at rest aktif edin veya Sealed Secrets / External Secrets / Vault kullanın.

Horizontal Pod Autoscaler

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: webapp
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: webapp
  minReplicas: 3
  maxReplicas: 20
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

Rolling Update ve Rollback

# Yeni versiyona geç
kubectl set image deployment/webapp app=ghcr.io/user/webapp:v1.3.0

# Rollout durumu
kubectl rollout status deployment/webapp

# Geçmiş
kubectl rollout history deployment/webapp

# Geri al
kubectl rollout undo deployment/webapp
kubectl rollout undo deployment/webapp --to-revision=3

Yaygın kubectl Komutları

# Context ve namespace
kubectl config current-context
kubectl config use-context prod-cluster
kubectl get all -n my-namespace

# Pod'a shell
kubectl exec -it pod/webapp-abc123 -- /bin/sh

# Port forward (local debug)
kubectl port-forward service/webapp 8080:80

# Log (tüm pod'lar)
kubectl logs -l app=webapp --all-containers --tail=100 -f

# Resource kullanımı (metrics-server gerekli)
kubectl top pods
kubectl top nodes

# YAML olarak dışa aktar
kubectl get deployment webapp -o yaml > webapp.yaml

Helm ile Paket Yönetimi

Raw YAML''lar karmaşıklaştıkça Helm devreye girer — template + values.yaml ile aynı manifest''i farklı ortamlarda yeniden kullanırsınız. Neredeyse her popüler servisin hazır Helm chart''ı var (ingress-nginx, cert-manager, prometheus, grafana, redis).

helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-redis bitnami/redis --set auth.password=secret
helm list
helm upgrade my-redis bitnami/redis --set replica.replicaCount=3

Local Development

  • minikube — single-node K8s local
  • kind — Docker içinde K8s, CI için de
  • k3d — k3s (hafif K8s) Docker''da
  • Docker Desktop — tek tık K8s

Managed K8s Servisleri

Cluster''ı kendi yönetmek karmaşıktır. Managed tercih edin: GKE (Google), EKS (AWS), AKS (Azure), DigitalOcean, Hetzner (managed değil ama ucuz), Civo. Control plane''i cloud yönetir, sadece worker node''lara odaklanırsınız.

Modern Web Hosting ve Sunucu Altyapısı

Performanslı bir web hosting hizmeti üç temel altyapı kararına dayanır: NVMe SSD diskler (klasik SATA SSD'ye göre 4-6 kat IOPS), LiteSpeed Web Server veya Nginx + LSCache kombinasyonu (Apache'ye göre 9 kat istek kapasitesi) ve CloudLinux + Imunify360 izolasyonu. Hosting sağlayıcısının kontrol paneli (cPanel, Plesk, DirectAdmin), günlük yedek politikası, veri merkezi konumu ve destek ekibi yanıt süresi de büyük fark yaratır. Türkiye lokasyonu yerli ziyaretçilere düşük gecikme verirken; Hetzner Frankfurt veya OVH Roubaix gibi Avrupa lokasyonları global trafik için daha uygundur. Site büyüdükçe paylaşımlı hosting'ten VPS, ardından dedicated server'a geçiş; CPU/RAM/disk kaynaklarının web sitemizin ihtiyaçlarına göre ölçeklenmesini sağlar.

Kubernetes migration ve yönetim

K8s cluster tasarımı, Helm chart yazımı ve migration için iletişime geçin

WhatsApp