forked from kubernetes-client/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingress.js
27 lines (25 loc) · 765 Bytes
/
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
const k8s = require('@kubernetes/client-node')
const kc = new k8s.KubeConfig()
kc.loadFromDefault()
const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1
const clientIdentifier = 'my-subdomain'
k8sApi.createNamespacedIngress('default', {
apiVersions: 'networking.k8s.io/v1beta1',
kind: 'Ingress',
metadata: { name: `production-custom-${clientIdentifier}` },
spec: {
rules: [{
host: `${clientIdentifier}.example.com`,
http: {
paths: [{
backend: {
serviceName: 'production-auto-deploy',
servicePort: 5000
},
path: '/'
}]
}
}],
tls: [{ hosts: [`${clientIdentifier}.example.com`] }]
}
}).catch(e => console.log(e))