Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: Kubernetes

Kubernetes

Kubernetes: Use HPA to Auto-Scale Pods Based on CPU/Memory

- 30.03.26 - ErcanOPAK comment on Kubernetes: Use HPA to Auto-Scale Pods Based on CPU/Memory

📈 Auto-Scale Based on Load Fixed 3 replicas? CPU spikes, users wait. Traffic drops, you waste money. HPA (Horizontal Pod Autoscaler) scales pods automatically based on metrics. How HPA Works # deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: web-app spec: replicas: 2 # Initial replicas template: spec: containers: – name: app image: myapp:latest resources: requests: […]

Read More
Kubernetes

Kubernetes: Use ConfigMaps and Secrets to Separate Configuration from Code

- 22.03.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps and Secrets to Separate Configuration from Code

🔐 Never Hardcode Config Again API keys in code? Database passwords committed to Git? ConfigMaps and Secrets externalize all configuration. ConfigMaps vs Secrets 📝 ConfigMaps Non-sensitive configuration API endpoints Feature flags Environment settings Application config files 🔒 Secrets Sensitive data (base64 encoded) Database passwords API keys TLS certificates OAuth tokens Creating ConfigMaps # configmap.yaml apiVersion: […]

Read More
Kubernetes

Kubernetes: Use kubectl port-forward to Debug Services Locally

- 19.03.26 - ErcanOPAK comment on Kubernetes: Use kubectl port-forward to Debug Services Locally

🔌 Access K8s Services Like They’re Local Service running in cluster. Need to test it. Don’t want to expose it publicly. Port-forward to localhost. Basic Port Forward # Forward pod port to localhost kubectl port-forward pod/my-pod 8080:80 # Now access: http://localhost:8080 # Traffic goes to pod’s port 80 # Forward service instead kubectl port-forward svc/my-service […]

Read More
Kubernetes

Kubernetes: Use kubectl get events to Debug Pod Issues

- 19.03.26 | 19.03.26 - ErcanOPAK comment on Kubernetes: Use kubectl get events to Debug Pod Issues

Pod won’t start. kubectl describe pod shows nothing useful. What happened? Events: Kubernetes event log shows everything. # All events in namespace kubectl get events –sort-by=’.lastTimestamp’ # Filter by pod kubectl get events –field-selector involvedObject.name=my-pod # Watch live events kubectl get events –watch Common Issues Revealed: – Image pull failures – OOMKilled (out of memory) […]

Read More
Kubernetes

Kubernetes: Use kubectl logs –tail=100 -f to Debug Faster

- 19.03.26 - ErcanOPAK comment on Kubernetes: Use kubectl logs –tail=100 -f to Debug Faster

🔍 Log Debugging Shortcut Scrolling through 10,000 log lines? See only what matters. # Last 100 lines, follow mode (like tail -f) kubectl logs my-pod –tail=100 -f # From specific container in multi-container pod kubectl logs my-pod -c sidecar –tail=50 -f # Previous crashed pod kubectl logs my-pod –previous # All pods with label kubectl […]

Read More
Kubernetes

Kubernetes: Managing Clusters Visually with Lens IDE

- 01.03.26 - ErcanOPAK comment on Kubernetes: Managing Clusters Visually with Lens IDE

The terminal is great, but visualizing 100+ pods is hard. Lens is the ‘World’s Most Powerful Kubernetes IDE’. Real-time stats of CPU/RAM for every container. One-click access to Pod logs and Shell. Stop typing kubectl get pods every 5 seconds. Use Lens to see the health of your infrastructure at a glance.

Read More
Kubernetes

Kubernetes: Mastering HPA for Elastic Traffic Management

- 01.03.26 - ErcanOPAK comment on Kubernetes: Mastering HPA for Elastic Traffic Management

Static pod counts are either wasteful or dangerous. HPA scales your deployment based on real-time metrics. Standard Config: Scale up when CPU exceeds 70%. Pro Config: Scale based on Custom Metrics (like Request-per-Second) using Prometheus and Keda. This reacts much faster to traffic spikes than CPU metrics.

Read More
Kubernetes

Kubernetes: Mastering Helm Charts for Templated Deployments

- 01.03.26 - ErcanOPAK comment on Kubernetes: Mastering Helm Charts for Templated Deployments

