# ============================================================================== # EXAMPLE: Basic Kubernetes Ingress # ============================================================================== # # WHAT THIS DEMONSTRATES: # - Basic ingress configuration with EasyHAProxy # - Multiple domains pointing to the same service # - Complete deployment + service + ingress setup # - HTTP ingress without TLS # # REQUIREMENTS (run these first): # ```bash # # 1. Ensure EasyHAProxy is installed in your cluster # kubectl create namespace easyhaproxy # kubectl apply -f https://raw.githubusercontent.com/byjg/docker-easy-haproxy/5.0.0/deploy/kubernetes/easyhaproxy-daemonset.yml # # # 2. Label the node where EasyHAProxy will run # kubectl label nodes "easyhaproxy/node=master" # # # 3. Add to /etc/hosts for local testing (idempotent) # grep -q "example.org" /etc/hosts || echo " example.org www.example.org" | sudo tee -a /etc/hosts # ``` # # HOW TO START: # ```bash # kubectl apply -f service.yml # ``` # # HOW TO VERIFY IT'S WORKING: # ```bash # # Check resources are created # kubectl get deployment,service,ingress container-example # # # Test via node IP # curl -H "Host: example.org" http://:31080 # # Expected: 200 OK with "My Host Example" # # # Or use port-forward for testing # kubectl port-forward -n easyhaproxy deployment/easyhaproxy 8080:80 # curl -H "Host: example.org" http://localhost:8080 # # Expected: 200 OK with "My Host Example" # # # Test second domain # curl -H "Host: www.example.org" http://:31080 # # Expected: Same response # ``` # # CLEAN UP: # ```bash # kubectl delete -f service.yml # ``` # # ============================================================================== --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: container-example namespace: default spec: # Use ingressClassName instead of the deprecated annotation # For backward compatibility, annotation kubernetes.io/ingress.class is still supported ingressClassName: easyhaproxy rules: - host: example.org http: paths: - backend: service: name: container-example port: number: 8080 pathType: ImplementationSpecific - host: www.example.org http: paths: - backend: service: name: container-example port: number: 8080 pathType: ImplementationSpecific --- apiVersion: v1 kind: Service metadata: name: container-example namespace: default spec: ports: - name: http port: 8080 selector: app: container-example type: ClusterIP --- apiVersion: apps/v1 kind: Deployment metadata: name: container-example namespace: default spec: replicas: 1 revisionHistoryLimit: 10 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate selector: matchLabels: app: container-example template: metadata: labels: app: container-example spec: containers: - name: container-example image: byjg/static-httpserver ports: - containerPort: 8080 resources: limits: cpu: '0.05' memory: '20Mi' requests: cpu: '0.05' memory: '20Mi' env: - name: TITLE value: "My Host Example"