Skip to content

Commit 333732b

Browse files
authored
Merge pull request #437 from rayfoss/patch-1
[DOC] Show an example of creating an ingress
2 parents 3ef3738 + ba38464 commit 333732b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/ingress.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const k8s = require('@kubernetes/client-node')
2+
const kc = new k8s.KubeConfig()
3+
kc.loadFromDefault()
4+
5+
const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1
6+
const clientIdentifier = 'my-subdomain'
7+
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`] }]
26+
}
27+
}).catch(e => console.log(e))

0 commit comments

Comments
 (0)