Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 1 | // HSWAW / hscloud / k0-specific extensions to kube.libsonnet |
| 2 | |
| 3 | local kube = import "kube.libsonnet"; |
| 4 | |
| 5 | kube { |
radex | d45584a | 2023-11-24 12:51:57 +0100 | [diff] [blame] | 6 | // Basic Ingress config pointing `hosts` to the `target` service, with HTTPS set up |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 7 | SimpleIngress(name): kube.Ingress(name) { |
| 8 | local ingress = self, |
radex | d45584a | 2023-11-24 12:51:57 +0100 | [diff] [blame] | 9 | hosts:: error "SimpleIngress.hosts must be defined", |
| 10 | target:: error "SimpleIngress.target service must be defined", |
| 11 | extraPaths:: [], |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 12 | metadata+: { |
| 13 | annotations+: { |
| 14 | 'kubernetes.io/tls-acme': 'true', |
| 15 | 'cert-manager.io/cluster-issuer': 'letsencrypt-prod', |
| 16 | 'nginx.ingress.kubernetes.io/proxy-body-size': '0', |
| 17 | }, |
| 18 | }, |
| 19 | spec+: { |
| 20 | tls: [{ hosts: ingress.hosts, secretName: name + '-tls' }], |
| 21 | rules: [ |
| 22 | { |
| 23 | host: host, |
| 24 | http: { |
| 25 | paths: [ |
radex | d45584a | 2023-11-24 12:51:57 +0100 | [diff] [blame] | 26 | { path: '/', backend: ingress.target.name_port }, |
| 27 | ] + ingress.extraPaths, |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 28 | }, |
| 29 | } |
| 30 | for host in ingress.hosts |
| 31 | ], |
| 32 | }, |
| 33 | }, |
| 34 | } |