### Install Kubetools Source: https://github.com/editd/kubetools/blob/master/README.md Standard installation command for the Kubetools package. ```sh pip install kubetools ``` -------------------------------- ### Start Local Development Environment Source: https://context7.com/editd/kubetools/llms.txt Commands to initialize containers and run migrations. ```bash # Start all containers and run upgrades ktd up # Start specific containers only ktd up uwsgi mariadb # Start without running upgrades ktd up --no-upgrade ``` -------------------------------- ### Install Kubetools for development Source: https://github.com/editd/kubetools/blob/master/README.md Install the package in editable mode with development dependencies. ```sh pip install -e .[dev] ``` -------------------------------- ### Configure Minikube for local testing Source: https://github.com/editd/kubetools/blob/master/README.md Commands to start Minikube with registry support and deploy to the local environment. ```shell minikube start --addons registry --insecure-registry ${MINIKUBE_IP}:5000 ``` ```shell kubetools --context minikube deploy --default-registry ${MINIKUBE_IP}:5000 default . ``` ```shell minikube start MINIKUBE_IP=$(minikube ip) minikube delete ... ``` -------------------------------- ### Execute local development and deployment commands Source: https://github.com/editd/kubetools/blob/master/README.md Commands to start a local development environment and deploy the project to a Kubernetes namespace. ```sh # Bring up a local development environment using docker-compose ktd up # Deploy the project to a Kubernetes namespace kubetools deploy my-namespace ``` -------------------------------- ### Define project configuration in kubetools.yml Source: https://github.com/editd/kubetools/blob/master/README.md Example configuration for a Django application, including container contexts, upgrades, tests, deployments, dependencies, and cronjobs. ```yaml name: my-app containerContexts: django_app: build: registry: my-registry.net dockerfile: Dockerfile dev: volumes: - ./:/opt/django_app upgrades: - name: Upgrade database containerContext: django_app command: [./manage.py, migrate, --noinput] tests: - name: Nosetests containerContext: django_app command: [./manage.py, test] deployments: my-app-webserver: annotations: imageregistry: "https://hub.docker.com/" labels: app.kubernetes.io/name: my-app-webserver serviceAccountName: webserver secrets: secret-volume: mountPath: /mnt/secrets-store secretProviderClass: webserver-secrets containers: uwsgi: command: [uwsgi, --ini, /etc/uwsgi.conf] containerContext: django_app ports: - 80 dev: command: [./manage.py, runserver, '0.0.0.0:80'] dependencies: mariadb: containers: mariadb: image: mariadb:v10.4.1 cronjobs: my-cronjob: batch-api-version: 'batch/v1beta1' # Must add if k8s version < 1.21+ schedule: "*/1 * * * *" concurrency_policy: "Replace" containers: hello: image: busybox command: [/bin/sh, -c, date; echo Hello from the Kubernetes cluster] ``` -------------------------------- ### Test deployments locally with Minikube Source: https://context7.com/editd/kubetools/llms.txt Commands to initialize a local Minikube environment and deploy resources using the Kubetools CLI. ```bash # Start minikube with registry minikube start --addons registry --insecure-registry $(minikube ip):5000 # Get minikube IP for registry MINIKUBE_IP=$(minikube ip) # Deploy to minikube kubetools --context minikube deploy --default-registry ${MINIKUBE_IP}:5000 default . # Show deployed resources kubetools --context minikube show default ``` -------------------------------- ### Deploy applications with kubetools Source: https://context7.com/editd/kubetools/llms.txt Deploy applications to a Kubernetes namespace with support for custom replicas, registries, environment variables, and build arguments. ```bash # Deploy current directory to namespace kubetools deploy my-namespace # Deploy specific directories kubetools deploy my-namespace ./app1 ./app2 # Deploy with custom replica count kubetools deploy --replicas 3 my-namespace # Deploy with default registry kubetools deploy --default-registry registry.example.com:5000 my-namespace # Deploy with extra environment variables kubetools deploy -e API_KEY=secret -e DEBUG=false my-namespace # Deploy with extra annotations kubetools deploy -a version=1.2.3 -a team=platform my-namespace # Deploy with build arguments for Dockerfile kubetools deploy -b NPM_TOKEN=abc123 my-namespace # Deploy using custom kubetools config file kubetools deploy -f ./custom-kubetools.yml my-namespace # Deploy ignoring uncommitted git changes kubetools deploy --ignore-git-changes my-namespace # Auto-confirm deployment (for CI/CD) kubetools deploy -y my-namespace # Dry run - print objects without deploying kubetools deploy --dry my-namespace # Don't delete jobs after completion kubetools deploy --no-delete-jobs my-namespace ``` -------------------------------- ### Kubetools Settings Configuration Source: https://context7.com/editd/kubetools/llms.txt Configure kubetools settings in the `~/.kubetools/kubetools.conf` file. ```ini # ~/.kubetools/kubetools.conf [kubetools] # Default environment for dev commands dev-default-env = dev # Development hostname dev-host = localhost ``` -------------------------------- ### Manage Kubernetes contexts Source: https://context7.com/editd/kubetools/llms.txt List and select Kubernetes contexts for deployment operations. ```bash # List available Kubernetes contexts kubetools --contexts # Use specific context for command kubetools --context production deploy my-namespace # Set context via environment variable export KUBETOOLS_CONTEXT=production kubetools deploy my-namespace ``` -------------------------------- ### Configure Kubetools settings Source: https://context7.com/editd/kubetools/llms.txt Define global settings for Kubetools, including backend selection, environment defaults, and operation timeouts. ```ini # Backend for development (docker_compose) dev-backend = docker_compose # Default Kubernetes environment default-kube-env = staging # CronJob API version for older clusters cronjobs-batch-api-version = batch/v1 # Maximum wait time for K8s operations (seconds) # Can also be set via KUBETOOLS_WAIT_MAX_TIME env var wait-max-time = 300 # Custom script to check registry for images registry-check-script = /path/to/check_registry.sh ``` -------------------------------- ### Replica Configuration in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Configure replica counts using multipliers, minimums, and maximums, along with update strategies. ```yaml # kubetools.yml with replica configuration name: my-app deployments: my-app-webserver: # Multiply requested replicas by factor replicaMultiplier: 2 # Set minimum replicas minReplicas: 2 # Set maximum replicas maxReplicas: 10 # Update strategy for rolling updates updateStrategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 containers: uwsgi: image: my-app:latest ports: - 80 ``` -------------------------------- ### Follow Container Logs Source: https://context7.com/editd/kubetools/llms.txt Real-time log streaming for local containers. ```bash # Follow logs for all app containers (default) ktd logs # Follow logs for specific containers ktd logs uwsgi mariadb # Show all containers including dependencies ktd logs --all # Show specific number of history lines ktd logs -n 100 # Show all history ktd logs --with-history ``` -------------------------------- ### Load Kubetools configuration programmatically Source: https://context7.com/editd/kubetools/llms.txt Load and access project configuration using the Python API with support for environment filtering and custom file paths. ```python from kubetools.config import load_kubetools_config # Load config from current directory config = load_kubetools_config() # Load from specific directory config = load_kubetools_config(directory='/path/to/app') # Load with environment filtering config = load_kubetools_config( directory='/path/to/app', env='production', namespace='my-namespace', ) # Load for dev mode (applies dev overrides) config = load_kubetools_config(dev=True) # Load custom config file config = load_kubetools_config( custom_config_file='/path/to/custom-kubetools.yml' ) # Access configuration print(config['name']) print(config['deployments']) print(config['dependencies']) print(config['upgrades']) print(config['cronjobs']) ``` -------------------------------- ### Execute Commands in New Containers Source: https://context7.com/editd/kubetools/llms.txt Run commands in fresh container instances with optional environment variables. ```bash # Run command in a new container ktd run uwsgi python manage.py collectstatic # Run with environment variables ktd run -e DEBUG=true -e LOG_LEVEL=debug uwsgi python scripts/debug.py # Run tests in new container ktd run django_app ./manage.py test --verbosity=2 ``` -------------------------------- ### Minikube Local Testing CLI Source: https://context7.com/editd/kubetools/llms.txt Commands for testing deployments locally using Minikube and Kubetools CLI. ```APIDOC ## Minikube Local Testing ### Description Test deployments locally using minikube. ### Commands - `minikube start --addons registry --insecure-registry $(minikube ip):5000` - `kubetools --context deploy --default-registry ` - `kubetools --context show ` ### Usage 1. **Start Minikube with registry addon:** ```bash minikube start --addons registry --insecure-registry $(minikube ip):5000 ``` 2. **Get Minikube IP for registry:** ```bash MINIKUBE_IP=$(minikube ip) ``` 3. **Deploy to Minikube:** Replace ``, ``, ``, and `` with your specific values. ```bash kubetools --context minikube deploy --default-registry ${MINIKUBE_IP}:5000 default . ``` 4. **Show deployed resources:** ```bash kubetools --context minikube show default ``` ``` -------------------------------- ### Container Resources Configuration in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Define resource requests and limits for containers, including readiness probe configuration. ```yaml # kubetools.yml with resource configuration name: my-app deployments: my-app-webserver: containers: uwsgi: image: my-app:latest ports: - 80 resources: requests: memory: "256Mi" cpu: "100m" limits: memory: "1Gi" cpu: "1000m" # Readiness probe configuration readinessProbe: httpGet: path: /health port: 80 initialDelaySeconds: 5 periodSeconds: 10 failureThreshold: 3 ``` -------------------------------- ### Python API - Load Kubetools Config Source: https://context7.com/editd/kubetools/llms.txt Programmatically load and work with kubetools configuration files. ```APIDOC ## Python API - Load Kubetools Config ### Description Programmatically load and work with kubetools configuration. ### Method `load_kubetools_config()` ### Parameters #### Keyword Arguments - **directory** (string) - Optional - The directory to load the config from. - **env** (string) - Optional - Filter configuration by environment. - **namespace** (string) - Optional - Filter configuration by namespace. - **dev** (boolean) - Optional - Load for dev mode (applies dev overrides). - **custom_config_file** (string) - Optional - Path to a custom config file. ### Request Example ```python from kubetools.config import load_kubetools_config # Load config from current directory config = load_kubetools_config() # Load from specific directory config = load_kubetools_config(directory='/path/to/app') # Load with environment filtering config = load_kubetools_config( directory='/path/to/app', env='production', namespace='my-namespace', ) # Load for dev mode (applies dev overrides) config = load_kubetools_config(dev=True) # Load custom config file config = load_kubetools_config( custom_config_file='/path/to/custom-kubetools.yml' ) ``` ### Response #### Success Response (object) - **config** (object) - The loaded kubetools configuration. ### Response Example ```python # Access configuration print(config['name']) print(config['deployments']) print(config['dependencies']) print(config['upgrades']) print(config['cronjobs']) ``` ``` -------------------------------- ### Restart applications with kubetools Source: https://context7.com/editd/kubetools/llms.txt Restart running applications by deleting their associated pods. ```bash # Restart specific apps kubetools restart my-namespace my-app-webserver # Restart with auto-confirmation kubetools restart -y my-namespace my-app # Force restart objects not owned by kubetools kubetools restart --force my-namespace my-app ``` -------------------------------- ### Push Docker images Source: https://context7.com/editd/kubetools/llms.txt Build and push Docker images to a registry without deploying. ```bash # Push images with default registry kubetools push --default-registry registry.example.com:5000 # Push with additional tags kubetools push -t latest -t v1.2.3 --default-registry registry.example.com:5000 # Push with build arguments kubetools push -b NPM_TOKEN=abc123 --default-registry registry.example.com:5000 ``` -------------------------------- ### Enter Interactive Shell Source: https://context7.com/editd/kubetools/llms.txt Open a shell session inside a running container. ```bash # Enter container with default shell (sh) ktd enter uwsgi # Enter container with specific shell ktd enter --shell /bin/bash uwsgi ``` -------------------------------- ### Show application status Source: https://context7.com/editd/kubetools/llms.txt Display the status of deployments, services, jobs, and cronjobs within a namespace. ```bash # Show all resources in namespace kubetools show my-namespace # Filter by specific app kubetools show my-namespace my-app-webserver ``` -------------------------------- ### Define kubetools.yml Configuration Source: https://context7.com/editd/kubetools/llms.txt The central configuration file for defining microservices, dependencies, deployments, and jobs. ```yaml # Basic kubetools.yml configuration name: my-app # Minimum kubetools version required (optional) minKubetoolsVersion: 13.0 # Reusable container contexts for builds containerContexts: django_app: build: registry: my-registry.net dockerfile: Dockerfile dev: volumes: - ./:/opt/django_app # Database migrations and setup commands upgrades: - name: Upgrade database containerContext: django_app command: [./manage.py, migrate, --noinput] # Test configuration tests: - name: Nosetests containerContext: django_app command: [./manage.py, test] # Main application deployments deployments: my-app-webserver: annotations: imageregistry: "https://hub.docker.com/" labels: app.kubernetes.io/name: my-app-webserver serviceAccountName: webserver secrets: secret-volume: mountPath: /mnt/secrets-store secretProviderClass: webserver-secrets containers: uwsgi: command: [uwsgi, --ini, /etc/uwsgi.conf] containerContext: django_app ports: - 80 dev: command: [./manage.py, runserver, '0.0.0.0:80'] # External dependencies (databases, caches, etc.) dependencies: mariadb: containers: mariadb: image: mariadb:v10.4.1 # Scheduled jobs cronjobs: my-cronjob: batch-api-version: 'batch/v1beta1' # Required if k8s version < 1.21 schedule: "*/1 * * * *" concurrency_policy: "Replace" containers: hello: image: busybox command: [/bin/sh, -c, date; echo Hello from the Kubernetes cluster] ``` -------------------------------- ### Restart containers with ktd Source: https://context7.com/editd/kubetools/llms.txt Restart containers without destroying the underlying environment. ```bash # Restart all containers ktd restart # Restart specific containers ktd restart uwsgi ``` -------------------------------- ### Job Configuration with TTL in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Configure one-time jobs with a time-to-live after completion for automatic deletion. ```yaml # kubetools.yml with job TTL name: my-app upgrades: - name: Database migration containerContext: django_app command: [./manage.py, migrate, --noinput] ttl_seconds_after_finished: 3600 # Delete job after 1 hour completions: 1 parallelism: 1 resources: requests: memory: "128Mi" cpu: "50m" ``` -------------------------------- ### Generate Kubernetes configs Source: https://context7.com/editd/kubetools/llms.txt Generate Kubernetes configuration files from kubetools.yml without performing a deployment. ```bash # Generate configs as JSON (default) kubetools config ./my-app # Generate configs as YAML kubetools config --format yaml ./my-app # Generate with specific replica count kubetools config --replicas 3 ./my-app # Generate using custom kubetools file kubetools config -f ./custom-kubetools.yml ./my-app # Generate with default registry kubetools config --default-registry registry.example.com:5000 ./my-app ``` -------------------------------- ### Run tests with ktd Source: https://context7.com/editd/kubetools/llms.txt Execute tests within the development environment with options to persist containers or pass arguments to the underlying test command. ```bash ktd test --keep-containers ``` ```bash ktd test -- --ipdb-failures --verbose ``` -------------------------------- ### Check Development Environment Status Source: https://context7.com/editd/kubetools/llms.txt Monitor the status of local containers. ```bash # Show all containers for the project ktd status # Show only containers from the active environment ktd status --active-only ``` -------------------------------- ### Generate Kubernetes resource configurations Source: https://context7.com/editd/kubetools/llms.txt Programmatically generate Kubernetes resource dictionaries based on project configuration and environment variables. ```python from kubetools.config import load_kubetools_config from kubetools.kubernetes.config import generate_kubernetes_configs_for_project # Load kubetools config config = load_kubetools_config(directory='/path/to/app') # Map of context names to Docker images context_to_image = { 'django_app': 'registry.example.com/my-app:v1.2.3', } # Generate all Kubernetes configs services, deployments, jobs, cronjobs = generate_kubernetes_configs_for_project( config, replicas=3, context_name_to_image=context_to_image, default_registry='registry.example.com', envvars={'ENVIRONMENT': 'production'}, base_labels={'team': 'platform'}, base_annotations={'version': '1.2.3'}, ) # Each item is a Kubernetes resource dict for deployment in deployments: print(f"Deployment: {deployment['metadata']['name']}") print(f"Replicas: {deployment['spec']['replicas']}") ``` -------------------------------- ### Python API - Generate Kubernetes Configs Source: https://context7.com/editd/kubetools/llms.txt Generate Kubernetes resource configurations programmatically. ```APIDOC ## Python API - Generate Kubernetes Configs ### Description Generate Kubernetes resource configurations programmatically. ### Method `generate_kubernetes_configs_for_project(config, ...)` ### Parameters #### Required Parameters - **config** (object) - The loaded kubetools configuration object. #### Optional Parameters - **replicas** (integer) - The number of replicas for deployments. - **context_name_to_image** (dict) - A mapping of context names to Docker image tags. - **default_registry** (string) - The default Docker registry to use. - **envvars** (dict) - Environment variables to inject into containers. - **base_labels** (dict) - Base labels to apply to Kubernetes resources. - **base_annotations** (dict) - Base annotations to apply to Kubernetes resources. ### Request Example ```python from kubetools.config import load_kubetools_config from kubetools.kubernetes.config import generate_kubernetes_configs_for_project # Load kubetools config config = load_kubetools_config(directory='/path/to/app') # Map of context names to Docker images context_to_image = { 'django_app': 'registry.example.com/my-app:v1.2.3', } # Generate all Kubernetes configs services, deployments, jobs, cronjobs = generate_kubernetes_configs_for_project( config, replicas=3, context_name_to_image=context_to_image, default_registry='registry.example.com', envvars={'ENVIRONMENT': 'production'}, base_labels={'team': 'platform'}, base_annotations={'version': '1.2.3'}, ) ``` ### Response #### Success Response (tuple of lists) - **services** (list) - List of Kubernetes service resource dictionaries. - **deployments** (list) - List of Kubernetes deployment resource dictionaries. - **jobs** (list) - List of Kubernetes job resource dictionaries. - **cronjobs** (list) - List of Kubernetes cronjob resource dictionaries. ### Response Example ```python # Each item is a Kubernetes resource dict for deployment in deployments: print(f"Deployment: {deployment['metadata']['name']}") print(f"Replicas: {deployment['spec']['replicas']}") ``` ``` -------------------------------- ### CronJob Configuration in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Define scheduled jobs with cron expressions, concurrency policies, and resource configurations. ```yaml # kubetools.yml with cronjob configuration name: my-app cronjobs: # Basic cronjob hourly-cleanup: schedule: "0 * * * *" concurrency_policy: "Forbid" containers: cleanup: image: my-app:latest command: [python, cleanup.py] # Cronjob with all options daily-report: schedule: "0 2 * * *" concurrency_policy: "Replace" batch-api-version: 'batch/v1' # or 'batch/v1beta1' for older k8s successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 5 serviceAccountName: report-sa nodeSelector: node-type: batch secrets: report-secrets: mountPath: /mnt/secrets secretProviderClass: report-secrets containers: reporter: image: my-app:latest command: [python, generate_report.py] resources: requests: memory: "256Mi" cpu: "100m" limits: memory: "512Mi" cpu: "500m" ``` -------------------------------- ### Cleanup orphaned resources Source: https://context7.com/editd/kubetools/llms.txt Remove orphaned replica sets, pods, and optionally empty namespaces. ```bash # Cleanup orphaned resources kubetools cleanup my-namespace # Cleanup with auto-confirmation kubetools cleanup -y my-namespace # Also cleanup completed jobs and associated pods kubetools cleanup --cleanup-jobs my-namespace ``` -------------------------------- ### Remove applications with kubetools Source: https://context7.com/editd/kubetools/llms.txt Remove specific applications from a Kubernetes namespace with options for force removal and cleanup. ```bash # Remove specific apps from namespace kubetools remove my-namespace my-app-webserver my-app-worker # Remove with auto-confirmation kubetools remove -y my-namespace my-app # Force remove objects not owned by kubetools kubetools remove --force my-namespace my-app # Remove and cleanup orphaned resources immediately kubetools remove --cleanup my-namespace my-app ``` -------------------------------- ### Conditional Deployments in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Configure deployments to be active only under specific conditions like environment, namespace, or development mode. ```yaml name: my-app deployments: # Always deployed my-app-webserver: containers: uwsgi: image: my-app:latest ports: - 80 # Only deployed in production environment my-app-worker: conditions: envs: - production containers: worker: image: my-app:latest command: [python, worker.py] # Only deployed to specific namespaces my-app-admin: conditions: namespaces: - admin-ns - staging-ns containers: admin: image: my-app:latest # Exclude from certain namespaces my-app-debug: conditions: notNamespaces: - production containers: debug: image: my-app:latest # Dev-only deployment (used by ktd only) dev-tools: conditions: dev: true containers: tools: image: dev-tools:latest dependencies: # Only in dev mock-api: conditions: dev: true containers: mock: image: mock-api:latest ``` -------------------------------- ### Run Tests in Isolated Environment Source: https://context7.com/editd/kubetools/llms.txt Execute tests and clean up the environment afterwards. ```bash # Run all tests ktd test ``` -------------------------------- ### Execute Commands in Existing Containers Source: https://context7.com/editd/kubetools/llms.txt Run ad-hoc commands inside running containers. ```bash # Run a shell command in a container ktd exec uwsgi python manage.py shell # Run database migrations manually ktd exec uwsgi ./manage.py migrate # Run a specific script ktd exec worker python scripts/process_queue.py ``` -------------------------------- ### Secrets and Service Account Configuration in Kubetools Source: https://context7.com/editd/kubetools/llms.txt Mount Kubernetes secrets and configure service accounts for deployments and jobs. ```yaml # kubetools.yml with secrets configuration name: my-app deployments: my-app-webserver: serviceAccountName: my-app-sa secrets: api-secrets: mountPath: /mnt/secrets secretProviderClass: my-app-secrets db-credentials: mountPath: /mnt/db-secrets secretProviderClass: db-secrets nodeSelector: node-type: high-memory zone: us-east-1a containers: uwsgi: image: my-app:latest ports: - 80 # Jobs can also use secrets upgrades: - name: Database migration containerContext: django_app command: [./manage.py, migrate] serviceAccountName: migration-sa secrets: db-credentials: mountPath: /mnt/secrets secretProviderClass: db-secrets ``` -------------------------------- ### Destroy containers with ktd Source: https://context7.com/editd/kubetools/llms.txt Stop and remove containers from the development environment. ```bash # Destroy all containers ktd destroy # Destroy specific containers ktd destroy uwsgi worker ``` -------------------------------- ### Python API - Kubernetes Operations Source: https://context7.com/editd/kubetools/llms.txt Direct API for performing Kubernetes operations. ```APIDOC ## Python API - Kubernetes Operations ### Description Direct API for Kubernetes operations. ### Methods - `list_deployments(env, namespace)` - `list_services(env, namespace)` - `list_jobs(env, namespace)` - `list_cronjobs(env, namespace)` - `deployment_exists(env, namespace, deployment_obj)` - `create_deployment(env, namespace, deployment_config)` - `update_deployment(env, namespace, deployment_config)` - `delete_deployment(env, namespace, deployment_obj)` - `wait_for_deployment(env, namespace, deployment_obj)` ### Parameters #### Common Parameters - **env** (string) - Kubernetes context name. - **namespace** (string) - The namespace to operate in. - **deployment_obj** (object) - The deployment object. - **deployment_config** (object) - The configuration for the deployment. ### Request Example ```python from kubetools.kubernetes.api import ( list_deployments, list_services, list_jobs, list_cronjobs, create_deployment, update_deployment, delete_deployment, wait_for_deployment, deployment_exists ) # List resources in a namespace env = 'minikube' # Kubernetes context name namespace = 'my-namespace' deployments = list_deployments(env, namespace) services = list_services(env, namespace) jobs = list_jobs(env, namespace) cronjobs = list_cronjobs(env, namespace) # Check if deployment exists # Assuming deployment_obj is defined elsewhere # exists = deployment_exists(env, namespace, deployment_obj) # Create deployment # Assuming deployment_config is defined elsewhere # k8s_deployment = create_deployment(env, namespace, deployment_config) # Update deployment (waits for rollout) # k8s_deployment = update_deployment(env, namespace, deployment_config) # Delete deployment # delete_deployment(env, namespace, deployment_obj) # Wait for deployment to be ready # wait_for_deployment(env, namespace, deployment_obj) ``` ### Response #### Success Response (list or object) - **deployments, services, jobs, cronjobs** (list) - Lists of respective Kubernetes resources. - **deployment_exists** (boolean) - True if the deployment exists, False otherwise. - **create_deployment, update_deployment** (object) - The created or updated Kubernetes deployment object. ### Error Handling - Specific error responses depend on the Kubernetes API and kubetools implementation. ``` -------------------------------- ### Perform Kubernetes operations via Python API Source: https://context7.com/editd/kubetools/llms.txt Execute direct Kubernetes operations such as listing, creating, updating, and deleting resources. ```python from kubetools.kubernetes.api import ( list_deployments, list_services, list_jobs, list_cronjobs, create_deployment, update_deployment, delete_deployment, wait_for_deployment, ) # List resources in a namespace env = 'minikube' # Kubernetes context name namespace = 'my-namespace' deployments = list_deployments(env, namespace) services = list_services(env, namespace) jobs = list_jobs(env, namespace) cronjobs = list_cronjobs(env, namespace) # Check if deployment exists from kubetools.kubernetes.api import deployment_exists exists = deployment_exists(env, namespace, deployment_obj) # Create deployment k8s_deployment = create_deployment(env, namespace, deployment_config) # Update deployment (waits for rollout) k8s_deployment = update_deployment(env, namespace, deployment_config) # Delete deployment delete_deployment(env, namespace, deployment_obj) # Wait for deployment to be ready wait_for_deployment(env, namespace, deployment_obj) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.