|
1 |
| -const k8s = require('@kubernetes/client-node') |
2 |
| -const kc = new k8s.KubeConfig() |
3 |
| -kc.loadFromDefault() |
| 1 | +const k8s = require('@kubernetes/client-node'); |
| 2 | +const kc = new k8s.KubeConfig(); |
| 3 | +kc.loadFromDefault(); |
4 | 4 |
|
5 |
| -const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1 |
6 |
| -const clientIdentifier = 'my-subdomain' |
| 5 | +const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api); // before 1.14 use extensions/v1beta1 |
| 6 | +const clientIdentifier = 'my-subdomain'; |
7 | 7 |
|
8 | 8 | k8sApi.createNamespacedIngress('default', {
|
9 |
| - apiVersions: 'networking.k8s.io/v1beta1', |
| 9 | + apiVersions: 'networking.k8s.io/v1', |
10 | 10 | kind: 'Ingress',
|
11 |
| - metadata: { name: `production-custom-${clientIdentifier}` }, |
| 11 | + metadata: { |
| 12 | + name: `production-custom-${clientIdentifier}`, |
| 13 | + labels: { |
| 14 | + createdBy: 'node-client', |
| 15 | + }, |
| 16 | + annotations: { |
| 17 | + 'meta.helm.sh/release-namespace': 'production-auto-deploy', |
| 18 | + }, |
| 19 | + }, |
12 | 20 | spec: {
|
| 21 | + ingressClassName: 'nginx', |
13 | 22 | rules: [{
|
14 |
| - host: `${clientIdentifier}.example.com`, |
| 23 | + host: `${clientIdentifier}`, |
15 | 24 | http: {
|
16 | 25 | paths: [{
|
17 | 26 | backend: {
|
18 |
| - serviceName: 'production-auto-deploy', |
19 |
| - servicePort: 5000 |
| 27 | + service: { |
| 28 | + name: 'production-auto-deploy', |
| 29 | + port: { |
| 30 | + number: 5000, |
| 31 | + }, |
| 32 | + }, |
20 | 33 | },
|
21 |
| - path: '/' |
22 |
| - }] |
23 |
| - } |
| 34 | + path: '/default-kuberiq(/|$)(.*)', |
| 35 | + pathType: 'ImplementationSpecific', |
| 36 | + }], |
| 37 | + }, |
24 | 38 | }],
|
25 |
| - tls: [{ hosts: [`${clientIdentifier}.example.com`] }] |
26 |
| - } |
27 |
| -}).catch(e => console.log(e)) |
| 39 | + tls: [{ |
| 40 | + hosts: [`${clientIdentifier}.example.com`], |
| 41 | + }], |
| 42 | + }, |
| 43 | +}).catch(e => console.log(e)); |
0 commit comments