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 Jobs for One-Time Tasks and CronJobs for Scheduled Tasks

- 14.06.26 - ErcanOPAK comment on Kubernetes: Use Jobs for One-Time Tasks and CronJobs for Scheduled Tasks

โฐ Run Batch Jobs and Scheduled Tasks in Kubernetes Pods run forever. Jobs run to completion. CronJobs run on schedule. Perfect for backups, reports, data processing. ๐Ÿ“ Job Example (One-Time) apiVersion: batch/v1 kind: Job metadata: name: database-backup spec: template: spec: containers: – name: backup image: postgres:15 command: [‘pg_dump’, ‘-h’, ‘postgres’, ‘-U’, ‘user’, ‘dbname’, ‘>’, ‘/backup/db.sql’] […]

Read More
Kubernetes

Kubernetes: Configure Liveness, Readiness, and Startup Probes

- 14.06.26 - ErcanOPAK comment on Kubernetes: Configure Liveness, Readiness, and Startup Probes

โค๏ธ Is Your App Alive AND Ready? Liveness = restart if dead. Readiness = don’t send traffic until ready. Startup = extra time for slow-starting apps. Use all three for reliability. ๐Ÿ“ Probe Configuration livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 3 readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: […]

Read More
Kubernetes

Kubernetes: Use Helm Charts to Package and Deploy Apps

- 14.06.26 - ErcanOPAK comment on Kubernetes: Use Helm Charts to Package and Deploy Apps

๐Ÿ“ฆ Kubernetes Apps Need a Package Manager 50 YAML files for one app? Helm packages them. Templates, values, versioning, rollback. Like apt-get for Kubernetes. ๐Ÿ“ Install Helm # Install Helm curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash # Add repos helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update # Install popular charts helm […]

Read More
Kubernetes

Kubernetes: Use Ingress for HTTP Load Balancing and SSL

- 13.06.26 - ErcanOPAK comment on Kubernetes: Use Ingress for HTTP Load Balancing and SSL

๐ŸŒ One IP, Multiple Services, SSL Termination NodePort exposes high ports. LoadBalancer costs money. Ingress exposes HTTP/HTTPS routes, SSL termination, name-based virtual hosting. ๐Ÿ“ Basic Ingress apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp-ingress spec: rules: – host: myapp.example.com http: paths: – path: / pathType: Prefix backend: service: name: myapp-service port: number: 80 – path: /api […]

Read More
Kubernetes

Kubernetes: Use Labels and Selectors to Organize Resources

- 13.06.26 - ErcanOPAK comment on Kubernetes: Use Labels and Selectors to Organize Resources

๐Ÿท๏ธ Labels = Tags for Kubernetes Resources How to find all pods for an app? Labels and selectors group resources. Services find pods by labels. Deployments manage pod sets. Essential for organization. ๐Ÿ“ Adding Labels apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp environment: production tier: backend version: v1.0.0 team: payments spec: containers: […]

Read More
Kubernetes

Kubernetes: Use ConfigMap and Secrets for External Configuration

- 13.06.26 - ErcanOPAK comment on Kubernetes: Use ConfigMap and Secrets for External Configuration

๐Ÿ” Never Hardcode Config in Container Images Environment variables are okay. ConfigMap and Secrets are better. Separate config from code. Change without rebuild. ๐Ÿ“ ConfigMap # configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: app-config data: database.host: postgres-service database.port: “5432” app.properties: | app.name=myapp app.environment=production log.level=info # Use as environment variables apiVersion: v1 kind: Pod spec: containers: […]

Read More
Kubernetes

Kubernetes: Use Namespaces to Organize Your Cluster

- 07.06.26 - ErcanOPAK comment on Kubernetes: Use Namespaces to Organize Your Cluster

๐Ÿ“ Virtual Clusters Inside One Physical Cluster All pods in default namespace? Chaos. Namespaces separate environments, teams, or components. Resource quotas, RBAC per namespace. ๐Ÿ“ Create and Use Namespaces # Create namespace kubectl create namespace development kubectl create namespace staging kubectl create namespace production # List namespaces kubectl get namespaces # Run pod in specific […]

Read More
Kubernetes

Kubernetes: Always Set CPU and Memory Requests and Limits

- 07.06.26 - ErcanOPAK comment on Kubernetes: Always Set CPU and Memory Requests and Limits

