Created
September 24, 2025 01:13
-
-
Save binura-g/30ccb2f075a2eb8d7842088ea5a54a6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #@ load("@ytt:data", "data") | |
| #@ load("@ytt:struct", "struct") | |
| #@ load("@ytt:assert", "assert") | |
| #@ app = data.values.app | |
| ## Note how all the logic is written in yaml comments - hence why it's been excluded from the shortlist. | |
| --- | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: #@ app.name | |
| spec: | |
| replicas: #@ app.replicas | |
| selector: | |
| matchLabels: | |
| app: #@ app.name | |
| template: | |
| metadata: | |
| labels: | |
| app: #@ app.name | |
| spec: | |
| containers: | |
| - name: app | |
| image: #@ app.image | |
| ports: | |
| #@ for e in app.endpoints: | |
| - name: #@ e.name | |
| containerPort: #@ e.port | |
| #@ end | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: #@ app.name | |
| spec: | |
| type: #@ app.serviceType | |
| selector: | |
| app: #@ app.name | |
| ports: | |
| #@ for e in app.endpoints: | |
| - name: #@ e.name | |
| port: #@ e.port | |
| targetPort: #@ e.port | |
| #@ end | |
| #@ for e in app.endpoints: | |
| #@ if e.type == "ingress": | |
| --- | |
| apiVersion: networking.k8s.io/v1 | |
| kind: Ingress | |
| metadata: | |
| name: #@ app.name + "-" + e.name | |
| annotations: | |
| kubernetes.io/ingress.class: #@ app.ingressClass | |
| spec: | |
| rules: | |
| - host: #@ e.host | |
| http: | |
| paths: | |
| - path: #@ e.path | |
| pathType: Prefix | |
| backend: | |
| service: | |
| name: #@ app.name | |
| port: | |
| number: #@ e.port | |
| #@ if/end e.tlsSecretName != "": | |
| tls: | |
| - secretName: #@ e.tlsSecretName | |
| hosts: [#@ e.host] | |
| #@ else: | |
| --- | |
| apiVersion: gateway.networking.k8s.io/v1 | |
| kind: HTTPRoute | |
| metadata: | |
| name: #@ app.name + "-" + e.name | |
| spec: | |
| parentRefs: [{ name: #@ app.gatewayName }] | |
| hostnames: [#@ e.host] | |
| rules: | |
| - matches: | |
| - path: | |
| type: PathPrefix | |
| value: #@ e.path | |
| backendRefs: | |
| - name: #@ app.name | |
| port: #@ e.port | |
| #@ end | |
| #@ end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment