Thisprojectisnolongeractivelydevelopedormaintained.Theprojectexistshereforhistoricalreference.Ifyouareinterestedinthefutureoftheprojectandtakingoverstewardship,pleasecontactetcd-dev@googlegroups.com.
OverviewTheetcdoperatormanagesetcdclustersdeployedtoKubernetesandautomatestasksrelatedtooperatinganetcdcluster.
CreateandDestroyResizeFailoverRollingupgradeBackupandRestoreTherearemorespecexamplesonsettingupclusterswithdifferentconfigurations
ReadBestPracticesformoreinformationonhowtobetteruseetcdoperator.
ReadRBACdocsforhowtosetupRBACrulesforetcdoperatorifRBACisinplace.
ReadDeveloperGuideforsettingupadevelopmentenvironmentifyouwanttocontribute.
SeetheResourcesandLabelsdocforanoverviewoftheresourcescreatedbytheetcd-operator.
RequirementsKubernetes1.8+etcd3.2.13+DemoGettingstartedDeployetcdoperatorSeeinstructionsonhowtoinstall/uninstalletcdoperator.
Createanddestroyanetcdcluster$kubectlcreate-fexample/example-etcd-cluster.yamlA3memberetcdclusterwillbecreated.
$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-gxkmr9ql7z1/1Running01mexample-etcd-cluster-m6g62x6mwc1/1Running01mexample-etcd-cluster-rqk62l46kw1/1Running01mSeeclientserviceforhowtoaccessetcdclusterscreatedbytheoperator.
Ifyouareworkingwithminikubelocally,createanodePortserviceandtestthatetcdisresponding:
$kubectlcreate-fexample/example-etcd-cluster-nodeport-service.json$exportETCDCTL_API=3$exportETCDCTL_ENDPOINTS=$(minikubeserviceexample-etcd-cluster-client-service--url)$etcdctlputfoobarDestroytheetcdcluster:
$kubectldelete-fexample/example-etcd-cluster.yamlResizeanetcdclusterCreateanetcdcluster:
$kubectlapply-fexample/example-etcd-cluster.yamlInexample/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.yamlTheetcdclusterwillscaleto5members(5pods):
$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-cl2gpqsmsw1/1Running05mexample-etcd-cluster-cx2t6v8w781/1Running05mexample-etcd-cluster-gxkmr9ql7z1/1Running07mexample-etcd-cluster-m6g62x6mwc1/1Running07mexample-etcd-cluster-rqk62l46kw1/1Running07mSimilarlywecandecreasethesizeoftheclusterfrom5backto3bychangingthesizefieldagainandreapplyingthechange.
$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.yamlWeshouldseethatetcdclusterwilleventuallyreduceto3pods:
$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-cl2gpqsmsw1/1Running06mexample-etcd-cluster-gxkmr9ql7z1/1Running08mexample-etcd-cluster-rqk62l46kw1/1Running09mpFailoverIftheminorityofetcdmemberscrash,theetcdoperatorwillautomaticallyrecoverthefailure.Let'swalkthroughthisinthefollowingsteps.
Createanetcdcluster:
$kubectlcreate-fexample/example-etcd-cluster.yamlWaituntilallthreemembersareup.Simulateamemberfailurebydeletingapod:
$kubectldeletepodexample-etcd-cluster-cl2gpqsmsw--nowTheetcdoperatorwillrecoverthefailurebycreatinganewpodexample-etcd-cluster-n4h66wtjrg:
$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-gxkmr9ql7z1/1Running010mexample-etcd-cluster-n4h66wtjrg1/1Running026sexample-etcd-cluster-rqk62l46kw1/1Running010mDestroyetcdcluster:
$kubectldelete-fexample/example-etcd-cluster.yamletcdoperatorrecoveryLet'swalkthroughoperatorrecoveryinthefollowingsteps.
Createanetcdcluster:
$kubectlcreate-fexample/example-etcd-cluster.yamlWaituntilallthreemembersareup.Thenstoptheetcdoperatoranddeleteoneoftheetcdpods:
$kubectldelete-fexample/deployment.yamldeployment"etcd-operator"deleted$kubectldeletepodexample-etcd-cluster-8gttjl679c--nowpod"example-etcd-cluster-8gttjl679c"deletedNextrestarttheetcdoperator.Itshouldrecoveritselfandtheetcdclustersitmanages.
$kubectlcreate-fexample/deployment.yamldeployment"etcd-operator"created$kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEexample-etcd-cluster-m8gk76l4ns1/1Running03mexample-etcd-cluster-q6mff85hml1/1Running03mexample-etcd-cluster-xnfvm7lg661/1Running011sUpgradeanetcdclusterCreateandhavethefollowingyamlfileready:
$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/1Running14mThecontainerimageversionshouldbe3.1.10:
$kubectlgetpodexample-etcd-cluster-795649v9kq-oyaml|grep"image:"|uniqimage:quay.io/coreos/etcd:v3.1.10Nowmodifythefileupgrade-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-exampleWait~30seconds.Thecontainerimageversionshouldbeupdatedtov3.2.13:
$kubectlgetpodexample-etcd-cluster-795649v9kq-oyaml|grep"image:"|uniqimage:gcr.io/etcd-development/etcd:v3.2.13Checktheothertwopodsandyoushouldseethesameresult.
BackupandRestoreanetcdclusterNote:Theprovidedetcdbackup/restoreoperatorsareexampleimplementations.
Followtheetcdbackupoperatorwalkthroughtobackupanetcdcluster.
FollowtheetcdrestoreoperatorwalkthroughtorestoreanetcdclusteronKubernetesfrombackup.
ManageetcdclustersinallnamespacesSeeinstructionsonclusterwidefeature.
评论