#K8s

K8s管理crd和K8SAPI编程

Published at February 11, 2020 ·  10 min read

k8s每个版本看起来兼容性不是太好,很多网上的例子跑起来往往都有问题。 目前用的版本 root@de001:/develop# kubectl version Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2+k3s1", GitCommit:"cdab19b09a84389ffbf57bebd33871c60b1d6b28", GitTreeState:"clean", BuildDate:"2020-01-27T18:09:26Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2+k3s1", GitCommit:"cdab19b09a84389ffbf57bebd33871c60b1d6b28", GitTreeState:"clean", BuildDate:"2020-01-27T18:09:26Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"} 1.编写Spec文档 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the form: <plural>.<group> name: crontabs.chenwen.com spec: # group name to use for REST API: /apis/<group>/<version> group: chenwen.com # list of versions supported by this CustomResourceDefinition versions: - name: v2 # Each version can be enabled/disabled by Served flag....