Manually editing YAML files for Dev, Staging, and Prod is a recipe for disaster. Helm acts as the package manager for K8s. “Treat your infrastructure like code, but treat your deployments like templates.” Using values.yaml, you can change replicas, image tags, and resource limits per environment without touching the core manifest. This is the cornerstone […]

Read More
Kubernetes

Kubernetes: Keeping Critical Pods Safe with Taints and Tolerations

- 28.02.26 - ErcanOPAK comment on Kubernetes: Keeping Critical Pods Safe with Taints and Tolerations

In a large cluster, you don’t want ‘general’ workloads running on your expensive GPU nodes or high-security master nodes. The Logic: – Taint: Applied to a Node (“Only special pods allowed here”). – Toleration: Applied to a Pod (“I am allowed to run on that special node”). This is the foundation of multi-tenant cluster management […]

Read More
Kubernetes

Kubernetes: The Critical Difference Between Liveness and Readiness Probes

- 28.02.26 - ErcanOPAK comment on Kubernetes: The Critical Difference Between Liveness and Readiness Probes

Misconfiguring these two can cause your app to go into a restart loop or serve 500 errors to users. Readiness Probe: Tells K8s when the app is ready to receive traffic (e.g., after DB migrations). Liveness Probe: Tells K8s if the app is alive. If this fails, K8s kills and restarts the container. Pro Tip: […]

Read More
Kubernetes

Kubernetes: Avoiding the ‘OOMKilled’ Error with Proper Resource Limits

- 28.02.26 - ErcanOPAK comment on Kubernetes: Avoiding the ‘OOMKilled’ Error with Proper Resource Limits

One of the most common K8s failures is the Out of Memory (OOM) Killer. This happens when your container exceeds its allocated limit. Type Definition Requests What the pod is guaranteed to have. Limits The absolute maximum the pod can consume. Pro Strategy: Always set requests equal to limits for memory to avoid unstable rescheduling […]

Read More
Kubernetes

Kubernetes Monitoring: The Prometheus + Grafana Stack That Saved Our Production

- 23.02.26 - ErcanOPAK comment on Kubernetes Monitoring: The Prometheus + Grafana Stack That Saved Our Production

🚨 The 3 AM Wake-Up Call Your Kubernetes cluster is down. Users are angry. You have no idea what happened. This is why Fortune 500 companies spend $500K/year on observability. The Complete Observability Stack 📊 The Three Pillars Metrics – What’s happening right now (Prometheus) Logs – What happened in the past (Loki) Traces – […]

Read More
Kubernetes

Kubernetes: Use Kustomize for Environment-Specific Configurations

- 22.02.26 - ErcanOPAK comment on Kubernetes: Use Kustomize for Environment-Specific Configurations

Maintaining separate YAML files for dev/staging/prod is messy. Kustomize manages variations without duplication. Base Configuration: # base/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 2 template: spec: containers: – name: app image: myapp:latest Production Override: # overlays/production/kustomization.yaml resources: – ../../base patchesStrategicMerge: – replicas.yaml # Sets replicas: 10 – image.yaml # Sets image: myapp:1.5.3 […]

Read More
Kubernetes

Kubernetes: Implementing a GitOps Workflow with ArgoCD

- 21.02.26 | 22.02.26 - ErcanOPAK comment on Kubernetes: Implementing a GitOps Workflow with ArgoCD

In a professional DevOps environment, the Git repository is the Single Source of Truth. Manual kubectl apply commands are replaced by ArgoCD. Git Push → CI Build → Manifest Update → ArgoCD Sync → K8s Cluster This ensures that your cluster state always matches your code, enabling instant rollbacks and better security audits.

Read More
Kubernetes

Kubernetes: Advanced Node Scheduling with Taints and Tolerations

- 21.02.26 - ErcanOPAK comment on Kubernetes: Advanced Node Scheduling with Taints and Tolerations

In a production cluster, you often want to keep ‘special’ nodes (like GPU-powered ones) only for specific pods. Concept: • Taint: The Node says “I only allow special pods.” • Toleration: The Pod says “I am allowed on that special node.” # Add taint to node kubectl taint nodes node1 key1=value1:NoSchedule

Read More
Kubernetes

Kubernetes: Namespace Resource Quotas to Prevent Cost Spikes

- 21.02.26 - ErcanOPAK comment on Kubernetes: Namespace Resource Quotas to Prevent Cost Spikes

