{"id":13548061,"url":"https://github.com/godaddy/kubernetes-client","last_synced_at":"2025-07-27T10:20:43.824Z","repository":{"id":10159108,"uuid":"64572848","full_name":"godaddy/kubernetes-client","owner":"godaddy","description":"Simplified Kubernetes API client for Node.js.","archived":false,"fork":false,"pushed_at":"2024-07-23T20:48:03.000Z","size":3251,"stargazers_count":968,"open_issues_count":146,"forks_count":192,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-02T03:41:28.940Z","etag":null,"topics":["api-client","kubernetes","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/godaddy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-31T02:18:15.000Z","updated_at":"2025-03-31T11:48:13.000Z","dependencies_parsed_at":"2024-01-14T09:59:59.016Z","dependency_job_id":"90f89467-c801-4734-94ce-6ccd2a2642e4","html_url":"https://github.com/godaddy/kubernetes-client","commit_stats":{"total_commits":437,"total_committers":56,"mean_commits":7.803571428571429,"dds":0.528604118993135,"last_synced_commit":"2f0676b8b35914fad90365671e9d508e8fb417aa"},"previous_names":[],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godaddy%2Fkubernetes-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godaddy%2Fkubernetes-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godaddy%2Fkubernetes-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godaddy%2Fkubernetes-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/godaddy","download_url":"https://codeload.github.com/godaddy/kubernetes-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246888061,"owners_count":20850193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","kubernetes","nodejs"],"created_at":"2024-08-01T12:01:05.250Z","updated_at":"2025-04-02T20:31:30.767Z","avatar_url":"https://github.com/godaddy.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","nodejs"],"sub_categories":[],"readme":"# kubernetes-client\n\n[![Build Status][build]](https://travis-ci.org/godaddy/kubernetes-client) [![Greenkeeper badge][greenkeeper]](https://greenkeeper.io/)\n\n[greenkeeper]: https://badges.greenkeeper.io/godaddy/kubernetes-client.svg\n[build]: https://travis-ci.org/godaddy/kubernetes-client.svg?branch=master\n\nSimplified [Kubernetes API](http://kubernetes.io/) client for Node.js.\n\n## Installation\n\nInstall via npm:\n\n```\nnpm i kubernetes-client --save\n```\n\n## Initializing\n\nkubernetes-client generates a Kubernetes API client at runtime based\non a Swagger / OpenAPI specification. You can generate a client using\nthe cluster's kubeconfig file and that cluster's API specification.\n\nTo create the config required to make a client, you can either:\n\nlet kubernetes-client configure automatically by trying the `KUBECONFIG`\nenvironment variable first, then `~/.kube/config`, then an in-cluster\nservice account, and lastly settling on a default proxy configuration:\n\n```js\nconst client = new Client({ version: '1.13' })\n```\n\nprovide your own path to a file:\n\n```js\nconst { KubeConfig } = require('kubernetes-client')\nconst kubeconfig = new KubeConfig()\nkubeconfig.loadFromFile('~/some/path')\nconst Request = require('kubernetes-client/backends/request')\n\nconst backend = new Request({ kubeconfig })\nconst client = new Client({ backend, version: '1.13' })\n```\n\nprovide a configuration object from memory:\n\n```js\n// Should match the kubeconfig file format exactly\nconst config = {\n  apiVersion: 'v1',\n  clusters: [],\n  contexts: [],\n  'current-context': '',\n  kind: 'Config',\n  users: []\n}\nconst { KubeConfig } = require('kubernetes-client')\nconst kubeconfig = new KubeConfig()\nkubeconfig.loadFromString(JSON.stringify(config))\n\nconst Request = require('kubernetes-client/backends/request')\nconst backend = new Request({ kubeconfig })\nconst client = new Client({ backend, version: '1.13' })\n```\n\nand you can also specify the context by setting it in the `kubeconfig`\nobject:\n\n```js\nkubeconfig.setCurrentContext('dev')\n```\n\nYou can also elide the `.version` and pass an OpenAPI specification:\n\n```js\nconst spec = require('./swagger.json')\nconst client = new Client({ spec })\n```\n\nor load a specification dynamically from the kube-apiserver:\n\n```js\nconst client = new Client()\nawait client.loadSpec()\n```\n\nSee [Examples](#examples) for more configuration examples.\n\n## Basic usage\n\nkubernetes-client translates Path Item Objects \\[[1]\\] (*e.g*.,\n`/api/v1/namespaces`) to object chains ending in HTTP methods (*e.g.*,\n`api.v1.namespaces.get`).\n\nSo, to fetch all Namespaces:\n\n```js\nconst namespaces = await client.api.v1.namespaces.get()\n```\n\nkubernetes-client translates Path Templating \\[[2]\\] (*e.g.*,\n`/apis/apps/v1/namespaces/{namespace}/deployments`) to function calls (*e.g.*,\n`apis.apps.v1.namespaces('default').deployments`).\n\nSo, to create a new Deployment in the default Namespace:\n\n```js\nconst deploymentManifest = require('./nginx-deployment.json')\nconst create = await client.apis.apps.v1.namespaces('default').deployments.post({ body: deploymentManifest })\n```\n\nand then fetch your newly created Deployment:\n\n```js\nconst deployment = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).get()\n```\n\nand finally, remove the Deployment:\n\n```js\nawait client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).delete()\n```\n\nkubernetes-client supports `.delete`, `.get`, `.patch`, `.post`, and `.put`.\n\n## Documentation\n\nkubernetes-client generates documentation for the included\nspecifications:\n\n* [Kubernetes API v1.10](docs/1.10/README.md)\n* [Kubernetes API v1.11](docs/1.11/README.md)\n* [Kubernetes API v1.12](docs/1.12/README.md)\n* [Kubernetes API v1.13](docs/1.13/README.md)\n\n## TypeScript\n\nkubernetes-client includes a typings declartion file for Kubernetes\nAPI 1.13 and a complimentry `Client1_13` class:\n\n```typescript\nimport * as ApiClient from 'kubernetes-client';\n\nconst Client = ApiClient.Client1_13;\nconst client = new Client({ version: '1.13' });\n```\n\nWhen using TypeScript, kubernetes-client does not support dynamically\ngenerating a client via `.loadSpec()`.\n\n## Examples\n\n[examples/](examples/) has snippets for using kubernetes-client:\n\n* The basic usage example from above: [basic.js](./examples/basic.js)\n* Use error handling to simulate `kubectl apply -f`: [apply-deploy.js](./examples/apply-deploy.js)\n* Create a `client` from your kube-apiserver's swagger.json:\n  [client-from-apiserver-swagger.js](./examples/client-from-apiserver-swagger.js)\n* Create a `client` from one of the included Swagger specifications:\n  [sync-client-version.js](./examples/sync-client-version.js)\n* Using resource aliases supported by `kubectl` (*e.g.*, `.po` vs\n  `.pods`): [convenience-properties.js](./examples/convenience-properties.js)\n* Use watch endpoints to get a JSON stream of Deployment events:\n  [watch.js](./examples/watch.js)\n* Extend the Kubernetes API and a `client` with a\n  CustomerResourceDefinition: [using-crds.js](./examples/using-crds.js)\n* An extended CustomResourceDefinition example that implements a\n  controller to \"notify\" on changes to Deployment objects:\n  [deployment-notifier.js](./examples/deployment-notifier.js)\n* A basic canary controller that removes Pods from a Service if they\n  log an error: [canary-controller.js](./examples/canary-controller.js)\n* Create a `client` using basic-auth:\n  [basic-auth.js](./examples/basic-auth.js)\n* Create a `client` using IAM authenticator and cmd auth (works with Amazon EKS):\n  [iam-auth.js](./examples/iam-auth.js)\n* Generate [badges](https://github.com/badges/shields) showing the\n  status of your Deployments. Illustrates using the in-cluster config:\n  [kubernetes-badges](https://github.com/silasbw/kubernetes-badges)\n* Create a deployment, patch a change, and rollback to the original version:\n  [deployment-create-patch-rollback.js](./examples/deployment-create-patch-rollback.js)\n* Access [VerticalPodAutoscalers](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler): [vpas/](./examples/vpas)\n* Create a `client` using an in-cluster configuration: [in-cluster-auth.js](./examples/in-cluster-auth.js)\n\n## Contributing\n\nSee the kubernetes-client [Issues](./issues) if you're interested in\nhelping out; and look over the [CONTRIBUTING.md](./CONTRIBUTING.md)\nbefore submitting new Issues and Pull Requests.\n\n## Testing\n\nRun the unit tests:\n\n```\nnpm test\n```\n\nThe integration tests use the `current-context` in your kubeconfig file. Run the integration tests:\n\n```\nnpm run test-integration\n```\n\nRun integration tests with the `@kubernetes/client-node` backend:\n\n```\nKUBERNETES_CLIENT_BACKEND=client-node npm run test-integration\n```\n\n## References\n\n* [An Intuitive Node.js Client for the Kubernetes API](https://godaddy.github.io/2018/04/10/an-intuitive-nodejs-client-for-the-kubernetes-api/)\n* [Kubernetes Reference Documentation](https://kubernetes.io/docs/reference/)\n\n## License\n\n[MIT](LICENSE)\n\n[1]: https://swagger.io/specification/#pathItemObject\n[2]: https://swagger.io/specification/#pathTemplating\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodaddy%2Fkubernetes-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodaddy%2Fkubernetes-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodaddy%2Fkubernetes-client/lists"}