---DEMO ---

---
apiVersion: v1
kind: Namespace
metadata:
  name: demo-apps
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-v1
  namespace: demo-apps
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demo
      version: v1
  template:
    metadata:
      labels:
        app: demo
        version: v1
    spec:
      containers:
      - name: app
        image: hashicorp/http-echo
        args:
        - "-text=Hello from App v1"
        ports:
        - containerPort: 5678
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-v2
  namespace: demo-apps
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demo
      version: v2
  template:
    metadata:
      labels:
        app: demo
        version: v2
    spec:
      containers:
      - name: app
        image: hashicorp/http-echo
        args:
        - "-text=Hello from App v2"
        ports:
        - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: app-v1
  namespace: demo-apps
spec:
  selector:
    app: demo
    version: v1
  ports:
  - port: 80
    targetPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: app-v2
  namespace: demo-apps
spec:
  selector:
    app: demo
    version: v2
  ports:
  - port: 80
    targetPort: 5678





----  HTTP ROUTE ---
kind: HTTPRoute
metadata:
  name: demo-route
  namespace: demo-apps
spec:
  parentRefs:
  - name: main-gateway
    namespace: nginx-gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: app-v1
      port: 80











***to add for https ***

    # HTTP'S Listener (Add Muliple HTTPS listner)
    - name: https-api-artha-link
      port: 443
      protocol: HTTPS
      hostname: domain1.com
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: domain1-ssl
            namespace: default
      allowedRoutes:
        namespaces:
          from: All

    - name: https-app-artha-link
      port: 443
      protocol: HTTPS
      hostname: domain2.com
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: domain2-ssl
            namespace: default
      allowedRoutes:
        namespaces:
          from: All


apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: demo-route
  namespace: demo-apps
spec:
  parentRefs:
  - name: main-gateway
    namespace: nginx-gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: app-v1
      port: 80
	  
	  


	  
	  
	  
kubectl create -n demo-apps -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: swiss-army-knife
  labels:
    app: swiss-army-knife
spec:
  containers:
  - name: swiss-army-knife
    image: leodotcloud/swiss-army-knife:latest
    command: ["/bin/sleep", "3650d"]
    imagePullPolicy: IfNotPresent
  restartPolicy: Always
EOF

kubectl exec -n demo_apps swiss-army-knife  -it -- /bin/bash