<!--DEBUG:--><!--DEBUG:dc3-united-states-software-in-english-pdf-2--><!--DEBUG:--><!--DEBUG:dc3-united-states-software-in-english-pdf-2--><!--DEBUG-spv-->{"id":1830395,"date":"2021-02-01T02:55:00","date_gmt":"2021-02-01T00:55:00","guid":{"rendered":"http:\/\/nhub.news\/?p=1830395"},"modified":"2021-02-01T06:03:11","modified_gmt":"2021-02-01T04:03:11","slug":"alexa-and-kubernetes-deploying-the-alexa-skill-on-google-kubernetes-engine-ix","status":"publish","type":"post","link":"http:\/\/nhub.news\/ru\/2021\/02\/alexa-and-kubernetes-deploying-the-alexa-skill-on-google-kubernetes-engine-ix\/","title":{"rendered":"Alexa and Kubernetes: Deploying the Alexa Skill on Google Kubernetes Engine (IX)"},"content":{"rendered":"<p style=\"text-align: justify;\"><b>In this last article in my installment, I will teach you how to automatically deploy an Alexa Skill to Google Kubernetes Engine using Terraform.<\/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 creating a cluster in any cloud provider manually is a difficult task. Moreover, if we want to automate this deployment, we need something that helps us in this tedious task. In this article, we will see how to create a Kubernetes Cluster and all of its required objects, deploying our Alexa Skill with Terraform using Google Kubernetes Engine. 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 that 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, I am going to explain all the terraform files and its objects that we are going to use to deploy the cluster and our Alexa Skill. You can find all the files related to this deployment in terraform\/gke 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 Google Kubernetes Engine, we will use the google provider. This provider allows us to create all Google Cloud 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: One of the most important resources of an EKS Cluster is networking. Because of that, we have to create our Virtual Private Cloud Network and Subnetworks: 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 google_container_cluster module: Every cluster should have a pool of Nodes where the Kubernetes objects will be deployed. For creating that pool of nodes on Google Cloud, we will use the google_container_node_pool resource: All the resources and modules commented on 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 project_id or the region where the cluster will be deployed. For that, you can modify the variables on terraform.tfvars: To create a Google Cloud project using the gcloud and setting this project as the default project, 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 the 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 at the Google Kubernetes Engine to see that our cluster now appears. We need to wait about 10 minutes until the cluster is created. Once the cluster is created, we can see the full specifications. After the cluster creation, Terraform will deploy all the Helm charts. There you can see all the Kubernetes Pods deployed. And, you can see 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 here. With Postman, you can emulate any Alexa Request. For example, you can test a LaunchRequest: And, there, you can see 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. If we want to remove all the stack created by Terraform, just run: Now, we have the Alexa Skill running in a Kubernetes Cluster of the cloud provider with everything automated with Terraform; it&#8217;s 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 last article in my installment, I will teach you how to automatically deploy an Alexa Skill to Google Kubernetes Engine using Terraform. 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":1830394,"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\/1830395"}],"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=1830395"}],"version-history":[{"count":1,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts\/1830395\/revisions"}],"predecessor-version":[{"id":1830396,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/posts\/1830395\/revisions\/1830396"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/media\/1830394"}],"wp:attachment":[{"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/media?parent=1830395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/categories?post=1830395"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nhub.news\/ru\/wp-json\/wp\/v2\/tags?post=1830395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}