โš™๏ธ No Requests = Unpredictable Scheduling Without resource requests, pods can starve others. Requests and limits ensure fair sharing and prevent resource exhaustion. ๐Ÿ“ Setting Resources apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:latest resources: requests: memory: “256Mi” cpu: “250m” limits: memory: “512Mi” cpu: “500m” # CPU units: 1000m […]

Read More
Kubernetes

Kubernetes: Use Priority Classes to Ensure Critical Pods Run First

- 06.06.26 - ErcanOPAK comment on Kubernetes: Use Priority Classes to Ensure Critical Pods Run First

โญ DNS Pods Should Evict Batch Jobs When cluster is full, which pods get evicted? Priority Classes define importance. Critical pods survive. Batch jobs go first. ๐Ÿ“ Define Priority Classes apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: critical value: 1000000000 globalDefault: false description: “Critical system pods that must never be evicted” — apiVersion: scheduling.k8s.io/v1 kind: PriorityClass […]

Read More
Kubernetes

Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

- 06.06.26 - ErcanOPAK comment on Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

๐Ÿ›ก๏ธ Don’t Drain All Pods at Once Node draining, cluster upgrades kill pods. PodDisruptionBudget (PDB) ensures minimum availability during voluntary disruptions. ๐Ÿ“ PDB Examples # At least 2 pods available at all times apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: minAvailable: 2 selector: matchLabels: app: myapp # No more than 1 pod unavailable apiVersion: […]

Read More
Kubernetes

Kubernetes: Enforce Pod Security Standards at Namespace Level

- 06.06.26 - ErcanOPAK comment on Kubernetes: Enforce Pod Security Standards at Namespace Level

๐Ÿ”’ PodSecurityPolicy is Deprecated. PSS is Here. PSP was complex. Pod Security Standards (PSS) are built-in. Three levels: Privileged, Baseline, Restricted. Apply per namespace. ๐Ÿ“ Apply PSS to Namespace # Label namespace for enforcement kubectl label namespace production pod-security.kubernetes.io/enforce=baseline kubectl label namespace production pod-security.kubernetes.io/enforce-version=latest # Warn mode (logs warning, doesn’t block) kubectl label namespace staging […]

Read More
Kubernetes

Kubernetes: Use Kustomize to Manage Multiple Environments Without Templates

- 05.06.26 - ErcanOPAK comment on Kubernetes: Use Kustomize to Manage Multiple Environments Without Templates

๐Ÿ“ No Helm. No Templating. Pure YAML. Helm templates are complex. Kustomize is built into kubectl. Overlay configs for dev, staging, prod. No new syntax to learn. ๐Ÿ“ Folder Structure k8s/ โ”œโ”€โ”€ base/ โ”‚ โ”œโ”€โ”€ deployment.yaml โ”‚ โ”œโ”€โ”€ service.yaml โ”‚ โ””โ”€โ”€ kustomization.yaml โ””โ”€โ”€ overlays/ โ”œโ”€โ”€ dev/ โ”‚ โ”œโ”€โ”€ replica_count.yaml โ”‚ โ”œโ”€โ”€ configmap.yaml โ”‚ โ””โ”€โ”€ kustomization.yaml […]

Read More
Kubernetes

Kubernetes: Use Topology Spread Constraints for Even Pod Distribution

- 05.06.26 - ErcanOPAK comment on Kubernetes: Use Topology Spread Constraints for Even Pod Distribution

๐Ÿ—บ๏ธ Spread Pods Across Zones, Nodes, Racks All pods on same node? Node failure = downtime. Topology spread constraints spread pods evenly across zones, nodes, or custom domains. ๐Ÿ“ Pod Topology Spread apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 6 template: spec: topologySpreadConstraints: – maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app: […]

Read More
Kubernetes

Kubernetes: Use VPA to Automatically Adjust CPU/Memory Requests

- 31.05.26 - ErcanOPAK comment on Kubernetes: Use VPA to Automatically Adjust CPU/Memory Requests

๐Ÿ“ˆ HPA Scales Pods. VPA Scales Pod Resources. Guessing CPU/memory requests is hard. Vertical Pod Autoscaler recommends or automatically adjusts resource requests based on actual usage. ๐Ÿ“ Install VPA git clone https://github.com/kubernetes/autoscaler.git cd autoscaler/vertical-pod-autoscaler ./hack/vpa-up.sh kubectl get pods -n kube-system | grep vpa ๐ŸŽฏ VPA Configuration apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: myapp-vpa spec: targetRef: […]

Read More
Kubernetes

Kubernetes: Use Pod Affinity to Schedule Related Pods Together

