Skip to content

Instantly share code, notes, and snippets.

@doshiraki
Last active December 18, 2022 12:53
Show Gist options
  • Select an option

  • Save doshiraki/28fa67ad854c4d27f67683b5d16c79dd to your computer and use it in GitHub Desktop.

Select an option

Save doshiraki/28fa67ad854c4d27f67683b5d16c79dd to your computer and use it in GitHub Desktop.
How to use kubernetes with k3d in GCE

Settings

Boot disk

15GB standard

Add disk

15GB standard

  • 5GB swap
  • 10GB /dev/pv

memo

  • You stop and start VM instance. But It may be bad response slowly after it takes some time.
#cloud-config
mounts:
- [ /dev/mapper/VG_SDB-pv, /mnt/pv, xfs, rw, "0", "1" ]
- [ /dev/mapper/VG_SDB-swap, none, swap, sw, "0", "0" ]
runcmd:
- apt-get update
- apt-get install -y vim less bash-completion
- pvcreate /dev/sdb
- vgcreate VG_SDB /dev/sdb
- lvcreate -L 5G -n swap VG_SDB
- lvcreate -l 100%FREE -n pv VG_SDB
- mkfs -t xfs /dev/mapper/VG_SDB-pv
- |2
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- |2
apt-get update
apt-get upgrade -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
- curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- k3d cluster create mycluster --agents 1
- bash -c "cd /root; curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\" "
- cp /root/kubectl /usr/local/bin
- chmod ugo+x /usr/local/bin/kubectl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment