Best Method to Customize Image on GKE

1,366 views
Skip to first unread message

ch...@oakleon.com

unread,
Jan 16, 2015, 8:55:47 PM1/16/15
to gce-dis...@googlegroups.com
On GCE one can use a startup script to modify the VM environment, but on GKE I can only see the possibility to use a custom source image. I would like to, for example, modify security limits (nofile) for docker processes. Is using a custom source image the best way to accomplish this type of OS-customizing task?

Thanks,
Chris

Samuel Cozannet

unread,
Feb 16, 2016, 1:55:50 AM2/16/16
to gce-discussion
+1 on the question. 
The current method is very misleading. If you add a startup script as a project metadata, and start instances in GCE, and, in the same project, a GKE cluster, the cluster fails to deploy. I assume this is because the mechanic of GKE is actually using startup scripts to install k8s. 
But this is a big problem for one willing to customize the deployment. 

Any official answer much appreciated. 

George

unread,
Feb 17, 2016, 2:26:34 PM2/17/16
to gce-discussion
Hello Chris,

As you suggested, the best approach is using a custom source image.

Samuel, what is the key that you are using for the startup script? Make sure it doesn't conflict with other scripts as documented here.

I hope this helps.

Sincerely,
George

Ju Go

unread,
Mar 13, 2018, 9:22:49 AM3/13/18
to gce-discussion
Hi,

I stumbled upon this topic when desparately searching for ways to run a custom VM image (or customize one of the two existing images you can choose fromwhen creating your cluster) with GKE.
In the GKE cluster creation wizard, I can only choose two images (cos and ubuntu).
Motivation is that I need to set a certain host-level parameter to make Elasticsearch work on the cluster. Basically it is just one command

sysctl -w vm.max_map_count=262144

Without this setting, my Elasticsearch pods will crash on startup.
I got it to run by using a NON-autoscaling cluster, logging in to each worker node, and change the setting manually (by also adding it to /etc/sysctl.d/00-sysctl.conf file).
Alas, this gets annoying really fast and will obviously not work for autoscaling clusters.

Next I tried to create a regular (non-GKE) instance from the cos image manually, then change the setting, and then use this instance's disk to create a custome image.
That worked, but  the resulting image would not show up in the "create cluster" wizard.

Alas, I also noticed that an overlayfs is used for /etc in the cos image, so my change wouldn't be persisted anyway - which also means that the manual change I made on my GKE nodes would also not survive a reboot.

So is there a way to create and select one's own VM image for GKE?

Regards

JuGo

Tomasz W

unread,
Jun 20, 2018, 8:57:56 AM6/20/18
to gce-discussion
Reply all
Reply to author
Forward
0 new messages