{"id":2625,"date":"2019-03-17T19:14:08","date_gmt":"2019-03-17T13:44:08","guid":{"rendered":"http:\/\/navveenbalani.dev\/?p=2625"},"modified":"2019-12-17T20:58:21","modified_gmt":"2019-12-17T15:28:21","slug":"building-production-topology-with-google-cloud-part-2","status":"publish","type":"post","link":"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/","title":{"rendered":"Building Production Topology with Google Cloud &#8211; Part 2"},"content":{"rendered":"\n<p>In this section\nwe would go through the microservices application and deploy the application on\nthe Kubernetes Cluster.<\/p>\n\n\n\n<ul><li>Download the project from GitHub.<\/li><\/ul>\n\n\n\n<p>git clone https:\/\/github.com\/navveenbalani\/google-cloud-kubernetes-secure-e2e.git<\/p>\n\n\n\n<ul><li>Go to the google-cloud-kubernetes-secure-e2e\nmicroservice folder. Our microservice comprises of these simple services listed\nin server.js &#8211; echo, healthz, and fecthWebsite.<\/li><\/ul>\n\n\n\n<p>Echo service\nlistens over POST and sends the request message back as a response:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.post('\/echo', (req, res) => {\n  res\n    .status(200)\n    .json({message: req.body.message})\n    .end();\n});\n<\/code><\/pre>\n\n\n\n<p>The healthz service provides a health status for\nour services. A Service exposed through an Ingress must respond to health\nchecks from the load balancer. We would specify this URL in the readinessProbe\nconfiguration while deploying our service.<\/p>\n\n\n\n<p>The fetchWebsite tests out external connectivity from our private Kubernetes cluster. This basically checks if Cloud NAT is configured properly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.get('\/fetchWebsite', (req, res) => {\n  \n  request('https:\/\/navveenbalani.dev\/', function (error, response, html) {\n  if (!error &amp;&amp; response.statusCode == 200) {\n    res\n    .status(200)\n    .json({message: \"ok\"})\n    .end();\n  } else {\n  \tres\n    .status(500)\n    .json({message: error})\n    .end();\n  }\n})\n});\n<\/code><\/pre>\n\n\n\n<p>You can deploy your own microservices application\nbut add healthz (or a similar health checkup service) to indicate that the service is healthy and ready.<\/p>\n\n\n\n<h2>Build the Microservice\nContainer<\/h2>\n\n\n\n<p>In this section, we would build the container. Go\nto the google-cloud-kubernetes-secure-e2e\/microservice folder and execute the\nfollowing command:<\/p>\n\n\n\n<ol><li>Build the docker container<\/li><\/ol>\n\n\n\n<p>&nbsp;&gt; sudo docker\nbuild -t kube-e2e-solution .<\/p>\n\n\n\n<ul><li>Run the container<\/li><\/ul>\n\n\n\n<p>&gt; sudo docker run -p 49180:8080 -d kube-e2e-solution<\/p>\n\n\n\n<ul><li>Execute the service<\/li><\/ul>\n\n\n\n<p>&gt; curl -i <a href=\"http:\/\/localhost:49180\/healthz\">http:\/\/localhost:49180\/healthz<\/a><\/p>\n\n\n\n<p>You should see a\n200-status message as shown below.<\/p>\n\n\n\n<p><em>Figure 14 \u2013 Output of curl invocation command<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"304\" height=\"159\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-15.png\" alt=\"\" class=\"wp-image-2630\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-15.png 304w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-15-300x157.png 300w\" sizes=\"(max-width: 304px) 100vw, 304px\" \/><\/figure>\n\n\n\n<h2>Push the Microservice\nContainer to the Google Container Registry<\/h2>\n\n\n\n<p>In this section, we would push the container\ncreated in earlier step to Google Container Registry. Google Container Registry\nprovides secure private registry and access controls for your docker containers.<\/p>\n\n\n\n<p>Follow the steps below &#8211;<\/p>\n\n\n\n<ol><li>Tag the image.<\/li><\/ol>\n\n\n\n<p>&gt; sudo docker tag kube-e2e-solution&nbsp; gcr.io\/navveen-api\/kube-e2e-solution:v1<\/p>\n\n\n\n<p>This assumes\nthat we would be deploying the container to the gcr.io region. Replace\nnavveen-api by our project name. For deploying to other regions, please refer\nto <a href=\"https:\/\/cloud.google.com\/container-registry\/docs\/pushing-and-pulling\">https:\/\/cloud.google.com\/container-registry\/docs\/pushing-and-pulling<\/a>.<\/p>\n\n\n\n<ol><li>Create a short\nlived Access Token to push to container registry (For more details, kindly\nrefer to &#8211; <a href=\"https:\/\/cloud.google.com\/container-registry\/docs\/advanced-authentication\">https:\/\/cloud.google.com\/container-registry\/docs\/advanced-authentication<\/a>).<\/li><\/ol>\n\n\n\n<p>&gt; sudo gcloud auth print-access-token\n| sudo docker login -u oauth2accesstoken &#8211;password-stdin https:\/\/gcr.io<\/p>\n\n\n\n<p><em>Figure 15 \u2013 Output of&nbsp; access login token command<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"321\" height=\"111\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-16.png\" alt=\"\" class=\"wp-image-2631\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-16.png 321w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-16-300x104.png 300w\" sizes=\"(max-width: 321px) 100vw, 321px\" \/><\/figure>\n\n\n\n<ol><li>Push the image\nto your project (in this case below, navveen-api is the project name).<\/li><\/ol>\n\n\n\n<p>&gt; sudo docker push\ngcr.io\/navveen-api\/kube-e2e-solution:v1<\/p>\n\n\n\n<p>You should see\nthe digest being printed as shown below.<\/p>\n\n\n\n<p><em>Figure 16 \u2013 Output of Docker push command<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"342\" height=\"154\" src=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-17.png\" alt=\"\" class=\"wp-image-2632\" srcset=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-17.png 342w, https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-17-300x135.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-3\/\">Click here for next section<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this section we would go through the microservices application and deploy the application on the Kubernetes Cluster. Download the project from GitHub. git clone https:\/\/github.com\/navveenbalani\/google-cloud-kubernetes-secure-e2e.git Go to the google-cloud-kubernetes-secure-e2e microservice folder. Our microservice comprises of these simple services listed in server.js &#8211; echo, healthz, and fecthWebsite. Echo service listens over POST and sends the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"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 2 - Current and Future Technology Trends by Navveen Balani<\/title>\n<meta name=\"description\" content=\"Building Production Topology with Google Cloud - Part 2 - Articles\" \/>\n<link rel=\"canonical\" href=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/\" \/>\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 2 - Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"og:description\" content=\"Building Production Topology with Google Cloud - Part 2 - Articles\" \/>\n<meta property=\"og:url\" content=\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Current and Future Technology Trends by Navveen Balani\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-17T13:44:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-17T15:28:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-15.png\" \/>\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=\"2 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-2\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/navveenbalani.dev\/wp-content\/uploads\/2019\/12\/image-15.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#webpage\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/\",\"name\":\"Building Production Topology with Google Cloud - Part 2 - 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-2\/#primaryimage\"},\"datePublished\":\"2019-03-17T13:44:08+00:00\",\"dateModified\":\"2019-12-17T15:28:21+00:00\",\"description\":\"Building Production Topology with Google Cloud - Part 2 - Articles\",\"breadcrumb\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#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-2\/\",\"url\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/\",\"name\":\"Building Production Topology with Google Cloud &#8211; Part 2\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#webpage\"},\"author\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"headline\":\"Building Production Topology with Google Cloud &#8211; Part 2\",\"datePublished\":\"2019-03-17T13:44:08+00:00\",\"dateModified\":\"2019-12-17T15:28:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/navveenbalani.dev\/#\/schema\/person\/51f7ab14b20611d95e3c7fd4ea0950bf\"},\"image\":{\"@id\":\"https:\/\/navveenbalani.dev\/index.php\/articles\/building-production-topology-with-google-cloud-part-2\/#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\/2625"}],"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=2625"}],"version-history":[{"count":7,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2625\/revisions"}],"predecessor-version":[{"id":2682,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/posts\/2625\/revisions\/2682"}],"wp:attachment":[{"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/media?parent=2625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/categories?post=2625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/navveenbalani.dev\/index.php\/wp-json\/wp\/v2\/tags?post=2625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}