virtual-kubelet开源项目

我要开发同款
匿名用户2021年11月26日
190阅读

技术信息

行业分类
云计算
开源地址
https://github.com/darklife/darkriscv
授权协议
Apache-2.0 License

作品详情

VirtualKubelet

VirtualKubeletisaopesourceKubereteskubeletimplemetatiothatmasqueradesasakubeletforthepurposesofcoectigKuberetestootherAPIs.ThisallowstheodestobebackedbyotherserviceslikeACI,AWSFargate,IoTEdge,TesileKubeetc.TheprimaryscearioforVKiseabligtheextesiooftheKuberetesAPIitoserverlesscotaierplatformslikeACIadFargate,thoughweareopetoothers.However,itshouldbeotedthatVKisexplicitlyotitededtobeaalterativetoKuberetesfederatio.

VirtualKubeletfeaturesapluggablearchitectureaddirectuseofKuberetesprimitives,makigitmucheasiertobuildo.

WeivitetheKuberetesecosystemtojoiusiempowerigdeveloperstobuildupoourbase.Joiourslackchaelamed,virtual-kubelet,withitheKuberetesslackgroup.

Thebestdescriptiois"KuberetesAPIotop,programmableback."

TableofCotetsHowItWorksUsageProvidersAdmiraltyMulti-ClusterSchedulerAlibabaCloudECIProviderAzureCotaierIstacesProviderAzureBatchGPUProviderAWSFargateProviderElotlKipHashiCorpNomadLiqoOpeStackZuTesileKubeProviderAddigaNewProviderviatheProviderIterfaceTestigUittestsEd-to-edtestsKowquirksadworkaroudsCotributigHowItWorks

ThediagrambelowillustrateshowVirtual-Kubeletworks.

Usage

VirtualKubeletisfocusedoprovidigalibrarythatyoucacosumeiyourprojecttobuildacustomKuberetesodeaget.

Seegodocforuptodateistructiosocosumigthisproject:https://godoc.org/github.com/virtual-kubelet/virtual-kubelet

Thereareimplemetatiosavailableforseveralproviders,seethosereposfordetailsohowtodeploy.

CurretFeaturescreate,deleteadupdatepodscotaierlogs,exec,admetricsgetpod,podsadpodstatuscapacityodeaddresses,odecapacity,odedaemoedpoitsoperatigsystembrigyourowvirtualetworkProviders

Thisprojectfeaturesapluggableprovideriterfacedeveloperscaimplemetthatdefiestheactiosofatypicalkubelet.

Thiseableso-demadadearlyistataeouscotaiercompute,orchestratedbyKuberetes,withouthavigVMifrastructuretomaageadwhilestillleveragigtheportableKuberetesAPI.

Eachprovidermayhaveitsowcofiguratiofile,adrequiredevirometalvariables.

ProvidersmustprovidethefollowigfuctioalitytobecosideredasupporteditegratiowithVirtualKubelet.

Providestheback-edplumbigecessarytosupportthelifecyclemaagemetofpods,cotaiersadsupportigresourcesithecotextofKuberetes.CoformstothecurretAPIprovidedbyVirtualKubelet.DoesothaveaccesstotheKuberetesAPIServeradhasawell-defiedcallbackmechaismforgettigdatalikesecretsorcofigmaps.AdmiraltyMulti-ClusterScheduler

AdmiraltyMulti-ClusterSchedulermutatesaotatedpodsito"proxypods"scheduledoavirtual-kubeletodeadcreatescorrespodig"delegatepods"iremoteclusters(actuallyruigthecotaiers).Afeedbackloopupdatesthestatusesadaotatiosoftheproxypodstoreflectthestatusesadaotatiosofthedelegatepods.YoucafidmoredetailsitheAdmiraltyMulti-ClusterSchedulerdocumetatio.

AlibabaCloudECIProvider

AlibabaCloudECI(ElasticCotaierIstace)isaservicethatallowyourucotaierswithouthavigtomaageserversorclusters.

YoucafidmoredetailsitheAlibabaCloudECIproviderdocumetatio.

CofiguratioFile

ThealibabaECIproviderwillreadcofiguratiofilespecifiedbythe--provider-cofigflag.

TheexamplecofigurefileisitheECIproviderrepository.

AzureCotaierIstacesProvider

TheAzureCotaierIstacesProviderallowsyoutoutilizebothtypicalpodsoVMsadAzureCotaieristacessimultaeouslyithesameKuberetescluster.

YoucafiddetailedistructiosohowtosetitupadhowtotestititheAzureCotaierIstacesProviderdocumetatio.

CofiguratioFile

TheAzurecoectorcauseacofiguratiofilespecifiedbythe--provider-cofigflag.ThecofigfileisiTOMLformat,adaexamplelivesiproviders/azure/example.toml.

