Questions tagged [kubernetes-python-client]

93 questions
3
votes
1 answer

How to edit/patch kubernetes deployment to add label using python

I am fairly new to kubernetes - I have developed web UI/API that automates model deployment using Azure Machine Learning Services to Azure Kubernetes Services (AKS). As a hardening measure, I am tying to set up managed identity for deployed pods in…
3
votes
2 answers

Cannot patch Kubernetes node using python kubernetes-client library

I'm trying to patch a kube node using the Python kubernetes-client library. Specifically, I'm trying to cordon the node. Using kubectl, I'm able to do it successfully: kubectl patch node mynode -json --patch={"op":"replace",…
SiHa
  • 7,830
  • 13
  • 34
  • 43
3
votes
1 answer

How to watch/verify pod eviction call is complete with python client?

Using the python client, I've written a function to evict all pods on a node. How can i monitor/watch for all pods to be fully evicted? I'm using the create_namespaced_pod_eviction method to evict all pods on a single node. While this works, it…
N. Alston
  • 61
  • 3
3
votes
1 answer

Use python client to create Kubernetes CronJob from yaml

I am trying to use the K8S python client to create a bunch of cronjobs on my cluster. I can't seem to find a create_from_yaml for cornjobs or any resources other than deployments for that matter. What I want to do is: from kubernetes import client,…
cookiedough
  • 3,552
  • 2
  • 26
  • 51
3
votes
1 answer

Token generated for GKE auth is missing privileges

I try to create roles in an automated way in Google Kubernetes (GKE). For that, I use the python client library, but I don't want to have any dependency to kubectl and kubeconfig, or gcloud, I use a service account (with a json key file from GCP)…
3
votes
2 answers

How to control a SparkApplication programatically using the python kubernetes client?

I'd like to submit a SparkApplication to a Kubernetes cluster programmatically from python. A job definition job.yaml like this apiVersion: sparkoperator.k8s.io/v1beta1 kind: SparkApplication metadata: name: my-test namespace: default spec: …
3
votes
1 answer

kubectl cp in kubernetes python client

I have been trying to convert kubectl cp command to it's equivalent kubernetes python client program. I have following code for that: from kubernetes import client, config from kubernetes.stream import stream import tarfile from tempfile import…
Prafull Ladha
  • 12,341
  • 2
  • 37
  • 58
3
votes
3 answers

Why shouldn't you run Kubernetes pods for longer than an hour from Composer?

The Cloud Composer documentation explicitly states that: Due to an issue with the Kubernetes Python client library, your Kubernetes pods should be designed to take no more than an hour to run. However, it doesn't provide any more context than…
3
votes
0 answers

python kubernetes api connection unauthorized 401

I'm having trouble connecting to the python kubernetes client, but I'm getting this 404 url not found error when I run curl -k https://ip-address:30000/pods which is an endpoint I wrote to connect to kubernetes & list pods. I'm running this locally…
helloworld
  • 399
  • 3
  • 9
  • 21
3
votes
1 answer

Get Service selectors with K8s Python client

I am trying to get Service label selectors through Kubernetes Python Client. I am using list_service_for_all_namespaces method to retrieve the services, and filter it with field_selector parameter like: ... field_selector="spec.selector={u'app':…
suren
  • 7,817
  • 1
  • 30
  • 51
3
votes
0 answers

Unable to authenticate with Kubernetes python client?

I'm running a simple script that calls into kubernetes via the python client: from kubernetes import client, config # Configs can be set in Configuration class directly or using helper utility config.load_kube_config() v1 =…
2
votes
1 answer

How to get billing cost of GCP project using python

I am trying to get billing cost of GCP project, but I could not see expected result for the client library that I am using in my code. I want to get report or spend cost for current month, but it just providing me: project_id:…
2
votes
0 answers

Python Kubernetes MaxRetryError

I am trying to use Kubernetes in a django app in my PC (Ubuntu 20.04 LTS) but after going through a lot of different errors I went and tried a simple example (Deploy Pod from YAML file) from the kubernetes python library. Even though the example is…
Francisco
  • 31
  • 4
2
votes
1 answer

Why am I getting "401 unauthorized" sometimes in gcloud API on GKE?

I have a google kubernetes cluster running and I am trying to manually scale some pods with the python-client kubernetes SDK. I use the following command on my terminal to get my google account credentials: gcloud auth login Next, I connect to my…
2
votes
1 answer

Kubernetes Python Client : update deployment spec with affinity

from kubernetes import client, config config.load_kube_config() api = client.AppsV1Api() deployment = api.read_namespaced_deployment(name='foo', namespace='bar') i tried to add affinity object to deployment spec i got this…