0

Hi I am working on Google Cloud platform where I am not using GKE. Rather I am creating k8s cluster manually. Following is my setup, Total 11 server

  1. Out of these 5 servers would be static servers and don't need any scaling
  2. remaining 5 server would need up scaling if CPU or RAM consumption goes beyond certain limit. i.e. I will spin only 3 servers initially and if CPU/RAM threshold is crossed then I will spin 2 more using Google Cloud Load balancer.
  3. 1 k8s Master server

To implement this load balancer I have already created one Custom Image on which I have installed docker and kubernetes. Using this I have create one instance template and then instance group.

Now the problem statement is , Although I have created image with everything installed , When I am creating a instance group in which 3 VM are being created , these VMs does not automatically connect to my k8s master. Is there any way to automatically connect newly created VM as a node to k8s master so that I do not have run join command manually on each server ?

Thanks for the help in advance.

TheAkashKamble
  • 181
  • 2
  • 17
  • Since your stack is custom your requirement may be custom as well. You can try GCP's Google Cloud Composer which is cloud orchestration tool. Or you can use [Terraform with GCP](https://cloud.google.com/docs/terraform) – Abhijith Chitrapu Oct 24 '21 at 07:41

1 Answers1

3

so that I do not have run join command manually on each server

I am assuming that you can successfully run the join command to join the newly created VMs to the Kubernetes master manually.
If that is the case, you can use the startup-script feature in the Google Compute Engine.
Here is the documentation:
https://cloud.google.com/compute/docs/instances/startup-scripts
https://cloud.google.com/compute/docs/instances/startup-scripts/linux#passing-directly

In short, startup-script is the feature from Google Compute Engine to automatically run our customized script during start-up.

And, the script could look something like this:

#! /bin/bash
kubeadm join .......
Hartono Wen
  • 116
  • 5