{"id":37756,"date":"2019-09-25T07:42:27","date_gmt":"2019-09-25T14:42:27","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/premier-developer\/?p=37756"},"modified":"2019-09-23T09:10:59","modified_gmt":"2019-09-23T16:10:59","slug":"a-survey-of-kubernetes-features-in-azure","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/a-survey-of-kubernetes-features-in-azure\/","title":{"rendered":"A Survey of Kubernetes Features in Azure"},"content":{"rendered":"<p>App Dev Manager <a href=\"https:\/\/www.linkedin.com\/in\/jasonvenema\/\">Jason Venema<\/a> explores support and functionality for Kubernetes offered across a range of Azure services.<\/p>\n<hr \/>\n<p>So, have you heard about Kubernetes? I bet you have. It\u2019s no secret that Kubernetes has become the <em>de facto<\/em> container orchestrator for companies that develop software and want to maintain highly available applications for their customers. And let\u2019s be honest, these days that includes pretty much <em>every<\/em> company that writes <em>any<\/em> sort of software.<\/p>\n<p>Alright, so we all know that Kubernetes is taking over the world. For those of you who may have been sitting on the sidelines for a while, biding your time until the inevitable freight train that is Kubernetes comes to run you over, let me help demystify some of the tools and services available in Azure that make Kubernetes much easier to use than it ever has been before.<\/p>\n<p>You may be wondering what it\u2019s like to actually develop something that will run on Kubernetes. Maybe you\u2019ve heard that Kubernetes can be complex to set up and operate, and you\u2019re wondering if it\u2019s also complex to develop and deploy your applications? And what about event driven auto-scaling \u2013 is that even possible in Kubernetes?<\/p>\n<p>In this post, I\u2019m going to provide an overview of some of the features and services available in Azure that make developing applications for Kubernetes a relative breeze. I\u2019ll be giving an overview of the following features:<\/p>\n<ul>\n<li>Azure Kubernetes Service (AKS)<\/li>\n<li>Azure Container Instance (ACI)<\/li>\n<li>Kubernetes-based Event Drive Autoscaling (KEDA)<\/li>\n<li>Azure Dev Spaces<\/li>\n<li>Azure Pipelines Kubernetes CI\/CD<\/li>\n<\/ul>\n<h2>Azure Kubernetes Service<\/h2>\n<p>Alright, admittedly this one is kind of obvious. If you want to deploy a containerized application to Kubernetes, you\u2019re clearly going to need a Kubernetes cluster. And if you want to deploy your own Kubernetes cluster, then Azure Kubernetes Service is <em>by far <\/em>the easiest way to do it. If you want to do it the hip way (you do), then it\u2019s a simple matter of navigating to the Azure portal, opening up a Bash <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cloud-shell\/overview\">Cloud Shell<\/a> and typing:<\/p>\n<pre class=\"lang:default decode:true \">az aks create --resource-group myResourceGroup --name myAKSCluster<\/pre>\n<p>That\u2019s the simplest possible way to create a cluster, though to be honest you might want to <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/kubernetes-walkthrough\">pass a few other parameters<\/a> to control things like the number of agent nodes, install add-ons, and so on. Oh, and if you want to create your cluster <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/kubernetes-walkthrough-portal\">using the portal<\/a>, that\u2019s perfectly alright, too (no shame!)<\/p>\n<p>In addition to being simple to deploy a cluster (a major feat in itself), AKS brings a lot of other benefits to the table. One key benefit is that although AKS is comprised of both master and agent nodes (servers), you will only pay for the agent nodes. Microsoft covers the cost of the masters, and also takes care of managing them behind the scenes so you don\u2019t have to think about. And don\u2019t forget about <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#identity-and-security-management\">Azure AD integration<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#integrated-logging-and-monitoring\">integrated logging and monitoring using Azure Monitor<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#cluster-node-and-pod-scaling\">auto-scaling<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#cluster-node-upgrades\">managed upgrades of the agent nodes<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#storage-volume-support\">storage volume support<\/a>, <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#virtual-networks-and-ingress\">virtual network support<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/aks\/intro-kubernetes#ingress-with-http-application-routing\">ingress with HTTP application routing<\/a>\u2026 to name just a few.<\/p>\n<h2>Azure Container Instances (ACI)<\/h2>\n<p>You\u2019re probably convinced by now that AKS is pretty great. I would agree. For organizations that want to run their production applications on top of a fully featured container orchestrator, AKS is definitely the way to go. Sometimes, though, you just need a place to deploy a container and let it run for a few minutes. Maybe you\u2019re just doing some testing, or running a batch job that only takes a few minutes to complete. For those cases, setting up a full-blown AKS cluster would be overkill.<\/p>\n<p>This is where Azure Container Instances (ACI) comes in. Simply <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/container-instances\/container-instances-quickstart\">point ACI at the container image you want to run<\/a>, give it a DNS name, tell it which ports you need to expose and you\u2019re done. ACI will pull down your container image and run it until you tell it to stop. You can see this in action by running a single CLI command from the Azure Cloud Shell:<\/p>\n<pre class=\"lang:default decode:true \">az container create --resource-group myResourceGroup --name mycontainer --image mcr.microsoft.com\/azuredocs\/aci-helloworld --dns-name-label aci-demo --ports 80<\/pre>\n<p>The great thing about this is that within seconds (yes, <em>seconds<\/em>) your container instance will be up and running. This is a world-away from VMs, where it would take <em>minutes<\/em> just to start the VM, let alone fire up and begin using your application. Best of all, ACI charges for usage by the second, so you truly pay only for what you use. If you just need your container to run for a few minutes, you only pay for a few minutes of runtime!<\/p>\n<p><img decoding=\"async\" width=\"605\" height=\"365\" class=\"wp-image-37757\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/09\/word-image-1.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/09\/word-image-1.png 605w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/09\/word-image-1-300x181.png 300w\" sizes=\"(max-width: 605px) 100vw, 605px\" \/><\/p>\n<h2>Azure Dev Spaces<\/h2>\n<p>Now that we know how to create our cluster with AKS, let\u2019s get back to talking about the developer experience. You\u2019re probably convinced by now that it\u2019s really easy to run and orchestrate containers in AKS. You might be <em>less<\/em> convinced that containerized applications are easy to create and debug in Kubernetes, though.<\/p>\n<p>The reality is, if I\u2019m deploying my applications as a set of containers then I\u2019m probably doing at least some amount of microservice development. Even if it\u2019s not full-blown microservices, if you\u2019re bothering to containerize your applications at all, then they are probably architected in such a way that the individual services can run independently from one another. This introduces some potential complexity, because <em>you personally <\/em>are probably only working on a small fraction of all the containers the make up your application. This begs the question: How can you test your containers in the context of the full application without having to deploy your own personal Kubernetes cluster, and without stepping on the rest of your team\u2019s changes? The larger your application gets, the bigger this challenge becomes.<\/p>\n<p>Fear not, though. This is exactly the problem that <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/dev-spaces\/\">Azure Dev Spaces<\/a> solves. By enabling Dev Spaces on your AKS development cluster, everyone in your team can share the same cluster but <em>see only their own changes<\/em> during development. This requires you to first deploy a \u201cbaseline\u201d working version of your entire application \u2013 every container \u2013 to the AKS cluster. Then, as individual developers make changes to their portion of the application, they can deploy updated versions of their containers.<\/p>\n<p>Here\u2019s the magic part: When you deploy your container with Azure Dev Spaces enabled, each developer gets their own special URL that ensures they are hitting the code in their own updated containers, but they continue to hit the \u201cbaseline\u201d containers for the rest of the application. This is true even if other team members have also deployed their own changes! This GIF from the Azure Dev Spaces documentation page is the best visual explanation of how this work:<\/p>\n<p><img decoding=\"async\" width=\"1778\" height=\"528\" class=\"wp-image-37758\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/09\/azure-dev-spaces-in-action.gif\" alt=\"Azure Dev Spaces in action\" \/><\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/dev-spaces\/how-dev-spaces-works\">Behind the scenes<\/a>, Azure Dev Spaces is creating designated Kubernetes namespaces for each dev space. A namespace is a way of isolating containers in Kubernetes, so it\u2019s perfect for keeping your changes isolated from the rest of your team. Dev Spaces also takes care of the routing needed to ensure you only see your own changes. When you\u2019re ready for the rest of your team to see your changes, simply update the \u201cbaseline\u201d version with your new containers. Simple!<\/p>\n<h2>Event Driven Kubernetes with KEDA<\/h2>\n<p>Many organizations have already adopted event driven application designs leveraging serverless technologies like Azure Functions, which provides a really fantastic development and debugging experience both locally, as well as in Azure. And while it is very convenient to have a fully managed environment for running your functions, sometimes you want a little more control over the underlying infrastructure. This is where KEDA comes in.<\/p>\n<p>KEDA is <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-functions\/functions-kubernetes-keda\">Kubernetes-based Event Driven Autoscaling<\/a>. Let\u2019s break that down. Azure Functions can, of course, run in Azure but they can also run in a container on a server that has the Azure Functions runtime installed on it. That server could be, say, an agent node(s) in a Kubernetes cluster. This is nice, because you can run your functions in a container and have full control over the underlying infrastructure. However, the piece missing is auto-scaling of the number of instances. In Kubernetes, it\u2019s possible to auto-scale based on CPU or memory thresholds being reached, but in oftentimes what you really want is to scale <em>before <\/em>those metrics are impacted.<\/p>\n<p>Azure Functions has a solution for this in the form of a component called the <em>scale controller<\/em>, which intelligently monitors events and proactively scales out your Functions as needed. KEDA enables you to take advantage of this scale controller to do the same thing in Kubernetes, <a href=\"https:\/\/cloudblogs.microsoft.com\/opensource\/2019\/05\/06\/announcing-keda-kubernetes-event-driven-autoscaling-containers\/\">automatically scaling your containerized Functions<\/a> based on event metrics from any number of different sources. And because KEDA is extensible, new event metrics sources can be added meaning you can auto-scale based on anything you like.<\/p>\n<p><a href=\"https:\/\/github.com\/kedacore\/keda\">Getting started with KEDA<\/a> is as simple as deploying a Helm chart to your Kubernetes cluster, and then deploying the Azure Functions core tools. Just be aware that as of today, KEDA is currently in preview so you shouldn\u2019t use it for your production workloads just yet.<\/p>\n<h2>Deploy to AKS with Azure Pipelines<\/h2>\n<p>As we\u2019ve seen, creating a Kubernetes cluster and getting started developing applications is made much easier with AKS, ACI and Azure Dev Spaces. Automatically scaling your applications using event driven metrics is also made possible with KEDA. The final piece of the puzzle is automatically deploying your application to AKS. Azure Pipelines makes this incredibly easy with built-in CI\/CD pipeline templates.<\/p>\n<p>All you need to get started is a repository that contains your source code and a Dockerfile. <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/ecosystems\/kubernetes\/aks-template?view=azure-devops&amp;tabs=java\">Follow the documentation<\/a> the create a YAML based CI\/CD pipeline in Azure Pipelines, and every time you push a code change to your repository Azure Pipelines will build your application and push the new container image to Azure Container Registry. Once the container image is in the registry, the pipeline applies a deployment manifest to your AKS cluster, causing the new image to be pulled down and deployed. That\u2019s all there is to it!<\/p>\n<h2>Conclusion<\/h2>\n<p>While Kubernetes itself may be complex, getting started with it is not as hard as it might seem. Using Azure services like AKS, Azure Container Instances and Azure Dev Spaces makes setting up a cluster and testing your containers relatively simple. Azure Pipelines adds the ability to quickly setup an automated CI\/CD pipeline that will deploy your new container images whenever a change is checked in to your code repository. Finally, the preview KEDA service lets you experiment with custom auto-scaling of containers running in a Kubernetes cluster using the Azure Functions scale controller.<\/p>\n<p>Kubernetes has experienced massive growth since its inception, and it is not losing any momentum. If you\u2019ve been sitting on the sidelines, it\u2019s time to jump in and get started. And there\u2019s no better place to do that than in Azure!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Azure services like AKS, Azure Container Instances and Azure Dev Spaces makes setting up a cluster and testing your containers relatively simple.<\/p>\n","protected":false},"author":582,"featured_media":37760,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,126],"tags":[5332,153,7819,2571,29,92,3],"class_list":["post-37756","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-kubernetes","tag-aks","tag-azure-container-service","tag-azure-dev-spaces","tag-azure-devops","tag-docker","tag-kubernetes","tag-team"],"acf":[],"blog_post_summary":"<p>Using Azure services like AKS, Azure Container Instances and Azure Dev Spaces makes setting up a cluster and testing your containers relatively simple.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/37756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=37756"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/37756\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37760"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=37756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=37756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=37756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}