Skip to content

Kubernetes python client wrapper for better typing leveraging Pydantic

License

Notifications You must be signed in to change notification settings

hrk091/kubernetes-pydantic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1b34ca1 · Apr 24, 2022

History

11 Commits
Apr 18, 2022
Apr 24, 2022
Apr 18, 2022
Apr 24, 2022
Apr 18, 2022
Apr 17, 2022
Apr 24, 2022
Apr 24, 2022
Apr 18, 2022
Apr 18, 2022
Apr 18, 2022
Apr 24, 2022
Apr 18, 2022

Repository files navigation

kubernetes-pydantic

Wrapper of kubernetes-client/python for better typing leveraging Pydantic.

Installation

From source:

git clone https://github.com/hrk091/kubernetes-pydantic
pip install kubernetes-pydantic

Examples

List all pods:

import asyncio

from kubernetes_pydantic.corev1 import PodApi

async def main():
    api = PodApi.new(namespace="kube-system")

    items, err = await api.list()
    if err:
        raise err
    for i in items:
        print(i.metadata.name)


if __name__ == "__main__":
    asyncio.run(main())

You can see type hints of all nested fields on your IDE since all of them are Pydantic types.

Capabilities

Following resources are supported:

apps/v1

  • DaemonSet
  • Deployment
  • ReplicaSet
  • StatefulSet

batch/v1

  • CronJob
  • Job

core/v1

  • ConfigMap
  • Endpoints
  • Event
  • LimitRange
  • Namespace
  • Node
  • PersistentVolume
  • PersistentVolumeClaim
  • Pod
  • PodTemplate
  • ResourceQuota
  • SecretApi
  • ServiceAccount
  • Service

networking.k8s.io/v1

  • IngressClass
  • Ingress

rbac.authorization.k8s.io/v1

  • ClusterRoleBinding
  • ClusterRole
  • RoleBinding
  • Role

tekton.dev/v1beta1

  • ClusterTask
  • PipelineRun
  • Pipeline
  • TaskRun
  • Task

Caveats

  • Watch API is not supported yet.

About

Kubernetes python client wrapper for better typing leveraging Pydantic

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published