Skip to main content

Python wrapper on kubectl that makes deploying easy.

Project description

kubepy

Latest Version Supported Python versions Wheel Status License

Python wrapper on kubectl that makes deploying easy.

Installation

Requires python 3.5 and configured kubectl. To install run: pip3 install kubepy

Usage

You can use this package to install all yml definitions from given directory. Just run kubepy-apply-all from a directory where all of you Kubernetes definition yml files are.

Supported Kubernetes resources:

  • CronJob
  • Deployment
  • StatefulSet
  • Job
  • Pod (used to run a one-off command)
  • Service
  • Ingress
  • Secret
  • StorageClass
  • PersistentVolume
  • PersistentVolumeClaim
  • PodDisruptionBudget

Options:

  • --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>=value Sets 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 also kubepy-apply-one command which is called as kubepy-apply-one name1 [name2 ...] It applies only files selected files. Names should be without ".yml". It accepts all options from kubepy-apply-all. Additionally you can pass option:

  • --show-definition - shows definition instead of applying them.

Applying jobs.

Applying usualy means that underlying kubectl apply or kubectl replace is called. However applying job is treated differently. To ensure that job finished and succeeded kubectl waits 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 with restartPolicy: 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubepy-1.20.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

kubepy-1.20.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file kubepy-1.20.0.tar.gz.

File metadata

  • Download URL: kubepy-1.20.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for kubepy-1.20.0.tar.gz
Algorithm Hash digest
SHA256 5201c7c380983c0d58cc73ad38e5030a718aacc0535c4ab1dedae4252b2292a4
MD5 474f4851f5f8673dcbddeb65f41c3d04
BLAKE2b-256 6523163b53b346c8472e317f9a944608c6e4e7f5e70c60dc71f0320f82a0439d

See more details on using hashes here.

File details

Details for the file kubepy-1.20.0-py3-none-any.whl.

File metadata

  • Download URL: kubepy-1.20.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for kubepy-1.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2105238267b719b7772b45205e5547a4207e633263eea489fa780ec722ae5a9
MD5 a4bb06a7f01296d8b2e38c43d02cb7ca
BLAKE2b-256 628e4c976f402242c1ac128aa0697afe275a7e87368bcb1c191c25e31f20976d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page