I want to create a service in Java which will take a yaml file and create whatever object is in there on a Kubernetes cluster.
Somewhat like how kubectl create -f file.yaml
does.
The yaml file can contain a pod, service or deployment.
Can this be done in either official Kubernetes Java Client or fabric8 Kubernetes Java Client? How can it be achieved?
You can use Kubernetes REST API
Example create new deployment:
curl -X POST -d @deployment.json -H "Content-Type: application/json" -H "Authorization: Bearer ${ACCESS_TOKEN}" ${API}/apis/extensions/v1beta1/namespaces/${namespace}/deployments