# 1. Create a Deployment of nginx
kubectl create deployment my-nginx --image=nginx:latest --port=80

# 2. Expose the Deployment as a NodePort service
kubectl expose deployment my-nginx \
  --type=NodePort \
  --port=80 \
  --target-port=80 \
  --name=my-nginx-service

===============
# backend-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
      - name: http-echo
        image: hashicorp/http-echo:0.2.3
        args:
          - "-listen=:8080"
          - "-text=Hello from the Backend!"
        ports:
        - containerPort: 8080
-------------

# backend-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  type: ClusterIP  # Default
  selector:
    app: backend
  ports:
    - port: 80         # Service port (used by internal clients)
      targetPort: 8080 # Container port in the backend Pod
------------
# frontend-deployment.yaml
-------
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
      - name: curl-loop
        image: curlimages/curl:7.86.0
        command: ["/bin/sh"]
        args:
          - "-c"
          - |
            while true; do
              echo "=== Calling backend-service:80 ==="
              curl -s backend-service:80
              echo
              sleep 5
            done
-----------