In a multi-tenant cluster, one runaway pod can consume all resources and crash other services. The Solution: Define a ResourceQuota per namespace. This limits the total CPU and Memory that a specific team or environment (dev/prod) can use. apiVersion: v1 kind: ResourceQuota metadata: name: mem-cpu-demo spec: hard: requests.cpu: “1” requests.memory: 1Gi limits.cpu: “2” limits.memory: 2Gi

Read More
Kubernetes

Kubernetes: Liveness vs Readiness Probes – Don’t Kill Your Traffic

- 21.02.26 - ErcanOPAK comment on Kubernetes: Liveness vs Readiness Probes – Don’t Kill Your Traffic

If your pod is ‘Alive’ but not ‘Ready’ to serve traffic (e.g., still loading cache), K8s might send traffic to a black hole. Use Readiness Probes. readinessProbe: httpGet: path: /health/ready port: 8080 initialDelaySeconds: 5

Read More
Kubernetes

Kubernetes: Use Resource Requests vs Limits to Optimize Pod Scheduling

- 21.02.26 - ErcanOPAK comment on Kubernetes: Use Resource Requests vs Limits to Optimize Pod Scheduling

Not setting resources leads to unpredictable behavior. Requests guarantee minimum, Limits cap maximum. Understanding the Difference: – Requests: Guaranteed resources (used for scheduling) – Limits: Maximum resources (hard cap) Example Configuration: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 resources: requests: memory: “256Mi” cpu: “250m” # 0.25 CPU core […]

Read More
Kubernetes

Kubernetes: Use Pod Disruption Budget to Ensure Availability During Maintenance

- 17.02.26 - ErcanOPAK comment on Kubernetes: Use Pod Disruption Budget to Ensure Availability During Maintenance

Rolling updates can accidentally take down too many pods. PDB guarantees minimum availability. Create PDB: apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: myapp-pdb spec: minAvailable: 2 # Always keep at least 2 pods running selector: matchLabels: app: myapp Or Use maxUnavailable: spec: maxUnavailable: 1 # At most 1 pod can be down at a time selector: […]

Read More
Kubernetes

Kubernetes: Use Secrets to Store Sensitive Data Instead of ConfigMaps

- 16.02.26 - ErcanOPAK comment on Kubernetes: Use Secrets to Store Sensitive Data Instead of ConfigMaps

Storing passwords in ConfigMaps exposes them in plain text. Secrets encode data and have better access control. Create Secret: kubectl create secret generic db-secret \ –from-literal=username=admin \ –from-literal=password=secretpass123 Use in Pod: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 env: – name: DB_USER valueFrom: secretKeyRef: name: db-secret key: username […]

Read More
Kubernetes

Kubernetes: Use Horizontal Pod Autoscaler to Scale Based on CPU/Memory

- 15.02.26 - ErcanOPAK comment on Kubernetes: Use Horizontal Pod Autoscaler to Scale Based on CPU/Memory

Manual scaling is reactive and slow. HPA automatically scales pods based on resource usage. Create HPA: kubectl autoscale deployment myapp \ –cpu-percent=70 \ –min=2 \ –max=10 # When CPU > 70%, adds pods (up to 10) # When CPU < 70%, removes pods (down to 2) YAML Version: apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: myapp-hpa […]

Read More
Kubernetes

Kubernetes: Use ConfigMaps to Store Configuration Separately from Pods

- 15.02.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps to Store Configuration Separately from Pods

Hardcoding config in containers requires rebuilding images. ConfigMaps separate config from code. Create ConfigMap: kubectl create configmap app-config \ –from-literal=API_URL=https://api.example.com \ –from-literal=MAX_RETRIES=3 Use in Pod: apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:1.0 envFrom: – configMapRef: name: app-config Change config without rebuilding image – just update ConfigMap! Update ConfigMap: […]

Read More
Kubernetes

Kubernetes: Use kubectl top to Monitor Real-Time Resource Usage

- 14.02.26 - ErcanOPAK comment on Kubernetes: Use kubectl top to Monitor Real-Time Resource Usage

Want to see CPU/Memory usage without installing monitoring tools? kubectl top shows real-time stats. Node Resource Usage: kubectl top nodes # Output: # NAME CPU MEMORY # node-1 45% 2.5Gi # node-2 23% 1.8Gi Pod Resource Usage: kubectl top pods # Or specific namespace: kubectl top pods -n production # Sort by CPU: kubectl top […]

