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 ConfigMaps for Configuration

- 12.07.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps for Configuration

โš™๏ธ ConfigMaps = Configuration Hardcoding config is bad. ConfigMaps externalize configuration. Change settings without rebuilding. ๐Ÿ“ Creating ConfigMaps # From literal values kubectl create configmap app-config \ –from-literal=env=production \ –from-literal=log-level=debug \ –from-literal=api-url=https://api.example.com # From file kubectl create configmap app-config \ –from-file=./configs/app.properties \ –from-file=./configs/log4j.properties # From YAML apiVersion: v1 kind: ConfigMap metadata: name: app-config data: env: […]

Read More
Kubernetes

Kubernetes: Use Ingress Controllers for HTTP Routing

- 12.07.26 - ErcanOPAK comment on Kubernetes: Use Ingress Controllers for HTTP Routing

๐Ÿšช Ingress = HTTP Routing NodePort and LoadBalancer are basic. Ingress provides advanced HTTP routing. Single entry point, multiple services. ๐Ÿ“ Ingress Basics # Install NGINX Ingress Controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml # Ingress Resource apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress spec: rules: – host: app.example.com http: paths: – path: / pathType: Prefix backend: […]

Read More
Kubernetes

Kubernetes: Manage Storage with Persistent Volumes

- 12.07.26 - ErcanOPAK comment on Kubernetes: Manage Storage with Persistent Volumes

๐Ÿ’พ Persistent Volumes = Storage Management Data outlives pods. Persistent Volumes store data. PV, PVC, StorageClass โ€” storage done right. ๐Ÿ“ PV and PVC # PersistentVolume (PV) apiVersion: v1 kind: PersistentVolume metadata: name: postgres-pv spec: capacity: storage: 10Gi volumeMode: Filesystem accessModes: – ReadWriteOnce persistentVolumeReclaimPolicy: Retain hostPath: path: /data/postgres # PersistentVolumeClaim (PVC) apiVersion: v1 kind: PersistentVolumeClaim […]

Read More
Kubernetes

Kubernetes: Understand Service Discovery (DNS)

- 11.07.26 - ErcanOPAK comment on Kubernetes: Understand Service Discovery (DNS)

๐ŸŒ Service Discovery = DNS Services need to find each other. Service Discovery uses DNS. Automatic, built-in, easy. ๐Ÿ“ DNS Basics # Service DNS format service-name.namespace.svc.cluster.local # Example my-service.default.svc.cluster.local # Short form (same namespace) my-service # With port my-service.default.svc.cluster.local:8080 # Headless Service (No cluster IP) apiVersion: v1 kind: Service metadata: name: headless-service spec: clusterIP: None […]

Read More
Kubernetes

Kubernetes: Use Pod Lifecycle Hooks

- 11.07.26 - ErcanOPAK comment on Kubernetes: Use Pod Lifecycle Hooks

