Ngenye imini, ngexesha lohlaziyo olucwangcisiweyo lweqela le-k8s, safumanisa ukuba phantse zonke iiPOD zethu (malunga nama-500 kwi-1,000) kwiindawo ezintsha azikwazanga ukuqalisa, kwaye imizuzu yakhawuleza yajika yaba ziiyure. Sikhangelwa ngenkuthalo oyena nobangela, kodwa emva kweeyure ezintathu, ii-PODS zazisekwimeko ye ContainerCreating
.
Okuvuyisayo kukuba, le ibingeyiyo imeko yemveliso kwaye ifestile yolondolozo yayicwangciselwe ngempelaveki. Saba nexesha lokuphanda ngalo mba ngaphandle koxinzelelo.
Kufuneka uqale phi ukukhangela oyena nobangela? Ngaba ungathanda ukufunda ngakumbi ngesicombululo esisifumeneyo? Xhuma kwaye wonwabe!
Ingxaki yayikukuba sinenani elikhulu lemifanekiso ye-docker efuna ukutsalwa kwaye iqale kwindawo nganye kwiqela ngexesha elinye. Oku kungenxa yokuba i-docker ye-docker yemifanekiso emininzi itsalwa kwindawo enye inokukhokelela ekusebenziseni idisk ephezulu kunye namaxesha okuqala okubandayo.
Ixesha nexesha, inkqubo yeCD ithatha ukuya kwiiyure ezi-3 ukutsala imifanekiso. Nangona kunjalo, ngeli xesha lalibambekile ngokupheleleyo, kuba inani le-PODS ngexesha lokuphucula i-EKS (inline, xa sithatha indawo yazo zonke ii-nodes kwiqela) laliphezulu kakhulu.
Zonke ii-apps zethu zihlala kwii-k8s ( EKS esekwe). Ukugcina iindleko zethu ze-DEV env, sisebenzisa iimeko zendawo.
Sisebenzisa umfanekiso weAmazonLinux2 kwiinodi.
Sinenani elikhulu lamasebe abonakalayo (ii-FBs) kwindawo yophuhliso esasazwa ngokuqhubekayo kwiqela lethu le-Kubernetes. I-FB nganye ineseti yayo yezicelo, kwaye isicelo ngasinye sineseti yaso yokuxhomekeka (ngaphakathi komfanekiso).
Kwiprojekthi yethu, phantse ii -apps ezingama-200 kwaye eli nani liyakhula. I-app nganye isebenzisa enye ye-7 yemifanekiso ye-docker enobungakanani be ~ 2 GB. Ubungakanani obupheleleyo bomfanekiso ogciniweyo (kwi -ECR ) malunga ne-3 GB.
Yonke imifanekiso igcinwe kwi-Amazon Elastic Container Registry (ECR).
Sisebenzisa uhlobo lwevolyum ye-gp3 EBS engagqibekanga kwiinodi.
Ixesha elongeziweyo lokuQala okuBanda: Ukuqala ipod entsha ngomfanekiso omtsha kunokuthatha ngaphezulu kweyure enye, ngakumbi xa imifanekiso emininzi itsalwa ngaxeshanye kwindawo enye.
Iimpazamo ze-ErrImagePull: ErrImagePull
rhoqo okanye unamathele kwi- ContainerCreating
states, ebonisa imiba ngokutsalwa komfanekiso.
Ukusetyenziswa kweDiski ePhezulu: Ukusetyenziswa kweDiski kuhlala kufutshane ne-100% ngexesha lenkqubo yokutsalwa komfanekiso, ngokuyinhloko ngenxa yedisk enzulu ye-I/O efunekayo ukuthotywa (umzekelo, "unpigz").
Imiba yeSixokelelwano seDaemonSet: Enye inkqubo yeDaemonSets(efana ne aws-node
okanye ebs-csi-node
) isiwe kwindawo "engekalungi" ngenxa yoxinzelelo lwediski, ichaphazela ukulungela indawo.
Akukho cache yomfanekiso kwiindawo: Kuba sisebenzisa imizekelo yamabala, asinako ukusebenzisa idiski yendawo kwimifanekiso egciniweyo.
Oku kubangela ukusasazwa okuninzi okumisiweyo kumasebe ophawu, ngakumbi kuba iFB eyahlukileyo ineseti ezahlukeneyo zemifanekiso esisiseko.
Emva kophando olukhawulezayo, sifumene ukuba eyona nto iphambili yayiluxinzelelo lwediski kwiinodi ngenkqubo unpigz
. Le nkqubo inoxanduva lokunciphisa imifanekiso ye-docker. Asizange sitshintshe izicwangciso ezingagqibekanga zohlobo lwevolumu ye-gp3 EBS, kuba ayifanelekanga kwimeko yethu.
Njengenyathelo lokuqala, sagqiba ekubeni sinciphise inani le-PODs kwiinodi.
Ingcamango ephambili yesisombululo kukufudumala iindawo zokuhlala phambi kokuba inkqubo yeCD iqale ngeyona ndawo inkulu yomfanekiso we-docker (i-JS dependencies layer), esebenzisa njengomfanekiso weengcambu kuzo zonke ii-apps zethu. Ubuncinci sineentlobo ze-7 zeengcambu zemifanekiso exhomekeke kwi-JS, ehambelana nohlobo lwe-app. Ke, makhe sihlalutye uyilo loqobo lweCI/CD.
Kwimibhobho yethu ye-CI/CD, sineentsika ezi-3:
Umbhobho woqobo weCI/CD:
Kwinyathelo le Init
: silungiselela imeko-bume / izinto eziguquguqukayo, sichaza iseti yemifanekiso eza kuphinda yakhiwe, njl.
Kwinqanaba Build
: sakha imifanekiso kwaye siyityhalele kwi-ECR
Kwinqanaba Deploy
: sihambisa imifanekiso kwiik8s (uhlaziyo lokusasazwa, njl..)
Iinkcukacha ezithe vetshe malunga noyilo lwe-CICD yoqobo:
main
. Kwinkqubo yeCI, sihlala sihlalutya iseti yemifanekiso eyatshintshwa kwi-FB kwaye yakha kwakhona. Isebe main
lihlala lizinzile, njengenkcazo, kufuneka kubekho inguqu yamva nje yemifanekiso yesiseko.Kukho iimfuno zenkqubo yokufudumala.
Isinyanzelo:
ContainerCreating
imiba.Kumnandi ukuba nophuculo:
Emva kokuhlalutya iimfuno kunye nezithintelo, sagqiba ekubeni siphumeze inkqubo yokufudumala eya kutshisa i-nodes kunye nesiseko semifanekiso ye-cache ye-JS. Le nkqubo iya kuqaliswa ngaphambi kokuba inkqubo yeCD iqale, ukuqinisekisa ukuba iindawo zilungele ukuthunyelwa kwe-FB, kwaye sinethuba elikhulu lokubetha i-cache.
Olu phuculo sahlulahlula kumthi amanyathelo amakhulu:
Yenza iiseti zeendawo (iQela leeNodi eziNgcolileyo) kwi-FB nganye
Yongeza imifanekiso esisiseko kwi-cloud-init script kwiinodi ezintsha
Yongeza inyathelo lokusasaza kwangaphambili ukuqhuba i-DaemonSet kunye necandelo le initContainers
ukukhuphela imifanekiso efunekayo yedokhi kwiindawo zokuhlala phambi kokuba inkqubo yeCD iqale.
Yenza iseti entsha yeenodi kwi-FB nganye ngokusebenzisa umnxeba we-API (kwinkqubo ye-3rd party autoscaling) ukusuka kumbhobho wethu weCI.
Imiba esonjululweyo:
Ukwahlukaniswa : I-FB nganye ineseti yayo yeenodi, eqinisekisa ukuba okusingqongileyo akuchatshazelwa zezinye ii-FB.
Ukuguquguquka : Sinokulutshintsha ngokulula uhlobo lwe-node kunye nobomi bayo.
Ukusebenza kweendleko : Sinokucima ii-nodes ngokukhawuleza emva kokuba i-FB icinyiwe.
Ukungafihli : Siyakwazi ukulandelela ngokulula ukusetyenziswa kunye nokusebenza kweenodi (i-node nganye inethegi ehambelana ne-FB).
Ukusetyenziswa okusebenzayo kweziganeko zendawo : Umzekelo webala uqala ngemifanekiso esele ichazwe kwangaphambili, oko kuthetha ukuba, emva kokuba indawo yendawo iqalile, sele kukho imifanekiso esisiseko kwi-node (ukusuka kwisebe eliphambili).
Khuphela yonke imifanekiso yesiseko se-JS ukusuka kwisebe eliphambili ukuya kwiindawo ezintsha nge cloud-init
script.
Ngelixa imifanekiso ikhutshelwa ngasemva, inkqubo yeCD ingaqhubeka nokwakha imifanekiso emitsha ngaphandle kwemiba. Ngaphezu koko, ii-nodes ezilandelayo (eziya kudalwa yinkqubo ye-autoscaling) ukusuka kweli qela liya kudalwa kunye nedatha ehlaziyiweyo cloud-init
, esele inemiyalelo yokukhuphela imifanekiso ngaphambi kokuqala.
Imiba esonjululweyo:
Isisombululo soMba : Uxinzelelo lweDiski luhambile, kuba sihlaziye iskripthi cloud-init
ngokongeza ukukhuphela kwemifanekiso yesiseko kwisebe eliphambili. Oku kusivumela ukuba sibethe i-cache ekuqaleni kokuqala kwe-FB.
Usebenziso olusebenzayo lweziganeko zendawo : Umzekelo webala uqala ngedatha ehlaziyiweyo cloud-init
. Kuthetha ukuba, emva kokuba i-node yendawo iqala, sele sele ikhona imifanekiso esisiseko kwi-node (ukusuka kwisebe eliphambili).
Ukusebenza okuphuculweyo : Inkqubo yeCD ingaqhubeka nokwakha imifanekiso emitsha ngaphandle kwemiba.
Esi senzo songeza imizuzwana eyi-17 (umnxeba we-API) kumbhobho wethu we-CI/CD.
Esi senzo siyavakala kuphela okokuqala xa siqala i-FB. Kwixesha elizayo, sihambisa ii-apps zethu kwiindawo esele zikhona, esele zinemifanekiso esisiseko, esithe sayihambisa kuthumelo lwangaphambili.
Sidinga eli nyathelo, kuba imifanekiso ye-FB ihluke kwimifanekiso yesebe eliphambili. Kufuneka sikhuphele isiseko semifanekiso ye-FB kwiindawo ngaphambi kokuba inkqubo yeCD iqale. Oku kuya kunceda ukunciphisa amaxesha okuqalisa okubandayo kunye nokusetyenziswa kwedisk ephezulu okunokuthi kwenzeke xa kutsalwa imifanekiso emininzi enzima ngaxeshanye.
Iinjongo zeNyathelo yokusasazwa kwangaphambili
Thintela Uxinzelelo lweDiski : Khuphela ngokulandelelana idocker eyona mifanekiso inzima. Emva kwesinyathelo se-init-deploy, sele sinemifanekiso esisiseko kwii-nodes, oku kuthetha ukuba sinethuba elikhulu kwi-cache hit.
Phucula iNdlela yokuSebenza ngokuFanelekileyo : Qinisekisa ukuba iindawo zokuhlala zifudunyezwa kwangaphambili ngemifanekiso ye-docker ebalulekileyo, ekhokelela ngokukhawuleza (phantse ngoko nangoko) amaxesha okuqalisa kwePOD.
Ukuphucula Uzinzo : Nciphisa amathuba okudibana neempazamo ErrImagePull
/ ContainerCreating
kwaye uqinisekise ukuba iiseti ze-daemon zenkqubo zihlala "zilungile".
Ngaphantsi kweli nyathelo, songeza imizuzu eyi-10-15 kwinkqubo yeCD.
Inyathelo lokusasaza kwangaphambili Iinkcukacha:
initContainers
.initContainers
lenziwa phambi kokuba isikhongozeli esiphambili siqale, siqinisekisa ukuba imifanekiso eyimfuneko ikhutshelwe ngaphandle phambi kokuba isikhongozeli esikhulu siqale.Ukuthelekiswa kwamanyathelo okuqala kunye nokuhlaziywa kunye nenkqubo yokutshisa.
Inyathelo | Init deploy step | Inyathelo lokusasaza kwangaphambili | Hambisa | Ixesha elipheleleyo | Diff |
---|---|---|---|---|---|
Ngaphandle kokushisa kwangaphambili | 0 | 0 | 11m 21s | 11m 21s | 0 |
Ngokutshisa kwangaphambili | 8 imizuzwana | 58 imizuzwana | 25 imizuzwana | 1m 31s | -9m 50s |
Into ephambili, ixesha elithi "Deploy" litshintshile (ukusuka kumyalelo wokuqala wokusebenza kwi-Running state of pods) ukusuka kwi-11m 21s ukuya kwi-25 imizuzwana. Ixesha elipheleleyo litshintshile ukusuka kwi-11m 21s ukuya kwi-1m 31s.
Iphuzu elibalulekileyo, ukuba akukho mifanekiso yesiseko evela kwisebe eliphambili, ngoko ixesha elithi "Deploy" liya kufana nexesha lokuqala okanye lincinci. Kodwa nangona kunjalo, sisombulule umba ngoxinzelelo lwediski kunye nexesha lokuqala elibandayo.
Umba ophambili ContainerCreating
wasonjululwa yinkqubo yokufudumala. Njengenzuzo, sinciphise kakhulu ixesha lokuqala elibandayo le-POD.
Uxinzelelo lwedisk lwaluphelile, kuba sele sinemifanekiso yesiseko kwiinodes. Inkqubo ye-daemonSets ikwimeko "elungile" kwaye "isempilweni" (kuba akukho xinzelelo lwediski), kwaye asikhange sidibane nazo naziphi na iimpazamo ErrImagePull
ezinxulumene nalo mba.
I-PS: Ndingathanda ukukhwaza kwiqela elikhulu lobugcisa eJust ( https://www.linkedin.com/company/justt-ai ) ngomsebenzi ongadinwayo kunye nendlela yokuyila ngokwenene kuwo nawuphi na umcimbi abajongene nawo. kunye. Ngokukodwa, ukukhwaza kuRonny Sharaby, okhokelayo obalaseleyo onoxanduva lomsebenzi omkhulu owenziwa liqela. Ndijonge phambili ekuboneni imizekelo emininzi nangaphezulu yendlela ubuchule bakho obuchaphazela ngayo imveliso yeJust.