AWSFargateProvider

AWSFargateisatechologythatallowsyoutorucotaierswithouthavigtomaageserversorclusters.

TheAWSFargateproviderallowsyoutodeploypodstoAWSFargate.YourpodsoAWSFargatehaveaccesstoVPCetworkigwithdedicatedENIsiyoursubets,publicIPaddressestocoecttotheiteret,privateIPaddressestocoecttoyourKuberetescluster,securitygroups,IAMroles,CloudWatchLogsadmayotherAWSservices.PodsoFargatecaco-existwithpodsoregularworkerodesithesameKuberetescluster.

EasyistructiosadasamplecofiguratiofileisavailableitheAWSFargateproviderdocumetatio.Pleaseotethatthisproviderisotcurretlysupported.

ElotlKip

Kipisaproviderthatruspodsicloudistaces,allowigaKuberetesclustertotrasparetlyscaleworkloadsitoacloud.Wheapodisscheduledotothevirtualode,Kipstartsaright-sizedcloudistaceforthepod'sworkloadaddispatchesthepodototheistace.Whethepodisfiishedruig,thecloudistaceistermiated.

WheworkloadsruoKip,yourclustersizeaturallyscaleswiththeclusterworkload,podsarestroglyisolatedfromeachotheradtheuserisfreedfrommaagigworkerodesadstrategicallypackigpodsotoodes.

HashiCorpNomadProvider

HashiCorpNomadproviderforVirtualKubeletcoectsyourKuberetesclusterwithNomadclusterbyexposigtheNomadclusterasaodeiKuberetes.Byusigtheprovider,podsthatarescheduledothevirtualNomadoderegisteredoKubereteswillruasjobsoNomadclietsastheywouldoaKuberetesode.

Fordetailedistructios,followtheguidehere.

LiqoProvider

LiqoimplemetsaproviderforVirtualKubeletdesigedtotrasparetlyoffloadpodsadservicesto"peered"Kuberetesremotecluster.Liqoiscapableofdiscoverigeighborclusters(usigDNS,mDNS)ad"peer"withthem,oriotherwords,establisharelatioshiptosharepartoftheclusterresources.Wheaclusterhasestablishedapeerig,aewistaceoftheLiqoVirtualKubeletisspawedtoseamlesslyextedthecapacityofthecluster,byprovidigaabstractiooftheresourcesoftheremotecluster.TheprovidercombiedwiththeLiqoetworkfabricextedstheclusteretworkigbyeabligPod-to-Podtrafficadmulti-clustereast-westservices,supportigedpoitsobothclusters.

Fordetailedistructio,followtheguidehere

OpeStackZuProvider

OpeStackZuproviderforVirtualKubeletcoectsyourKuberetesclusterwithOpeStackiordertoruKuberetespodsoOpeStackCloud.YourpodsoOpeStackhaveaccesstoOpeStackteatetworksbecausetheyhaveNeutroportsiyoursubets.EachpodwillhaveprivateIPaddressestocoecttootherOpeStackresources(i.e.VMs)withiyourteat,optioallyhavefloatigIPaddressestocoecttotheiteret,adbid-moutCidervolumesitoapathisideapod'scotaier.

./bi/virtual-kubelet--provider="opestack"

Fordetailedistructios,followtheguidehere.

TesileKubeProvider

Tesilekubeiscotributedbytecetgames,whichisproviderforVirtualKubeletcoectsyourKuberetesclusterwithotherKuberetesclusters.ThisprovidereablesusextedigKuberetestoaulimitedoe.Byusigtheprovider,podsthatarescheduledothevirtualoderegisteredoKubereteswillruasjobsootherKuberetesclusters'odes.

AddigaNewProviderviatheProviderIterface

ProviderscosumethisprojectasalibrarywhichimplemetsthecorelogicofaKuberetesodeaget(Kubelet),adwireuptheirimplemetatioforperformigtheeccessaryactios.

Thereare3maiiterfaces:

PodLifecylceHadler

Whepodsarecreated,updated,ordeletedfromKuberetes,thesemethodsarecalledtohadlethoseactios.

godoc#PodLifecylceHadler

