-
Notifications
You must be signed in to change notification settings - Fork 552
chore: update examples node fetch #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
// in a real program use require('@kubernetes/client-node') | ||
const k8s = require('../dist/index'); | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
@@ -8,7 +9,7 @@ const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | |
const path = '/api/v1/pods'; | ||
const watch = new k8s.Watch(kc); | ||
|
||
const listFn = () => k8sApi.listPodForAllNamespaces() | ||
const listFn = () => k8sApi.listPodForAllNamespaces(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these examples got formatted with prettier. |
||
|
||
const cache = new k8s.ListWatch(path, watch, listFn); | ||
|
||
|
@@ -22,6 +23,6 @@ const looper = () => { | |
console.log(names.join(',')); | ||
} | ||
setTimeout(looper, 2000); | ||
} | ||
}; | ||
|
||
looper(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
// in a real program use require('@kubernetes/client-node') | ||
const k8s = require('../dist/index'); | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | ||
|
||
k8sApi.listNamespacedPod('default') | ||
k8sApi | ||
.listNamespacedPod({ namespace: 'default' }) | ||
.then((res) => { | ||
console.log(res.body); | ||
console.log(res); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
const k8s = require('@kubernetes/client-node'); | ||
// in a real program use require('@kubernetes/client-node') | ||
const k8s = require('../dist/index'); | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromCluster(); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | ||
|
||
k8sApi.listNamespacedPod('default') | ||
k8sApi | ||
.listNamespacedPod({ namespace: 'default' }) | ||
.then((res) => { | ||
console.log(res.body); | ||
console.log(res); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you've switched that to the complete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't. That is what this function is now returning. This example now reflects that. |
||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
console.error(err); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
const k8s = require('@kubernetes/client-node') | ||
const kc = new k8s.KubeConfig() | ||
kc.loadFromDefault() | ||
// in a real program use require('@kubernetes/client-node') | ||
const k8s = require('../dist/index'); | ||
|
||
const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1 | ||
const clientIdentifier = 'my-subdomain' | ||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
k8sApi.createNamespacedIngress('default', { | ||
apiVersions: 'networking.k8s.io/v1beta1', | ||
kind: 'Ingress', | ||
metadata: { name: `production-custom-${clientIdentifier}` }, | ||
spec: { | ||
rules: [{ | ||
host: `${clientIdentifier}.example.com`, | ||
http: { | ||
paths: [{ | ||
backend: { | ||
serviceName: 'production-auto-deploy', | ||
servicePort: 5000 | ||
}, | ||
path: '/' | ||
}] | ||
} | ||
}], | ||
tls: [{ hosts: [`${clientIdentifier}.example.com`] }] | ||
} | ||
}).catch(e => console.log(e)) | ||
const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api); | ||
const clientIdentifier = 'my-subdomain'; | ||
|
||
k8sApi | ||
.createNamespacedIngress({ | ||
namespace: 'default', | ||
body: { | ||
apiVersion: 'networking.k8s.io/v1', | ||
kind: 'Ingress', | ||
metadata: { name: `production-custom-${clientIdentifier}` }, | ||
spec: { | ||
rules: [ | ||
{ | ||
host: `${clientIdentifier}.example.com`, | ||
http: { | ||
paths: [ | ||
{ | ||
backend: { | ||
service: { | ||
name: 'production-auto-deploy', | ||
port: { number: 5000 }, | ||
}, | ||
}, | ||
path: '/', | ||
pathType: 'ImplementationSpecific', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
tls: [{ hosts: [`${clientIdentifier}.example.com`] }], | ||
}, | ||
}, | ||
}) | ||
.catch((e) => console.error(e)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't account for the TypeScript examples before.