Is there any REST APIs for native kubectl cmds like apply/delete etc

9/20/2019

I am trying to write an automation script in for deploying some application to azure kubernetes service. So, I need some REST APIs or client libraries that i can use instead of using kubectl native cmds. I can either use C# or Powershell for automation script.

I have found one client library for managing kubernetes cluster with dotnet but it does not seems to support apply/delete cmds. Link

-- Tarun
azure
kubectl
kubernetes

2 Answers

9/21/2019

Azure Kubernetes Service supports deploying Kubernetes applications using Helm charts. Using Helm for automated deployments is a better option.

-- Nilesh Gule
Source: StackOverflow

9/20/2019

kubectl makes API calls to the Kubernetes API server in the background, so I guess you could use any of the official or community-mantained client libraries to achieve what you describe. You can find the list of libraries here.

The apply command can generate a a bunch of different API calls depending on the object it is applied onto, if it is a new object or if it exists already, etc. I think this is the reason you don't find it available on client libraries

Try running kubectl with any of the commands you would like to get into the automation script. For example

kubectl get pods -v=10

You'll see the underlying API calls that are generated

    GET https://172.17.0.45:8443/api/v1/namespaces/default/pods?limit=500 200 OK in 9 milliseconds
    Response Headers:
        Content-Type: application/json
        Content-Length: 3631
        Date: Fri, 20 Sep 2019 20:21:48GMT 
    ...

Maybe a simpler option would be to simply automate via a Powershell script that calls the kubectl native client

-- juancho85
Source: StackOverflow