etcd-operator开源项目

我要开发同款
匿名用户2021年11月26日
47阅读
所属分类Google Go、云计算、云原生
授权协议Apache-2.0 License

作品详情

etcdoperatorProjectstatus:archived

Thisprojectisnolongeractivelydevelopedormaintained.Theprojectexistshereforhistoricalreference.Ifyouareinterestedinthefutureoftheprojectandtakingoverstewardship,pleasecontactetcd-dev@googlegroups.com.

Overview

TheetcdoperatormanagesetcdclustersdeployedtoKubernetesandautomatestasksrelatedtooperatinganetcdcluster.

CreateandDestroyResizeFailoverRollingupgradeBackupandRestore

Therearemorespecexamplesonsettingupclusterswithdifferentconfigurations

ReadBestPracticesformoreinformationonhowtobetteruseetcdoperator.

ReadRBACdocsforhowtosetupRBACrulesforetcdoperatorifRBACisinplace.

ReadDeveloperGuideforsettingupadevelopmentenvironmentifyouwanttocontribute.

SeetheResourcesandLabelsdocforanoverviewoftheresourcescreatedbytheetcd-operator.

RequirementsKubernetes1.8+etcd3.2.13+DemoGettingstarted

Deployetcdoperator

Seeinstructionsonhowtoinstall/uninstalletcdoperator.

Createanddestroyanetcdcluster$kubectlcreate-fexample/example-etcd-cluster.yaml

A3memberetcdclusterwillbecreated.

$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-gxkmr9ql7z1/1Running01mexample-etcd-cluster-m6g62x6mwc1/1Running01mexample-etcd-cluster-rqk62l46kw1/1Running01m

Seeclientserviceforhowtoaccessetcdclusterscreatedbytheoperator.

Ifyouareworkingwithminikubelocally,createanodePortserviceandtestthatetcdisresponding:

$kubectlcreate-fexample/example-etcd-cluster-nodeport-service.json$exportETCDCTL_API=3$exportETCDCTL_ENDPOINTS=$(minikubeserviceexample-etcd-cluster-client-service--url)$etcdctlputfoobar

Destroytheetcdcluster:

$kubectldelete-fexample/example-etcd-cluster.yamlResizeanetcdcluster

Createanetcdcluster:

$kubectlapply-fexample/example-etcd-cluster.yaml

Inexample/example-etcd-cluster.yamltheinitialclustersizeis3.Modifythefileandchangesizefrom3to5.

$catexample/example-etcd-cluster.yamlapiVersion:"etcd.database.coreos.com/v1beta2"kind:"EtcdCluster"metadata:name:"example-etcd-cluster"spec:size:5version:"3.2.13"

ApplythesizechangetotheclusterCR:

$kubectlapply-fexample/example-etcd-cluster.yaml

Theetcdclusterwillscaleto5members(5pods):

$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-cl2gpqsmsw1/1Running05mexample-etcd-cluster-cx2t6v8w781/1Running05mexample-etcd-cluster-gxkmr9ql7z1/1Running07mexample-etcd-cluster-m6g62x6mwc1/1Running07mexample-etcd-cluster-rqk62l46kw1/1Running07m

Similarlywecandecreasethesizeoftheclusterfrom5backto3bychangingthesizefieldagainandreapplyingthechange.

$catexample/example-etcd-cluster.yamlapiVersion:"etcd.database.coreos.com/v1beta2"kind:"EtcdCluster"metadata:name:"example-etcd-cluster"spec:size:3version:"3.2.13"$kubectlapply-fexample/example-etcd-cluster.yaml

Weshouldseethatetcdclusterwilleventuallyreduceto3pods:

$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-cl2gpqsmsw1/1Running06mexample-etcd-cluster-gxkmr9ql7z1/1Running08mexample-etcd-cluster-rqk62l46kw1/1Running09mpFailover

Iftheminorityofetcdmemberscrash,theetcdoperatorwillautomaticallyrecoverthefailure.Let'swalkthroughthisinthefollowingsteps.

Createanetcdcluster:

$kubectlcreate-fexample/example-etcd-cluster.yaml

Waituntilallthreemembersareup.Simulateamemberfailurebydeletingapod:

$kubectldeletepodexample-etcd-cluster-cl2gpqsmsw--now

Theetcdoperatorwillrecoverthefailurebycreatinganewpodexample-etcd-cluster-n4h66wtjrg:

$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-gxkmr9ql7z1/1Running010mexample-etcd-cluster-n4h66wtjrg1/1Running026sexample-etcd-cluster-rqk62l46kw1/1Running010m

Destroyetcdcluster:

$kubectldelete-fexample/example-etcd-cluster.yamletcdoperatorrecovery

Let'swalkthroughoperatorrecoveryinthefollowingsteps.

Createanetcdcluster:

$kubectlcreate-fexample/example-etcd-cluster.yaml

Waituntilallthreemembersareup.Thenstoptheetcdoperatoranddeleteoneoftheetcdpods:

$kubectldelete-fexample/deployment.yamldeployment"etcd-operator"deleted$kubectldeletepodexample-etcd-cluster-8gttjl679c--nowpod"example-etcd-cluster-8gttjl679c"deleted

Nextrestarttheetcdoperator.Itshouldrecoveritselfandtheetcdclustersitmanages.

$kubectlcreate-fexample/deployment.yamldeployment"etcd-operator"created$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-m8gk76l4ns1/1Running03mexample-etcd-cluster-q6mff85hml1/1Running03mexample-etcd-cluster-xnfvm7lg661/1Running011sUpgradeanetcdcluster

Createandhavethefollowingyamlfileready:

$catupgrade-example.yamlapiVersion:"etcd.database.coreos.com/v1beta2"kind:"EtcdCluster"metadata:name:"example-etcd-cluster"spec:size:3version:"3.1.10"repository:"quay.io/coreos/etcd"

Createanetcdclusterwiththeversionspecified(3.1.10)intheyamlfile:

$kubectlapply-fupgrade-example.yaml$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-795649v9kq1/1Running13mexample-etcd-cluster-jtp447ggnq1/1Running14mexample-etcd-cluster-psw7sf2hhr1/1Running14m

Thecontainerimageversionshouldbe3.1.10:

$kubectlgetpodexample-etcd-cluster-795649v9kq-oyaml|grep"image:"|uniqimage:quay.io/coreos/etcd:v3.1.10

Nowmodifythefileupgrade-exampleandchangetheversionfrom3.1.10to3.2.13:

$catupgrade-exampleapiVersion:"etcd.database.coreos.com/v1beta2"kind:"EtcdCluster"metadata:name:"example-etcd-cluster"spec:size:3version:"3.2.13"

ApplytheversionchangetotheclusterCR:

$kubectlapply-fupgrade-example

Wait~30seconds.Thecontainerimageversionshouldbeupdatedtov3.2.13:

$kubectlgetpodexample-etcd-cluster-795649v9kq-oyaml|grep"image:"|uniqimage:gcr.io/etcd-development/etcd:v3.2.13

Checktheothertwopodsandyoushouldseethesameresult.

BackupandRestoreanetcdcluster

Note:Theprovidedetcdbackup/restoreoperatorsareexampleimplementations.

Followtheetcdbackupoperatorwalkthroughtobackupanetcdcluster.

FollowtheetcdrestoreoperatorwalkthroughtorestoreanetcdclusteronKubernetesfrombackup.

Manageetcdclustersinallnamespaces

Seeinstructionsonclusterwidefeature.

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论