-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from DavidIsa/master
Examples improvements
- Loading branch information
Showing
24 changed files
with
400 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
|
||
const namespace = 'default'; | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | ||
|
||
k8sApi.listNamespacedPod('default') | ||
.then((res) => { | ||
console.log(res.body); | ||
}); | ||
const main = async () => { | ||
const res = await k8sApi.listNamespacedPod(namespace); | ||
|
||
console.log(`${namespace} namespace pods: `, res.body); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
|
||
const namespace = 'default'; | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromCluster(); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | ||
|
||
k8sApi.listNamespacedPod('default') | ||
.then((res) => { | ||
console.log(res.body); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
const main = async () => { | ||
try { | ||
const podsRes = await k8sApi.listNamespacedPod(namespace); | ||
console.log(podsRes.body); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,61 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
|
||
const namespace = 'default'; | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api); // before 1.14 use extensions/v1beta1 | ||
const clientIdentifier = 'my-subdomain'; | ||
|
||
k8sApi.createNamespacedIngress('default', { | ||
apiVersions: 'networking.k8s.io/v1', | ||
kind: 'Ingress', | ||
metadata: { | ||
name: `production-custom-${clientIdentifier}`, | ||
labels: { | ||
createdBy: 'node-client', | ||
}, | ||
annotations: { | ||
'meta.helm.sh/release-namespace': 'production-auto-deploy', | ||
}, | ||
}, | ||
spec: { | ||
ingressClassName: 'nginx', | ||
rules: [{ | ||
host: `${clientIdentifier}`, | ||
http: { | ||
paths: [{ | ||
backend: { | ||
service: { | ||
name: 'production-auto-deploy', | ||
port: { | ||
number: 5000, | ||
}, | ||
const main = async () => { | ||
try { | ||
const createIngressRes = k8sApi.createNamespacedIngress(namespace, { | ||
apiVersions: 'networking.k8s.io/v1', | ||
kind: 'Ingress', | ||
metadata: { | ||
name: `production-custom-${clientIdentifier}`, | ||
labels: { | ||
createdBy: 'node-client', | ||
}, | ||
annotations: { | ||
'meta.helm.sh/release-namespace': 'production-auto-deploy', | ||
}, | ||
}, | ||
}, | ||
path: '/default-kuberiq(/|$)(.*)', | ||
pathType: 'ImplementationSpecific', | ||
}], | ||
}, | ||
}], | ||
tls: [{ | ||
hosts: [`${clientIdentifier}.example.com`], | ||
}], | ||
}, | ||
}).catch(e => console.log(e)); | ||
spec: { | ||
ingressClassName: 'nginx', | ||
rules: [ | ||
{ | ||
host: `${clientIdentifier}`, | ||
http: { | ||
paths: [ | ||
{ | ||
backend: { | ||
service: { | ||
name: 'production-auto-deploy', | ||
port: { | ||
number: 5000, | ||
}, | ||
}, | ||
}, | ||
path: '/default-kuberiq(/|$)(.*)', | ||
pathType: 'ImplementationSpecific', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
tls: [ | ||
{ | ||
hosts: [`${clientIdentifier}.example.com`], | ||
}, | ||
], | ||
}, | ||
}); | ||
console.log(createIngressRes.body); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.