๐Ÿ”„ Pod Lifecycle Hooks Pods have lifecycle events. Lifecycle hooks run at specific times. Init, pre-stop, post-start. ๐Ÿ“ Hook Types apiVersion: v1 kind: Pod metadata: name: app spec: containers: – name: app image: myapp:latest lifecycle: postStart: exec: command: [“/bin/sh”, “-c”, “echo ‘Container started'”] preStop: exec: command: [“/bin/sh”, “-c”, “echo ‘Container stopping’ && sleep 5”] # […]

Read More
Kubernetes

Kubernetes: Use Init Containers for Setup Tasks

- 11.07.26 - ErcanOPAK comment on Kubernetes: Use Init Containers for Setup Tasks

โš™๏ธ Init Containers = Setup Tasks Apps need setup before start. Init containers run before main containers. Database migrations, permissions, downloads. ๐Ÿ“ Init Container Basics apiVersion: v1 kind: Pod metadata: name: app-with-init spec: initContainers: – name: init-db image: busybox command: [‘sh’, ‘-c’, ‘echo “Initializing database…” && sleep 5’] – name: init-permissions image: busybox command: [‘sh’, […]

Read More
Kubernetes

Kubernetes: Use CronJobs for Scheduled Tasks

- 10.07.26 - ErcanOPAK comment on Kubernetes: Use CronJobs for Scheduled Tasks

โฐ CronJobs = Scheduled Tasks Regular tasks need automation. CronJobs schedule tasks in Kubernetes. Backups, cleanup, reports โ€” automatic. ๐Ÿ“ CronJob Setup apiVersion: batch/v1 kind: CronJob metadata: name: daily-backup spec: schedule: “0 2 * * *” # Daily at 2 AM jobTemplate: spec: template: spec: containers: – name: backup image: alpine:latest command: – /bin/sh – […]

Read More
Kubernetes

Kubernetes: Choose the Right Service Type

- 10.07.26 - ErcanOPAK comment on Kubernetes: Choose the Right Service Type

๐Ÿ”Œ Service Types = How to Expose Apps Pods need access. Service types control exposure. ClusterIP, NodePort, LoadBalancer โ€” choose right one. ๐Ÿ“ Service Types # ClusterIP (Default) apiVersion: v1 kind: Service metadata: name: internal-app spec: type: ClusterIP selector: app: myapp ports: – port: 80 targetPort: 8080 # NodePort apiVersion: v1 kind: Service metadata: name: […]

Read More
Kubernetes

Kubernetes: Use HPA for Automatic Scaling

- 10.07.26 - ErcanOPAK comment on Kubernetes: Use HPA for Automatic Scaling

๐Ÿ“ˆ HPA = Automatic Scaling Traffic changes constantly. Horizontal Pod Autoscaler scales automatically. More pods when needed, less when not. ๐Ÿ“ HPA Setup # Install metrics-server kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml # Verify metrics-server kubectl top pods kubectl top nodes # Create HPA apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: web-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment […]

Read More
Kubernetes

Kubernetes: Set Resource Limits for Stability

- 09.07.26 - ErcanOPAK comment on Kubernetes: Set Resource Limits for Stability

โš–๏ธ Resource Limits = Stability Pods can consume all resources. Resource limits ensure stability. CPU, memory โ€” protect your cluster. ๐Ÿ“ Setting Limits apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: – name: app image: myapp:latest resources: requests: memory: “64Mi” cpu: “250m” limits: memory: “128Mi” cpu: “500m” # Requests: Minimum guaranteed # Limits: Maximum […]

Read More
Kubernetes

Kubernetes: Secure Your Cluster with Network Policies

- 09.07.26 - ErcanOPAK comment on Kubernetes: Secure Your Cluster with Network Policies

๐Ÿ›ก๏ธ Network Policies = Cluster Security Default is allow all. Network Policies control traffic. Zero trust, micro-segmentation, security. ๐Ÿ“ Network Policy Basics # Deny all (Default deny) apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-all spec: podSelector: {} policyTypes: – Ingress – Egress # Allow specific ingress apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-nginx spec: podSelector: […]

Read More
Kubernetes

Kubernetes: Use PodDisruptionBudget for High Availability

- 09.07.26 - ErcanOPAK comment on Kubernetes: Use PodDisruptionBudget for High Availability

๐Ÿ›ก๏ธ PodDisruptionBudget = High Availability Pods fail, nodes upgrade. PodDisruptionBudget ensures availability. Minimum pods running, safe operations. ๐Ÿ“ PDB Basics apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: minAvailable: 2 # Minimum 2 pods running selector: matchLabels: app: myapp — # Or use maxUnavailable apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: maxUnavailable: 1 # […]

Read More
Kubernetes

Kubernetes: Use Operators for Automated Management

- 07.07.26 - ErcanOPAK comment on Kubernetes: Use Operators for Automated Management

๐Ÿค– Operators = Automated Management Manual operations are error-prone. Operators automate complex applications. Database, monitoring, custom apps โ€” self-healing. ๐Ÿ“ Popular Operators # Databases – Postgres Operator (Crunchy Data) – MySQL Operator (Oracle) – MongoDB Operator – Elasticsearch Operator – Redis Operator # Monitoring – Prometheus Operator – Grafana Operator – Datadog Operator # Infrastructure […]

Read More
Kubernetes

Kubernetes: Use Ingress Controllers for HTTP Routing

- 07.07.26 - ErcanOPAK comment on Kubernetes: Use Ingress Controllers for HTTP Routing

๐Ÿšช Ingress = HTTP Routing NodePort and LoadBalancer are basic. Ingress provides advanced HTTP routing. Single entry point, multiple services, SSL. ๐Ÿ“ Ingress Basics # Install NGINX Ingress Controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml # Ingress Resource apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress spec: rules: – host: app.example.com http: paths: – path: / pathType: Prefix […]

Read More
Kubernetes

Kubernetes: Use Helm Charts for Package Management

- 07.07.26 - ErcanOPAK comment on Kubernetes: Use Helm Charts for Package Management

๐Ÿ“ฆ Helm = Kubernetes Package Manager Kubernetes YAML is repetitive. Helm packages Kubernetes apps. Templates, versioning, sharing โ€” like apt/yum for K8s. ๐Ÿ“ Helm Commands # Install Helm curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash # Add repositories helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add stable https://charts.helm.sh/stable helm repo update # Search charts helm search repo nginx […]

Read More
Kubernetes

Kubernetes: Use Persistent Volumes for Data Persistence

- 05.07.26 - ErcanOPAK comment on Kubernetes: Use Persistent Volumes for Data Persistence

๐Ÿ’พ Persistent Data in Kubernetes Pods are ephemeral. Data disappears. Persistent Volumes store data beyond pod life. Essential for databases, files, state. ๐Ÿ“ PV and PVC # PersistentVolume (PV) apiVersion: v1 kind: PersistentVolume metadata: name: postgres-pv spec: capacity: storage: 10Gi volumeMode: Filesystem accessModes: – ReadWriteOnce persistentVolumeReclaimPolicy: Retain hostPath: path: /data/postgres # PersistentVolumeClaim (PVC) apiVersion: v1 […]

Read More
Kubernetes

Kubernetes: Use ConfigMaps for Configuration Management

- 05.07.26 - ErcanOPAK comment on Kubernetes: Use ConfigMaps for Configuration Management

โš™๏ธ Centralized Configuration Hardcoding config is bad. ConfigMaps externalize configuration. Change settings without rebuilding. ๐Ÿ“ Creating ConfigMaps # From literal values kubectl create configmap app-config \ –from-literal=env=production \ –from-literal=log-level=debug \ –from-literal=api-url=https://api.example.com # From file kubectl create configmap app-config \ –from-file=./configs/app.properties \ –from-file=./configs/log4j.properties # From directory kubectl create configmap app-config \ –from-file=./configs/ # From YAML apiVersion: […]

Read More
Kubernetes

Kubernetes: Use Secrets to Store Sensitive Data Securely

- 05.07.26 - ErcanOPAK comment on Kubernetes: Use Secrets to Store Sensitive Data Securely

๐Ÿ” Secure Secrets Management Passwords, tokens, keys โ€” never hardcode. Kubernetes Secrets store sensitive data securely. Use in pods via environment variables or volumes. ๐Ÿ“ Creating Secrets # Create from literal values kubectl create secret generic app-secret \ –from-literal=db-password=SecurePass123 \ –from-literal=api-key=abc-123-xyz # Create from file kubectl create secret generic app-secret \ –from-file=./secrets/db-password.txt \ –from-file=./secrets/api-key.txt # […]

Read More
Kubernetes

Kubernetes: Use Service Mesh (Istio) for Advanced Traffic Management

- 04.07.26 - ErcanOPAK comment on Kubernetes: Use Service Mesh (Istio) for Advanced Traffic Management

๐Ÿšฆ Advanced Traffic Management for Microservices Service Mesh adds features to Kubernetes. Istio provides traffic routing, load balancing, security, observability. ๐Ÿ“ Install Istio # Download Istio curl -L https://istio.io/downloadIstio | sh – cd istio-1.20.0 export PATH=$PWD/bin:$PATH # Install Istio istioctl install –set profile=demo -y # Enable sidecar injection kubectl label namespace default istio-injection=enabled # Deploy […]

Read More
Kubernetes

Kubernetes: Use PodDisruptionBudget for Zero Downtime

- 04.07.26 - ErcanOPAK comment on Kubernetes: Use PodDisruptionBudget for Zero Downtime

๐Ÿ›ก๏ธ Prevent Simultaneous Pod Evictions Node draining can evict all pods at once. PodDisruptionBudget ensures minimum availability during disruptions. ๐Ÿ“ PDB Example apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: minAvailable: 2 selector: matchLabels: app: myapp — apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: app-pdb spec: maxUnavailable: 1 selector: matchLabels: app: myapp ๐ŸŽฏ PDB Status # […]

Read More
Kubernetes

Kubernetes: Use StatefulSets for Stateful Applications

- 04.07.26 - ErcanOPAK comment on Kubernetes: Use StatefulSets for Stateful Applications
Read More
Kubernetes

Kubernetes: Use HPA to Auto-Scale Pods Based on Load

- 24.06.26 - ErcanOPAK comment on Kubernetes: Use HPA to Auto-Scale Pods Based on Load

๐Ÿ“ˆ Scale Pods Automatically Fixed replicas waste resources. HorizontalPodAutoscaler scales pods based on CPU/memory. Scale up during load, down during low traffic. ๐Ÿ“ HPA Configuration apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: myapp-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: myapp minReplicas: 2 maxReplicas: 10 metrics: – type: Resource resource: name: cpu target: type: Utilization averageUtilization: […]

Read More
Kubernetes

Kubernetes: Use DaemonSets to Run Pods on Every Node

- 24.06.26 - ErcanOPAK comment on Kubernetes: Use DaemonSets to Run Pods on Every Node

๐Ÿ“ก One Pod Per Node โ€” Automatically Need monitoring agent on every node? Log collector? DaemonSet runs one pod per node. New nodes get pod automatically. ๐Ÿ“ DaemonSet Example apiVersion: apps/v1 kind: DaemonSet metadata: name: node-monitor namespace: kube-system spec: selector: matchLabels: name: node-monitor template: metadata: labels: name: node-monitor spec: containers: – name: monitor image: prom/node-exporter […]

Read More
Kubernetes

Kubernetes: Use StorageClasses for Dynamic Volume Provisioning

- 24.06.26 - ErcanOPAK comment on Kubernetes: Use StorageClasses for Dynamic Volume Provisioning

๐Ÿ’พ StorageClasses Create Volumes Automatically Manual volume creation is tedious. StorageClasses provision volumes dynamically. Specify storage type, size, performance. ๐Ÿ“ StorageClass Examples apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast-ssd provisioner: kubernetes.io/aws-ebs parameters: type: gp3 encrypted: “true” iopsPerGB: “50” allowVolumeExpansion: true — apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: kubernetes.io/aws-ebs parameters: type: gp2 encrypted: “true” […]

Read More
Kubernetes

Kubernetes: Use Node Affinity to Control Pod Placement

- 21.06.26 - ErcanOPAK comment on Kubernetes: Use Node Affinity to Control Pod Placement

๐ŸŽฏ Put Pods Where They Belong Some nodes have GPUs. Some are in different zones. Node affinity schedules pods on specific nodes. Control placement precisely. ๐Ÿ“ Node Affinity apiVersion: v1 kind: Pod metadata: name: gpu-pod spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: – matchExpressions: – key: gpu operator: In values: – “nvidia” – “amd” containers: – name: […]

Read More
Kubernetes

Kubernetes: Extend Kubernetes with Custom Resource Definitions

- 21.06.26 - ErcanOPAK comment on Kubernetes: Extend Kubernetes with Custom Resource Definitions

๐Ÿ”Œ Define Your Own Kubernetes Objects Kubernetes has Pods, Services, Deployments. Custom Resource Definitions (CRD) create your own objects. Extend Kubernetes for your needs. ๐Ÿ“ Create a CRD apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: databases.myapp.com spec: group: myapp.com versions: – name: v1 served: true storage: true schema: openAPIV3Schema: type: object properties: spec: type: object properties: […]

Read More
Kubernetes

Kubernetes: Use Service Accounts for Pod Authentication

- 21.06.26 - ErcanOPAK comment on Kubernetes: Use Service Accounts for Pod Authentication
Read More
Kubernetes

Kubernetes: Use Security Context to Control Pod Permissions

- 20.06.26 - ErcanOPAK comment on Kubernetes: Use Security Context to Control Pod Permissions

๐Ÿ” Run Containers as Non-Root User Containers run as root by default. Security context runs as non-root. Less privilege, better security. ๐Ÿ“ Security Context apiVersion: v1 kind: Pod metadata: name: secure-pod spec: securityContext: runAsUser: 1000 runAsGroup: 3000 fsGroup: 2000 containers: – name: myapp image: myapp:latest securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: [“ALL”] add: [“NET_ADMIN”] […]

Read More
Kubernetes

Kubernetes: Use Persistent Volumes for Data Storage

- 20.06.26 - ErcanOPAK comment on Kubernetes: Use Persistent Volumes for Data Storage

๐Ÿ’พ Pods Are Ephemeral. Data Shouldn’t Be. Pod restarts lose data. Persistent Volumes (PV) store data outside pods. Databases, uploads, logs survive restarts. ๐Ÿ“ Persistent Volume Claim apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgres-pvc spec: accessModes: – ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard — apiVersion: v1 kind: Pod metadata: name: postgres spec: containers: – […]

Read More
Kubernetes

Kubernetes: Understand Service Types โ€” ClusterIP, NodePort, LoadBalancer

- 20.06.26 - ErcanOPAK comment on Kubernetes: Understand Service Types โ€” ClusterIP, NodePort, LoadBalancer

๐ŸŒ Internal vs External Access Pods have IPs, but they change. Services provide stable access. Choose the right type: ClusterIP (internal), NodePort (external on node IP), LoadBalancer (cloud load balancer). ๐Ÿ“ Service Types ClusterIP (default): – Internal cluster access only – Virtual IP accessible inside cluster – Use for microservices communicating internally apiVersion: v1 kind: […]

Read More
Page 1 of 4
1 2 3 4 Next ยป

Posts pagination

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 (860)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (815)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (600)
  • Add Constraint to SQL Table to ensure email contains @ (583)
  • 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 (860)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (815)

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