@@ -2,52 +2,26 @@ const k8s = require('@kubernetes/client-node')
2
2
const kc = new k8s . KubeConfig ( )
3
3
kc . loadFromDefault ( )
4
4
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'
7
7
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` ] } ]
40
26
}
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