Skip to content

Instantly share code, notes, and snippets.

@astromechza
Last active May 29, 2024 23:03
Show Gist options
  • Save astromechza/a652699839726de074c5d3919497b2d0 to your computer and use it in GitHub Desktop.
Save astromechza/a652699839726de074c5d3919497b2d0 to your computer and use it in GitHub Desktop.
- uri: template://custom/dns
type: dns
class: default
outputs: |
host: image-service.hensteeth.meierhost.com
- uri: template://custom/ingress
type: route
class: default
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 }}
routeName: route-{{ .SourceWorkload }}-{{ substr 0 8 .Guid | lower }}
secretName: route-{{ .SourceWorkload }}-{{ substr 0 8 .Guid | lower }}-secret
outputs: |
_secretName: {{ .Init.secretName }}
manifests: |
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Init.routeName }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
nginx.ingress.kubernetes.io/proxy-body-size: 512M
spec:
ingressClassName: public
rules:
- host: {{ .Params.host | quote }}
http:
paths:
- path: {{ .Params.path | quote }}
pathType: Prefix
backend:
service:
name: {{ (index .WorkloadServices .SourceWorkload).ServiceName }}
port:
number: {{ .Params.port }}
tls:
- secretName: {{ .Init.secretName }}
hosts:
- {{ .Params.host | quote }}
- uri: template://custom/postgres
type: postgres
class: default
outputs: |
host: postgres-postgresql
port: 5432
name: postgres
database: postgres
username: postgres
password: {{ encodeSecretRef "postgres-postgresql" "postgres-password" }}
- uri: template://custom/rabbitmq
type: amqp
class: default
id: common-queue
outputs: |
host: rabbitmq
port: 5672
vhost: ""
username: user
password: {{ encodeSecretRef "rabbitmq" "rabbitmq-password" }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment