Home
%3CLINGO-SUB%20id%3D%22lingo-sub-360010%22%20slang%3D%22en-US%22%3EFirst%20steps%20with%20Docker%20and%20Kubernetes%20-%20Moving%20to%20Azure%20Kubernetes%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-360010%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FFirst-steps-with-Docker-and-Kubernetes-Introduction%2Fba-p%2F357525%22%20target%3D%22_blank%22%3EIn%20the%20previous%20post%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewe%20have%20learned%20some%20basic%20concepts%20of%20Kubernetes%20and%20how%20it%20helps%20us%20to%20leverage%20Docker%20containers%20in%20a%20better%20way.%20However%2C%20the%20samples%20we%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FFirst-steps-with-Docker-and-Kubernetes-Introduction%2Fba-p%2F357525%22%20target%3D%22_blank%22%3Ein%20the%20previous%20post%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ehave%20been%20helpful%20to%20understand%20the%20basics%2C%20but%20they%20aren't%20realistic.%20If%20you%20remember%2C%20as%20first%20step%20we%20have%20manually%20created%20a%20deployment%20using%20the%20NGINX%20image%20published%20on%20Docker%20Hub.%20However%2C%20in%20a%20real%20scenario%2C%20you%20will%20hardly%20have%20to%20manually%20create%20deployments%20and%20services.%20The%20second%20sample%20was%20closer%20to%20the%20real%20world%2C%20since%20we%20have%20used%20a%20more%20formal%20definition%20(the%20Docker%20Compose%20file)%20to%20deploy%20the%20whole%20architecture%20of%20our%20application.%20However%2C%20it%20still%20wasn't%20completely%20realistic%2C%20because%20we%20were%20taking%20advantage%20of%20the%20Kubernetes%20engine%20built-in%20inside%20Docker%2C%20which%20allowed%20us%20to%20use%20a%20Docker%20Compose%20file%20to%20describe%20the%20deployment.%20When%20you%20use%20a%20real%20Kubernetes%20infrastructure%2C%20you%20can't%20leverage%20Docker%20Compose%20files%2C%20but%20you%20need%20to%20create%20a%20YAML%20file%20which%20follows%20the%20Kubernetes%20specification.%3C%2FP%3E%0A%3CP%3EIn%20this%20post%20we're%20going%20to%20do%20exactly%20that%3A%20we're%20going%20to%20write%20a%20Kubernetes%20YAML%20definition%20to%20map%20our%20application%20and%20we're%20going%20to%20deploy%20it%20in%20the%20cloud%2C%20using%20Azure%20Kubernetes%20Service.%20Then%2C%20we're%20going%20to%20see%20how%20can%20easily%20scale%20our%20application%20in%20case%20of%20heavy%20load.%3C%2FP%3E%0A%3CP%3ELet's%20start!%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1509055778%22%20id%3D%22toc-hId-1535863900%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22writing-our-first-yaml-file%22%20id%3D%22toc-hId--1043101183%22%20id%3D%22toc-hId--1016293061%22%3EWriting%20our%20first%20YAML%20file%3C%2FH3%3E%0A%3CP%3ELet's%20start%20with%20something%20simple.%20In%20the%20previous%20post%2C%20as%20first%20step%2C%20we%20have%20manually%20created%20a%20deployment%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20run%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%2C%20followed%20by%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20expose%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20create%20a%20service%20so%20that%20we%20could%20connect%20to%20the%20web%20server%20from%20our%20machine.%20Let's%20create%20a%20YAML%20file%20to%20achieve%20the%20same%20goal%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-13%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enginx%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20type%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3ELoadBalancer%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEach%20definition%20is%20composed%20by%20three%20items%3A%3C%2FP%3E%0A%3CUL%20id%3D%22pragma-line-46%22%3E%0A%3CLI%20id%3D%22pragma-line-46%22%3E%3CSTRONG%3Ekind%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Especifices%20which%20kind%20of%20Kubernetes%20resource%20we%20want%20to%20deploy.%20This%20is%20a%20big%20difference%20compared%20to%20Docker%20Compose%20files.%20We%20have%20to%20specify%20each%20Kubernetes%20object%2C%20which%20means%20that%20a%20single%20layer%20of%20application%20is%20typically%20composed%20by%20at%20least%20two%20objects%3A%20a%20deployment%20(with%20the%20app%20definition)%20and%20a%20service%20(to%20expose%20it%20to%20the%20other%20applications%20or%20to%20the%20outside%20world).%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-47%22%3E%3CSTRONG%3Emetadata%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eallows%20to%20specify%20some%20information%20that%20are%20helpful%20to%20describe%20the%20object.%20In%20this%20case%20we're%20setting%20a%20name%20to%20make%20it%20easyer%20to%20identify%20the%20resource.%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-48%22%3E%3CSTRONG%3Espec%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Econtains%20the%20full%20specification%20of%20the%20resource%20we%20want%20to%20deploy.%20The%20content%20of%20this%20section%20can%20be%20very%20different%2C%20based%20on%20the%20kind%20of%20resource.%20For%20example%2C%20you%20can%20notice%20how%20the%20spec%20section%20of%20the%20first%20resource%20(%3CSTRONG%3EDeployment%3C%2FSTRONG%3E)%20is%20different%20from%20the%20one%20of%20the%20second%20resource%20(%3CSTRONG%3EService%3C%2FSTRONG%3E).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ELet's%20take%20a%20closer%20look%20at%20the%20first%20section.%20Since%20it's%20used%20to%20setup%20a%20deployment%2C%20the%20spec%20section%20contains%20all%20the%20information%20about%20the%20application%20we%20want%20to%20deploy%20and%20its%20desired%20state.%20We%20have%20defined%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etemplate%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewith%20a%20single%20container%2C%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eweb%3C%2FSTRONG%3E%2C%20which%20is%20based%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Enginx%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eimage.%20We%20have%20also%20specified%20that%20we%20want%205%20replicas%20of%20this%20application%20as%20desired%20state.%20The%20expected%20outcome%20is%20that%2C%20like%20we%20have%20seen%20in%20the%20previous%20article%20when%20we%20have%20used%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20scale%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%2C%20Kubernetes%20will%20take%20care%20of%20creating%20(and%20always%20keeping%20alive)%205%20pods%20out%20of%20this%20deployment.%3C%2FP%3E%0A%3CP%3EThe%20second%20section%2C%20instead%2C%20is%20dedicated%20to%20configure%20the%20service%20and%2C%20as%20such%2C%20you%20have%20less%20options.%20It's%20enough%20to%20specify%20the%20type%20(%3CSTRONG%3ELoadBalancer%3C%2FSTRONG%3E%2C%20since%20we%20want%20to%20expose%20the%20web%20server%20to%20the%20outside%20world)%20and%20the%20exposed%20port.%20A%20very%20important%20property%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eselector%3C%2FSTRONG%3E%2C%20which%20allows%20us%20to%20specify%20which%20deployment%20we%20want%20to%20expose%20through%20this%20service.%20In%20our%20case%2C%20it's%20the%20resource%20identified%20by%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eweb%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Elabel%20we%20have%20just%20created%20in%20the%20first%20section.%3C%2FP%3E%0A%3CP%3ENow%20that%20the%20we%20have%20the%20full%20definition%20of%20our%20application%2C%20we%20can%20deploy%20it%20with%20the%20following%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-56%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20apply%20-f%20web.yml%0Adeployment.apps%2Fweb%20created%0Aservice%2Fweb%20created%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWe%20use%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20apply%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%2C%20specifying%20as%20parameter%20the%20path%20of%20the%20YAML%20file%20which%20we%20have%20just%20created.%20Now%20we%20can%20use%20the%20usual%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommands%20to%20check%20what%20happened.%20Let's%20see%20first%20the%20deployments%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-65%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20deployments%0ANAME%20%20%20READY%20%20%20UP-TO-DATE%20%20%20AVAILABLE%20%20%20AGE%0Aweb%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E4%3C%2FSPAN%3Em9s%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWe%20have%20a%20new%20deployment%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eweb%3C%2FSTRONG%3E%2C%20which%20is%20composed%20by%205%20instances.%20We%20can%20see%20them%20in%20more%20details%20by%20getting%20the%20list%20of%20pods%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-73%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20pods%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20READY%20%20%20STATUS%20%20%20%20RESTARTS%20%20%20AGE%0Aweb-d54594dc4-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Ept9d%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E83%3C%2FSPAN%3Es%0Aweb-d54594dc4-ddpgv%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E83%3C%2FSPAN%3Es%0Aweb-d54594dc4-kqnsq%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E83%3C%2FSPAN%3Es%0Aweb-d54594dc4-srcxl%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E83%3C%2FSPAN%3Es%0Aweb-d54594dc4-x2p48%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E83%3C%2FSPAN%3Es%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ELast%2C%20we%20can%20check%20the%20available%20services%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-85%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20services%0ANAME%20%20%20%20%20%20%20%20%20TYPE%20%20%20%20%20%20%20%20%20%20%20CLUSTER-IP%20%20%20%20%20%20%20EXTERNAL-IP%20%20%20PORT(S)%20%20%20%20%20%20%20%20AGE%0Akubernetes%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.96%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E443%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3Ed3h%0Aweb%20%20%20%20%20%20%20%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.110%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E107.154%3C%2FSPAN%3E%20%20%20localhost%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30514%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E91%3C%2FSPAN%3Es%0A%3C%2FNONE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESince%20the%20service's%20type%20we%20have%20created%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELoadBalancer%3C%2FSTRONG%3E%2C%20our%20application%20is%20exposed%20to%20the%20outside%20world%20through%20an%20external%20ip.%20Since%20we're%20running%20our%20Kubernetes%20cluster%20on%20our%20local%20machine%2C%20it%20means%20that%20we%20can%20open%20a%20browser%20and%20hit%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehttp%3A%2F%2Flocalhost%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20see%20the%20default%20NGINX%20page%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84998iD0C55FFC5151CFD6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22nginx.png%22%20title%3D%22nginx.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-699709152%22%20id%3D%22toc-hId-726517274%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22azure-kubernetes-service%22%20id%3D%22toc-hId--1852447809%22%20id%3D%22toc-hId--1825639687%22%3EAzure%20Kubernetes%20Service%3C%2FH3%3E%0A%3CP%3ENow%20that%20we%20have%20learned%20to%20create%20a%20proper%20YAML%20file%2C%20we%20can%20try%20to%20deploy%20our%20application%20in%20a%20real%20environment%20like%20Azure%20Kubernetes%20Service%20(AKS%2C%20from%20now%20on).%20AKS%20is%20one%20of%20the%20many%20Azure%20services%20which%20belongs%20to%20the%20PaaS%20(Platform-As-A-Service)%20world.%20It%20means%20that%20we%20can%20deploy%20a%20Kubernetes%20cluster%20without%20having%20to%20worry%20about%20manually%20creating%2C%20maintaining%20and%20configuring%20the%20virtual%20machines.%20We%20will%20just%20have%20to%20create%20a%20new%20cluster%2C%20specify%20how%20much%20power%20we%20need%20(which%20translates%20into%20the%20CPU%2C%20RAM%2C%20hard%20disk%2C%20etc.%20which%20our%20VM%20will%20have)%20and%20how%20many%20nodes%20we%20need.%3C%2FP%3E%0A%3CP%3EIn%20order%20to%20start%20with%20Azure%20Kubernetes%20Service%2C%20login%20with%20your%20account%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20portal%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECreate%20a%20resource%3C%2FSTRONG%3E.%20Under%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EContainers%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecategory%20you%20will%20find%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKubernetes%20service%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84999iD1151E12DE05F352%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22kubernetes-azure.png%22%20title%3D%22kubernetes-azure.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESelect%20it%20to%20start%20the%20process%20of%20creating%20a%20new%20Kubernetes%20cluster%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20887px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85000iF27C4C96ECF87311%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22create-aks.png%22%20title%3D%22create-aks.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20first%20section%20you%20just%20have%20to%20select%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ESubscription%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eyou%20want%20to%20leverage%20and%20the%20resource%20group%20where%20you%20want%20to%20store%20all%20the%20resources%20related%20to%20the%20cluster.%20For%20keeping%20things%20better%20organized%2C%20I%20prefer%20to%20create%20a%20dedicated%20resource%20group%20for%20AKS.%3C%2FP%3E%0A%3CP%3EIn%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECluster%20Details%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%20you%20can%20configure%20all%20the%20settings%20of%20the%20cluster%3A%3C%2FP%3E%0A%3CUL%20id%3D%22pragma-line-111%22%3E%0A%3CLI%20id%3D%22pragma-line-111%22%3E%3CSTRONG%3EKubernetes%20cluster%20name%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20name%20which%20identifies%20the%20cluster%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-112%22%3E%3CSTRONG%3ERegion%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20Azure%20region%20where%20you%20want%20to%20create%20the%20cluster.%20Choose%20a%20region%20close%20to%20you%20for%20lower%20latency.%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-113%22%3E%3CSTRONG%3EKubernetes%20version%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eshould%20be%20self-explanatory.%20Just%20leave%20the%20default%20one.%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-114%22%3E%3CSTRONG%3EDNS%20name%20prefix%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20prefix%20that%20will%20be%20used%20for%20the%20full%20URL%20assigned%20to%20the%20cluster.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20the%20end%2C%20you%20need%20to%20choose%20how%20much%20resoruces%20you%20need%2C%20based%20on%20the%20requirements%20of%20your%20application.%20You%20will%20have%20to%20choose%3A%3C%2FP%3E%0A%3CUL%20id%3D%22pragma-line-118%22%3E%0A%3CLI%20id%3D%22pragma-line-118%22%3EThe%20size%20of%20the%20VMs%20which%20will%20be%20used%20as%20nodes.%20You%20can%20choose%20between%20different%20sizes%2C%20with%20different%20amount%20of%20RAM%2C%20CPU%20cores%2C%20etc.%20This%20choice%20must%20be%20done%20carefuly%2C%20because%20you%20won't%20be%20able%20to%20change%20it%20later.%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-119%22%3EThe%20number%20of%20nodes%20you%20want%20to%20create.%20This%20value%2C%20instead%2C%20can%20be%20changed%20also%20later%20if%20you%20need%20to%20scale%20your%20application%20up%20or%20down.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20last%20option%20lets%20you%20enable%20a%20preview%20feature%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EVirtual%20nodes%3C%2FSTRONG%3E%2C%20which%20is%20a%20new%20Azure%20feature%20to%20leverage%20Kubernetes%20with%20a%20serverless%20approach.%20We%20have%20just%20shared%20that%20AKS%20uses%20the%20PaaS%20approach%2C%20which%20means%20that%20you%20don't%20have%20to%20care%20about%20the%20underlying%20infrastructure%2C%20but%20you%20still%20have%20to%20choose%20the%20size%20of%20the%20VMs%20that%20will%20power%20up%20each%20node.%20As%20a%20consequence%2C%20scaling%20up%20could%20take%20a%20while%2C%20because%20AKS%20will%20need%20to%20spin%20up%20new%20VMs%20if%20you%20need%20more%20nodes.%20Virtual%20nodes%2C%20instead%2C%20allow%20to%20quickly%20spin%20up%20new%20nodes%20beyond%20the%20size%20of%20the%20cluster%20you%20have%20defined%2C%20by%20leveraging%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fcontainer-instances%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Container%20Instances%3C%2FA%3E.%20For%20the%20moment%2C%20we%20aren't%20going%20to%20leverage%20it%2C%20so%20feel%20free%20to%20leave%20it%20disabled.%3C%2FP%3E%0A%3CP%3EPress%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EReview%20%2B%20Create%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20kick%20off%20the%20deployment%20process%2C%20which%20will%20take%20a%20while.%20Once%20it's%20finished%2C%20you%20will%20have%20a%20new%20Kubernetes%20cluster%20up%20%26amp%3B%20running.%3C%2FP%3E%0A%3CP%3ENow%20we%20need%20to%20connect%20to%20it.%20The%20easiest%20way%20is%20through%20the%20Azure%20CLI%20(Command%20Line%20Interface)%2C%20which%20can%20configure%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Etool%20to%20connect%20directly%20to%20AKS.%20If%20you%20don't%20have%20the%20Azure%20CLI%20on%20your%20machine%2C%20you%20can%20get%20in%20different%20ways%20based%20on%20your%20environment.%20You%20can%20leverage%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcli%2Fazure%2Finstall-azure-cli-windows%3Fview%3Dazure-cli-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%20installer%3C%2FA%3E%2C%20you%20can%20use%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwsl%2Fabout%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%20Subsystem%20for%20Linux%20(WSL)%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%20you%20can%20even%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcli%2Fazure%2Frun-azure-cli-docker%3Fview%3Dazure-cli-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Erun%20it%20inside%20a%20Docker%20container%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3ENo%20matter%20which%20path%20you%20choose%2C%20at%20the%20end%20you'll%20be%20able%20to%20use%20a%20command%20prompt%20to%20execute%20commands%20against%20your%20Azure%20subscription.%20The%20first%20step%20is%20to%20execute%20the%20login%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-129%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20az%20login%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EYour%20default%20browser%20will%20open%20up%20and%20you%20will%20be%20asked%20to%20login%20to%20your%20Azure%20subcription.%20Once%20you're%20logged%20in%2C%20you're%20ready%20to%20interact%20with%20the%20resources%20you%20have%20in%20your%20subscription.%20The%20easiest%20way%20to%20connect%20to%20your%20AKS%20cluster%20is%20to%20open%20the%20Azure%20dashboard%20and%2C%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EOverview%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%2C%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EView%20Kubernetes%20dashboard%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85001i77594ED4D598ED71%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22kubernetes-dashboard.png%22%20title%3D%22kubernetes-dashboard.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EA%20new%20panel%20will%20open%20up%20from%20the%20right%20with%20a%20set%20of%20Azure%20CLI%20commands%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20565px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85002i00009051A34BBB2A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22dashboard.png%22%20title%3D%22dashboard.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20one%20will%20install%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eon%20your%20local%20machine%2C%20even%20if%20you%20should%20already%20have%20it%20thanks%20to%20Docker%20Desktop%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-144%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20az%20aks%20install-cli%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENow%20you%20can%20connect%20to%20your%20AKS%20instance%20by%20copying%20and%20pasting%20the%20second%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-150%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20az%20aks%20get-credentials%20--resource-group%20AKS%20--name%20aksappconsult%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMake%20sure%20to%20copy%20and%20paste%20the%20command%20from%20your%20dashboard%20and%20not%20the%20one%20above.%20In%20fact%2C%20you%20need%20to%20be%20sure%20that%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E--resource-group%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E--name%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameters%20are%20set%20with%20the%20specific%20values%20of%20your%20cluster.%20This%20command%20will%20store%20in%20the%20local%20Kubernetes%20configuration%20file%20the%20new%20context.%20If%20you%20have%20done%20everything%20properly%2C%20you%20should%20see%20something%20like%20this%20when%20you%20click%20on%20the%20Docker%20Desktop%20icon%20in%20your%20taskbar%20and%20you%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKubernetes%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20691px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85003i7B6BE2ABE18F935C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22context.png%22%20title%3D%22context.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20there%20are%20two%20contexts%20listed%20in%20the%20menu%3A%3C%2FP%3E%0A%3CUL%20id%3D%22pragma-line-161%22%3E%0A%3CLI%20id%3D%22pragma-line-161%22%3EThe%20first%20is%20the%20one%20related%20to%20AKS%20we%20have%20just%20created%20(%3CSTRONG%3Eaksappconsult%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20name%20of%20the%20AKS%20cluster%20I've%20created%20in%20my%20Azure%20portal)%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-162%22%3EThe%20second%20is%20the%20local%20one%20created%20by%20Docker%20Desktop%20and%20which%20we%20have%20used%20in%20the%20previous%20post%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EMake%20sure%20that%20the%20AKS%20context%20is%20set.%20Now%20we%20can%20start%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Etool%20against%20our%20AKS%20cluster.%20We%20can%20immediately%20see%20that%20by%20getting%20the%20list%20of%20available%20nodes%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-166%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20nodes%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20STATUS%20%20%20ROLES%20%20%20AGE%20%20%20%20VERSION%0Aaks-agentpool-%3CSPAN%20class%3D%22hljs-number%22%3E27951239%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20Ready%20%20%20%20agent%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed1h%20%20%20v1.%3CSPAN%20class%3D%22hljs-number%22%3E12.5%3C%2FSPAN%3E%0Aaks-agentpool-%3CSPAN%20class%3D%22hljs-number%22%3E27951239%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20Ready%20%20%20%20agent%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed1h%20%20%20v1.%3CSPAN%20class%3D%22hljs-number%22%3E12.5%3C%2FSPAN%3E%0Aaks-agentpool-%3CSPAN%20class%3D%22hljs-number%22%3E27951239%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-number%22%3E2%3C%2FSPAN%3E%20%20%20Ready%20%20%20%20agent%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed1h%20%20%20v1.%3CSPAN%20class%3D%22hljs-number%22%3E12.5%3C%2FSPAN%3E%0Avirtual-node-aci-linux%20%20%20%20%20Ready%20%20%20%20agent%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed%20%20%20%20%20v1.%3CSPAN%20class%3D%22hljs-number%22%3E13.1%3C%2FSPAN%3E-vk-v0.%3CSPAN%20class%3D%22hljs-number%22%3E7.4%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-number%22%3E44%3C%2FSPAN%3E-g4f3bd20e-dev%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWhen%20I%20created%20my%20AKS%20cluster%2C%20I've%20specified%20that%20I%20wanted%203%20nodes%20and%20I've%20enabled%20the%20Virtual%20Node%20option.%20As%20such%2C%20the%20output%20of%20the%20command%20is%20the%20expected%20one%3A%20we%20have%203%20physical%20nodes%20and%20a%20virtual%20one%2C%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Evirtual-node-aci-linux%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3ENow%20it%20comes%20the%20fun%20part!%20Since%20we're%20connected%20to%20our%20AKS%20cluster%2C%20the%20same%20exact%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommands%20we%20have%20previously%20executed%20on%20our%20local%20cluster%20will%20work%20exactly%20in%20the%20same%20on%20our%20cloud%20cluster.%20For%20example%2C%20let's%20try%20to%20deploy%20the%20sample%20YAML%20file%20we%20have%20previously%20created%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-179%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20apply%20-f%20web.yml%0Adeployment.apps%2Fweb%20created%0Aservice%2Fweb%20created%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20outcome%20will%20be%20exactly%20the%20same%20but%2C%20this%20time%2C%20our%20NGINX%20instance%20will%20be%20deployed%20on%20the%20cloud.%20We%20can%20use%20the%20usual%20commands%20to%20see%20that%20everything%20is%20indeed%20up%20%26amp%3B%20running.%20First%2C%20let's%20take%20a%20look%20at%20the%20deployments%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-187%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20deployments%0ANAME%20%20%20DESIRED%20%20%20CURRENT%20%20%20UP-TO-DATE%20%20%20AVAILABLE%20%20%20AGE%0Aweb%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThen%20let's%20take%20a%20look%20at%20the%20pods%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-195%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20pods%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20READY%20%20%20STATUS%20%20%20%20RESTARTS%20%20%20AGE%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E64888%3C%2FSPAN%3Edbd49-j4nbr%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E64888%3C%2FSPAN%3Edbd49-n4s8s%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E64888%3C%2FSPAN%3Edbd49-rb2x9%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E64888%3C%2FSPAN%3Edbd49-wgnlm%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E64888%3C%2FSPAN%3Edbd49-zd4h7%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E94%3C%2FSPAN%3Em%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENo%20surprises%20here.%20It's%20the%20same%20exact%20scenario%20that%20we%20saw%20when%20we%20deployed%20the%20YAML%20locally.%20We%20can%20see%20only%20a%20small%20difference%20when%20we%20look%20at%20the%20services%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-207%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20services%0ANAME%20%20%20%20%20%20%20%20%20TYPE%20%20%20%20%20%20%20%20%20%20%20CLUSTER-IP%20%20%20EXTERNAL-IP%20%20%20PORT(S)%20%20%20%20%20%20%20%20AGE%0Akubernetes%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%20%20%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E443%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed1h%0Aweb%20%20%20%20%20%20%20%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E1.69%3C%2FSPAN%3E%20%20%20%20%3CPENDING%3E%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30216%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E6%3C%2FSPAN%3Es%0A%3C%2FPENDING%3E%3C%2FNONE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThis%20time%20we%20aren't%20exposing%20the%20application%20on%20our%20local%20machine%2C%20but%20on%20a%20remote%20server.%20As%20such%2C%20the%20external%20IP%20takes%20a%20while%20to%20be%20assigned%20so%2C%20at%20first%2C%20you%20will%20see%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Epending%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eas%20value.%20You%20can%20add%20a%20watch%20to%20be%20notified%20when%20the%20external%20IP%20is%20assigned%20using%20the%20following%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-216%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20services%20web%20--watch%0ANAME%20%20%20TYPE%20%20%20%20%20%20%20%20%20%20%20CLUSTER-IP%20%20%20EXTERNAL-IP%20%20%20PORT(S)%20%20%20%20%20%20%20%20AGE%0Aweb%20%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E1.69%3C%2FSPAN%3E%20%20%20%20%3CPENDING%3E%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30216%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E23%3C%2FSPAN%3Es%0Aweb%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E1.69%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E65.52%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E134.127%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30216%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E39%3C%2FSPAN%3Es%0A%3C%2FPENDING%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAt%20first%2C%20you%20will%20see%20just%20the%20first%20line%20but%2C%20as%20soon%20as%20the%20IP%20is%20assigned%2C%20a%20new%20one%20will%20pop%20up.%20Now%20you%20can%20just%20copy%20the%20value%20from%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EEXTERNAL-IP%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecolumn%20and%20paste%20it%20in%20your%20browser%20to%20see%20the%20default%20NGINX%20web%20page%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85006i39EBA8E7ADDD097F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22nginx-ask.png%22%20title%3D%22nginx-ask.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22a-more-complex-deployment%22%20id%3D%22toc-hId--109637474%22%20id%3D%22toc-hId--82829352%22%3EA%20more%20complex%20deployment%3C%2FH3%3E%0A%3CP%3EThe%20experiment%20we%20have%20just%20did%20was%20helpful%20to%20understand%20the%20basic%20concepts%20of%20AKS.%20In%20the%20end%2C%20the%20only%20difference%20from%20what%20we%20have%20learned%20in%20the%20first%20post%20is%20about%20setting%20up%20the%20environment.%20Once%20it's%20up%20%26amp%3B%20running%2C%20we%20can%20execute%20the%20same%20exact%20commands%20we%20were%20running%20on%20our%20local%20Kubernetes%20cluster.%3C%2FP%3E%0A%3CP%3EHowever%2C%20it%20isn't%20a%20very%20realistic%20scenario%20because%20the%20application%20is%20very%20simple%20and%20made%20by%20a%20single%20layer.%20Let's%20deploy%20on%20AKS%20the%20original%20web%20application%20we%20are%20using%20as%20playground%20in%20the%20various%20posts.%20However%2C%20as%20first%2C%20we%20need%20to%20create%20the%20YAML%20definition%20since%2C%20at%20the%20moment%2C%20we%20have%20only%20a%20Docker%20Compose%20file%20that%20we%20can't%20deploy%20as%20it%20is%20on%20AKS.%20As%20a%20reminder%2C%20this%20is%20the%20structure%20of%20our%20project%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-233%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3Eversion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'3'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Eservices%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20web%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapp%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-bullet%22%3E%20%20%20%20%20%20-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%221983%3A80%22%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20newsfeed%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapi%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20redis%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWe%20need%20to%20convert%20these%203%20layers%20into%20a%20Kubernetes%20YAML%20file.%20Let's%20start%20with%20the%20Redis%20cache%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-248%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIf%20you%20remember%20what%20we%20have%20learned%20in%20the%20previous%20post%2C%20we%20need%20to%20define%20at%20least%20two%20resources%20for%20each%20layer.%20We%20need%2C%20in%20fact%2C%20a%20service%20for%20any%20deployment%20which%20must%20be%20exposed%2C%20regardless%20if%20it%20will%20be%20only%20internally%20or%20externally.%3C%2FP%3E%0A%3CP%3EThe%20first%20element%2C%20which%20kind%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EDeployment%3C%2FSTRONG%3E%2C%20defines%20the%20layer%20for%20the%20Redis%20cache.%20It's%20based%20on%20the%20official%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eredis%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eimage%20on%20Docker%20Hub%2C%20it's%20exposed%20as%20a%20single%20instance%20and%20it's%20identified%20by%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eredis%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ename.%20Naming%20is%20important%2C%20since%20it's%20the%20one%20that%20will%20be%20used%20by%20Kubernetes%20through%20the%20internal%20DNS.%20If%20you%20remember%2C%20in%20fact%2C%20our%20Web%20API%20connects%20to%20the%20Redis%20cache%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eredis%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eas%20server%20name.%3C%2FP%3E%0A%3CP%3EThe%20second%20one%2C%20instead%2C%20is%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EService%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20it%20exposes%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eredis%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edeployment%20through%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E6379%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eport%2C%20which%20is%20the%20default%20Redis%20one.%20Since%20we%20haven't%20specified%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etype%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%2C%20the%20service%20will%20be%20exposed%20only%20in%20the%20internal%20network.%3C%2FP%3E%0A%3CP%3ENow%20let's%20move%20to%20the%20Web%20API%20layer%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-288%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapi%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20structure%20is%20the%20same%20we%20have%20used%20for%20Redis.%20We%20have%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EDeployment%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eentry%20which%20defines%20a%20single%20instance%20based%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eqmatteoq%2Ftestwebapi%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eimage%20on%20Docker%20Hub%2C%20which%20is%20identified%20by%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Enewsfeed%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Elabel.%20Also%20in%20this%20case%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Enewsfeed%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20name%20used%20in%20the%20internal%20DNS.%20The%20web%20application%2C%20in%20fact%2C%20connects%20to%20the%20Web%20API%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ehttp%3A%2F%2Fnewsfeed%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EURL.%20The%20second%20section%2C%20instead%2C%20defines%20a%20service%20which%20exposes%20the%20deployment%20through%20the%2080%20port%20in%20the%20internal%20network.%3C%2FP%3E%0A%3CP%3ENow%20let's%20take%20a%20look%20at%20the%20final%20section%20of%20the%20YAML%20file%3A%20the%20main%20web%20application.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-324%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapp%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20type%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3ELoadBalancer%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EDeployment%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%20has%20always%20the%20same%20structure.%20It%20creates%20a%20deployment%20based%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eqmatteoq%2Ftestwebapp%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eimage%20on%20Docker%20Hub.%20The%20only%20difference%20is%20that%20we%20want%203%20instances%20of%20this%20layer.%20The%20second%20section%2C%20instead%2C%20is%20a%20bit%20different%20because%20we%20have%20added%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Etype%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%20set%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELoadBalancer%3C%2FSTRONG%3E.%20This%20means%20that%20we%20want%20to%20expose%20the%20layer%20through%20the%2080%20port%2C%20but%20externally%20and%20not%20only%20internally.%3C%2FP%3E%0A%3CP%3EFor%20reference%2C%20this%20is%20how%20the%20full%20YAML%20file%20looks%20like%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-358%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eredis%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapi%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enewsfeed%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapp%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-meta%22%3E---%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ev1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EService%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20type%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3ELoadBalancer%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20-%20port%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20selector%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESave%20this%20file%20and%20give%20it%20a%20name.%20Now%20we're%20ready%20to%20deploy%20it%20on%20AKS%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20apply%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-446%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20apply%20-f%20%3CSPAN%20class%3D%22hljs-string%22%3E%22.%5Cweb-aks.yml%22%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ECan%20you%20guess%20which%20is%20the%20outcome%3F%20We%20should%20have%20now%203%20deployments%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-452%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20deployments%0ANAME%20%20%20%20%20%20%20DESIRED%20%20%20CURRENT%20%20%20UP-TO-DATE%20%20%20AVAILABLE%20%20%20AGE%0Anewsfeed%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aredis%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aweb%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThese%20deployments%20should%20have%20kicked%20off%205%20pods%2C%20since%20we%20have%20asked%20for%203%20replicas%20of%20the%20web%20layer%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-462%22%20class%3D%22language-powershell%20hljs%22%3Ekubectl%20get%20pods%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20READY%20%20%20STATUS%20%20%20%20RESTARTS%20%20%20AGE%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-t4j79%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aredis-%3CSPAN%20class%3D%22hljs-number%22%3E56%3C%2FSPAN%3Ef8fbc4d-lvxj8%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-%3CSPAN%20class%3D%22hljs-number%22%3E9%3C%2FSPAN%3Ekbx9%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-dkq9b%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-rdc52%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E25%3C%2FSPAN%3Em%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20the%20end%2C%20we%20should%20have%204%20services%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-474%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20services%0ANAME%20%20%20%20%20%20%20%20%20TYPE%20%20%20%20%20%20%20%20%20%20%20CLUSTER-IP%20%20%20%20%20EXTERNAL-IP%20%20%20%20%20PORT(S)%20%20%20%20%20%20%20%20AGE%0Akubernetes%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%20%20%20%20%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E443%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed3h%0Anewsfeed%20%20%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E142.105%3C%2FSPAN%3E%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E23%3C%2FSPAN%3Em%0Aredis%20%20%20%20%20%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E252.243%3C%2FSPAN%3E%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E23%3C%2FSPAN%3Em%0Aweb%20%20%20%20%20%20%20%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E177.19%3C%2FSPAN%3E%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E13.80%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E251.199%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30474%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E24%3C%2FSPAN%3Em%0A%3C%2FNONE%3E%3C%2FNONE%3E%3C%2FNONE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EOnly%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eweb%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eone%2C%20which%20type%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELoadBalancer%3C%2FSTRONG%3E%2C%20will%20have%20an%20external%20IP.%20As%20we%20have%20seen%20when%20we%20have%20deployed%20NGINX%2C%20it%20may%20take%20a%20while%20before%20the%20external%20IP%20is%20assigned%2C%20so%20you%20can%20use%20the%20following%20command%20to%20track%20it%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-485%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20service%20web%20--watch%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EOnce%20the%20external%20IP%20is%20available%2C%20you%20can%20just%20open%20your%20browser%20pointing%20to%20it%20to%20see%20our%20web%20application%20up%20%26amp%3B%20running%20in%20the%20cloud%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85007i63AF56E73F5EF1A4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22akswebapp.png%22%20title%3D%22akswebapp.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20advantage%20of%20using%20a%20YAML%20definition%20is%20that%2C%20unlike%20we%20have%20seen%20in%20the%20previous%20post%20with%20Docker%20Compose%2C%20we%20are%20allowed%20to%20change%20it%20for%20scaling%20purpose.%20For%20example%2C%20let's%20run%20the%20following%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-495%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20scale%20deployments%20newsfeed%20--replicas%3D%3CSPAN%20class%3D%22hljs-number%22%3E4%3C%2FSPAN%3E%0Adeployment.extensions%2Fnewsfeed%20scaled%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAfter%20a%20few%20seconds%2C%20you%20should%20see%203%20more%20pods%20up%20%26amp%3B%20running%20for%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Enewsfeed%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edeployment%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-502%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20pods%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20READY%20%20%20STATUS%20%20%20%20RESTARTS%20%20%20AGE%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-%3CSPAN%20class%3D%22hljs-number%22%3E2%3C%2FSPAN%3Eql4h%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E24%3C%2FSPAN%3Es%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-mk47m%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E24%3C%2FSPAN%3Es%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-t4j79%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E30%3C%2FSPAN%3Em%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-vc4mp%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E24%3C%2FSPAN%3Es%0Aredis-%3CSPAN%20class%3D%22hljs-number%22%3E56%3C%2FSPAN%3Ef8fbc4d-lvxj8%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E30%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-%3CSPAN%20class%3D%22hljs-number%22%3E9%3C%2FSPAN%3Ekbx9%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E30%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-dkq9b%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E30%3C%2FSPAN%3Em%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7658%3C%2FSPAN%3Ecd5c85-rdc52%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E30%3C%2FSPAN%3Em%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EHowever%2C%20the%20most%20interesting%20aspect%20of%20the%20cloud%20is%20that%20you%20can%20easily%20scale%20automatically.%20Having%20to%20manually%20scale%20our%20deployments%2C%20in%20fact%2C%20isn't%20a%20very%20realistic%20scenario%2C%20since%20we%20can't%20always%20predict%20peaks.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1633172861%22%20id%3D%22toc-hId-1659980983%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22setting-up-auto-scale%22%20id%3D%22toc-hId--918984100%22%20id%3D%22toc-hId--892175978%22%3ESetting%20up%20auto-scale%3C%2FH3%3E%0A%3CP%3EThe%20first%20step%20to%20setup%20auto%20scaling%20is%20to%20define%2C%20for%20the%20layers%20of%20your%20application%2C%20how%20many%20resources%20they%20can%20use.%20We%20can%20do%20this%20by%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eresources%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%20in%20a%20YAML%20file.%20Here%20is%20how%20we%20can%20update%2C%20for%20example%2C%20the%20web%20deployment%20of%20our%20application%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-520%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3EapiVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eapps%2Fv1beta1%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ekind%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDeployment%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Emetadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3Espec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20replicas%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20template%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20metadata%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20labels%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20app%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20spec%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20containers%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20-%20name%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eweb%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20image%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eqmatteoq%2Ftestwebapp%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20ports%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20-%20containerPort%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20resources%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20requests%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20%20%20cpu%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E250%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Em%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20limits%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20%20%20%20%20%20%20%20%20cpu%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E500%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Em%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAs%20you%20can%20see%2C%20we%20have%20added%20a%20new%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eresources%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eentry%20which%20specifies%20that%20the%20container%20is%20going%20to%20request%200.25%20CPU%2C%20with%20a%20maximum%20allowed%20of%200.5.%20Now%20that%20we%20have%20defined%20these%20limits%2C%20we%20can%20apply%20again%20our%20YAML%20file%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-546%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20apply%20-f%20%3CSPAN%20class%3D%22hljs-string%22%3E%22.%2Fweb-aks.yml%22%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20advantage%20of%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20apply%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%20is%20that%20it%20doesn't%20wipe%20and%20reload%20the%20whole%20configuration%2C%20but%20it%20just%20applies%20the%20changes%20compared%20to%20the%20previous%20configuration.%20As%20a%20consequence%2C%20the%20newsfeed%20and%20redis%20deployments%20will%20be%20untouched.%20Only%20the%20web%20deployment%20will%20be%20updated%2C%20which%20will%20cause%20the%20various%20pods%20which%20hosts%20it%20to%20be%20terminated%20and%20recreated.%20Now%20we%20are%20ready%20to%20setup%20the%20auto%20scaling.%20You%20can%20set%20scaling%20rules%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20autoscale%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%2C%20as%20in%20the%20following%20example%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-553%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20autoscale%20deployment%20web%20--cpu-percent%3D%3CSPAN%20class%3D%22hljs-number%22%3E15%3C%2FSPAN%3E%20--min%3D%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20--max%3D%3CSPAN%20class%3D%22hljs-number%22%3E10%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWe're%20telling%20to%20Kubernetes%20that%20we%20want%20the%20web%20deployment%20to%20automatically%20scale%20up%20when%20the%20CPU%20usage%20of%20the%20node%20goes%20above%2015%25%2C%20from%20a%20minimum%20of%203%20pods%20to%20a%20maximum%20of%2010%20pods.%20Of%20course%2C%20this%20is%20an%20unrealistic%20example%2C%20since%2015%25%20is%20a%20too%20low%20threshold.%20However%2C%20thanks%20to%20this%20value%20we'll%20be%20able%20to%20easily%20test%20if%20the%20auto%20scaling%20works.%3C%2FP%3E%0A%3CP%3EWe%20can%20check%20the%20status%20of%20the%20configuration%20with%20the%20following%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-561%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20hpa%0ANAME%20%20%20REFERENCE%20%20%20%20%20%20%20%20TARGETS%20%20%20MINPODS%20%20%20MAXPODS%20%20%20REPLICAS%20%20%20AGE%0Aweb%20%20%20%20Deployment%2Fweb%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E4%3C%2FSPAN%3E%25%2F%3CSPAN%20class%3D%22hljs-number%22%3E15%3C%2FSPAN%3E%25%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E19%3C%2FSPAN%3Eh%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ETargets%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecolumn%20we%20can%20see%2C%20as%20first%20value%2C%20the%20current%20threshold%20followed%20by%20the%20limit%20we%20have%20set%20(15%25).%20Initially%2C%20the%20current%20threshold%20might%20be%20missing%20because%20Kubernetes%20will%20start%20to%20track%20it%20after%20the%20creation%20of%20the%20autoscale%20rule.%20As%20such%2C%20you%20might%20need%20to%20wait%20for%20a%20while%20before%20seeing%20a%20value%20there.%20From%20the%20other%20columns%20we%20can%20see%20that%20right%20now%20the%20application%20isn't%20under%20heavy%20load%20and%2C%20as%20such%2C%20Kubernetes%20is%20maintaining%203%20pods%2C%20which%20is%20the%20minimum%20value%20we%20have%20set.%20Now%20let's%20try%20to%20stress%20a%20bit%20our%20application%20to%20see%20if%20the%20auto%20scale%20kicks%20in.%20There%20are%20many%20tools%20and%20platforms%20to%20perform%20stress%20testing.%20The%20one%20I've%20chosen%20for%20my%20tests%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Floader.io%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELoader.io%3C%2FA%3E%2C%20which%20has%20a%20generous%20free%20tier.%20It%20allows%2C%20in%20fact%2C%20to%20simulate%20up%20to%201000%20concurrent%20clients%20using%20the%20free%20version%2C%20which%20is%20more%20than%20enough%20to%20stress%20our%20application%20for%20demo%20purposes.%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20created%20an%20account%20and%20verified%20it%2C%20you'll%20be%20asked%20to%20add%20a%20new%20host%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20915px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85008i1CBA89F8D749733B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22addnewhost.png%22%20title%3D%22addnewhost.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20first%20step%2C%20you%20will%20have%20to%20specify%20the%20full%20URL%20of%20your%20application.%20In%20our%20case%2C%20it's%20the%20one%20assigned%20by%20AKS%20to%20our%20Load%20Balancer%2C%20which%20you%20can%20retrieve%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20get%20services%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%20in%20case%20you%20have%20forgotten%20it%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-576%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20services%0ANAME%20%20%20%20%20%20%20%20%20TYPE%20%20%20%20%20%20%20%20%20%20%20CLUSTER-IP%20%20%20%20%20EXTERNAL-IP%20%20%20%20%20PORT(S)%20%20%20%20%20%20%20%20AGE%0Akubernetes%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%20%20%20%20%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E443%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3Ed23h%0Anewsfeed%20%20%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E142.105%3C%2FSPAN%3E%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E20%3C%2FSPAN%3Eh%0Aredis%20%20%20%20%20%20%20%20ClusterIP%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E252.243%3C%2FSPAN%3E%20%20%20%3CNONE%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E6379%3C%2FSPAN%3E%2FTCP%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E20%3C%2FSPAN%3Eh%0Aweb%20%20%20%20%20%20%20%20%20%20LoadBalancer%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E177.19%3C%2FSPAN%3E%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E13.80%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E251.199%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E80%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E30474%3C%2FSPAN%3E%2FTCP%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E20%3C%2FSPAN%3Eh%3C%2FNONE%3E%3C%2FNONE%3E%3C%2FNONE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20973px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85009i11348CC4B0DB92CF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22newhost.png%22%20title%3D%22newhost.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EOnce%20you%20move%20on%20to%20the%20next%20step%2C%20you%20will%20be%20asked%20to%20verify%20that%20you're%20indeed%20the%20owner%20of%20the%20website.%20It's%20a%20security%20measure%20to%20avoid%20that%20you%20can%20put%20under%20stress%20websites%20you%20don't%20own%20for%20malicious%20purposes.%20You%20will%20see%20a%20page%20like%20this%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20649px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85010i80FDD7A109C19A82%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22verify.png%22%20title%3D%22verify.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWe%20need%20to%20add%20a%20file%20in%20our%20web%20application%20with%20the%20provided%20token.%20However%2C%20in%20our%20scenario%2C%20we%20can't%20just%20upload%20the%20file%20over%20a%20FTP%20or%20similar%2C%20because%20we%20are%20running%20our%20web%20application%20inside%20a%20container.%20As%20such%2C%20let's%20start%20to%20download%20the%20proposed%20TXT%20file.%20Then%20open%20the%20folder%20which%20contains%20the%20web%20application%20and%20copy%20it%20inside%20the%26nbsp%3B%3CSTRONG%3Ewwwroot%3C%2FSTRONG%3E%26nbsp%3Bsubfolder%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20304px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85011i5450988A67956773%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22verificationfile.png%22%20title%3D%22verificationfile.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20we%20need%20to%20rebuild%20again%20the%20image%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-597%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20docker%20build%20-t%20%3CSPAN%20class%3D%22hljs-string%22%3E%22qmatteoq%2Ftestwebapp%22%3C%2FSPAN%3E%20.%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAnd%20finally%20we%20can%20push%20the%20updated%20image%20to%20Docker%20Hub%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-603%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20docker%20push%20qmatteoq%2Ftestwebapp%3Alatest%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENow%20we%20need%20to%20update%20our%20deployment%20image%2C%20by%20using%20the%20same%20command%20we%20have%20seen%20in%20the%20previous%20post%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-609%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20set%20image%20deployment%20web%20web%3Dqmatteoq%2Ftestwebapp%3Alatest%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAfter%20a%20few%20seconds%2C%20Kubernetes%20will%20replace%20all%20the%20running%20pods%20of%20the%20web%20application%20with%20an%20updated%20version%20which%20contains%20the%20text%20file%20we've%20added.%20We%20can%20verify%20it%20by%20opening%20with%20our%20browser%20the%20link%20suggested%20by%20the%20Loader.io%20website%20(it%20will%20be%20something%20like%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22http%3A%2F%2F13.80.251.199%2Floaderio-89eed0a56f943681855ff49b4d5ec377.txt%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F13.80.251.199%2Floaderio-89eed0a56f943681855ff49b4d5ec377.txt%3C%2FA%3E).%20If%20we%20can%20see%20the%20content%20of%20the%20file%20like%20in%20the%20below%20image%2C%20we're%20good%20to%20go%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20623px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85012i9264AC9E24954A54%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22verifiedimage.png%22%20title%3D%22verifiedimage.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20you%20can%20go%20back%20to%20the%20Loader.io%20wizard%20and%20press%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EVerify%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bbutton.%20The%20process%20should%20complete%20without%20errors%20and%20propose%20you%20to%20create%20a%20new%20test%2C%20thanks%20to%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ENew%20test%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bbutton%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20976px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85013i254BBCBFA3607D02%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22newloadtest.png%22%20title%3D%22newloadtest.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESet%20the%20following%20fields%3A%3C%2FP%3E%0A%3CUL%20id%3D%22pragma-line-623%22%3E%0A%3CLI%20id%3D%22pragma-line-623%22%3E%3CSTRONG%3EName%3C%2FSTRONG%3E%3A%20choose%20the%20name%20you%20prefer%20to%20identify%20the%20test%20(for%20example%2C%20Stress%20test).%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-624%22%3E%3CSTRONG%3ETest%20type%3C%2FSTRONG%3E%3A%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EClients%20per%20second%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-625%22%3E%3CSTRONG%3EClients%3C%2FSTRONG%3E%3A%20type%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E500%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%20id%3D%22pragma-line-626%22%3E%3CSTRONG%3EDuration%3C%2FSTRONG%3E%3A%20leave%201%20minute.%20In%20the%20free%20plan%20you%20can't%20define%20a%20longer%20timeframe.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThis%20test%20will%20execute%20500%20HTTP%20GETs%20per%20second%20to%20our%20web%20application%20for%201%20minute.%20Press%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERun%20test%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20start%20the%20experiment.%20During%20the%20execution%2C%20you%20will%20see%20many%20useful%20information%2C%20like%20the%20average%20response%20time%20and%20a%20chart%20with%20the%20number%20of%20requests%20being%20executed.%20You%20will%20quickly%20start%20to%20notice%20that%20the%20average%20time%20will%20start%20to%20grow%20significantly%20over%20time%20and%20you%20will%20have%20many%20timeouts%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20987px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85014i56ACBB5E67384B83%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22timeouts.png%22%20title%3D%22timeouts.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20to%20repeat%20the%20test%20multiple%20times%20and%2C%20in%20the%20meantime%2C%20use%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ekubectl%20get%20hpa%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%20to%20track%20the%20scaling%20status.%20At%20some%20point%2C%20you%20will%20see%20something%20like%20this%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-634%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20hpa%0ANAME%20%20%20REFERENCE%20%20%20%20%20%20%20%20TARGETS%20%20%20MINPODS%20%20%20MAXPODS%20%20%20REPLICAS%20%20%20AGE%0Aweb%20%20%20%20Deployment%2Fweb%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E22%3C%2FSPAN%3E%25%2F%3CSPAN%20class%3D%22hljs-number%22%3E15%3C%2FSPAN%3E%25%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E5%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E19%3C%2FSPAN%3Eh%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAs%20you%20can%20see%2C%20the%20current%20target%20is%20higher%20than%20the%20one%20we%20have%20set%2C%20so%20Kubernetes%20has%20started%20to%20spin%20up%20more%20pods.%20The%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EReplicas%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecolumn%2C%20in%20fact%2C%20is%20showing%20a%20value%20of%205%20instead%20of%20the%20usual%203%20one.%20Additionally%2C%20if%20you%20check%20the%20list%20of%20pods%2C%20we%20will%20see%20new%20pods%20spinning%20up%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-642%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20pods%0ANAME%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20READY%20%20%20STATUS%20%20%20%20%20%20%20%20%20%20%20%20%20%20RESTARTS%20%20%20AGE%0Anewsfeed-%3CSPAN%20class%3D%22hljs-number%22%3E595%3C%2FSPAN%3Ed865b75-t4j79%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E19%3C%2FSPAN%3Eh%0Aredis-%3CSPAN%20class%3D%22hljs-number%22%3E56%3C%2FSPAN%3Ef8fbc4d-lvxj8%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E19%3C%2FSPAN%3Eh%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Edb6cdbcfc-%3CSPAN%20class%3D%22hljs-number%22%3E655%3C%2FSPAN%3Ekk%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E118%3C%2FSPAN%3Es%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Edb6cdbcfc-%3CSPAN%20class%3D%22hljs-number%22%3E8%3C%2FSPAN%3Ebdxc%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20ContainerCreating%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3Es%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Edb6cdbcfc-%3CSPAN%20class%3D%22hljs-number%22%3E8%3C%2FSPAN%3Epd25%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E2%3C%2FSPAN%3Em1s%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Edb6cdbcfc-%3CSPAN%20class%3D%22hljs-number%22%3E944%3C%2FSPAN%3Eg4%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20ContainerCreating%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3Es%0Aweb-%3CSPAN%20class%3D%22hljs-number%22%3E7%3C%2FSPAN%3Edb6cdbcfc-z9pzt%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%20%20%20%20%20Running%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E0%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E2%3C%2FSPAN%3Em5s%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENow%2C%20if%20you%20stop%20running%20the%20stress%20test%20and%20you%20leave%20your%20web%20application%20idle%20for%20a%20while%2C%20you%20will%20notice%20that%20at%20some%20point%20Kubernetes%20will%20scale%20down%20your%20solution%20since%20the%20CPU%20usage%20is%20below%20the%20target%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-656%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20kubectl%20get%20hpa%0ANAME%20%20%20REFERENCE%20%20%20%20%20%20%20%20TARGETS%20%20%20MINPODS%20%20%20MAXPODS%20%20%20REPLICAS%20%20%20AGE%0Aweb%20%20%20%20Deployment%2Fweb%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E8%3C%2FSPAN%3E%25%2F%3CSPAN%20class%3D%22hljs-number%22%3E15%3C%2FSPAN%3E%25%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E10%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E3%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-number%22%3E19%3C%2FSPAN%3Eh%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId-823826235%22%20id%3D%22toc-hId-850634357%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22monitoring-your-cluster-thanks-to-aks%22%20id%3D%22toc-hId--1728330726%22%20id%3D%22toc-hId--1701522604%22%3EMonitoring%20your%20cluster%20thanks%20to%20AKS%3C%2FH3%3E%0A%3CP%3EOne%20of%20the%20advantages%20of%20using%20AKS%20instead%20of%20an%20on-premises%20cluster%20is%20that%20you%20get%2C%20out%20of%20the%20box%2C%20lot%20of%20insights%20about%20its%20status.%20It's%20enough%20to%20click%2C%20in%20the%20dashboard%2C%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EInsights%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%20to%20see%20lot%20of%20useful%20metrics%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85016iF848E959BE1E4BD1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22insights.png%22%20title%3D%22insights.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20quickly%20see%2C%20for%20example%2C%20that%20we%20had%20a%20spike%20of%20CPU%20usage%2C%20which%20has%20been%20translated%20in%20a%20higher%20number%20of%20pods.%20This%20happened%20when%20we%20have%20run%20the%20stress%20test%20using%20Loader.io.%3C%2FP%3E%0A%3CP%3EWhat%20if%20you%20want%20to%20use%20the%20same%20Kubernetes%20dashboard%20we%20have%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FFirst-steps-with-Docker-and-Kubernetes-Introduction%2Fba-p%2F357525%22%20target%3D%22_blank%22%3Ein%20the%20previous%20post%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eon%20our%20local%20machine%3F%20Good%20news%2C%20it's%20already%20deployed%20on%20AKS!%20In%20order%20to%20see%20it%2C%20just%20return%20to%20the%20home%20of%20your%20AKS%20cluster%20and%20click%20on%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EView%20Kubernetes%20dashboard%3C%2FSTRONG%3E.%20If%20you%20remember%2C%20we%20have%20already%20used%20this%20section%20to%20retrieve%20the%202%20commands%20we%20needed%20to%20setup%20kubectl%20to%20connect%20to%20our%20AKS%20cluster%20of%20the%20local%20one.%20But%20there's%20also%20a%20third%20command%20we%20didn't%20use%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20565px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85017iE3655B4BED14CDDC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22dashboard.png%22%20title%3D%22dashboard.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20exact%20command%20we%20need%20to%20see%20the%20dashboard.%20Copy%20and%20paste%20in%20your%20command%20prompt.%20It%20will%20spin%20up%20a%20proxy%20that%20will%20launch%20the%20dashboard%20on%20your%20local%20machine%2C%20but%20with%20the%20data%20coming%20from%20your%20AKS%20instance.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-675%22%20class%3D%22language-powershell%20hljs%22%3EPS%26gt%3B%20az%20aks%20browse%20--resource-group%20AKS%20--name%20aksappconsult%0AMerged%20%3CSPAN%20class%3D%22hljs-string%22%3E%22aksappconsult%22%3C%2FSPAN%3E%20as%20current%20context%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ein%3C%2FSPAN%3E%20C%3A%5CUsers%5Cmpagani%5CAppData%5CLocal%5CTemp%5Ctmpb68eguz8%0AProxy%20running%20on%20http%3A%2F%2F%3CSPAN%20class%3D%22hljs-number%22%3E127.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E8001%3C%2FSPAN%3E%2F%0APress%20CTRL%2BC%20to%20close%20the%20tunnel...%0AForwarding%20from%20%5B%3A%3A%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%5D%3A%3CSPAN%20class%3D%22hljs-number%22%3E8001%3C%2FSPAN%3E%20-%26gt%3B%20%3CSPAN%20class%3D%22hljs-number%22%3E9090%3C%2FSPAN%3E%0AForwarding%20from%20%3CSPAN%20class%3D%22hljs-number%22%3E127.0%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E0.1%3C%2FSPAN%3E%3A%3CSPAN%20class%3D%22hljs-number%22%3E8001%3C%2FSPAN%3E%20-%26gt%3B%20%3CSPAN%20class%3D%22hljs-number%22%3E9090%3C%2FSPAN%3E%0AHandling%20connection%20%3CSPAN%20class%3D%22hljs-keyword%22%3Efor%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-number%22%3E8001%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EYour%20default%20browser%20will%20automatically%20be%20launched%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CA%20href%3D%22http%3A%2F%2F127.0.0.1%3A8001%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F127.0.0.1%3A8001%3C%2FA%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EURL%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85018i616723510B0F6305%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22dashboard%20page.png%22%20title%3D%22dashboard%20page.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThanks%20to%20the%20dashboard%2C%20you%20will%20be%20able%20to%20review%20all%20the%20events%20that%20happened%20during%20the%20stress%20test.%20For%20example%2C%20click%20on%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eweb%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bin%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EDeployments%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bsection.%20You%20will%20be%20able%20to%20quickly%20see%20the%20CPU%20spike%20we%20had%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20739px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85019iA7CDCF5C64FEA8B8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22cpuspike.png%22%20title%3D%22cpuspike.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIf%20you%20scroll%20down%20you%20will%20find%20a%20section%20called%26nbsp%3B%3CSTRONG%3EHorizontal%20Pod%20Autoscalers%3C%2FSTRONG%3E%26nbsp%3B(HPA)%2C%20which%20will%20list%20the%20auto%20scale%20definition%20we%20have%20previously%20set%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85020iABCCE5349B4B5FBC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22hpa.png%22%20title%3D%22hpa.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20the%26nbsp%3B%3CSTRONG%3EEvents%3C%2FSTRONG%3E%26nbsp%3Bsection%20we%20can%20see%20that%20we%20have%20exceeded%20all%20the%20defined%20metrics%2C%20so%20auto%20scaling%20kicked%20in%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85021i3D132BE080F8C731%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22events.png%22%20title%3D%22events.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAs%20a%20consequence%2C%20in%20the%26nbsp%3B%3CSTRONG%3ENew%20replica%20set%3C%2FSTRONG%3E%26nbsp%3Bwe%20can%20see%20that%20we%20have%20now%207%20pods%20running%20for%20the%20web%20deployment%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F85022i3DA548F55941F8FC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pods.png%22%20title%3D%22pods.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22wrapping-up%22%20id%3D%22toc-hId-14479609%22%20id%3D%22toc-hId-41287731%22%3EWrapping%20up%3C%2FH3%3E%0A%3CP%3EIn%20this%20long%20post%20we%20have%20seen%20how%2C%20after%20having%20learned%20the%20basics%20of%20Kubernetes%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FFirst-steps-with-Docker-and-Kubernetes-Introduction%2Fba-p%2F357525%22%20target%3D%22_blank%22%3Ein%20the%20previous%20post%3C%2FA%3E%2C%20it's%20easy%20to%20reuse%20the%20same%20knowledge%20in%20a%20real%20environment%20like%20Azure%20Kubernetes%20Service%2C%20which%20is%20powered%20by%20the%20cloud%20and%2C%20as%20such%2C%20it%20offers%20a%20lot%20more%20flexibility.%20Additionally%2C%20thanks%20to%20the%20auto%20scaling%2C%20we%20can%20quickly%20scale%20up%20the%20resources%20of%20our%20application%20to%20satisfy%20any%20peak%20load%20that%20our%20application%20may%20experience%20and%20quickly%20scale%20down%20once%20the%20situation%20is%20back%20to%20normal.%3C%2FP%3E%0A%3CP%3EI've%20updated%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2FWindows-AppConsult-samples-PWA%2Ftree%2Fmaster%2FDocker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Emy%20sample%20on%20Docker%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20include%20the%20Kubernetes%20YAML%20file%20we%20have%20created%20during%20this%20blog%20post.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHappy%20deploying!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

In the previous post we have learned some basic concepts of Kubernetes and how it helps us to leverage Docker containers in a better way. However, the samples we used in the previous post have been helpful to understand the basics, but they aren't realistic. If you remember, as first step we have manually created a deployment using the NGINX image published on Docker Hub. However, in a real scenario, you will hardly have to manually create deployments and services. The second sample was closer to the real world, since we have used a more formal definition (the Docker Compose file) to deploy the whole architecture of our application. However, it still wasn't completely realistic, because we were taking advantage of the Kubernetes engine built-in inside Docker, which allowed us to use a Docker Compose file to describe the deployment. When you use a real Kubernetes infrastructure, you can't leverage Docker Compose files, but you need to create a YAML file which follows the Kubernetes specification.

In this post we're going to do exactly that: we're going to write a Kubernetes YAML definition to map our application and we're going to deploy it in the cloud, using Azure Kubernetes Service. Then, we're going to see how can easily scale our application in case of heavy load.

Let's start!

 

Writing our first YAML file

Let's start with something simple. In the previous post, as first step, we have manually created a deployment using the kubectl run command, followed by kubectl expose to create a service so that we could connect to the web server from our machine. Let's create a YAML file to achieve the same goal:

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 5
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: web

Each definition is composed by three items:

  • kind specifices which kind of Kubernetes resource we want to deploy. This is a big difference compared to Docker Compose files. We have to specify each Kubernetes object, which means that a single layer of application is typically composed by at least two objects: a deployment (with the app definition) and a service (to expose it to the other applications or to the outside world).
  • metadata allows to specify some information that are helpful to describe the object. In this case we're setting a name to make it easyer to identify the resource.
  • spec contains the full specification of the resource we want to deploy. The content of this section can be very different, based on the kind of resource. For example, you can notice how the spec section of the first resource (Deployment) is different from the one of the second resource (Service).

Let's take a closer look at the first section. Since it's used to setup a deployment, the spec section contains all the information about the application we want to deploy and its desired state. We have defined a template with a single container, called web, which is based on the nginx image. We have also specified that we want 5 replicas of this application as desired state. The expected outcome is that, like we have seen in the previous article when we have used the kubectl scale command, Kubernetes will take care of creating (and always keeping alive) 5 pods out of this deployment.

The second section, instead, is dedicated to configure the service and, as such, you have less options. It's enough to specify the type (LoadBalancer, since we want to expose the web server to the outside world) and the exposed port. A very important property is selector, which allows us to specify which deployment we want to expose through this service. In our case, it's the resource identified by the web label we have just created in the first section.

Now that the we have the full definition of our application, we can deploy it with the following command:

PS> kubectl apply -f web.yml
deployment.apps/web created
service/web created

We use the kubectl apply command, specifying as parameter the path of the YAML file which we have just created. Now we can use the usual kubectl commands to check what happened. Let's see first the deployments:

PS> kubectl get deployments
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
web    5/5     5            5           4m9s

We have a new deployment called web, which is composed by 5 instances. We can see them in more details by getting the list of pods:

PS> kubectl get pods
NAME                  READY   STATUS    RESTARTS   AGE
web-d54594dc4-7pt9d   1/1     Running   0          83s
web-d54594dc4-ddpgv   1/1     Running   0          83s
web-d54594dc4-kqnsq   1/1     Running   0          83s
web-d54594dc4-srcxl   1/1     Running   0          83s
web-d54594dc4-x2p48   1/1     Running   0          83s

Last, we can check the available services:

PS> kubectl get services
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP      10.96.0.1        <none>        443/TCP        3d3h
web          LoadBalancer   10.110.107.154   localhost     80:30514/TCP   91s

Since the service's type we have created is LoadBalancer, our application is exposed to the outside world through an external ip. Since we're running our Kubernetes cluster on our local machine, it means that we can open a browser and hit http://localhost to see the default NGINX page:

 

nginx.png

 

Azure Kubernetes Service

Now that we have learned to create a proper YAML file, we can try to deploy our application in a real environment like Azure Kubernetes Service (AKS, from now on). AKS is one of the many Azure services which belongs to the PaaS (Platform-As-A-Service) world. It means that we can deploy a Kubernetes cluster without having to worry about manually creating, maintaining and configuring the virtual machines. We will just have to create a new cluster, specify how much power we need (which translates into the CPU, RAM, hard disk, etc. which our VM will have) and how many nodes we need.

In order to start with Azure Kubernetes Service, login with your account on the Azure portal and choose Create a resource. Under the Containers category you will find the Kubernetes service:

 

kubernetes-azure.png

Select it to start the process of creating a new Kubernetes cluster:

 

create-aks.png

 

In the first section you just have to select the Subscription you want to leverage and the resource group where you want to store all the resources related to the cluster. For keeping things better organized, I prefer to create a dedicated resource group for AKS.

In the Cluster Details section you can configure all the settings of the cluster:

  • Kubernetes cluster name is the name which identifies the cluster
  • Region is the Azure region where you want to create the cluster. Choose a region close to you for lower latency.
  • Kubernetes version should be self-explanatory. Just leave the default one.
  • DNS name prefix is the prefix that will be used for the full URL assigned to the cluster.

In the end, you need to choose how much resoruces you need, based on the requirements of your application. You will have to choose:

  • The size of the VMs which will be used as nodes. You can choose between different sizes, with different amount of RAM, CPU cores, etc. This choice must be done carefuly, because you won't be able to change it later.
  • The number of nodes you want to create. This value, instead, can be changed also later if you need to scale your application up or down.

The last option lets you enable a preview feature called Virtual nodes, which is a new Azure feature to leverage Kubernetes with a serverless approach. We have just shared that AKS uses the PaaS approach, which means that you don't have to care about the underlying infrastructure, but you still have to choose the size of the VMs that will power up each node. As a consequence, scaling up could take a while, because AKS will need to spin up new VMs if you need more nodes. Virtual nodes, instead, allow to quickly spin up new nodes beyond the size of the cluster you have defined, by leveraging Azure Container Instances. For the moment, we aren't going to leverage it, so feel free to leave it disabled.

Press Review + Create to kick off the deployment process, which will take a while. Once it's finished, you will have a new Kubernetes cluster up & running.

Now we need to connect to it. The easiest way is through the Azure CLI (Command Line Interface), which can configure the kubectl tool to connect directly to AKS. If you don't have the Azure CLI on your machine, you can get in different ways based on your environment. You can leverage the Windows installer, you can use the Windows Subsystem for Linux (WSL) or you can even run it inside a Docker container.

No matter which path you choose, at the end you'll be able to use a command prompt to execute commands against your Azure subscription. The first step is to execute the login command:

PS> az login

Your default browser will open up and you will be asked to login to your Azure subcription. Once you're logged in, you're ready to interact with the resources you have in your subscription. The easiest way to connect to your AKS cluster is to open the Azure dashboard and, in the Overview section, choose View Kubernetes dashboard.

 

kubernetes-dashboard.png

A new panel will open up from the right with a set of Azure CLI commands:

 

dashboard.png

 

The first one will install kubectl on your local machine, even if you should already have it thanks to Docker Desktop:

PS> az aks install-cli

Now you can connect to your AKS instance by copying and pasting the second command:

PS> az aks get-credentials --resource-group AKS --name aksappconsult

Make sure to copy and paste the command from your dashboard and not the one above. In fact, you need to be sure that the --resource-group and the --name parameters are set with the specific values of your cluster. This command will store in the local Kubernetes configuration file the new context. If you have done everything properly, you should see something like this when you click on the Docker Desktop icon in your taskbar and you choose Kubernetes:

 

context.png

As you can see, there are two contexts listed in the menu:

  • The first is the one related to AKS we have just created (aksappconsult is the name of the AKS cluster I've created in my Azure portal)
  • The second is the local one created by Docker Desktop and which we have used in the previous post

Make sure that the AKS context is set. Now we can start using the kubectl tool against our AKS cluster. We can immediately see that by getting the list of available nodes:

PS> kubectl get nodes
NAME                       STATUS   ROLES   AGE    VERSION
aks-agentpool-27951239-0   Ready    agent   5d1h   v1.12.5
aks-agentpool-27951239-1   Ready    agent   5d1h   v1.12.5
aks-agentpool-27951239-2   Ready    agent   5d1h   v1.12.5
virtual-node-aci-linux     Ready    agent   5d     v1.13.1-vk-v0.7.4-44-g4f3bd20e-dev

When I created my AKS cluster, I've specified that I wanted 3 nodes and I've enabled the Virtual Node option. As such, the output of the command is the expected one: we have 3 physical nodes and a virtual one, called virtual-node-aci-linux.

Now it comes the fun part! Since we're connected to our AKS cluster, the same exact kubectl commands we have previously executed on our local cluster will work exactly in the same on our cloud cluster. For example, let's try to deploy the sample YAML file we have previously created:

PS> kubectl apply -f web.yml
deployment.apps/web created
service/web created

The outcome will be exactly the same but, this time, our NGINX instance will be deployed on the cloud. We can use the usual commands to see that everything is indeed up & running. First, let's take a look at the deployments:

PS> kubectl get deployments
NAME   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
web    5         5         5            5           94m

Then let's take a look at the pods:

PS> kubectl get pods
NAME                   READY   STATUS    RESTARTS   AGE
web-64888dbd49-j4nbr   1/1     Running   0          94m
web-64888dbd49-n4s8s   1/1     Running   0          94m
web-64888dbd49-rb2x9   1/1     Running   0          94m
web-64888dbd49-wgnlm   1/1     Running   0          94m
web-64888dbd49-zd4h7   1/1     Running   0          94m

No surprises here. It's the same exact scenario that we saw when we deployed the YAML locally. We can see only a small difference when we look at the services:

PS> kubectl get services
NAME         TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP      10.0.0.1     <none>        443/TCP        5d1h
web          LoadBalancer   10.0.1.69    <pending>     80:30216/TCP   6s

This time we aren't exposing the application on our local machine, but on a remote server. As such, the external IP takes a while to be assigned so, at first, you will see pending as value. You can add a watch to be notified when the external IP is assigned using the following command:

PS> kubectl get services web --watch
NAME   TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
web    LoadBalancer   10.0.1.69    <pending>     80:30216/TCP   23s
web   LoadBalancer   10.0.1.69   65.52.134.127   80:30216/TCP   39s

At first, you will see just the first line but, as soon as the IP is assigned, a new one will pop up. Now you can just copy the value from the EXTERNAL-IP column and paste it in your browser to see the default NGINX web page:

 

nginx-ask.png

 

A more complex deployment

The experiment we have just did was helpful to understand the basic concepts of AKS. In the end, the only difference from what we have learned in the first post is about setting up the environment. Once it's up & running, we can execute the same exact commands we were running on our local Kubernetes cluster.

However, it isn't a very realistic scenario because the application is very simple and made by a single layer. Let's deploy on AKS the original web application we are using as playground in the various posts. However, as first, we need to create the YAML definition since, at the moment, we have only a Docker Compose file that we can't deploy as it is on AKS. As a reminder, this is the structure of our project:

version: '3'
services:
  web:
    image: qmatteoq/testwebapp
    ports:
      - "1983:80"
  newsfeed:
    image: qmatteoq/testwebapi
  redis:
    image: redis

We need to convert these 3 layers into a Kubernetes YAML file. Let's start with the Redis cache:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis
        ports:
        - containerPort: 6379
          name: redis
---
apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  ports:
  - port: 6379
  selector:
    app: redis
---

If you remember what we have learned in the previous post, we need to define at least two resources for each layer. We need, in fact, a service for any deployment which must be exposed, regardless if it will be only internally or externally.

The first element, which kind is Deployment, defines the layer for the Redis cache. It's based on the official redis image on Docker Hub, it's exposed as a single instance and it's identified by the redis name. Naming is important, since it's the one that will be used by Kubernetes through the internal DNS. If you remember, in fact, our Web API connects to the Redis cache using redis as server name.

The second one, instead, is the Service and it exposes the redis deployment through the 6379 port, which is the default Redis one. Since we haven't specified the type property, the service will be exposed only in the internal network.

Now let's move to the Web API layer:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: newsfeed
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: newsfeed
    spec:
      containers:
      - name: newsfeed
        image: qmatteoq/testwebapi
        ports:
        - containerPort: 80
          name: newsfeed
---
apiVersion: v1
kind: Service
metadata:
  name: newsfeed
spec:
  ports:
  - port: 80
  selector:
    app: newsfeed
---

The structure is the same we have used for Redis. We have a Deployment entry which defines a single instance based on the qmatteoq/testwebapi image on Docker Hub, which is identified by the newsfeed label. Also in this case, newsfeed is the name used in the internal DNS. The web application, in fact, connects to the Web API using the http://newsfeed URL. The second section, instead, defines a service which exposes the deployment through the 80 port in the internal network.

Now let's take a look at the final section of the YAML file: the main web application.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: qmatteoq/testwebapp
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:

The Deployment section has always the same structure. It creates a deployment based on the qmatteoq/testwebapp image on Docker Hub. The only difference is that we want 3 instances of this layer. The second section, instead, is a bit different because we have added a type property set to LoadBalancer. This means that we want to expose the layer through the 80 port, but externally and not only internally.

For reference, this is how the full YAML file looks like:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis
        ports:
        - containerPort: 6379
          name: redis
---
apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  ports:
  - port: 6379
  selector:
    app: redis
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: newsfeed
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: newsfeed
    spec:
      containers:
      - name: newsfeed
        image: qmatteoq/testwebapi
        ports:
        - containerPort: 80
          name: newsfeed
---
apiVersion: v1
kind: Service
metadata:
  name: newsfeed
spec:
  ports:
  - port: 80
  selector:
    app: newsfeed
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: qmatteoq/testwebapp
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: web

Save this file and give it a name. Now we're ready to deploy it on AKS using the kubectl apply command:

PS> kubectl apply -f ".\web-aks.yml"

Can you guess which is the outcome? We should have now 3 deployments:

PS> kubectl get deployments
NAME       DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
newsfeed   1         1         1            1           25m
redis      1         1         1            1           25m
web        3         3         3            3           25m

These deployments should have kicked off 5 pods, since we have asked for 3 replicas of the web layer:

kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
newsfeed-595d865b75-t4j79   1/1     Running   0          25m
redis-56f8fbc4d-lvxj8       1/1     Running   0          25m
web-7658cd5c85-9kbx9        1/1     Running   0          25m
web-7658cd5c85-dkq9b        1/1     Running   0          25m
web-7658cd5c85-rdc52        1/1     Running   0          25m

In the end, we should have 4 services:

PS> kubectl get services
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP      10.0.0.1       <none>          443/TCP        5d3h
newsfeed     ClusterIP      10.0.142.105   <none>          80/TCP         23m
redis        ClusterIP      10.0.252.243   <none>          6379/TCP       23m
web          LoadBalancer   10.0.177.19    13.80.251.199   80:30474/TCP   24m

Only the web one, which type is LoadBalancer, will have an external IP. As we have seen when we have deployed NGINX, it may take a while before the external IP is assigned, so you can use the following command to track it:

PS> kubectl get service web --watch

Once the external IP is available, you can just open your browser pointing to it to see our web application up & running in the cloud:

 

akswebapp.png

 

The advantage of using a YAML definition is that, unlike we have seen in the previous post with Docker Compose, we are allowed to change it for scaling purpose. For example, let's run the following command:

PS> kubectl scale deployments newsfeed --replicas=4
deployment.extensions/newsfeed scaled

After a few seconds, you should see 3 more pods up & running for the newsfeed deployment:

PS> kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
newsfeed-595d865b75-2ql4h   1/1     Running   0          24s
newsfeed-595d865b75-mk47m   1/1     Running   0          24s
newsfeed-595d865b75-t4j79   1/1     Running   0          30m
newsfeed-595d865b75-vc4mp   1/1     Running   0          24s
redis-56f8fbc4d-lvxj8       1/1     Running   0          30m
web-7658cd5c85-9kbx9        1/1     Running   0          30m
web-7658cd5c85-dkq9b        1/1     Running   0          30m
web-7658cd5c85-rdc52        1/1     Running   0          30m

However, the most interesting aspect of the cloud is that you can easily scale automatically. Having to manually scale our deployments, in fact, isn't a very realistic scenario, since we can't always predict peaks.

 

Setting up auto-scale

The first step to setup auto scaling is to define, for the layers of your application, how many resources they can use. We can do this by using the resources property in a YAML file. Here is how we can update, for example, the web deployment of our application:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: qmatteoq/testwebapp
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 250m
          limits:
            cpu: 500m

As you can see, we have added a new resources entry which specifies that the container is going to request 0.25 CPU, with a maximum allowed of 0.5. Now that we have defined these limits, we can apply again our YAML file:

PS> kubectl apply -f "./web-aks.yml"

The advantage of using the kubectl apply command is that it doesn't wipe and reload the whole configuration, but it just applies the changes compared to the previous configuration. As a consequence, the newsfeed and redis deployments will be untouched. Only the web deployment will be updated, which will cause the various pods which hosts it to be terminated and recreated. Now we are ready to setup the auto scaling. You can set scaling rules using the kubectl autoscale command, as in the following example:

PS> kubectl autoscale deployment web --cpu-percent=15 --min=3 --max=10

We're telling to Kubernetes that we want the web deployment to automatically scale up when the CPU usage of the node goes above 15%, from a minimum of 3 pods to a maximum of 10 pods. Of course, this is an unrealistic example, since 15% is a too low threshold. However, thanks to this value we'll be able to easily test if the auto scaling works.

We can check the status of the configuration with the following command:

PS> kubectl get hpa
NAME   REFERENCE        TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
web    Deployment/web   4%/15%    3         10        3          19h

In the Targets column we can see, as first value, the current threshold followed by the limit we have set (15%). Initially, the current threshold might be missing because Kubernetes will start to track it after the creation of the autoscale rule. As such, you might need to wait for a while before seeing a value there. From the other columns we can see that right now the application isn't under heavy load and, as such, Kubernetes is maintaining 3 pods, which is the minimum value we have set. Now let's try to stress a bit our application to see if the auto scale kicks in. There are many tools and platforms to perform stress testing. The one I've chosen for my tests is Loader.io, which has a generous free tier. It allows, in fact, to simulate up to 1000 concurrent clients using the free version, which is more than enough to stress our application for demo purposes.

Once you have created an account and verified it, you'll be asked to add a new host:

 

addnewhost.png

 

As first step, you will have to specify the full URL of your application. In our case, it's the one assigned by AKS to our Load Balancer, which you can retrieve using the kubectl get services command in case you have forgotten it:

PS> kubectl get services
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP      10.0.0.1       <none>          443/TCP        5d23h
newsfeed     ClusterIP      10.0.142.105   <none>          80/TCP         20h
redis        ClusterIP      10.0.252.243   <none>          6379/TCP       20h
web          LoadBalancer   10.0.177.19    13.80.251.199   80:30474/TCP   20h

newhost.png

 

Once you move on to the next step, you will be asked to verify that you're indeed the owner of the website. It's a security measure to avoid that you can put under stress websites you don't own for malicious purposes. You will see a page like this:

 

verify.png

 

We need to add a file in our web application with the provided token. However, in our scenario, we can't just upload the file over a FTP or similar, because we are running our web application inside a container. As such, let's start to download the proposed TXT file. Then open the folder which contains the web application and copy it inside the wwwroot subfolder:

 

verificationfile.png

 

Now we need to rebuild again the image:

PS> docker build -t "qmatteoq/testwebapp" .

And finally we can push the updated image to Docker Hub:

PS> docker push qmatteoq/testwebapp:latest

Now we need to update our deployment image, by using the same command we have seen in the previous post:

PS> kubectl set image deployment web web=qmatteoq/testwebapp:latest

After a few seconds, Kubernetes will replace all the running pods of the web application with an updated version which contains the text file we've added. We can verify it by opening with our browser the link suggested by the Loader.io website (it will be something like http://13.80.251.199/loaderio-89eed0a56f943681855ff49b4d5ec377.txt). If we can see the content of the file like in the below image, we're good to go:

 

verifiedimage.png

 

Now you can go back to the Loader.io wizard and press the Verify button. The process should complete without errors and propose you to create a new test, thanks to the New test button:

 

newloadtest.png

 

Set the following fields:

  • Name: choose the name you prefer to identify the test (for example, Stress test).
  • Test type: choose Clients per second
  • Clients: type 500
  • Duration: leave 1 minute. In the free plan you can't define a longer timeframe.

This test will execute 500 HTTP GETs per second to our web application for 1 minute. Press Run test to start the experiment. During the execution, you will see many useful information, like the average response time and a chart with the number of requests being executed. You will quickly start to notice that the average time will start to grow significantly over time and you will have many timeouts:

 

timeouts.png

 

Try to repeat the test multiple times and, in the meantime, use the kubectl get hpa command to track the scaling status. At some point, you will see something like this:

PS> kubectl get hpa
NAME   REFERENCE        TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
web    Deployment/web   22%/15%   3         10        5          19h

As you can see, the current target is higher than the one we have set, so Kubernetes has started to spin up more pods. The Replicas column, in fact, is showing a value of 5 instead of the usual 3 one. Additionally, if you check the list of pods, we will see new pods spinning up:

PS> kubectl get pods
NAME                        READY   STATUS              RESTARTS   AGE
newsfeed-595d865b75-t4j79   1/1     Running             0          19h
redis-56f8fbc4d-lvxj8       1/1     Running             0          19h
web-7db6cdbcfc-655kk        1/1     Running             0          118s
web-7db6cdbcfc-8bdxc        0/1     ContainerCreating   0          3s
web-7db6cdbcfc-8pd25        1/1     Running             0          2m1s
web-7db6cdbcfc-944g4        0/1     ContainerCreating   0          3s
web-7db6cdbcfc-z9pzt        1/1     Running             0          2m5s

Now, if you stop running the stress test and you leave your web application idle for a while, you will notice that at some point Kubernetes will scale down your solution since the CPU usage is below the target:

PS> kubectl get hpa
NAME   REFERENCE        TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
web    Deployment/web   8%/15%    3         10        3          19h

 

Monitoring your cluster thanks to AKS

One of the advantages of using AKS instead of an on-premises cluster is that you get, out of the box, lot of insights about its status. It's enough to click, in the dashboard, on the Insights section to see lot of useful metrics:

 

insights.png

 

You can quickly see, for example, that we had a spike of CPU usage, which has been translated in a higher number of pods. This happened when we have run the stress test using Loader.io.

What if you want to use the same Kubernetes dashboard we have used in the previous post on our local machine? Good news, it's already deployed on AKS! In order to see it, just return to the home of your AKS cluster and click on View Kubernetes dashboard. If you remember, we have already used this section to retrieve the 2 commands we needed to setup kubectl to connect to our AKS cluster of the local one. But there's also a third command we didn't use:

 

dashboard.png

 

This is the exact command we need to see the dashboard. Copy and paste in your command prompt. It will spin up a proxy that will launch the dashboard on your local machine, but with the data coming from your AKS instance.

PS> az aks browse --resource-group AKS --name aksappconsult
Merged "aksappconsult" as current context in C:\Users\mpagani\AppData\Local\Temp\tmpb68eguz8
Proxy running on http://127.0.0.1:8001/
Press CTRL+C to close the tunnel...
Forwarding from [::1]:8001 -> 9090
Forwarding from 127.0.0.1:8001 -> 9090
Handling connection for 8001

Your default browser will automatically be launched on the http://127.0.0.1:8001 URL:

 

dashboard page.png

 

Thanks to the dashboard, you will be able to review all the events that happened during the stress test. For example, click on web in the Deployments section. You will be able to quickly see the CPU spike we had:

 

cpuspike.png

 

If you scroll down you will find a section called Horizontal Pod Autoscalers (HPA), which will list the auto scale definition we have previously set:

 

hpa.png

 

In the Events section we can see that we have exceeded all the defined metrics, so auto scaling kicked in:

 

events.png

 

As a consequence, in the New replica set we can see that we have now 7 pods running for the web deployment:

 

pods.png

 

Wrapping up

In this long post we have seen how, after having learned the basics of Kubernetes in the previous post, it's easy to reuse the same knowledge in a real environment like Azure Kubernetes Service, which is powered by the cloud and, as such, it offers a lot more flexibility. Additionally, thanks to the auto scaling, we can quickly scale up the resources of our application to satisfy any peak load that our application may experience and quickly scale down once the situation is back to normal.

I've updated my sample on Docker to include the Kubernetes YAML file we have created during this blog post.

 

Happy deploying!