Skip to content

Commit 14b6d48

Browse files
authored
Merge pull request #962 from vBitza/feature/update-ingress-example
add NetworkingV1 Ingress example
2 parents 7c3f4e1 + e848e4d commit 14b6d48

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

examples/ingress.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
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();
44

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';
77

88
k8sApi.createNamespacedIngress('default', {
9-
apiVersions: 'networking.k8s.io/v1beta1',
9+
apiVersions: 'networking.k8s.io/v1',
1010
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+
},
1220
spec: {
21+
ingressClassName: 'nginx',
1322
rules: [{
14-
host: `${clientIdentifier}.example.com`,
23+
host: `${clientIdentifier}`,
1524
http: {
1625
paths: [{
1726
backend: {
18-
serviceName: 'production-auto-deploy',
19-
servicePort: 5000
27+
service: {
28+
name: 'production-auto-deploy',
29+
port: {
30+
number: 5000,
31+
},
32+
},
2033
},
21-
path: '/'
22-
}]
23-
}
34+
path: '/default-kuberiq(/|$)(.*)',
35+
pathType: 'ImplementationSpecific',
36+
}],
37+
},
2438
}],
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

Comments
 (0)