--- # Namespace for testing apiVersion: v1 kind: Namespace metadata: name: ha-test --- # ConfigMap with application configuration apiVersion: v1 kind: ConfigMap metadata: name: nginx-config namespace: ha-test data: index.html: | HA Cluster Test

Kubernetes HA Cluster Test

Pod Hostname:

Timestamp:

Node IP:

--- # Deployment with multiple replicas for HA testing apiVersion: apps/v1 kind: Deployment metadata: name: ha-test-app namespace: ha-test labels: app: ha-test-app spec: replicas: 6 # Deploy across multiple nodes strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 selector: matchLabels: app: ha-test-app template: metadata: labels: app: ha-test-app spec: # Anti-affinity to spread pods across nodes affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - key: app operator: In values: - ha-test-app topologyKey: kubernetes.io/hostname containers: - name: nginx image: nginx:1.25-alpine ports: - containerPort: 80 name: http env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP volumeMounts: - name: nginx-config mountPath: /usr/share/nginx/html resources: requests: memory: "64Mi" cpu: "50m" limits: memory: "128Mi" cpu: "100m" livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 10 periodSeconds: 10 readinessProbe: httpGet: path: / port: 80 initialDelaySeconds: 5 periodSeconds: 5 volumes: - name: nginx-config configMap: name: nginx-config --- # Service to expose the deployment apiVersion: v1 kind: Service metadata: name: ha-test-service namespace: ha-test labels: app: ha-test-app spec: selector: app: ha-test-app ports: - port: 80 targetPort: 80 protocol: TCP name: http type: ClusterIP --- # NodePort Service for external access (alternative to ingress) apiVersion: v1 kind: Service metadata: name: ha-test-nodeport namespace: ha-test labels: app: ha-test-app spec: selector: app: ha-test-app ports: - port: 80 targetPort: 80 nodePort: 30080 protocol: TCP name: http type: NodePort --- # HorizontalPodAutoscaler for testing scaling apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: ha-test-hpa namespace: ha-test spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: ha-test-app minReplicas: 3 maxReplicas: 12 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 --- # PodDisruptionBudget for HA apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: ha-test-pdb namespace: ha-test spec: minAvailable: 2 selector: matchLabels: app: ha-test-app