How to use cloud-init with a debian-based image on Google Cloud?

To complement answer from @norbjd, posting this for completeness:

  • in order to install kubectl package that I planned initially, I had to write this cloud-init config:

    #cloud-config
    
    bootcmd:
     - curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    
    apt:
      sources:
        kubernetes.list:
          source: "deb http://apt.kubernetes.io/ kubernetes-xenial main"
    
    packages:
     - kubectl
    
  • if you need to know which images contain which packages, these resources may be helpful:

    • Ubuntu:

      • Ubuntu Cloud Images (RELEASED)

      • Actual contents (example):

        • https://cloud-images.ubuntu.com/releases/releases/18.04/release-20191003/ubuntu-18.04-server-cloudimg-amd64.manifest
    • Debian:

      • List of differences between standard and cloud systems

      • Actual contents:

        • https://salsa.debian.org/cloud-team/debian-cloud-images/blob/master/config_space/package_config/EXTRAS
        • https://salsa.debian.org/cloud-team/debian-cloud-images/blob/master/config_space/package_config/CLOUD

cloud-init is installed on the latest (at the moment of writing) Ubuntu 18.04 LTS (ubuntu-1804-bionic-v20191002) image :

<my_user>@instance-1:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"

<my_user>@instance-1:~$ which cloud-init
/usr/bin/cloud-init

You should replace debian-cloud/debian-9 with ubuntu-os-cloud/ubuntu-1804-bionic-v20191002.