Saravanan666/pypi-org huggingface dataset:
Package: kubemo
KubeMoKubeMo aims to simplify ML model deployment by aggregating as many machine-learning frameworks as possible into unified APIs along with the help of cloud-native toolkits.InstallationKubeMo needs Python (>= 3.7) installed on your device.From PyPiKubeMo has been published toPyPi, so you can install it simply by using pip.pip install kubemoNote that KubeMo is not ready for production until the first stable release, so you can eithor wait or help us reach the day earlier :)ManuallyClone or download this repo and install it by using pip in its root directory.git clone https://github.com/kubemo/kubemo.git && cd kubemo

pip install .Or add the-eflag if you would like to play around KubeMo before an actual installation.pip install -e .DocumentationCheck outthis sitefor detailed information about KubeMo, or you may first take a look at somebasic examples.ContributionPull requestsare welcome. Note that every PR needs to refer to an issue, so please submit an issue before sending a new PR.FeedbacksBugshereand ideashere, thanks.LicenseKubeMo is Apache 2.0 licensed.
Package: kubemq
KubeMQ Python SDKKubeMQ is an enterprise-grade message queue and broker for containers, designed for any workload and architecture running in Kubernetes.
This library is Python implementation of KubeMQ client connection.Install KubeMQ Community EditionPlease visitKubeMQ Communityfor intallation steps.Examples - Cookbook RecipesPlease visit our cookbookrepositoryInstall Python SDKPrerequisitesKubeMQ-SDK-Python works withPython 3.2or newer.InstallingThe recommended way to use the SDK for Python in your project is to consume it from pip.pip install kubemqThis package uses setuptools for the installation if needed please run:python3 -m pip install --upgrade pip setuptools wheelBuilding from sourceOnce you check out the code from GitHub, you can install the package locally with:$ pip install .You can also install the package with a symlink,
so that changes to the source files will be immediately available:$ pip install -e .Installation:
$ pip install kubemqLearn KubeMQVisit ourExtensive KubeMQ Documentation.Supportif you encounter any issues, please open an issue here,
In addition, you can reach us for support by:EmailSlack
Package: kubeobject
KubeObjectA simple to use wrapping on top of Kubernetes custom resources with
object oriented semantics.KubeObject allows you to use Kubernetes Custom Objects in an object
oriented way. It works by defining an object, by instantiating it with
anameandnamespaceand then "bounding" this object to a
Kubernetes object by creating it, or loading it, if it already exists.Quick StartIn the following example we create an "Istio" object, which will
manage one of the Custom Objects defined by theIstiooperator. A simple
lifecycle is explained below.# Builds the object, but it is "unbound", this is, it is not# referring to an actual object in Kubernetes.istio=CustomObject("my-istio","my-namespace",plural="istios",api_version="istio.banzaicloud.io/v1beta1")# Let's pass the simplest spec we canistio["spec"]={"version":"1.1.0","mtls":True}# And now create it; after creation the object is "bound"istio.create()Updating the object'sSpecand checking the object'sStatusis one
of our goals as well, like in the following example:# The Istio operator should have started working on deploying# this new Custom Resource. Let's get the status of the objectprint(istio["status"])# This is empty, because since calling `create()` we have not# updated from the actual object in Kubernetes. Let's get an# up-to-date object.istio.reload()# I want to avoid calling `reload()` everytime I need a new# versionistio.auto_reload=True# Now we'll wait until the object has reached a given status:whileistio["status"]["Status"]=="Reconciling":time.sleep(5)# Check the Status after "Reconciling"print("Our status is:",istio["status"]["Status"])After doing all its work, theIstioobject might need to be deleted:istio.delete()
Package: kube-ops
kube-pyUse OOP to manage Kubernetes objectsUsagesimportkube# Make containercontainer=kube.Container('nginx')container.set_image('nginx:alpine')# Add environment variables to configmap## Make configmapcm=kube.ConfigMap('nginx')cm.set_data(NGINX_ENTRYPOINT_QUIET_LOGS='true')## Make env from configmapenv=kube.env_from_configmap(cm.name)container.add_env_from(env)# Add port to containercontainer.add_port('http',80)# Make deploymentdeploy=kube.Deployment('nginx-test',container)deploy.set_pod_labels(key='value',app='nginx',name='nginx-test')deploy.add_volume_to_container(container.name,kube.empty_dir(),'/mnt')# Add volume from secret with cert and private keywithopen('server.crt')asf:crt=f.read()withopen('server.key')asf:key=f.read()## Make secret with type kubernetes.io/tlssec=kube.SecretTLS('nginx')sec.set(crt,key)## Add secret as volumesec_vol=kube.volume_from_secret(sec.name)deploy.add_volume_to_container(sec.name,sec_vol,'/etc/nginx/certs')# Disable service link in pod's containersdeploy.enable_service_links(False)# Add service and link by selectorselector={'app':'nginx','name':'nginx-test'}deploy.set_selector_match_labels(**selector)## Make servicesvc=kube.Service('www-nginx')svc.add_port('http',80,'http')svc.set_type(kube.ServiceType.ClusterIP)svc.set_selector(**selector)# Create objects in Kubernetesk=kube.KubeApi()k.secret_create(sec.manifest)k.configmap_create(cm.manifest)k.deployment_create(deploy.manifest)k.service_create(svc.manifest)
Package: kubepi
KubePI CLI for easier k1s setup on Raspberry PIs. Seek1s on
GitHub.UsageKubePI is a custom tool for making the k1s management easier for the K3D
setup, dependencies, submodules, and more. It needs at least Python 3.7.
Please check that you have Python 3.7 or later by running:# Raspberry Pi OS (Raspbian) userspython3--version# Arch userspython--versionIf you are not running Python 3.7 or later, please upgrade your Python
version.Follow these steps to install kubepi by using `pip`:# Raspberry Pi OS (Raspbian) still shipping python2 by defaultpip3installkubepi# Arch shipping python3 by defaultpipinstallkubepiNow you should have the kubepi command in your path and you can run
kubepi to display the help:pi@k1s:~$kubepiUsage:kubepi[OPTIONS]COMMAND[ARGS]...KubePICLIforeasierk1ssetuponRaspberryPIs.Options:--kube-contextTEXTThekubernetescontexttouse-v,--verbosityLVLEitherCRITICAL,ERROR,WARNING,INFOorDEBUG--helpShowthismessageandexit.Commands:appsAppcommandsk3dManagek3dclustersplatformPlatformcommandspreflightPreflightcheckssetupSetupinfrastructureservicesTo see the options of each command, just run:kubepi<COMMAND>--helpFor example:pi@k1s:~$kubepik3d--helpUsage:kubepik3d[OPTIONS]COMMAND[ARGS]...Managek3dclusters.Thenameoftheclusteristakenfromtheoption--kube-contextwhichdefaultsto'k1s'Options:--helpShowthismessageandexit.Commands:createCreateclusterdeleteDeleteclusterstartStartclusterstatusClusterstatusstopStopclusterContributingPlease readCONTRIBUTINGfor details on our code of conduct, and the process for submitting pull
requests to us.VersioningWe useSemVerfor versioning. For the versions
available, see thetags on this
repository.AuthorsGoran NushkovLicenseThis project is licensed under the MIT License - see theLICENSEfile for details.
Package: kubepy
kubepyPython wrapper onkubectlthat makes deploying easy.InstallationRequires python 3.5 and configuredkubectl. To install run:pip3 install kubepyUsageYou can use this package to install all yml definitions from given directory.
Just runkubepy-apply-allfrom a directory where all of you Kubernetes definition yml files are.Supported Kubernetes resources:CronJobDeploymentStatefulSetJobPod (used to run a one-off command)ServiceIngressSecretStorageClassPersistentVolumePersistentVolumeClaimPodDisruptionBudgetOptions:--directory <path>- uses path instead of local directory.
Can be used multiple times to add new and partially override existing definitions.--build-tag <tag>- sets tag to all images without specified tag in your definition files--label <key>=<value>- adds label to definition. Can be used multiple times.--label-pod <key>=<value>- adds label to each pod definition. Can be used multiple times.--annotate <key>=<value>- adds annotation to definition. Can be used multiple times.--annotate-pod <key>=<value>- adds annotation to each pod definition. Can be used multiple times.--replace- if present, replaces deployments instead of updating them. Default: false.--host-volume <name>=<path>Adds host volume to each pod definition. Can be used multiple times.--env <VAR>=valueSets environment variable on every container.--max-job-retries <n>While waiting for job to finish if it fails n times than delete job and fail.
Job sometimes can still be executed more than n times.There is alsokubepy-apply-onecommand which is called askubepy-apply-one name1 [name2 ...]It applies only files selected files. Names should be without ".yml".
It accepts all options fromkubepy-apply-all. Additionally you can pass option:--show-definition- shows definition instead of applying them.Applying jobs.Applying usualy means that underlyingkubectl applyorkubectl replaceis called. However applying job is treated
differently.
To ensure that job finished and succeededkubectlwaits for job to finish and fails if job failed.Applying pods.Usually you don't need to apply pods manually, but if you want to run some kind of check and you need to know if it
succeeded without retries then you can use pod withrestartPolicy: Never. Only pods with this policy are currently
supported. They are treated as jobs, so applying waits for them to finish and fails if they fail.
Package: kuberesources
InstallationInstall usingpip3 install kuberesourcesDescriptionUtility for retrieving the status of resource requests across nodes in a Kubernetes cluster.Useful for planning capacity.kresourcesgives an overview of the reserved capacity for each node as well as total for the clusterkresources -vlists pods' resource requests on each node, as well.Sample outputKnown issuesIf using Azure AD as authentication, you might run into errors where it fails to authenticate.Since this script merely loads your kubeconfig, it doesn't do any token refresh or anything like that - so, if when this problem pops up you can just issue akubectl <something>command against your cluster and the tokens should be refreshed and the script can run.
Package: kubernetes-dynamic
kubernetes-dynamicThis project aims to provide an easy interface over kubernetes API based on the official kubernetes package.Basic syntax is very similar to kubectl.client.pods.get()is the same askubectl get podsExample Usageimportkubernetes_dynamicaskdclient=kd.K8sClient()pods:list[kd.models.V1Pod]=client.pods.get()forpodinpods:print(pod.metadata.name)Custom resourcesimportkubernetes_dynamicaskdclassMyModel(kd.models.ResourceItem):field:strapi:ResourceApi[MyModel]=kc.cl.get_api("mycustomresources",MyModel)api:ResourceApi[MyModel]=kc.cl.get_api(kind="MyCustomResource",object_type=MyModel)items:List[MyModel]=api.get()item:Optional[MyModel]=api.get(name="exact-name")ifitem:item.field="modified"item.patch()else:item=MyModel(metadata={"name":"exact-name","namespace":"namespace-name"},field="created",client=kd.cl)item.create()# item = MyModel(field="created")# item.metadata.name = "exact-name"# item = MyModel(metadata={"name": "exact-name"}, field="created")# item = MyModel(metadata=kd.models.V1Metadata(name="exact-name"), field="created")# item.create(namespace="namespace-name")ModelsWe aim to provide pydantic models for all reasources.Because the model names are exactly the same as in thekubernetespackage, make sure you import the models fromkubernetes_dynamic.modelsProper type hintingAll models are flexible (less dependent on kubernetes version):accept extra valuesall optional (type checker is tricked into assuming everything exists)Models created by queries have a reference to the client it was created by, manually creating models creates a default client(without arguments), or you can specifyclientmanually.Base model contains common methods for all models:refreshpatchcreatereaddeleteis_readyadditional features for specific models (just examples):configmap:from_pathingress:get_default_hostnamespace:annotateensurepod:get_restartsexecdisk_usageget_controller_typeget_envsecretexistssetdecodeSubresourcesSubresources are available under the main resource api objects:example:client.pods.execWork in progressExpect breaking changes
Package: kubernetes-job
Kubernetes-job: simple Kubernetes job creationA library for starting a Kubernetes batch job as a normal Python function call.For source code and tickets, see ourproject pageonGitlab.
The documentation is hosted onReadTheDocs.Kubernetes-job can be found onPypifor easy installation withpip.InstallationInstallation with Pip:pipinstallkubernetes-jobQuick startfromkubernetes_jobimportJobManagerdefadd(a,b):returna+bmanager=JobManager(k8s_client=k8s_client,k8s_job_spec='job.yaml',namespace='default')job=manager.create_job(add,1,2)TheJobManagerwill now create a Kubernetes job using the basic job specification in thejob.yamlfile.
The call toaddis then passed on to the new job node, where the function is subsequently executed.Thejob.yamlfile should be adjusted to your needs.
This is the place to put Kubernetes node selectors, Docker base images, etc. etc.
Please refer to theKubernetes documentationfor details.Please note: this is a very silly example, for two obvious reasons.First,addwill take a very short time to complete, and is therefore not a function
you would want to spawn a Kubernetes job for.
A job should be created for a task that is not easily performed on the calling machine.
A good example would be training Machine Learning models on a heavy CUDA node,
started from a web server node with modest resources.Second,Kubernetes jobs do not return values!This means the result of this addition will be lost.
In a Kubernetes job, it is up to the job to save its work.
In this case, the result of(1 + 2)will be lost for humanity.Please see theexamplesand thetest/directory.API usageInitializing the JobManagerTheJobManagermust be supplied ayaml template file(see above) and the Kubernetes client.frompathlibimportPathfromkubernetes_jobimportJobManager# Path to worker configurationyaml_spec=Path(__file__).parent/'job.yml'# initialize the job managermanager=JobManager(k8s_client=k8s_client,k8s_job_spec=yaml_spec,namespace='default')Thek8s_job_specmay be a path to a file, or adictinstance.The latter is handy for generating configuration on the fly!JobManageralso needs a Kubernetes client.
More information abouthow to connect to Kubernetescan be foundhere.Creating a new jobA job can be started by invokingcreate_jobon theJobManagerinstance:# function to pass to the jobdefadd(a,b):result=a+bprint(result)returnresult# create a new jobjob=manager.create_job(add,123,456)create_jobtakes afunction pointer. This function pointer and all arguments
(*argsand**kwargs) are then "pickled", and merged in thejob template.Our job is now running on the Kubernetes cluster!Listing jobs# list all jobsforjobinmanager.list_jobs():print(f"Found:{job.metadata.name}")Retrieving job statusfromkubernetes_jobimportis_active,is_succeeded,is_failed,is_completed,job_status# get the status of a jobjob=manager.read_job(name)print(f"Status:{job_status(job)}")print(f"Running:{is_active(job)}Completed:{is_completed(job)}")print(f"Succeeded:{is_succeeded(job)}Failed:{is_failed(job)}")Cleaning up finished jobs# cleaning up finished jobsmanager.cleanup_jobs()Deleting jobs# delete a jobmanager.delete_job(name)
Package: kubernetes-stubs-elephant-fork
kubernetes-stubs-elephant-forkfork ofkubernetes-stubswhy fork?kubernetes-stubshas not provided stubs forkubernetes>= 23.0 yet (2023-05-30).kubernetes-stubs-elephant-forkprovides stubs for all releases after 7.0 ofkubernetes,
even includes any release in the future automatically.I run a crontab by github actions which looks for new releases ofkubernetesand build stubs for it.
Package: kubernetes-typed
kubernetes-typedmypy plugin to dynamically define types for Kubernetes objects.FeaturesType checking for Custom ResourcesType checking forkubernetes-clientInstallationInstall withpip:pipinstallkubernetes-typedVersioningThis package followskubernetesclientversioning approach.MAJOR.MINORparts of version will match client version for which stubs were generated, andPATCHversion will be stub or plugin specific updates.Custom Resource DefinitionsAdd type checks forCustom Resource Definitionspec given its definition inyamlfile .Configuremypyto usecrd_typedplugin:[mypy]plugins=crd_typed.pluginImportCustomResourcefrom crd_type import CustomResourceAnnotateyour variables:resource:CustomResource["relative/path/to/crd.yaml"]You can get type definition for different parts of crd:GetTypeDictdefinition for custom resource body:fromcrd_typeimportCustomResourceresource:CustomResource["relative/path/to/crd.yaml"]Get definition only for resourcespec:fromcrd_typeimportCustomResourceresource:CustomResource["relative/path/to/crd.yaml","spec"]Get definition for nested spec item, if that item is typeobjectorarray:fromcrd_typeimportCustomResourceresource:CustomResource["relative/path/to/crd.yaml","spec","some_property"]Get definition for array item, if that is array of objects, viaitemskey:fromcrd_typeimportCustomResourceresource:CustomResource["relative/path/to/crd.yaml","spec","some_array_of_objects","items"]LimitationsCRDs that useadditionalPropertiesare not supported.CRDs can define multipleversions, currently only first one will be usedCustom attributes likex-kubernetes-int-or-string,x-kubernetes-embedded-resource, are not supportedKubernetes Python Client typesThis package provides basictype stubsforkubernetes python clientout of the box.To enable full type checking for classes use providedkubernetes_typedplugin. This plugin requireskubernetes, you can require it during installation like this:pip install kubernetes-typed[client]Configuremypyto use it and it will automatically type check classes fromkubernetes.client:[mypy]plugins=kubernetes_typed.pluginKubernetes Python Client Models Dict TypesIf you want to type check resource dicts instead of classes, you can use generatedTypedDicts provided by this package.To do this for any model class inkubernetes.clientappend its name withDict, and import it fromkubernetes_type.clientFor example:kubernetes.client.V1Pod->kubernetes_typed.client.V1PodDictfromkubernetes.client.apiimportcore_v1_apifromkubernetes_typed.clientimportV1PodDictapi_instance=core_v1_api.CoreV1Api()pod_manifest:V1PodDict={"apiVersion":"v1","kind":"Pod","metadata":{"name":"test-pod"},"spec":{"containers":[{"image":"nginx","name":"nginx",},],},}api_instance.create_namespaced_pod(body=pod_manifest,namespace='default')LimitationsKubernetes client api functions are currently not covered by stubs, so you might getCall to untyped functionerrors. Checkmypy config docon how to disable separate warnings.
Package: kubernetes-validate
kubernetes-validatekubernetes-validate validates Kubernetes resource definitions against the
declared Kubernetes schemas.Based on Gareth Rushgrove's excellent work providing a basis for turning Kubernetes
Swagger API definitions into JSONSchema definitions, kubernetes-validate will report
on mismatches between schema defnition and resource definitionNote that this currently uses a fork of kubernetes-json-schema for the following reasons:Add API versions into schema names (built usinghttps://github.com/garethr/openapi2jsonschema/pull/11)Increase coverage of strict versionsUpdate to latest Kubernetes released API versionsProvide local-strict schemasReduce Kubernetes version support (v1.5 and v1.6 schemas are not included to reduce
library size and schema build time)Furthermore, the module now includes only the .0 API schemas, as they change so little within a Kubernetes
version (there are some differences but they seem to be mostly irrelevant to validation - e.g. description
updates). This has taken the module down from 300MB to less than 30MB.If the relevant PRs get accepted upstream, then this will revert to the upstream fork.Installationpip install kubernetes-validateUsageCommand line$ kubernetes-validate
usage: kubernetes-validate [-h] [-k KUBERNETES_VERSION] [--strict] [--version]
                           ...