Read More
Kubernetes

Kubernetes: Use kubectl diff Before Applying Changes to Preview Impact

- 13.02.26 - ErcanOPAK comment on Kubernetes: Use kubectl diff Before Applying Changes to Preview Impact

Applying YAML changes blindly is risky. Preview exactly what will change first. Before Applying: # See what kubectl apply will change kubectl diff -f deployment.yaml # Output shows: # – Lines being removed # + Lines being added # ~ Lines being modified Safe Workflow: # 1. Check diff kubectl diff -f deployment.yaml # 2. […]

Read More
Kubernetes

Kubernetes: View Real-Time Pod Logs with Stern Instead of kubectl

- 13.02.26 - ErcanOPAK comment on Kubernetes: View Real-Time Pod Logs with Stern Instead of kubectl

Tired of running kubectl logs for each pod separately? Stern streams logs from multiple pods simultaneously. Install Stern: # Mac brew install stern # Linux wget https://github.com/stern/stern/releases/download/v1.28.0/stern_linux_amd64 Usage: # Tail all pods matching pattern stern my-app # All pods in namespace stern . -n production # Color-coded by pod, auto-follows new pods Why Better: Kubectl […]

Read More
Kubernetes

Kubernetes Ingress: Expose Multiple Services Through One Load Balancer

- 05.02.26 - ErcanOPAK comment on Kubernetes Ingress: Expose Multiple Services Through One Load Balancer

Paying for multiple cloud load balancers? Ingress routes traffic to different services based on hostname or path. # ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: main-ingress annotations: # NGINX Ingress Controller nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/ssl-redirect: “true” nginx.ingress.kubernetes.io/proxy-body-size: “10m” # Cert-Manager for SSL cert-manager.io/cluster-issuer: “letsencrypt-prod” spec: tls: – hosts: – api.example.com – app.example.com – admin.example.com secretName: tls-secret […]

Read More
Kubernetes

Kubernetes: Force Delete Stuck Pods in Terminating State Instantly

- 03.02.26 - ErcanOPAK comment on Kubernetes: Force Delete Stuck Pods in Terminating State Instantly

Pod stuck in “Terminating” state for hours? Kubernetes is waiting for graceful shutdown that will never complete. Force delete it properly. The Problem: # Pod stuck forever kubectl get pods NAME STATUS AGE stuck-pod-abc123 Terminating 3h # Normal delete doesn’t work kubectl delete pod stuck-pod-abc123 # Still shows Terminating… Why Pods Get Stuck: When deleting […]

Read More
Kubernetes

Debug Kubernetes Pods That Keep Crashing Before Logs Disappear

- 01.02.26 | 01.02.26 - ErcanOPAK comment on Debug Kubernetes Pods That Keep Crashing Before Logs Disappear

Your pod crashes in 2 seconds, and logs vanish before you can read them? Here’s how to catch the output before Kubernetes deletes the container. The Problem: When a pod CrashLoops, the container exits so fast that ‘kubectl logs’ shows nothing useful or “container not found” errors. By the time you run the command, Kubernetes […]

Read More
Kubernetes

Why Your Pod “Looks Healthy” But Still Drops Traffic

- 31.01.26 - ErcanOPAK comment on Why Your Pod “Looks Healthy” But Still Drops Traffic

This is a classic production trap. Root cause readinessProbe ≠ livenessProbe Most people use only one. Correct pattern livenessProbe: httpGet: path: /health/live port: 80 readinessProbe: httpGet: path: /health/ready port: 80 Why this matters Liveness = should I restart? Readiness = should I receive traffic? If your app is warming caches or reconnecting DBs, traffic arrives […]

Read More
Kubernetes

Why Pods Restart Even When CPU & Memory Look Fine

- 30.01.26 - ErcanOPAK comment on Why Pods Restart Even When CPU & Memory Look Fine

Everything green… pods still restart. Hidden killer Liveness probes too aggressive Short timeouts during GC pauses Cold starts under load Fix Separate readiness & liveness Increase initialDelaySeconds Avoid HTTP probes on heavy endpoints livenessProbe: initialDelaySeconds: 30 timeoutSeconds: 5  

Read More
Page 1 of 2
1 2 Next »

Posts navigation

Older posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (448)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com