{"id":13607101,"url":"https://github.com/nubank/k8s-api","last_synced_at":"2025-04-05T11:10:34.074Z","repository":{"id":43317694,"uuid":"229070982","full_name":"nubank/k8s-api","owner":"nubank","description":"Kubernetes client, data driven","archived":false,"fork":false,"pushed_at":"2024-05-20T18:17:02.000Z","size":974,"stargazers_count":153,"open_issues_count":9,"forks_count":13,"subscribers_count":745,"default_branch":"master","last_synced_at":"2025-03-29T10:05:54.954Z","etag":null,"topics":["clojure","foundation","kubernetes-api","kubernetes-client"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nubank.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2019-12-19T14:26:22.000Z","updated_at":"2025-03-18T21:49:03.000Z","dependencies_parsed_at":"2024-01-14T04:54:42.985Z","dependency_job_id":"4e65acf0-b791-4d7b-a13d-3559470b1de7","html_url":"https://github.com/nubank/k8s-api","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"5d8fb2e3ef789222f98092d48af454d297a41bc7"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubank%2Fk8s-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubank%2Fk8s-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubank%2Fk8s-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubank%2Fk8s-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nubank","download_url":"https://codeload.github.com/nubank/k8s-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"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":["clojure","foundation","kubernetes-api","kubernetes-client"],"created_at":"2024-08-01T19:01:15.582Z","updated_at":"2025-04-05T11:10:34.057Z","avatar_url":"https://github.com/nubank.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# kubernetes-api\n\n[![Clojars Project](https://img.shields.io/clojars/v/nubank/k8s-api.svg)](https://clojars.org/nubank/k8s-api)\n\nkubernetes-api is a Clojure library that acts as a kubernetes client\n\n## Motivation\n\nWe had a good experience with\n [cognitect-labs/aws-api](https://github.com/cognitect-labs/aws-api), and missed\n something like that for Kubernetes API. We had some client libraries that\n generated a lot of code, but it lacked discoverability and documentation.\n\n### clojure.deps\n```clojure\n{:deps {nubank/k8s-api {:mvn/version \"1.0.0\"}}}\n```\n\n### Leiningen\n```clojure\n[nubank/k8s-api \"1.0.0\"]\n```\n\n```clojure\n;; In your ns statement\n(ns my.ns\n  (:require [kubernetes-api.core :as k8s]))\n```\n\n\n## Usage\n### Instantiate a client\n\nThere're multiple options for authentication while instantiating a client. You\ncan explicit set a token:\n```clojure\n(def k8s (k8s/client \"http://some.host\" {:token \"...\"}))\n```\n\nOr a function that returns the token\n\n```clojure\n(def k8s (k8s/client \"http://some.host\" {:token-fn (constantly \"...\")}))\n```\n\nYou can also define client certificates\n```clojure\n(def k8s (k8s/client \"http://some.host\" {:ca-cert     \"/some/path/ca-docker.crt\"\n                                         :client-cert \"/some/path/client-cert.pem\"\n                                         :client-key  \"/some/path/client-java.key\"}))\n```\n\n#### OpenAPI config\n\n##### Discovery\n\nIt's possible but NOT RECOMMENDED to disable the OpenAPI specification discovery. This will prevent requests to\n`/openapi/...` endpoints and use the specification from the resources folder. This specification has no guarantees in\n terms of versioning, so it will be outdated.\n```clojure\n(def k8s (k8s/client \"http://some.host\" {:token \"...\"\n                                         :openapi {:discovery :disabled}}))\n```\n\n##### Filter paths from api\n\nYou can filter the paths from the OpenAPI specification. This is useful when you want to use a specific version of the\napi, or when you want to use a specific group of resources.\n\n```clojure\n(def k8s (k8s/client \"http://some.host\" {:token \"...\"\n                                         :apis  [\"some.api/v1alpha1\", \"another.api\"]}))\n```\n\n### Discover\nYou can list all operations with\n```clojure\n(k8s/explore k8s)\n```\n\nor specify a specific entity\n```clojure\n(k8s/explore k8s :Deployment)\n;=\u003e\n[:Deployment\n [:get \"read the specified Deployment\"]\n [:update \"replace the specified Deployment\"]\n [:delete \"delete a Deployment\"]\n [:patch \"partially update the specified Deployment\"]\n [:list \"list or watch objects of kind Deployment\"]\n [:create \"create a Deployment\"]\n [:deletecollection \"delete collection of Deployment\"]\n [:list-all \"list or watch objects of kind Deployment\"]]\n```\n\nget info on an operation\n```clojure\n(k8s/info k8s {:kind :Deployment\n               :action :create})\n;=\u003e\n{:summary \"create a Deployment\",\n :parameters {:namespace java.lang.String,\n              #schema.core.OptionalKey{:k :pretty} (maybe Str),\n              #schema.core.OptionalKey{:k :dry-run} (maybe Str),\n              #schema.core.OptionalKey{:k :field-manager} (maybe Str),\n              :body ...},\n :returns {200 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),\n                #schema.core.OptionalKey{:k :kind} (maybe Str),\n                #schema.core.OptionalKey{:k :metadata} ...,\n                #schema.core.OptionalKey{:k :spec} ...,\n                #schema.core.OptionalKey{:k :status} ...},\n           201 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),\n                #schema.core.OptionalKey{:k :kind} (maybe Str),\n                #schema.core.OptionalKey{:k :metadata} ...,\n                #schema.core.OptionalKey{:k :spec} ...,\n                #schema.core.OptionalKey{:k :status} ...},\n           202 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),\n                #schema.core.OptionalKey{:k :kind} (maybe Str),\n                #schema.core.OptionalKey{:k :metadata} ...,\n                #schema.core.OptionalKey{:k :spec} ...,\n                #schema.core.OptionalKey{:k :status} ...},\n           401 Any}}\n```\n\n\n### Invoke\n\nYou can call an operation with\n```clojure\n(k8s/invoke k8s {:kind    :ConfigMap\n                 :action  :create\n                 :request {:namespace \"default\"\n                           :body      {:api-version \"v1\"\n                                       :data       {\"foo\" \"bar\"}}}})\n```\n\ninvoke it will return the body, with `:request` and `:response` in metadata\n```clojure\n(meta (k8s/invoke ...))\n;=\u003e\n{:request ...\n :response {:status ...\n            :body ...}}\n```\n\nYou can debug the request map with\n```clojure\n(k8s/request k8s {:kind    :ConfigMap\n                  :action  :create\n                  :request {:namespace \"default\"\n                            :body      {:api-version \"v1\"\n                                        :data       {\"foo\" \"bar\"}}}})\n```\n\nIf you want to read more about all different patch strategies Kubernetes offers,\n[check this document](doc/kubernetes-patch-strategies.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnubank%2Fk8s-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnubank%2Fk8s-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnubank%2Fk8s-api/lists"}