看一下k8s operator
etcd -operator
通过Kubernetes API观察etcd集群的当前状态
分析当前状态与期望状态的差别
调用etcd集群管理API或kubernetes API消除这些差别
安装operator-sdk
git clone https://github.com/operator-framework/operator-sdk
make dep&make install
mac电脑:brew install operator-sdk
windows安装参考https://cloud.tencent.com/developer/article/1585177
开发operator需要push到公共镜像上去
搭建docker registry
docker run -d -p 5000:5000 --restart always --name registry -v ~/docker-data/docker_registry:/var/lib/registry registry:2
docker run -d(后台启动) -p(端口号) 5000(宿主机):5000(docker镜像端口号) --restart always (重启策略)--name(docker镜像名字) registry -v(push的docker镜像存在本地)~/docker-data/docker_registry(本机目录):/var/lib/registry registry:2
"insecure-registries":["mock.com:5000"]
查看镜像:http://mock.com:5000/v2/_catalog
docker logs -f --tail=30 registry(查看最后的30行)
开发operator准备
git clone https://github.com/kubernetes/kubernetes.git
cp -R kubernetes/staging/src/k8s.io k8s.io
mkdir $GOPATH/src/sigs.k8s.io 在此目录下clone controller-runtime
git clone https://github.com/kubernetes-sigs/controller-runtime
k8s.io(github上k8s.io文件夹)
新建operator
operator-sdk new imoocpod-operator --skip-validation=true --repo=github.com/imooc-com/imoocpod-operator
operator-sdk new imoocpod-operator --skip-validation=true(跳过校验) --repo=github.com/wenchajun/imoocpod-operator(地址)
snap install tree创建tree视图
再输入tree就可以看到树形图了
然后就生成了一个operator项目
网友评论