%global _empty_manifest_terminate_build 0 Name: python-lightkube Version: 0.13.0 Release: 1 Summary: Lightweight kubernetes client library License: MIT URL: https://github.com/gtsystem/lightkube Source0: https://mirrors.nju.edu.cn/pypi/web/packages/27/83/534ae4490e95258b39765aaae1ef51723b022ceef2b102d9b80808ce0c7c/lightkube-0.13.0.tar.gz BuildArch: noarch Requires: python3-lightkube-models Requires: python3-httpx Requires: python3-PyYAML %description # lightkube ![](https://img.shields.io/github/actions/workflow/status/gtsystem/lightkube/python-package.yml?branch=master) [![Coverage Status](https://coveralls.io/repos/github/gtsystem/lightkube/badge.svg?branch=master)](https://coveralls.io/github/gtsystem/lightkube?branch=master) [![pypi supported versions](https://img.shields.io/pypi/pyversions/lightkube.svg)](https://pypi.python.org/pypi/lightkube) Modern lightweight kubernetes module for python **NOTICE:** This project is still under development and not suitable for production usage. ## Highlights * *Simple* interface shared across all kubernetes APIs. * Extensive *type hints* to avoid common mistakes and to support autocompletion. * Models and resources generated from the swagger specifications using standard dataclasses. * Load/Dump resource objects from YAML. * Support for async/await * Support for installing a specific version of the kubernetes models (1.15 to 1.27) * Lazy instantiation of inner models. * Fast startup and small memory footprint as only needed models and resources can be imported. * Automatic handling of pagination when listing resources. This module is powered by [httpx](https://github.com/encode/httpx/tree/master/httpx). ## Installation This module requires python >= 3.7 pip install lightkube ## Usage Read a pod ```python from lightkube import Client from lightkube.resources.core_v1 import Pod client = Client() pod = client.get(Pod, name="my-pod", namespace="default") print(pod.namespace.uid) ``` List nodes ```python from lightkube import Client from lightkube.resources.core_v1 import Node client = Client() for node in client.list(Node): print(node.metadata.name) ``` Watch deployments ```python from lightkube import Client from lightkube.resources.apps_v1 import Deployment client = Client() for op, dep in client.watch(Deployment, namespace="default"): print(f"{dep.namespace.name} {dep.spec.replicas}") ``` Create a config map ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta config = ConfigMap( metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) client.create(config) ``` Replace the previous config with a different content ```python config.data['key1'] = 'new value' client.replace(config) ``` Patch an existing config ```python patch = {'metadata': {'labels': {'app': 'xyz'}}} client.patch(ConfigMap, name='my-config', namespace='default', obj=patch) ``` Delete a namespaced resource ```python client.delete(ConfigMap, name='my-config', namespace='default') ``` Create resources defined in a file ```python from lightkube import Client, codecs client = Client() with open('deployment.yaml') as f: for obj in codecs.load_all_yaml(f): client.create(obj) ``` Scale a deployment ```python from lightkube.resources.apps_v1 import Deployment from lightkube.models.meta_v1 import ObjectMeta from lightkube.models.autoscaling_v1 import ScaleSpec obj = Deployment.Scale( metadata=ObjectMeta(name='metrics-server', namespace='kube-system'), spec=ScaleSpec(replicas=1) ) client.replace(obj, 'metrics-server', namespace='kube-system') ``` Create and modify resources using [server side apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/) *Note:* `field_manager` is required for server-side apply. You can specify it once in the client constructor or when calling `apply()`. Also `apiVersion` and `kind` need to be provided as part of the object definition. ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta client = Client(field_manager="my-manager") config = ConfigMap( # note apiVersion and kind need to be specified for server-side apply apiVersion='v1', kind='ConfigMap', metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) res = client.apply(config) print(res.data) # prints {'key1': 'value1', 'key2': 'value2'} del config.data['key1'] config.data['key3'] = 'value3' res = client.apply(config) print(res.data) # prints {'key2': 'value2', 'key3': 'value3'} ``` Stream pod logs ```python from lightkube import Client client = Client() for line in client.log('my-pod', follow=True): print(line) ``` ## Unsupported features The following features are not supported at the moment: * Special subresources `attach`, `exec`, `portforward` and `proxy`. * `auth-provider` authentication method is not supported. The supported authentication methods are `token`, `username` + `password` and `exec`. %package -n python3-lightkube Summary: Lightweight kubernetes client library Provides: python-lightkube BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-lightkube # lightkube ![](https://img.shields.io/github/actions/workflow/status/gtsystem/lightkube/python-package.yml?branch=master) [![Coverage Status](https://coveralls.io/repos/github/gtsystem/lightkube/badge.svg?branch=master)](https://coveralls.io/github/gtsystem/lightkube?branch=master) [![pypi supported versions](https://img.shields.io/pypi/pyversions/lightkube.svg)](https://pypi.python.org/pypi/lightkube) Modern lightweight kubernetes module for python **NOTICE:** This project is still under development and not suitable for production usage. ## Highlights * *Simple* interface shared across all kubernetes APIs. * Extensive *type hints* to avoid common mistakes and to support autocompletion. * Models and resources generated from the swagger specifications using standard dataclasses. * Load/Dump resource objects from YAML. * Support for async/await * Support for installing a specific version of the kubernetes models (1.15 to 1.27) * Lazy instantiation of inner models. * Fast startup and small memory footprint as only needed models and resources can be imported. * Automatic handling of pagination when listing resources. This module is powered by [httpx](https://github.com/encode/httpx/tree/master/httpx). ## Installation This module requires python >= 3.7 pip install lightkube ## Usage Read a pod ```python from lightkube import Client from lightkube.resources.core_v1 import Pod client = Client() pod = client.get(Pod, name="my-pod", namespace="default") print(pod.namespace.uid) ``` List nodes ```python from lightkube import Client from lightkube.resources.core_v1 import Node client = Client() for node in client.list(Node): print(node.metadata.name) ``` Watch deployments ```python from lightkube import Client from lightkube.resources.apps_v1 import Deployment client = Client() for op, dep in client.watch(Deployment, namespace="default"): print(f"{dep.namespace.name} {dep.spec.replicas}") ``` Create a config map ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta config = ConfigMap( metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) client.create(config) ``` Replace the previous config with a different content ```python config.data['key1'] = 'new value' client.replace(config) ``` Patch an existing config ```python patch = {'metadata': {'labels': {'app': 'xyz'}}} client.patch(ConfigMap, name='my-config', namespace='default', obj=patch) ``` Delete a namespaced resource ```python client.delete(ConfigMap, name='my-config', namespace='default') ``` Create resources defined in a file ```python from lightkube import Client, codecs client = Client() with open('deployment.yaml') as f: for obj in codecs.load_all_yaml(f): client.create(obj) ``` Scale a deployment ```python from lightkube.resources.apps_v1 import Deployment from lightkube.models.meta_v1 import ObjectMeta from lightkube.models.autoscaling_v1 import ScaleSpec obj = Deployment.Scale( metadata=ObjectMeta(name='metrics-server', namespace='kube-system'), spec=ScaleSpec(replicas=1) ) client.replace(obj, 'metrics-server', namespace='kube-system') ``` Create and modify resources using [server side apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/) *Note:* `field_manager` is required for server-side apply. You can specify it once in the client constructor or when calling `apply()`. Also `apiVersion` and `kind` need to be provided as part of the object definition. ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta client = Client(field_manager="my-manager") config = ConfigMap( # note apiVersion and kind need to be specified for server-side apply apiVersion='v1', kind='ConfigMap', metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) res = client.apply(config) print(res.data) # prints {'key1': 'value1', 'key2': 'value2'} del config.data['key1'] config.data['key3'] = 'value3' res = client.apply(config) print(res.data) # prints {'key2': 'value2', 'key3': 'value3'} ``` Stream pod logs ```python from lightkube import Client client = Client() for line in client.log('my-pod', follow=True): print(line) ``` ## Unsupported features The following features are not supported at the moment: * Special subresources `attach`, `exec`, `portforward` and `proxy`. * `auth-provider` authentication method is not supported. The supported authentication methods are `token`, `username` + `password` and `exec`. %package help Summary: Development documents and examples for lightkube Provides: python3-lightkube-doc %description help # lightkube ![](https://img.shields.io/github/actions/workflow/status/gtsystem/lightkube/python-package.yml?branch=master) [![Coverage Status](https://coveralls.io/repos/github/gtsystem/lightkube/badge.svg?branch=master)](https://coveralls.io/github/gtsystem/lightkube?branch=master) [![pypi supported versions](https://img.shields.io/pypi/pyversions/lightkube.svg)](https://pypi.python.org/pypi/lightkube) Modern lightweight kubernetes module for python **NOTICE:** This project is still under development and not suitable for production usage. ## Highlights * *Simple* interface shared across all kubernetes APIs. * Extensive *type hints* to avoid common mistakes and to support autocompletion. * Models and resources generated from the swagger specifications using standard dataclasses. * Load/Dump resource objects from YAML. * Support for async/await * Support for installing a specific version of the kubernetes models (1.15 to 1.27) * Lazy instantiation of inner models. * Fast startup and small memory footprint as only needed models and resources can be imported. * Automatic handling of pagination when listing resources. This module is powered by [httpx](https://github.com/encode/httpx/tree/master/httpx). ## Installation This module requires python >= 3.7 pip install lightkube ## Usage Read a pod ```python from lightkube import Client from lightkube.resources.core_v1 import Pod client = Client() pod = client.get(Pod, name="my-pod", namespace="default") print(pod.namespace.uid) ``` List nodes ```python from lightkube import Client from lightkube.resources.core_v1 import Node client = Client() for node in client.list(Node): print(node.metadata.name) ``` Watch deployments ```python from lightkube import Client from lightkube.resources.apps_v1 import Deployment client = Client() for op, dep in client.watch(Deployment, namespace="default"): print(f"{dep.namespace.name} {dep.spec.replicas}") ``` Create a config map ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta config = ConfigMap( metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) client.create(config) ``` Replace the previous config with a different content ```python config.data['key1'] = 'new value' client.replace(config) ``` Patch an existing config ```python patch = {'metadata': {'labels': {'app': 'xyz'}}} client.patch(ConfigMap, name='my-config', namespace='default', obj=patch) ``` Delete a namespaced resource ```python client.delete(ConfigMap, name='my-config', namespace='default') ``` Create resources defined in a file ```python from lightkube import Client, codecs client = Client() with open('deployment.yaml') as f: for obj in codecs.load_all_yaml(f): client.create(obj) ``` Scale a deployment ```python from lightkube.resources.apps_v1 import Deployment from lightkube.models.meta_v1 import ObjectMeta from lightkube.models.autoscaling_v1 import ScaleSpec obj = Deployment.Scale( metadata=ObjectMeta(name='metrics-server', namespace='kube-system'), spec=ScaleSpec(replicas=1) ) client.replace(obj, 'metrics-server', namespace='kube-system') ``` Create and modify resources using [server side apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/) *Note:* `field_manager` is required for server-side apply. You can specify it once in the client constructor or when calling `apply()`. Also `apiVersion` and `kind` need to be provided as part of the object definition. ```python from lightkube.resources.core_v1 import ConfigMap from lightkube.models.meta_v1 import ObjectMeta client = Client(field_manager="my-manager") config = ConfigMap( # note apiVersion and kind need to be specified for server-side apply apiVersion='v1', kind='ConfigMap', metadata=ObjectMeta(name='my-config', namespace='default'), data={'key1': 'value1', 'key2': 'value2'} ) res = client.apply(config) print(res.data) # prints {'key1': 'value1', 'key2': 'value2'} del config.data['key1'] config.data['key3'] = 'value3' res = client.apply(config) print(res.data) # prints {'key2': 'value2', 'key3': 'value3'} ``` Stream pod logs ```python from lightkube import Client client = Client() for line in client.log('my-pod', follow=True): print(line) ``` ## Unsupported features The following features are not supported at the moment: * Special subresources `attach`, `exec`, `portforward` and `proxy`. * `auth-provider` authentication method is not supported. The supported authentication methods are `token`, `username` + `password` and `exec`. %prep %autosetup -n lightkube-0.13.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-lightkube -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed May 10 2023 Python_Bot - 0.13.0-1 - Package Spec generated