Search code examples
javakuberneteskubectl

Kubernetes-client API to run and expose a docker image


I'm having trouble finding an easy way to automate the following kubectl command lines using Kubernetes-client Java API :

$ kubectl run foo --image=bar/baz:v1 --port 8080

$ kubectl expose deployment foo --type=LoadBalancer --port 80 --target-port 8080

The first one runs a docker image on port 8080 and the second one defines it as a load balancer and expose it to port 80.


Solution

  • Adding -v=9 shows the API requests made by those commands