ingress-route
Provisions an Ingress route on a shared nginx instance.
type: route
supported_params:
- path
- host
- port10-ingress-route.provisioners.yaml
(view on GitHub)
:
- uri: template://community-provisioners/ingress-route
type: route
description: Provisions an Ingress route on a shared nginx instance.
supported_params:
- path
- host
- port
init: |
{{ if not (regexMatch "^/|(/([^/]+))+$" .Params.path) }}{{ fail "params.path start with a / but cannot end with /" }}{{ end }}
{{ if not (regexMatch "^[a-z0-9_.-]{1,253}$" .Params.host) }}{{ fail (cat "params.host must be a valid hostname but was" .Params.host) }}{{ end }}
{{ $ports := (index .WorkloadServices .SourceWorkload).Ports }}
{{ if not $ports }}{{ fail "no service ports exist" }}{{ end }}
{{ $port := index $ports (print .Params.port) }}
{{ if not $port.TargetPort }}{{ fail "params.port is not a named service port" }}{{ end }}
state: |
routeName: route-{{ .SourceWorkload }}-{{ substr 0 8 .Guid | lower }}
manifests: |
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .State.routeName }}
{{ if ne .Namespace "" }}
namespace: {{ .Namespace }}
{{ end }}
spec:
ingressClassName: nginx
rules:
- host: {{ .Params.host | quote }}
http:
paths:
- path: {{ .Params.path | quote }}
pathType: Prefix
backend:
service:
name: {{ (index .WorkloadServices .SourceWorkload).ServiceName }}
port:
number: {{ .Params.port }}