forked from godaddy/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic-auth.js
40 lines (36 loc) · 938 Bytes
/
basic-auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint no-console:0 */
//
// Create an API client using basic auth
//
const Client = require('kubernetes-client').Client
async function main () {
try {
const client = new Client({
config: {
url: process.env.K8S_CLUSTER_HOST,
auth: {
user: process.env.K8S_USER,
pass: process.env.K8S_PASSWORD
},
insecureSkipTlsVerify: true
},
version: process.env.K8S_CLUSTER_VERSION
})
//
// Fetch all the pods
const pods = await client.api.v1.pods.get()
pods.body.items.forEach((item) => {
console.log(item.metadata)
})
//
// Fetch the Deployment from the kube-system namespace.
//
const deployment = await client.apis.apps.v1.namespaces('kube-system').deployments().get()
deployment.body.items.forEach((item) => {
console.log(item.metadata)
})
} catch (err) {
console.error('Error: ', err)
}
}
main()