How can I remotely call the kube-apiserver command via REST operations?

169 Views Asked by At

There is a command kube-apiserver --feature-gates=APIPriorityAndFairness=true --runtime-config=flowcontrol.apiserver.k8s.io/v1beta1=true,flowcontrol.apiserver.k8s.io/v1beta2=true. But it seems like run on the master machine.

Now I want to remotely call the command in my laptop. I have connected the master machine via kubeconfig already.

Which statement or format of statement should I use to accomplish this function?

2

There are 2 best solutions below

1
Nataraj Medayhal On

Please refer Kubernetes API access documentation how you can programmatically send API requests. Kubernetes supports various mechanisms and various clients in GO, Python, Java etc to send api requests. Below is the sample python code which will list all the pods from all namespaces.

from kubernetes import client, config

config.load_kube_config()

v1=client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
    print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))

Also when follow command is executed "kubectl get pods -v 9" it will give verbose information of rest request which kubectl tool will send to api server, this will help you to understand how to construct the api requests.

0
Wenming Chen On

I don't know if it is a real question.

This command kube-apiserver --feature-gates=APIPriorityAndFairness=true --runtime-config=flowcontrol.apiserver.k8s.io/v1beta1=true,flowcontrol.apiserver.k8s.io/v1beta2=true seems not like kubectl xxx. It's not a service that cluster offers to user to use.

I ssh the master machine to modify some flag or properties of the api-server.