Skip to content

Instantly share code, notes, and snippets.

@ajeetraina
Created April 25, 2023 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajeetraina/ee3e23e6ebe886b693cff549240b2cf6 to your computer and use it in GitHub Desktop.
Save ajeetraina/ee3e23e6ebe886b693cff549240b2cf6 to your computer and use it in GitHub Desktop.
Python and Kubernetes YAML
from kubernetes import client, config
# Load kubeconfig file
config.load_kube_config()
# Create an instance of the Kubernetes API client
api_instance = client.AppsV1Api()
# Specify the name and namespace of the deployment to update
name = "my-deployment"
namespace = "my-namespace"
# Get the current deployment object
deployment = api_instance.read_namespaced_deployment(name, namespace)
# Set the new replica count
deployment.spec.replicas = 3
# Update the deployment
api_instance.replace_namespaced_deployment(name, namespace, deployment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment