forked from kubernetes-client/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingress.js
61 lines (56 loc) · 1.99 KB
/
ingress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const k8s = require('@kubernetes/client-node');
const namespace = 'default';
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api); // before 1.14 use extensions/v1beta1
const clientIdentifier = 'my-subdomain';
const main = async () => {
try {
const createIngressRes = k8sApi.createNamespacedIngress(namespace, {
apiVersions: 'networking.k8s.io/v1',
kind: 'Ingress',
metadata: {
name: `production-custom-${clientIdentifier}`,
labels: {
createdBy: 'node-client',
},
annotations: {
'meta.helm.sh/release-namespace': 'production-auto-deploy',
},
},
spec: {
ingressClassName: 'nginx',
rules: [
{
host: `${clientIdentifier}`,
http: {
paths: [
{
backend: {
service: {
name: 'production-auto-deploy',
port: {
number: 5000,
},
},
},
path: '/default-kuberiq(/|$)(.*)',
pathType: 'ImplementationSpecific',
},
],
},
},
],
tls: [
{
hosts: [`${clientIdentifier}.example.com`],
},
],
},
});
console.log(createIngressRes.body);
} catch (err) {
console.error(err);
}
};
main();