{"id":17528610,"url":"https://github.com/thxcode/kubernetes-python-client","last_synced_at":"2025-03-06T08:32:05.121Z","repository":{"id":144370291,"uuid":"109778774","full_name":"thxCode/kubernetes-python-client","owner":"thxCode","description":"Kubernetes python client supports by Alpine in a docker container.","archived":true,"fork":false,"pushed_at":"2017-12-25T13:23:19.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T11:21:52.953Z","etag":null,"topics":["docker-images","kubernetes-client","python27"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/thxCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-11-07T02:53:34.000Z","updated_at":"2024-10-14T06:35:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c006f93-6a95-486a-aa9f-6a024d1e4c53","html_url":"https://github.com/thxCode/kubernetes-python-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thxCode%2Fkubernetes-python-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thxCode%2Fkubernetes-python-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thxCode%2Fkubernetes-python-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thxCode%2Fkubernetes-python-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thxCode","download_url":"https://codeload.github.com/thxCode/kubernetes-python-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242176498,"owners_count":20084583,"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":["docker-images","kubernetes-client","python27"],"created_at":"2024-10-20T15:44:21.447Z","updated_at":"2025-03-06T08:32:05.112Z","avatar_url":"https://github.com/thxCode.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes Python Client\n\nKubernetes python(based on Python 2.7.12) client supports by Alpine in a docker container.\n\n[![](https://img.shields.io/badge/Github-thxcode/kubernetes--python--client-orange.svg)](https://github.com/thxcode/kubernetes-python-client)\u0026nbsp;[![](https://img.shields.io/badge/Docker_Hub-maiwj/kubernetes--python--client-orange.svg)](https://hub.docker.com/r/maiwj/kubernetes-python-client)\u0026nbsp;[![](https://img.shields.io/docker/build/maiwj/kubernetes-python-client.svg)](https://hub.docker.com/r/maiwj/kubernetes-python-client)\u0026nbsp;[![](https://img.shields.io/docker/pulls/maiwj/kubernetes-python-client.svg)](https://store.docker.com/community/images/maiwj/kubernetes-python-client)\u0026nbsp;[![](https://img.shields.io/github/license/thxcode/kubernetes-python-client.svg)](https://github.com/thxcode/kubernetes-python-client)\n\n[![](https://images.microbadger.com/badges/image/maiwj/kubernetes-python-client.svg)](https://microbadger.com/images/maiwj/kubernetes-python-client)\u0026nbsp;[![](https://images.microbadger.com/badges/version/maiwj/kubernetes-python-client.svg)](http://microbadger.com/images/maiwj/kubernetes-python-client)\u0026nbsp;[![](https://images.microbadger.com/badges/commit/maiwj/kubernetes-python-client.svg)](http://microbadger.com/images/maiwj/kubernetes-python-client.svg)\n\n## References\n\n- [Kubernetes python client](https://github.com/kubernetes-incubator/client-python/blob/master/kubernetes/README.md)\n- [Access from Pod demo](https://github.com/kubernetes-incubator/client-python/blob/master/examples/in_cluster_config.py) via `kubernetes.config.load_incluster_config()`\n\n## How to use this image\n\n### Start an instance\n\nTo start a container, use the following:\n\n``` bash\n$ docker run -it --name test-kubernetes-python-client \\\n           maiwj/kubernetes-python-client\n\n```\n\n### Watching resources from Kubernetes Pod\n\n``` python\n#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport sys\nimport os\nfrom kubernetes import client\nfrom kubernetes.client.rest import ApiException\n\ndef main():\n    SERVICE_TOKEN_FILENAME = \"/var/run/secrets/kubernetes.io/serviceaccount/token\"\n    SERVICE_CERT_FILENAME = \"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\"\n    KUBERNETES_HOST = \"https://%s:%s\" % (os.getenv(\"KUBERNETES_SERVICE_HOST\"), os.getenv(\"KUBERNETES_SERVICE_PORT\"))\n\n    ## configure \n    configuration = client.Configuration()\n    configuration.host = KUBERNETES_HOST\n    if not os.path.isfile(SERVICE_TOKEN_FILENAME):\n        raise ApiException(\"Service token file does not exists.\")\n    with open(SERVICE_TOKEN_FILENAME) as f:\n        token = f.read()\n        if not token:\n            raise ApiException(\"Token file exists but empty.\")\n        configuration.api_key['authorization'] = \"bearer \" + token.strip('\\n')\n    if not os.path.isfile(SERVICE_CERT_FILENAME):\n        raise ApiException(\"Service certification file does not exists.\")\n    with open(SERVICE_CERT_FILENAME) as f:\n        if not f.read():\n            raise ApiException(\"Cert file exists but empty.\")\n        configuration.ssl_ca_cert = SERVICE_CERT_FILENAME\n    client.Configuration.set_default(configuration)\n\n    try:\n        ret = client.CoreV1Api().list_namespaced_config_map(namespace=os.getenv(\"CHART_NAMESPACE\"), field_selector=(\"metadata.name=%s\" % os.getenv(\"CHART_FULLNAME\")), watch=False)\n        print ret\n    except ApiException as e:\n        print(\"Exception when calling CoreV1Api-\u003elist_namespaced_config_map: %s\\n\" % e)\n\nif __name__ == '__main__':\n    main()\n\n```\n\n## License\n\n- Kuberentes python client is released under the [Apache2 License](https://github.com/kubernetes-incubator/client-python/blob/master/LICENSE)\n- This image is released under the [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthxcode%2Fkubernetes-python-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthxcode%2Fkubernetes-python-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthxcode%2Fkubernetes-python-client/lists"}