Questions tagged [kubernetes-python-client]

93 questions
0
votes
0 answers

How to read image tag value of kubernetes cronjob with python kubernetes client?

What is python code for kubernetes client same as: 'kubectl get cronjob -o yaml' I tried with https://github.com/kubernetes-client/python/blob/master/examples/cronjob_crud.py get_cronjob_body(namespace,name,command) which return body but this…
0
votes
1 answer

How to create a ServiceMonitor with create_from_yaml from k8s python client

I have the following manifest to export some RabbitMQ stats: apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: rabbitmq-exporter labels: app: rabbitmq spec: selector: matchLabels: app: rabbitmq …
Paulo
  • 6,982
  • 7
  • 42
  • 56
0
votes
0 answers

Not able to list the namesapce

i am new to python and Kubernetes, i have installed the Kubernetes client, i was trying to get the namespace below is my code: from kubernetes import client, config def main(): config.load_kube_config() k8s_apps_v1 = client.AppsV1Api() …
0
votes
1 answer

Scale deployment with python client in Kubernetes

I am trying to scale deployments using Kubernetes python client. The cluster is running on 3 nodes and I have remote access via kubectl. I need to scale my deployment based on a python script via Kubernetes python client. I am trying the following…
jkmp
  • 55
  • 2
  • 7
0
votes
1 answer

In kubectl python client how to get storage class by name in yaml format

I am trying to get yaml for the particular storage class using Kubernetes python client, following code does the job: list_storage_class = v1.list_storage_class(_preload_content=False) storageclass = list_storage_class.read().decode('utf-8') #…
0
votes
1 answer

Manipulating kubernetes yaml with python

I am trying to manipulate a kubernetes yaml file with python's pyyaml. I'm trying to add some annotations, but when I dump them the output is empty. Add key,val in a Deployment: file_content = "" try: with open(filename, "r") as f: …
sctx
  • 128
  • 2
  • 11
0
votes
1 answer

How to delete a kubernetes deployment using kubernetes python client?

I cannot find the python function to delete a kubernetes deployment. I can delete the pods but that would only cause the deployment to restart the pods again. Basically I want the equivalent of kubectl delete deployment deployment1 --namespace nms.
0
votes
0 answers

How can I dynamically allocate resources to each pod?

I want to change the resource allocation of each pod dynamically using python client. I tried below code but it seems doesn't change. I searched really hard but I don't know how to... Or is there any other API that makes this change possible? from…
0
votes
1 answer

is there Python client API for 'kubectl auth can-i --list'

I am trying to list permissions associated to a service account 'foobar-user' applied to my cluster in namespace 'kube-system': kubectl auth can-i --list --as=system:serviceaccount:kube-system:foobar-user --namespace=kube-system Resources …
0
votes
0 answers

How to get custom objects like VirtualMachine using kubernetes python client?

I am using kubernetes python client and I want to write a method to list/get custom objects like VirtualMachine or VirtualMachineInstance. I tried with the method client.CustomObjectsApi().list_cluster_custom_object() but it requires 3 necessary…
0
votes
1 answer

Python Docker SDK Inside Kubernetes

I followed this link - https://docs.docker.com/engine/api/sdk/examples/ and the docker SDK worked fine while I was using Docker containers. Now that I have moved to K8s, when I run the code I get error like "Container Not Found" . Is there a way to…
0
votes
1 answer

Internal communication between pods at Kubernetes with code

Maybe this question is very wrong but my research so far hasn't been very helpful. My plan is to deploy a server app to multiple pods , as replicas (same code running in multiple pods) and I want each pod to be able to communicate with the rest…
0
votes
0 answers

Managing Openshift cluster with Python

I have a requirement to use Python to deploy some things to an Openshift cluster (I've been pre-empted from any other solution), so I'm attempting to exercise the kubernetes module: from kubernetes import client, config configuration =…
John
  • 727
  • 5
  • 15
0
votes
1 answer

How to apply patch to make pod phase go to Succeeded or Failed?

This is a follow-up from my last question - How to programmatically modify a running k8s pod status conditions? after which I realized, you can only patch the container spec from the deployment manifest to seamlessly let the controller apply the…
Inian
  • 80,270
  • 14
  • 142
  • 161
0
votes
1 answer

How to programmatically modify a running k8s pod status conditions?

I'm trying to modify the running state of my pod, managed by a deployment controller both from command line via kubectl patch and from the k8s python client API. Neither of them seem to work From the command line, I tried both strategic merge match…