Is there a possibility to deploy a kubernetes Pod using golang code instead of command line Linux with kubectl ?
2条回答 默认 最新
dqsvf28682 2018-11-01 18:21关注Yes. Definitely you can. Kubernetes is written in golang. It has official client for go. You can create,delete,patch,list, control almost any Kubernetes resources with this go client.
Here is the official client repository: kubernetes/client-go
I have create a sample repository here to show how to create a pod using
client-go.You have to do following things to create a pod with this client. We are going to create a simple busybox pod.
- Create
configurationusing your kube-config file. Generally the configuration file is$HOME/.kube/configfile. See example here. - Create a
clientsetusing thisconfiguration. See example here. - Now, generate a pod definition that we want to deploy. See example here.
- Finally, create the pod in kubernetes cluster using the
clientset. See example here.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报- Create