ingress_spec:
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      nginx.ingress.kubernetes.io/use-regex: "true"
      nginx.ingress.kubernetes.io/rewrite-target: /$2
    name: {{ ingress_name }}
    namespace: {{ namespace }}
  spec:
    ingressClassName: nginx
    rules:
    - http:
        paths:
        - path: /{{ path_prefix }}(/|$)(.*)
          pathType: ImplementationSpecific
          backend:
            service:
              name: {{ service_name }}
              port:
                number: {{ service_port }}
service_spec:
  apiVersion: v1
  kind: Service
  metadata:
    name: {{ service_name }}
    labels:
      parent: skypilot
  spec:
    type: ClusterIP
    selector:
      {{ selector_key }}: {{ selector_value }}
    ports:
    - port: {{ service_port }}
      targetPort: {{ service_port }}
