
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
kuber is Python library for the management of Kubernetes resources. It's ideal for collectively managing groups of resources throughout their lifecycle. Resource definitions can be created and managed entirely in Python code (the pure-Python approach), but kuber is most effective when used in a hybrid fashion that combines configuration files and Python code. kuber also integrates and maintains compatibility with the lower-level official Kubernetes Python client, while abstracting basic CRUD operations into higher level constructs more inline with the behaviors of tools like kubectl and helm.
Here are some key things that kuber does well:
with
blocks as context
managers to simplify making multiple changes to a sub-resource.kuber available for installation with pip:
$ pip install kuber
kuber can be used to manage individual resources or a group of resources collectively. kuber is also very flexible about how resources are created - either directly from Python or by loading and parsing YAML/JSON configuration files. The first example shows the multi-resource management path:
import kuber
from kuber.latest import apps_v1
# Create a bundle and load all resource definitions from the
# `app_configs` directory as well as the `app-secret.yaml`
# configuration file from the local `secrets` directory.
resource_bundle = (
kuber.create_bundle()
.add_directory("app_configs")
.add_file("secrets/app-secret.yaml")
)
# Modify the metadata labels on all resources in the bundle.
for resource in resource_bundle.resources:
resource.metadata.labels.update(environment="production")
# Update the replica count of the loaded deployment named
# "my-app" to the desired initial count.
d: apps_v1.Deployment = resource_bundle.get(
name="my-app",
kind="Deployment"
)
d.spec.replicas = 20
# Load the current `kubeconfig` cluster configuration into
# kuber for interaction with the cluster.
kuber.load_access_config()
# Turn this bundle script into a file that can be called from
# the command line to carry out CRUD operations on all the
# resources contained within it collectively. For example,
# to create the resources in this bundle, call this script
# file with a create argument.
resource_bundle.cli()
Or managing resources individually:
from kuber.latest import batch_v1
job = batch_v1.Job()
# Populate metadata using context manager syntax for brevity.
with job.metadata as md:
md.name = "my-job"
md.namespace = "jobs"
md.labels.update(
component="backend-tasks",
environment="production"
)
# Add a container to the job spec.
job.spec.append_container(
name="main",
image="my-registry.com/projects/my-job:1.0.1",
image_pull_policy="Always",
env=[batch_v1.EnvVar("ENVIRONMENT", "production")]
)
# Print the resulting YAML configuration for display. This
# could also be saved somewhere to use later as the
# configuration file to deploy to the cluster in cases
# like a multi-stage CI pipeline.
print(job.to_yaml())
Check out the kuber documentation for more details and examples.
FAQs
Accelerated Kubernetes configuration and package management with Python.
We found that kuber demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.