{{- if  .Values.deployment.test.enabled }}
---
apiVersion: v1
kind: Pod
metadata:
  name: "{{ .Release.Name }}-httpbin"
  labels:
    app: httpbin
spec:
  containers:
    - name: httpbin
      image: kennethreitz/httpbin
      ports:
      - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: "{{ .Release.Name }}-httpbin"
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: httpbin
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "{{ .Release.Name }}-httpbin"
  annotations:
    httpbin.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: "kong"
    konghq.com/strip-path: "true"
spec:
  rules:
  - http:
      paths:
      - path: /httpbin
        pathType: Prefix
        backend:
          service:
            name: "{{ .Release.Name }}-httpbin"
            port:
              number: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
  name: "{{ .Release.Name }}-kong-test"
spec:
  controllerName: konghq.com/kic-gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
  name: "{{ .Release.Name }}-kong-test"
  annotations:
    konghq.com/gateway-unmanaged: "true"
spec:
  gatewayClassName: "{{ .Release.Name }}-kong-test"
  listeners:  # Use GatewayClass defaults for listener definition.
  - name: http
    protocol: HTTP
    port: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: "{{ .Release.Name }}-httpbin"
spec:
  parentRefs:
    - name: "{{ .Release.Name }}-kong-test"
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: "/httproute"
      backendRefs:
        - name: "{{ .Release.Name }}-httpbin"
          port: 80
{{- end }}
