{"id":9086,"date":"2024-09-09T06:14:42","date_gmt":"2024-09-09T06:14:42","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=9086"},"modified":"2024-09-09T09:29:18","modified_gmt":"2024-09-09T09:29:18","slug":"set-up-kubernetes-master-on-google-cloud-with-on-premise-gpus","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/set-up-kubernetes-master-on-google-cloud-with-on-premise-gpus\/","title":{"rendered":"Set Up Kubernetes Master on Google Cloud with On-Premise GPUs"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 1,670<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p>To create a Kubernetes master on Google Cloud and add on-premise instances with GPUs as nodes, follow these steps:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Set Up the Kubernetes Master on Google Cloud<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a Google Kubernetes Engine (GKE) Cluster:<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to the Google Cloud Console.<\/li>\n\n\n\n<li>Navigate to the <strong>Kubernetes Engine<\/strong> section and click on <strong>Clusters<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create<\/strong> and configure your cluster:\n<ul class=\"wp-block-list\">\n<li>Choose the <strong>Standard<\/strong> cluster type.<\/li>\n\n\n\n<li>Select a region or zone close to your on-premise instances.<\/li>\n\n\n\n<li>Configure the master and node settings as needed.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Click <strong>Create<\/strong> to launch the cluster.<\/li>\n<\/ul>\n\n\n\n<p>    2. <strong>Obtain Cluster Credentials:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After the cluster is created, click on the cluster name to view details.<\/li>\n\n\n\n<li>Click on the <strong>Connect<\/strong> button to get the command for obtaining the cluster credentials.<\/li>\n\n\n\n<li>Run the provided <code>gcloud<\/code> command in your terminal to authenticate your local environment with the GKE cluster:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh gcloud container clusters get-credentials &lt;cluster-name&gt; --region &lt;region&gt;<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Set Up On-Premise Nodes with GPU<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Kubernetes Components on On-Premise Instances:<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On each on-premise instance, install Docker, <code>kubeadm<\/code>, <code>kubelet<\/code>, and <code>kubectl<\/code>:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh sudo apt-get update sudo apt-get install -y docker.io sudo apt-get install -y apt-transport-https curl curl -s https:\/\/packages.cloud.google.com\/apt\/doc\/apt-key.gpg | sudo apt-key add - sudo apt-add-repository \"deb http:\/\/apt.kubernetes.io\/ kubernetes-xenial main\" sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<p>    2. <strong>Install NVIDIA Drivers and GPU Support:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install the NVIDIA drivers and CUDA Toolkit:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh sudo apt-get install -y nvidia-driver-450 sudo apt-get install -y nvidia-cuda-toolkit<\/mark><\/code><\/li>\n\n\n\n<li>Install the NVIDIA Kubernetes device plugin:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh kubectl apply -f https:\/\/github.com\/NVIDIA\/k8s-device-plugin\/blob\/master\/nvidia-device-plugin.yml<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<p>     3. <strong>Join the On-Premise Nodes to the GKE Cluster:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On your GKE master node, create a token to allow nodes to join the cluster:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh kubeadm token create --print-join-command<\/mark><\/code><\/li>\n\n\n\n<li>The output will provide a command that you need to run on each on-premise instance:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh kubeadm join &lt;master-ip&gt;:&lt;port&gt; --token &lt;token&gt; --discovery-token-ca-cert-hash sha256:&lt;hash&gt;<\/mark><\/code><\/li>\n\n\n\n<li>Run this command on each of your on-premise instances to join them to the cluster.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Verify and Configure the Cluster<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Verify Nodes in the Cluster:<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run the following command on your GKE master to see all nodes:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh kubectl get nodes<\/mark><\/code><\/li>\n\n\n\n<li>You should see both the GKE nodes and the on-premise nodes listed.<\/li>\n<\/ul>\n\n\n\n<p>     2. <strong>Configure Workloads to Use GPUs:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To use the GPUs on your on-premise nodes, create a Kubernetes deployment that requests GPU resources:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">yaml apiVersion: apps\/v1 <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">kind: Deployment <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">metadata: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">name: gpu-workload <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">spec: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">replicas: 1 <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">template: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">metadata: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">labels: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">app: gpu-workload <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">spec: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">containers: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">- name: gpu-container <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">image: &lt;your-gpu-enabled-image&gt; <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">resources: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">limits: <\/mark><\/code><br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">nvidia.com\/gpu: 1 # Request one GPU<\/mark><\/code><br><\/li>\n\n\n\n<li>Deploy this configuration with:<br><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">sh kubectl apply -f gpu-deployment.yaml<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Monitor and Manage the Cluster<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use Kubernetes tools like <strong>kubectl<\/strong>, <strong>Kubernetes Dashboard<\/strong>, or other monitoring tools to manage your cluster.<\/li>\n\n\n\n<li>Regularly update and patch both your GKE cluster and on-premise nodes to ensure compatibility and security.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Important Notes<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure network connectivity between your GKE cluster and on-premise instances. You might need a VPN or a secure connection to manage this.<\/li>\n\n\n\n<li>Properly configure firewall rules to allow traffic between the GKE master and on-premise nodes.<\/li>\n\n\n\n<li>Regularly update GPU drivers and Kubernetes versions on both GKE and on-premise nodes.<\/li>\n<\/ul>\n\n\n\n<p>This setup will allow you to have a Kubernetes cluster spanning both Google Cloud and your on-premise infrastructure with GPU capabilities.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>To simply create a Kubernetes master on Google Cloud and also want to add on-premise instances along with GPUs as nodes, then follow all the above-mentioned steps in the described order. For doing it seamlessly, make sure that you have the <a href=\"https:\/\/www.infinitivehost.com\/gpu-dedicated-server\"><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\"><strong>best GPU dedicated server<\/strong><\/mark><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1,670 Views To create a Kubernetes master on Google Cloud and add on-premise instances with GPUs as nodes, follow these steps: Step 1: Set Up the Kubernetes Master on Google Cloud 2. Obtain Cluster Credentials: Step 2: Set Up On-Premise Nodes with GPU 2. Install NVIDIA Drivers and GPU Support: 3. Join the On-Premise Nodes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[202],"tags":[],"class_list":["post-9086","post","type-post","status-publish","format-standard","hentry","category-gpu-server"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=9086"}],"version-history":[{"count":2,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9086\/revisions"}],"predecessor-version":[{"id":9092,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9086\/revisions\/9092"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=9086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=9086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=9086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}