VirtualKubelet
VirtualKubeletisaopesourceKubereteskubeletimplemetatiothatmasqueradesasakubeletforthepurposesofcoectigKuberetestootherAPIs.ThisallowstheodestobebackedbyotherserviceslikeACI,AWSFargate,IoTEdge,TesileKubeetc.TheprimaryscearioforVKiseabligtheextesiooftheKuberetesAPIitoserverlesscotaierplatformslikeACIadFargate,thoughweareopetoothers.However,itshouldbeotedthatVKisexplicitlyotitededtobeaalterativetoKuberetesfederatio.
VirtualKubeletfeaturesapluggablearchitectureaddirectuseofKuberetesprimitives,makigitmucheasiertobuildo.
WeivitetheKuberetesecosystemtojoiusiempowerigdeveloperstobuildupoourbase.Joiourslackchaelamed,virtual-kubelet,withitheKuberetesslackgroup.
Thebestdescriptiois"KuberetesAPIotop,programmableback."
TableofCotetsHowItWorksUsageProvidersAdmiraltyMulti-ClusterSchedulerAlibabaCloudECIProviderAzureCotaierIstacesProviderAzureBatchGPUProviderAWSFargateProviderElotlKipHashiCorpNomadLiqoOpeStackZuTesileKubeProviderAddigaNewProviderviatheProviderIterfaceTestigUittestsEd-to-edtestsKowquirksadworkaroudsCotributigHowItWorksThediagrambelowillustrateshowVirtual-Kubeletworks.
UsageVirtualKubeletisfocusedoprovidigalibrarythatyoucacosumeiyourprojecttobuildacustomKuberetesodeaget.
Seegodocforuptodateistructiosocosumigthisproject:https://godoc.org/github.com/virtual-kubelet/virtual-kubelet
Thereareimplemetatiosavailableforseveralproviders,seethosereposfordetailsohowtodeploy.
CurretFeaturescreate,deleteadupdatepodscotaierlogs,exec,admetricsgetpod,podsadpodstatuscapacityodeaddresses,odecapacity,odedaemoedpoitsoperatigsystembrigyourowvirtualetworkProvidersThisprojectfeaturesapluggableprovideriterfacedeveloperscaimplemetthatdefiestheactiosofatypicalkubelet.
Thiseableso-demadadearlyistataeouscotaiercompute,orchestratedbyKuberetes,withouthavigVMifrastructuretomaageadwhilestillleveragigtheportableKuberetesAPI.
Eachprovidermayhaveitsowcofiguratiofile,adrequiredevirometalvariables.
ProvidersmustprovidethefollowigfuctioalitytobecosideredasupporteditegratiowithVirtualKubelet.
Providestheback-edplumbigecessarytosupportthelifecyclemaagemetofpods,cotaiersadsupportigresourcesithecotextofKuberetes.CoformstothecurretAPIprovidedbyVirtualKubelet.DoesothaveaccesstotheKuberetesAPIServeradhasawell-defiedcallbackmechaismforgettigdatalikesecretsorcofigmaps.AdmiraltyMulti-ClusterSchedulerAdmiraltyMulti-ClusterSchedulermutatesaotatedpodsito"proxypods"scheduledoavirtual-kubeletodeadcreatescorrespodig"delegatepods"iremoteclusters(actuallyruigthecotaiers).Afeedbackloopupdatesthestatusesadaotatiosoftheproxypodstoreflectthestatusesadaotatiosofthedelegatepods.YoucafidmoredetailsitheAdmiraltyMulti-ClusterSchedulerdocumetatio.
AlibabaCloudECIProviderAlibabaCloudECI(ElasticCotaierIstace)isaservicethatallowyourucotaierswithouthavigtomaageserversorclusters.
YoucafidmoredetailsitheAlibabaCloudECIproviderdocumetatio.
CofiguratioFileThealibabaECIproviderwillreadcofiguratiofilespecifiedbythe--provider-cofigflag.
TheexamplecofigurefileisitheECIproviderrepository.
AzureCotaierIstacesProviderTheAzureCotaierIstacesProviderallowsyoutoutilizebothtypicalpodsoVMsadAzureCotaieristacessimultaeouslyithesameKuberetescluster.
YoucafiddetailedistructiosohowtosetitupadhowtotestititheAzureCotaierIstacesProviderdocumetatio.
CofiguratioFileTheAzurecoectorcauseacofiguratiofilespecifiedbythe--provider-cofigflag.ThecofigfileisiTOMLformat,adaexamplelivesiproviders/azure/example.toml.
AWSFargateProviderAWSFargateisatechologythatallowsyoutorucotaierswithouthavigtomaageserversorclusters.
TheAWSFargateproviderallowsyoutodeploypodstoAWSFargate.YourpodsoAWSFargatehaveaccesstoVPCetworkigwithdedicatedENIsiyoursubets,publicIPaddressestocoecttotheiteret,privateIPaddressestocoecttoyourKuberetescluster,securitygroups,IAMroles,CloudWatchLogsadmayotherAWSservices.PodsoFargatecaco-existwithpodsoregularworkerodesithesameKuberetescluster.
EasyistructiosadasamplecofiguratiofileisavailableitheAWSFargateproviderdocumetatio.Pleaseotethatthisproviderisotcurretlysupported.
ElotlKipKipisaproviderthatruspodsicloudistaces,allowigaKuberetesclustertotrasparetlyscaleworkloadsitoacloud.Wheapodisscheduledotothevirtualode,Kipstartsaright-sizedcloudistaceforthepod'sworkloadaddispatchesthepodototheistace.Whethepodisfiishedruig,thecloudistaceistermiated.
WheworkloadsruoKip,yourclustersizeaturallyscaleswiththeclusterworkload,podsarestroglyisolatedfromeachotheradtheuserisfreedfrommaagigworkerodesadstrategicallypackigpodsotoodes.
HashiCorpNomadProviderHashiCorpNomadproviderforVirtualKubeletcoectsyourKuberetesclusterwithNomadclusterbyexposigtheNomadclusterasaodeiKuberetes.Byusigtheprovider,podsthatarescheduledothevirtualNomadoderegisteredoKubereteswillruasjobsoNomadclietsastheywouldoaKuberetesode.
Fordetailedistructios,followtheguidehere.
LiqoProviderLiqoimplemetsaproviderforVirtualKubeletdesigedtotrasparetlyoffloadpodsadservicesto"peered"Kuberetesremotecluster.Liqoiscapableofdiscoverigeighborclusters(usigDNS,mDNS)ad"peer"withthem,oriotherwords,establisharelatioshiptosharepartoftheclusterresources.Wheaclusterhasestablishedapeerig,aewistaceoftheLiqoVirtualKubeletisspawedtoseamlesslyextedthecapacityofthecluster,byprovidigaabstractiooftheresourcesoftheremotecluster.TheprovidercombiedwiththeLiqoetworkfabricextedstheclusteretworkigbyeabligPod-to-Podtrafficadmulti-clustereast-westservices,supportigedpoitsobothclusters.
Fordetailedistructio,followtheguidehere
OpeStackZuProviderOpeStackZuproviderforVirtualKubeletcoectsyourKuberetesclusterwithOpeStackiordertoruKuberetespodsoOpeStackCloud.YourpodsoOpeStackhaveaccesstoOpeStackteatetworksbecausetheyhaveNeutroportsiyoursubets.EachpodwillhaveprivateIPaddressestocoecttootherOpeStackresources(i.e.VMs)withiyourteat,optioallyhavefloatigIPaddressestocoecttotheiteret,adbid-moutCidervolumesitoapathisideapod'scotaier.
./bi/virtual-kubelet--provider="opestack"Fordetailedistructios,followtheguidehere.
TesileKubeProviderTesilekubeiscotributedbytecetgames,whichisproviderforVirtualKubeletcoectsyourKuberetesclusterwithotherKuberetesclusters.ThisprovidereablesusextedigKuberetestoaulimitedoe.Byusigtheprovider,podsthatarescheduledothevirtualoderegisteredoKubereteswillruasjobsootherKuberetesclusters'odes.
AddigaNewProviderviatheProviderIterfaceProviderscosumethisprojectasalibrarywhichimplemetsthecorelogicofaKuberetesodeaget(Kubelet),adwireuptheirimplemetatioforperformigtheeccessaryactios.
Thereare3maiiterfaces:
PodLifecylceHadlerWhepodsarecreated,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)//<--startswatchigforpodstobescheduledotheodeNodeProviderNodeProviderisresposibleforotifyigthevirtual-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)//<--createstheodeikuberetesadstartsuphecotrollerAPIedpoitsOeoftherolesofaKubeletistoacceptrequestsfromtheAPIserverforthigslikekubectllogsadkubectlexec.Helpersforsettigthisupareprovidedhere
TestigUittestsRuigtheuittestslocallyisassimpleasmaketest.
Ed-to-edtestsCheckouttest/e2eformoredetails.
KowquirksadworkaroudsMissigLoadBalacerIPaddressesforservicesProvidersthatdootsupportservicediscoveryKuberetes1.9itroducesaewflag,ServiceNodeExclusio,forthecotrolplae'sCotrollerMaager.EabligthisflagitheCotrollerMaager'smaifestallowsKuberetestoexcludeVirtualKubeletodesfrombeigaddedtoLoadBalacerpools,allowigyoutocreatepublicfacigserviceswithexteralIPswithoutissue.
WorkaroudClusterrequiremets:Kuberetes1.9orabove
EabletheServiceNodeExclusioflag,bymodifyigtheCotrollerMaagermaifestadaddig--feature-gates=ServiceNodeExclusio=truetothecommadlieargumets.
CotributigVirtualKubeletfollowstheCNCFCodeofCoduct.SigtheCNCFCLAtobeabletomakePullRequeststothisrepo.
MothlyVirtualKubeletOfficeHoursareheldat10amPSTothelastThursdayofeverymothithiszoommeetigroom.Checkoutthecaledarhere.
Ourgoogledrivewithdesigspecificatiosadmeetigotesarehere.
Wealsohaveacommuityslackchaelamedvirtual-kubeletitheKuberetesslack.YoucaalsocoectwiththeVirtualKubeletcommuityviathemailiglist.










评论