validate a kubernetes resource definition

positional arguments:
  filenames

optional arguments:
  -h, --help            show this help message and exit
  -k KUBERNETES_VERSION, --kubernetes-version KUBERNETES_VERSION
                        version of kubernetes against which to validate.
                        Defaults to major/minor version of kubernetes-validate
                        (i.e. 1.22.1 supports kubernetes 1.22). Patch versions
                        of the version are ignored (1.22.4 validates against
                        1.22.0)
  --strict              whether to use strict validation, rejecting unexpected
                        properties
  --quiet               whether to only output warnings/failures
  --no-warn             whether to hide warnings
  --version             show program's version number and exite.g.$ kubernetes-validate -k 1.27 --strict resource.ymlPythonfrom __future__ import print_function
import kubernetes_validate
import yaml

try:
    data = yaml.load(open('resource.yaml').read())
    kubernetes_validate.validate(data, '1.22', strict=True)
except kubernetes_validate.ValidationError as e:
    print(''. join(e.path), e.message)Examples$ kubernetes-validate -k 1.21 examples/kuard-extra-property.yaml
INFO  examples/kuard-extra-property.yaml passed against version 1.21$ kubernetes-validate --strict examples/kuard-extra-property.yaml
ERROR examples/kuard-extra-property.yaml did not validate against version 1.28.0: spec.selector: Additional properties are not allowed ('unwanted' was unexpected)$ kubernetes-validate examples/kuard-invalid-type.yaml
ERROR examples/kuard-invalid-type.yaml did not validate against version 1.28.0: spec.replicas: 'hello' is not of type u'integer'
Package: kubernetes-wsgi
# Kubernetes_WSGIA wrapper for running your Python web application using Twisted in a way that works well for Kubernetes.This also includes Prometheus metrics support.## Quick StartTo install:` pip installkubernetes-wsgi`To launch your application:` python-mkubernetes_wsgi myapp--port8000 `wheremyappis an importable module name containing your WSGI application function.## Why Threads?The gold standard for Python WSGI servers is Gunicorn, renowned for its multi-process execution mode for effcient concurrency despite the dreaded Python GIL (Global Interpreter Lock). Unfortunately when working with containers, multi-process worker models can be difficult to work with as containers generally expect to only have a single process. Specifically this means if one of the forked workers is hit by an OOM and killed, the main process will simply restart it without triggering the usual metrics in Kubernetes for OOM’d Pods. Similarly we have a different way to handle multi-process concurrency in Kubernetes, through a Deployment with many replicas. In the simplest version would could use multiple replicas each handling only one request at a time, but using a thread pool improves throughput by taking advantage of the fact that most web applications are blocked on I/O most of the time (usually waiting for a response from a database or another web service).## Why Twisted?Gunicorn itself does have a threadpool mode, however it’s somewhat awkward to work with as it uses thefuturesThreadPool implementation. Twisted’s ThreadPool is more efficent. This also allows installing the Prometheus metrics as a native Twisted web handler so it will work even if the threadpool is exhausted, meaning your metrics keep working even during a system overload.