typePodLifecycleHadleriterface{//CreatePodtakesaKuberetesPodaddeploysitwithitheprovider.CreatePod(ctxcotext.Cotext,pod*corev1.Pod)error//UpdatePodtakesaKuberetesPodadupdatesitwithitheprovider.UpdatePod(ctxcotext.Cotext,pod*corev1.Pod)error//DeletePodtakesaKuberetesPodaddeletesitfromtheprovider.DeletePod(ctxcotext.Cotext,pod*corev1.Pod)error//GetPodretrievesapodbyamefromtheprovider(cabecached).GetPod(ctxcotext.Cotext,amespace,amestrig)(*corev1.Pod,error)//GetPodStatusretrievesthestatusofapodbyamefromtheprovider.GetPodStatus(ctxcotext.Cotext,amespace,amestrig)(*corev1.PodStatus,error)//GetPodsretrievesalistofallpodsruigotheprovider(cabecached).GetPods(cotext.Cotext)([]*corev1.Pod,error)}

ThereisalsoaoptioaliterfacePodNotifierwhicheablestheprovidertoasychroouslyotifythevirtual-kubeletaboutpodstatuschages.Ifthisiterfaceisotimplemeted,virtual-kubeletwillperiodicallycheckthestatusofallpods.

ItishighlyrecommededtoimplemetPodNotifier,especiallyifyouplatorualargeumberofpods.

godoc#PodNotifier

typePodNotifieriterface{//NotifyPodsistructstheotifiertocallthepassedifuctiowhe//thepodstatuschages.////NotifyPodsshouldotblockcallers.NotifyPods(cotext.Cotext,fuc(*corev1.Pod))}

PodLifecycleHadleriscosumedbythePodCotrollerwhichisthecorelogicformaagigpodsassigedtotheode.

pc,_:=ode.NewPodCotroller(podCotrollerCofig)//<--istatiatesthepodcotrollerpc.Ru(ctx)//<--startswatchigforpodstobescheduledotheodeNodeProvider

NodeProviderisresposibleforotifyigthevirtual-kubeletaboutodestatusupdates.Virtual-KubeletwillperiodicallycheckthestatusoftheodeadupdateKuberetesaccordigly.

godoc#NodeProvider

typeNodeProvideriterface{//Pigchecksiftheodeisstillactive.//Thisisitededtobelightweightasitwillbecalledperiodicallyasa//heartbeattokeeptheodemarkedasreadyiKuberetes.Pig(cotext.Cotext)error//NotifyNodeStatusisusedtoasychroouslymoitortheode.//Thepassedicallbackshouldbecalledaytimethereisachagetothe//ode'sstatus.//ThiswillgeerallytriggeracalltotheKuberetesAPIservertoupdate//thestatus.////NotifyNodeStatusshouldotblockcallers.NotifyNodeStatus(ctxcotext.Cotext,cbfuc(*corev1.Node))}

VirtualKubeletprovidesaNaiveNodeProviderthatyoucauseifyoudootplatohavecustomodebehavior.

godoc#NaiveNodeProvider

NodeProvidergetscosumedbytheNodeCotroller,whichiscorelogicformaagigtheodeobjectiKuberetes.

c,_:=ode.NewNodeCotroller(odeProvider,odeSpec)//<--istatiateaodecotrollerfromaodeprovideradakuberetesodespecc.Ru(ctx)//<--createstheodeikuberetesadstartsuphecotrollerAPIedpoits

OeoftherolesofaKubeletistoacceptrequestsfromtheAPIserverforthigslikekubectllogsadkubectlexec.Helpersforsettigthisupareprovidedhere

TestigUittests

Ruigtheuittestslocallyisassimpleasmaketest.

Ed-to-edtests

Checkouttest/e2eformoredetails.

KowquirksadworkaroudsMissigLoadBalacerIPaddressesforservicesProvidersthatdootsupportservicediscovery

Kuberetes1.9itroducesaewflag,ServiceNodeExclusio,forthecotrolplae'sCotrollerMaager.EabligthisflagitheCotrollerMaager'smaifestallowsKuberetestoexcludeVirtualKubeletodesfrombeigaddedtoLoadBalacerpools,allowigyoutocreatepublicfacigserviceswithexteralIPswithoutissue.

Workaroud

Clusterrequiremets:Kuberetes1.9orabove

EabletheServiceNodeExclusioflag,bymodifyigtheCotrollerMaagermaifestadaddig--feature-gates=ServiceNodeExclusio=truetothecommadlieargumets.

Cotributig

VirtualKubeletfollowstheCNCFCodeofCoduct.SigtheCNCFCLAtobeabletomakePullRequeststothisrepo.

MothlyVirtualKubeletOfficeHoursareheldat10amPSTothelastThursdayofeverymothithiszoommeetigroom.Checkoutthecaledarhere.

Ourgoogledrivewithdesigspecificatiosadmeetigotesarehere.

Wealsohaveacommuityslackchaelamedvirtual-kubeletitheKuberetesslack.YoucaalsocoectwiththeVirtualKubeletcommuityviathemailiglist.

功能介绍

Virtual Kubelet Virtual Kubelet is an open source Kubernetes kubelet implementation that masquera...

示例图片

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

评论