- 31.05.26 - ErcanOPAK comment on Kubernetes: Use Pod Affinity to Schedule Related Pods Together

๐Ÿ‘ฏ Keep Related Pods Close (or Far Apart) Cache and app should be on same node. Database replicas should be on different nodes. Pod affinity/anti-affinity controls pod placement. ๐Ÿ“ Pod Affinity (Same Node) apiVersion: v1 kind: Pod metadata: name: web-app spec: affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: – labelSelector: matchLabels: app: cache topologyKey: kubernetes.io/hostname containers: – name: app […]

Read More
Kubernetes

Kubernetes: Use Resource Quotas to Prevent One Namespace from Draining Cluster

- 30.05.26 - ErcanOPAK comment on Kubernetes: Use Resource Quotas to Prevent One Namespace from Draining Cluster

๐Ÿ“Š Don’t Let One Team Hog All Resources One namespace uses all CPU? Others starve. Resource quotas limit total CPU, memory, storage per namespace. Fair sharing for multi-tenant clusters. ๐Ÿ“ Basic Quota apiVersion: v1 kind: ResourceQuota metadata: name: namespace-quota namespace: development spec: hard: requests.cpu: “4” requests.memory: “8Gi” limits.cpu: “8” limits.memory: “16Gi” persistentvolumeclaims: “10” pods: “20” […]

Read More
Kubernetes

Kubernetes: Use Taints and Tolerations to Control Pod Placement

- 30.05.26 - ErcanOPAK comment on Kubernetes: Use Taints and Tolerations to Control Pod Placement

๐Ÿšซ Dedicated Nodes for Special Workloads Some nodes have GPUs. Some are spot instances. Taints repel pods. Tolerations allow them. Control exactly where workloads run. ๐Ÿ“ Add Taint to Node # Taint effects: # NoSchedule: Pods without toleration won’t be scheduled # PreferNoSchedule: Avoid if possible # NoExecute: Evict existing pods without toleration # Add […]

Read More
Kubernetes

Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

- 29.05.26 - ErcanOPAK comment on Kubernetes: Use PodDisruptionBudget to Prevent Service Interruption

๐Ÿ›ก๏ธ Don’t Drain All Pods at Once Node draining, cluster upgrades, autoscaling down โ€” they all kill pods. PodDisruptionBudget ensures minimum availability during voluntary disruptions. ๐Ÿ“ PDB Examples # At least 2 pods available at all times apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: minAvailable: 2 selector: matchLabels: app: myapp # No more than […]

Read More
Kubernetes

Kubernetes: Use Network Policies to Restrict Pod Communication

- 28.05.26 - ErcanOPAK comment on Kubernetes: Use Network Policies to Restrict Pod Communication

๐Ÿ”’ Zero Trust for Pods By default, all pods can talk to all pods. That’s a security risk. Network policies define who can talk to whom. ๐Ÿ“ Deny All Ingress apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-all-ingress spec: podSelector: {} # Applies to all pods policyTypes: – Ingress ingress: [] # Empty = deny all […]

Read More
Kubernetes

Kubernetes: Readiness vs Liveness Probes โ€” What’s the Difference?

- 27.05.26 - ErcanOPAK comment on Kubernetes: Readiness vs Liveness Probes โ€” What’s the Difference?

โค๏ธ Is Your App Alive AND Ready? Liveness = restart if dead. Readiness = don’t send traffic until ready. Use both for zero-downtime deployments. ๐Ÿ’“ Liveness Probe livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 30 periodSeconds: 10 If fails โ†’ Kubernetes restarts container. โœ… Readiness Probe readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: […]

Read More
Kubernetes

Kubernetes: Use Init Containers for Setup Tasks Before App Starts

- 26.05.26 - ErcanOPAK comment on Kubernetes: Use Init Containers for Setup Tasks Before App Starts

โณ Wait for Database, Then Start App needs database schema? Cache warmup? File permissions? Init containers run to completion before your main container starts. apiVersion: v1 kind: Pod metadata: name: my-app-pod spec: initContainers: – name: init-myservice image: busybox:1.28 command: [‘sh’, ‘-c’, ‘until nslookup myservice; do echo waiting; sleep 2; done;’] – name: init-db image: busybox:1.28 […]

Read More
Kubernetes

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

- 26.05.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 template: spec: containers: – name: app image: myapp:latest resources: requests: cpu: 100m # […]

Read More
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
Page 2 of 4
ยซ Previous 1 2 3 4 Next ยป

Posts pagination

« Previous 1 2 3 4 Next »
July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

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