Skip to main content

Kubernetes OOP

Project description

kube-py

Use OOP to manage Kubernetes objects

Usages

import kube_ops

# Create configmap
cm = kube_ops.ConfigMap("nginx")
cm.set(NGINX_ENTRYPOINT_QUIET_LOGS=True)
cm.create()

# Create secret with type kubernetes.io/tls
sec = kube_ops.SecretTLS("nginx")
with open("server.crt") as f:
    crt = f.read()
with open("server.key") as f:
    key = f.read()
sec.set(crt, key)
sec.create()

# Make container
container = kube_ops.Container("nginx")
container.set_image("nginx:alpine")
## Add port to container
container.add_port("http", 80)
## Make envFrom link to configmap and add to the container
env = kube_ops.env_from_configmap(cm.name)
container.add_env_from(env)

# Make deployment
deploy = kube_ops.Deployment("nginx-test", container)
deploy.add_volume_to_container(container.name, kube_ops.empty_dir(), "/mnt")

## Set labels
lbl = dict(key="value", app="nginx", name="nginx-test")
deploy.set_labels(**lbl)
deploy.set_pod_labels(**lbl)
deploy.set_selector_match_labels(**lbl)

## Add secret as volume to deployment
sec_vol = kube_ops.volume_from_secret(sec.name)
deploy.add_volume_to_container(sec.name, sec_vol, "/etc/nginx/certs")

## Create deployment
deploy.create()

## Create service from deployment definition
deploy.service().create()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

kube_ops-1.1.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file kube_ops-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: kube_ops-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for kube_ops-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e499da1e6f30b3e0b19f9e48622234e4fc87d44bbdf361c2da988b49f1d94a
MD5 04127a92901cf9e576e65afae8f394ff
BLAKE2b-256 b6f109a0ba791500d1b7d6d129a18f5b6acf0b9f0024c734a99e39f9d2b555d0

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