Skip to content

Commit ba38464

Browse files
authored
Shortened PR
"enriched" to fit small size
1 parent d6234f5 commit ba38464

File tree

1 file changed

+21
-47
lines changed

1 file changed

+21
-47
lines changed

examples/ingress.js

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,26 @@ const k8s = require('@kubernetes/client-node')
22
const kc = new k8s.KubeConfig()
33
kc.loadFromDefault()
44

5-
// Using apiVersion networking.k8s.io/v1beta1, for versions before 1.14 use extensions/v1beta1
6-
const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api)
5+
const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1
6+
const clientIdentifier = 'my-subdomain'
77

8-
function createIngress(clientIdentifier) {
9-
return {
10-
apiVersions: 'networking.k8s.io/v1beta1',
11-
kind: 'Ingress',
12-
metadata: {
13-
name: `production-custom-${clientIdentifier}`,
14-
namespace: 'default'
15-
},
16-
spec: {
17-
rules: [
18-
{
19-
name: `production-custom-${clientIdentifier}`,
20-
host: `${clientIdentifier}.example.com`,
21-
http: {
22-
paths: [
23-
{
24-
backend: {
25-
serviceName: 'production-auto-deploy',
26-
servicePort: 5000
27-
},
28-
path: '/'
29-
}
30-
]
31-
}
32-
}
33-
],
34-
tls: [
35-
{
36-
hosts: [`${clientIdentifier}.example.com`]
37-
}
38-
]
39-
},
8+
k8sApi.createNamespacedIngress('default', {
9+
apiVersions: 'networking.k8s.io/v1beta1',
10+
kind: 'Ingress',
11+
metadata: { name: `production-custom-${clientIdentifier}` },
12+
spec: {
13+
rules: [{
14+
host: `${clientIdentifier}.example.com`,
15+
http: {
16+
paths: [{
17+
backend: {
18+
serviceName: 'production-auto-deploy',
19+
servicePort: 5000
20+
},
21+
path: '/'
22+
}]
23+
}
24+
}],
25+
tls: [{ hosts: [`${clientIdentifier}.example.com`] }]
4026
}
41-
}
42-
43-
function main () {
44-
const clientIdentifier = 'poop'
45-
const ingress = createIngress(clientIdentifier)
46-
k8sApi.createNamespacedIngress('default', ingress)
47-
.then(() => console.log('Success'))
48-
.catch(e => {
49-
console.log(e)
50-
})
51-
}
52-
53-
main()
27+
}).catch(e => console.log(e))

0 commit comments

Comments
 (0)