Created
April 25, 2023 12:17
-
-
Save ajeetraina/ee3e23e6ebe886b693cff549240b2cf6 to your computer and use it in GitHub Desktop.
Python and Kubernetes YAML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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