<!--DEBUG:--><!--DEBUG:dc3-united-states-software-in-english-pdf-2--><!--DEBUG:--><!--DEBUG:dc3-united-states-software-in-english-pdf-2--><!--DEBUG-spv-->{"id":1830968,"date":"2021-02-02T05:25:00","date_gmt":"2021-02-02T03:25:00","guid":{"rendered":"http:\/\/nhub.news\/?p=1830968"},"modified":"2021-02-02T06:04:21","modified_gmt":"2021-02-02T04:04:21","slug":"alexa-and-kubernetes-deploying-the-alexa-skill-on-azure-kubernetes-services-viii","status":"publish","type":"post","link":"http:\/\/nhub.news\/ru\/2021\/02\/alexa-and-kubernetes-deploying-the-alexa-skill-on-azure-kubernetes-services-viii\/","title":{"rendered":"Alexa and Kubernetes. Deploying the Alexa Skill on Azure Kubernetes Services (VIII)"},"content":{"rendered":"<p style=\"text-align: justify;\"><b>In this blog post, we will see how to create a Kubernetes Cluster and deploy our Alexa Skill with Terraform using Azure Kubernetes Services.<\/b><br \/>\nJoin the DZone community and get the full member experience. Now we have everything prepared and ready to go to a Kubernetes Cluster in a cloud provider. It is a fact that create a cluster in any cloud provider manually is a hard task. Moreover, if we want to automate these deployments we need something that helps us in this tedious task. In this blog post, we will see how to create a Kubernetes Cluster and all of its required objects and deploying our Alexa Skill with Terraform using Azure Kubernetes Services. Here you have the technologies used in this project Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied. The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. After the brief overview of Terraform, we are going to explaining all the terraform files and its objects that we are going to use to deploy de cluster and our Alexa Skill. You can find all the files related to this deployment in terraform\/aks folder. A provider is responsible for understanding API interactions and exposing resources. Most of the available providers correspond to one cloud or on-premises infrastructure platform and offers resource types that correspond to each of the features of that platform. For the Azure Kubernetes Service, we will use the azurerm provider. This provider allow us to create all Azure objects that we need to create our Alexa Skill Stack: As we are going to deploy Helm Charts, it will be required to have the helm provider: Once the Private cloud Network has been created, we can create the cluster that will use that VPC. For that, we need to use the azurerm_resource_group module: Once the Resource Group has been created, we can create the cluster that will use that RG. For that, we need to use the azurerm_kubernetes_cluster module: All the resources and modules commented above are related to the Kubernetes cluster. Now it\u2019s time to deploy our Alexa Skill starting with the ngingx-ingress-controller: After that, we can proudly deploy our Alexa Skill Helm chart in our Kubernetes Cloud cluster: We have provided some variables that you can modify easily in order to change the name of the app_id or the password of this Azure app. For that, you can modify the variables on terraform.tfvars: To create an Azure Service Principal using the az cli and getting the password for that Service Principal. Terraform needs a Service Principal to create resources on your behalf. You can think of it as a user identity (login and password) with a specific role, and tightly controlled permissions to access your resources. It could have fine-grained permissions such as only to create virtual machines or read from a particular blob storage. For that, we need to execute the following commands: In order to make a provider available on Terraform, we need to make a terraform init, these commands download any plugins we need for our providers. After that, we have to execute terraform plan. The terraform plan command is used to create an execution plan. It will not modify things in infrastructure. Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files. This command is a convenient way to check whether the execution plan for a set of changes matches your expectations without making any changes to real resources or to the state. Then, we need to execute terraform apply. The terraform apply command is used to apply the changes required to reach the desired state of the configuration. Terraform apply will also write data to the terraform.tfstate file. Once the application is completed, resources are immediately available. Here you have the full command list: After running the terraform apply, we can take a look to Azure Kubernetes Service to see that our cluster now appears: We need to wait like 10 minutes until the cluster is created. Once the cluster is created now we can see the full specifications: After the cluster creation, Terraform will deploy all the Helm charts. Here you can see all the Kubernetes Pods deployed: And here the Kubernetes Services and the external IP of the nginx-ingress-controller. That IP is the one we are going to use to make Alexa requests: I\u2019m sure you already know the famous tool call Postman. REST APIs have become the new standard in providing a public and secure interface for your service. Though REST has become ubiquitous, it\u2019s not always easy to test. Postman makes it easier to test and manage HTTP REST APIs. Postman gives us multiple features to import, test, and share APIs, which will help you and your team be more productive in the long run. After running your application you will have an endpoint available at http:\/\/51.143.242.234. With Postman you can emulate any Alexa Request. For example, you can test a LaunchRequest: If we want to remove all the stack created by Terraform, just run: Now we have our Alexa Skill running in a Kubernetes Cluster of our cloud provider everything automated with Terraform and ready to use in our live Alexa Skills. I hope this example project is useful to you. You can find the code here. That\u2019s all folks! Happy coding! Opinions expressed by DZone contributors are their own.<\/p>\n<script>jQuery(function(){jQuery(\".vc_icon_element-icon\").css(\"top\", \"0px\");});<\/script><script>jQuery(function(){jQuery(\"#td_post_ranks\").css(\"height\", \"10px\");});<\/script><script>jQuery(function(){jQuery(\".td-post-content\").find(\"p\").find(\"img\").hide();});<\/script>","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will see how to create a Kubernetes Cluster and deploy our Alexa Skill with Terraform using Azure Kubernetes Services. Join the DZone community and get the full member experience. Now we have everything prepared and ready to go to a Kubernetes Cluster in a cloud provider. It is a fact [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1830967,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[93],"tags":[],"_links":{"self":[{"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts\/1830968"}],"collection":[{"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/comments?post=1830968"}],"version-history":[{"count":1,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts\/1830968\/revisions"}],"predecessor-version":[{"id":1830969,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts\/1830968\/revisions\/1830969"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/media\/1830967"}],"wp:attachment":[{"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/media?parent=1830968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/categories?post=1830968"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/tags?post=1830968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}