{"id":713,"date":"2018-10-27T06:07:30","date_gmt":"2018-10-27T06:07:30","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=713"},"modified":"2018-10-28T05:41:15","modified_gmt":"2018-10-28T05:41:15","slug":"adopting-a-gke-cluster-with-rancher-2-0","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/27\/adopting-a-gke-cluster-with-rancher-2-0\/","title":{"rendered":"Adopting a GKE Cluster with Rancher 2.0"},"content":{"rendered":"<p><a href=\"http:\/\/rancher.com\/announcing-rancher-2-0\/\">Rancher 2.0 is out<\/a> and<br \/>\nodds are, you\u2019re wondering what\u2019s so shiny and new about it. Well,<br \/>\nhere\u2019s a huge selling point for the next big Rancher release;<br \/>\nKubernetes cluster adoption! That\u2019s right, we here at Rancher wanted<br \/>\nmore kids, so we decided it was time to adopt. In all seriousness<br \/>\nthough, this feature helps make Rancher more relevant to developers who<br \/>\nalready have Kubernetes clusters deployed and are looking for a new way<br \/>\nto manage them. One of the most powerful aspects of this feature is that<br \/>\nit allows you to build a cluster from multiple cloud container engines,<br \/>\nincluding GKE, and keep them all under one management roof. In order to<br \/>\nadopt a GKE cluster into Rancher 2.0, you\u2019ll first need an instance of<br \/>\nRancher 2.0 running. To bootstrap a 2.0 server, check out this<br \/>\nguide <a href=\"https:\/\/rancher.com\/bootstrapping-rancher-2-0\/\">here<\/a>. Stop<br \/>\nbefore selecting to Add Hosts and pop right back here when you\u2019re<br \/>\ndone.<\/p>\n<h2>Acquiring your Kubectl Command<\/h2>\n<p>Now that you have a Rancher 2.0 server up and running, you\u2019ll be<br \/>\npresented with a page like the one below:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/dl4Eu5w.png\" alt=\"Rancher 2.0 Home Page\" \/><em>Rancher 2.0 Home Page<\/em><\/p>\n<p>Of course, we want to select Use Existing Kubernetes as we\u2019re trying<br \/>\nto adopt an existing GKE cluster. On the next page, we\u2019re presented<br \/>\nwith a Host Registration URL menu, where we want to provide the<br \/>\npublicly accessible hostname and port for our Rancher server. As I set<br \/>\nup my host using a domain name in the form rancher.&lt;domain&gt;.&lt;tld&gt;,<br \/>\nRancher has already found the address for the site and defaults to the<br \/>\nproper hostname. If you\u2019re using a different network setup, just know<br \/>\nthat this hostname has to be accessible by all the machines in the<br \/>\nKubernetes cluster we are adopting. Click Save when you\u2019re finished<br \/>\nmaking your choice.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/C0A7sul.png\" alt=\"Host Registration URL\" \/><em>Host Registration URL<\/em><\/p>\n<p>Now we are presented with a kubectl command which can be copied to<br \/>\nyour clipboard by clicking the little clipboard icon to the right of the<br \/>\ncommand. Copy the command and save it in a notepad to use later.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/d0fuA1b.png\" alt=\"Kubectl Apply\" \/><em>Kubectl Apply<\/em><\/p>\n<p><em>Important note: if you already have a cluster in GKE, you can skip<br \/>\nthe following section and go straight to <a href=\"#adoptingGKEcluster\">Adopting a GKE<br \/>\nCluster<\/a><\/em><\/p>\n<h2>Creating a GKE Cluster<\/h2>\n<p>Next, hop on over to your GKE control panel and, if you don\u2019t yet have<br \/>\na GKE cluster up and running, click the Create Cluster button.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/1IRYe2f.png\" alt=\"Create Cluster\" \/><em>Create Cluster<\/em><\/p>\n<p>The cluster settings can be configured however you wish. I\u2019ll be using<br \/>\nthe name eric-rancher-demo, the us-central1-a zone,<br \/>\nversion 1.7.5-gke.1 (default) and 1vCPU, 2GB RAM machines. Leave the<br \/>\nOS as the Container-Optimized OS(cos) and all other settings at the<br \/>\ndefault. My finished settings looks like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/BHiSFdm.png\" alt=\"Container Cluster Settings\" \/><br \/>\n[]<\/p>\n<p>You might want to grab some coffee after clicking Create, as GKE takes<br \/>\na while (5-10 minutes) to stand up your Kubernetes cluster.<\/p>\n<h2>Adopting a GKE Cluster<\/h2>\n<p>Now that we have both a Rancher 2.0 server stood up and a GKE cluster<br \/>\nrunning and ready, we want to configure gcloud utils and kubectl to<br \/>\nconnect to our GKE cluster. In order to install gcloud utils on Debian<br \/>\nand Ubuntu based machines, follow the steps<br \/>\noutlined <a href=\"https:\/\/cloud.google.com\/sdk\/docs\/quickstart-debian-ubuntu\">here<\/a> on<br \/>\nGoogle\u2019s website. For all other distros, find your<br \/>\nguide <a href=\"https:\/\/cloud.google.com\/sdk\/docs\/quickstarts\">here<\/a>. Once we get<br \/>\nthe message gcloud has now been configured!, we can move onto the next<br \/>\nstep. To install kubectl all we need to do is<br \/>\ntype gcloud components install kubectl. Now that we<br \/>\nhave kubectl installed, in order to connect to our cluster, we want to<br \/>\nclick on the Connect to the cluster link at the top of the page in<br \/>\nGKE.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/iCpUskp.png\" alt=\"Connect to the cluster\" \/><em>Connect to the cluster<\/em><\/p>\n<p>A window will pop up providing instructions<br \/>\nto Configure kubectl command line access by running the following command.<\/p>\n<p>Copy that command and paste it into your terminal window. In this case:<\/p>\n<p>$ gcloud container clusters get-credentials eric-rancher-demo &#8211;zone us-central1-a &#8211;project rancher-dev<br \/>\n&gt; Fetching cluster endpoint and auth data.<br \/>\n&gt; kubeconfig entry generated for eric-rancher-demo.<\/p>\n<p>Our kubectl is now hooked up to the cluster. We should be able to<br \/>\nsimply paste the command from the Rancher 2.0 setup we did earlier, and<br \/>\nRancher will adopt the cluster.<\/p>\n<p>$ kubectl apply -f http:\/\/rancher.&lt;domain&gt;.&lt;tld&gt;\/v3\/scripts\/2CFC9454A034E7C3E367:1483142400000:feQRTz4WmIemlAUSy4O37vuF0.yaml<br \/>\n&gt; namespace &#8220;cattle-system&#8221; created<br \/>\n&gt; serviceaccount &#8220;rancher&#8221; created<br \/>\n&gt; clusterrolebinding &#8220;rancher&#8221; created<br \/>\n&gt; secret &#8220;rancher-credentials-39124a03&#8221; created<br \/>\n&gt; pod &#8220;cluster-register-39124a03&#8221; created<br \/>\n&gt; daemonset &#8220;rancher-agent&#8221; created<\/p>\n<p><em>Note: You cannot adopt a Kubernetes cluster if it has been previously<br \/>\nadopted by a Rancher 2.0 server unless you delete the<br \/>\nnamespace cattle-system from the Kubernetes installation. You can do<br \/>\nthis by typing kubectl delete &#8211;namespace cattle-system and waiting 5<br \/>\nminutes for the namespace to clear out.<\/em><\/p>\n<p><a href=\"https:\/\/rancher.com\/adopting-gke-cluster-rancher-2-0\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rancher 2.0 is out and odds are, you\u2019re wondering what\u2019s so shiny and new about it. Well, here\u2019s a huge selling point for the next big Rancher release; Kubernetes cluster adoption! That\u2019s right, we here at Rancher wanted more kids, so we decided it was time to adopt. In all seriousness though, this feature helps &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/27\/adopting-a-gke-cluster-with-rancher-2-0\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Adopting a GKE Cluster with Rancher 2.0&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-713","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=713"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/713\/revisions"}],"predecessor-version":[{"id":730,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/713\/revisions\/730"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}