{"id":2657,"date":"2019-03-17T19:32:49","date_gmt":"2019-03-17T14:02:49","guid":{"rendered":"http:\/\/navveenbalani.dev\/?p=2657"},"modified":"2019-12-17T21:01:26","modified_gmt":"2019-12-17T15:31:26","slug":"building-production-topology-with-google-cloud-part-5","status":"publish","type":"post","link":"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/","title":{"rendered":"Building Production Topology with Google Cloud &#8211; Part 5"},"content":{"rendered":"\n<p>In\nthis chapter, we would deploy Nginx Ingress Controller instead of GCE. <\/p>\n\n\n\n<p>NGINX, by default, provides a lot of additional\ncapabilities as compared to the default GKE Ingress controller like URL\nrewriting, whitelisting, load balancing over HTTPS and websocket and advanced\nfeatures through Nginx Plus. For details, refer to <a href=\"https:\/\/www.nginx.com\/products\/nginx\/\">https:\/\/www.nginx.com\/products\/nginx\/<\/a>.<\/p>\n\n\n\n<p>It is assumed that you have executed Step 1 &#8211; 7 as per the previous article.<\/p>\n\n\n\n<h2><a>Install Nginx Ingress<\/a><\/h2>\n\n\n\n<p>The first step is to install Nginx Ingress in our\ncluster. Navigate to Cloud Console &#8211; &gt; Kubernetes Engine -&gt; Cluster.\nClick on the connect button for backend-cluster. This will launch the cloud\nshell as shown below. Click ok to Run in cloud shell to connect to the\nbackend-cluster.<\/p>\n\n\n\n<p><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Figure 35:&nbsp; Cloud Shell<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"294\" height=\"221\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-36.png\" alt=\"\" class=\"wp-image-2658\"\/><\/figure>\n\n\n\n<p>Next, we will install Helm which allows us to install and manage Kubernetes applications and resources effectively. Helm has two parts: a client (helm) which runs on cloud shell and a server\n(tiller) which runs inside of the kubernetes cluster and manages the\ninstallation.<\/p>\n\n\n\n<p>Install the latest version of Helm by running the\nfollowing command:<\/p>\n\n\n\n<p>&gt; curl -o get_helm.sh\nhttps:\/\/raw.githubusercontent.com\/kubernetes\/helm\/master\/scripts\/get<\/p>\n\n\n\n<p>&gt; chmod +x get_helm.sh<\/p>\n\n\n\n<p>&gt; .\/get_helm.sh<\/p>\n\n\n\n<p>Next, we would Install Tiller. Run the following\ncommands to install the server-side tiller to the Kubernetes cluster. The below\ncommand creates a service account and the cluster-admin role to manage the\ncluster.<\/p>\n\n\n\n<p>&gt; kubectl create\nserviceaccount &#8211;namespace kube-system tiller<\/p>\n\n\n\n<p>&gt; kubectl create\nclusterrolebinding tiller-cluster-rule &#8211;clusterrole=cluster-admin\n&#8211;serviceaccount=kube-system:tiller<\/p>\n\n\n\n<p>&gt; helm init &#8211;service-account\ntiller<\/p>\n\n\n\n<p>The following image shows the command\ninteractions and output at the google cloud shell.<\/p>\n\n\n\n<p><em>Figure 36:&nbsp; Cloud Shell -&gt; Installation of Helm<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"342\" height=\"232\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-37.png\" alt=\"\" class=\"wp-image-2659\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-37.png 342w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-37-300x204.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure>\n\n\n\n<p>Next, we will install the Nginx Ingress through\nHelm. Installing Nginx Ingress will configure a Service type of LoadBalancer in\nour cluster which will route all the incoming requests as per the rules you\ndefine in the deployment file (we will look at this later while deploying the\ningress.yaml file).&nbsp; <\/p>\n\n\n\n<p>LoadBalancer should listen over an IP. The IP can\nbe automatically assigned by the network system or you can create a static IP\naddress and use the ip address while installing Nginx. We will create a static IP\naddress since this IP address can then be mapped to your domain name where you\nwant to expose the service for public consumption (i.e. similar to domain like api.naveenbalani.dev\nthat we went through in Solution 1). SSL certificate can also be installed on\nthe domain, so you can receive HTTPS requests.<\/p>\n\n\n\n<p>Create a static IP address of type Regional and\nselect the region (select the same region as that of your VPN). Please note\nthat Global Type would not work with Nginx Ingress LoadBalancer. Following\nimage shows the configuration.<\/p>\n\n\n\n<p><em>Figure 37:&nbsp; Create Static IP<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"267\" height=\"245\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-38.png\" alt=\"\" class=\"wp-image-2660\"\/><\/figure>\n\n\n\n<p>Create the IP and note the IP address.<\/p>\n\n\n\n<p>Next, go back to cloud shell and install\nNginx Ingress by running the following command. Replace 35.231.11.11 by the IP\nfrom the earlier step.<\/p>\n\n\n\n<p>&gt; helm install &#8211;name\nnginx-ingress stable\/nginx-ingress \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set\ncontroller.service.loadBalancerIP=35.231.11.11\\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set rbac.create=true \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set\ncontroller.publishService.enabled=true<\/p>\n\n\n\n<p>The above command would create a Nginx\nIngress Controller of type HTTP Load Balancer at 35.231.11.11.<\/p>\n\n\n\n<p>You can also enable SSL while installing\nNginx Ingress. If you have an SSL certificate for your domain, you can enable\nSSL while installing Nginx ingress. <\/p>\n\n\n\n<p>First, you need to create the secret\nbased on your domain certificate and private key.<\/p>\n\n\n\n<p>&gt; kubectl create secret tls\nbackend-api-ssl-secret \\<\/p>\n\n\n\n<p>&nbsp;\n&#8211;cert \/Users\/navveenbalani\/&lt;domain.com&gt;\/certificate.crt &#8211;key\n\/Users\/navveenbalani\/&lt;domain.com&gt;\/private.key<\/p>\n\n\n\n<p>Next, you need to reference the\nbackend-api-ssl-secret while installing Nginx Ingress. Use the following\ncommand to enable SSL during installation:<\/p>\n\n\n\n<p>helm install &#8211;name nginx-ingress\nstable\/nginx-ingress \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set\ncontroller.service.loadBalancerIP=35.231.11.11\\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set rbac.create=true \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set\ncontroller.publishService.enabled=true \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;set controller.extraArgs.default-ssl-<\/p>\n\n\n\n<p>&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;certificate=default\/backend-ssl-secret<\/p>\n\n\n\n<p>After running the command, you should get the following\nmessage on the console:<\/p>\n\n\n\n<p><em>The nginx-ingress controller has been installed.<\/em><\/p>\n\n\n\n<p><em>It may take a few minutes for the LoadBalancer IP\nto be available.<\/em><\/p>\n\n\n\n<p>To see the status of the Nginx Ingress\ncontroller, run the following command:<\/p>\n\n\n\n<p>&gt; kubectl &#8211;namespace default\nget services -o wide -w nginx-ingress-controller<\/p>\n\n\n\n<p>If you see an external IP (the one that we\nprovided earlier), that implies the Nginx Controller is listening on the\nconfigured external IP.<\/p>\n\n\n\n<p><em>Figure 38:&nbsp; Nginx Ingress Status<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"342\" height=\"45\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-39.png\" alt=\"\" class=\"wp-image-2661\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-39.png 342w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-39-300x39.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure>\n\n\n\n<p>If you navigate to Kubernetes Engine -&gt;\nService &amp; Ingress, you will see nginx-ingress-controller listening on the\nip address that we configured earlier as shown in the figure below. You would\nalso see a service named \u201cnginx-ingress-default-backend\u201d. The nginx-ingress-default-backend\nservice provides default backend which handles all URL paths and hosts the nginx controller doesn&#8217;t\nunderstand (i.e., all the requests that are not mapped with an Ingress).\nBasically, a default backend exposes two URLs: &#8211; \/healthz that returns 200 and \/ that return 404.&nbsp; You can use the Nginx default backend service\nfor the health check instead of providing your own heath check service implementation,\nthat we discussed earlier in Solution 1. <\/p>\n\n\n\n<p><em>Figure 39:&nbsp; Nginx Ingress Status in Cloud Console<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"323\" height=\"146\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-40.png\" alt=\"\" class=\"wp-image-2662\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-40.png 323w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-40-300x136.png 300w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/figure>\n\n\n\n<p>With the Ingress controller setup, we would\nexecute the deployment scripts.<\/p>\n\n\n\n<p> <a href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-6\/\">Click here for next section.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this chapter, we would deploy Nginx Ingress Controller instead of GCE. NGINX, by default, provides a lot of additional capabilities as compared to the default GKE Ingress controller like URL rewriting, whitelisting, load balancing over HTTPS and websocket and advanced features through Nginx Plus. For details, refer to https:\/\/www.nginx.com\/products\/nginx\/. It is assumed that you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2128,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,79],"tags":[285],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building Production Topology with Google Cloud - Part 5 - Current and Future Technology Trends by Navveen Balani<\/title>\n<meta name=\"description\" content=\"Building Production Topology with Google Cloud - Part 5 - Articles\" \/>\n<link rel=\"canonical\" href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building Production Topology with Google Cloud - Part 5 - Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"og:description\" content=\"Building Production Topology with Google Cloud - Part 5 - Articles\" \/>\n<meta property=\"og:url\" content=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\" \/>\n<meta property=\"og:site_name\" content=\"Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-17T14:02:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-17T15:31:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"450\" \/>\n\t<meta property=\"og:image:height\" content=\"374\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"5 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/navveenbalani.dev\/#website\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Current and Future Technology Trends by Navveen Balani\",\"description\":\"Current and Future Technology Trends by Navveen Balani\",\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/navveenbalani.dev\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2016\/09\/bk6.jpg\",\"width\":450,\"height\":374},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#webpage\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\",\"name\":\"Building Production Topology with Google Cloud - Part 5 - Current and Future Technology Trends by Navveen Balani\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#primaryimage\"},\"datePublished\":\"2019-03-17T14:02:49+00:00\",\"dateModified\":\"2019-12-17T15:31:26+00:00\",\"description\":\"Building Production Topology with Google Cloud - Part 5 - Articles\",\"breadcrumb\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/\",\"url\":\"https:\/\/navveenbalani.dev\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/\",\"name\":\"Building Production Topology with Google Cloud &#8211; Part 5\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#webpage\"},\"author\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"headline\":\"Building Production Topology with Google Cloud &#8211; Part 5\",\"datePublished\":\"2019-03-17T14:02:49+00:00\",\"dateModified\":\"2019-12-17T15:31:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"image\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-5\/#primaryimage\"},\"keywords\":\"google-cloud\",\"articleSection\":\"Articles,Cloud Computing\",\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\",\"name\":\"Navveen\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/07\/navveen_balani.jpeg\",\"width\":200,\"height\":200,\"caption\":\"Navveen\"},\"logo\":{\"@id\":\"https:\/\/navveenbalani.dev\/#personlogo\"},\"sameAs\":[\"http:\/\/naveenbalani.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2657"}],"collection":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/comments?post=2657"}],"version-history":[{"count":3,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2657\/revisions"}],"predecessor-version":[{"id":2684,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2657\/revisions\/2684"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media\/2128"}],"wp:attachment":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media?parent=2657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/categories?post=2657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/tags?post=2657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}