Skip to content

Instantly share code, notes, and snippets.

@dictcp
Last active June 23, 2021 02:27
Show Gist options
  • Select an option

  • Save dictcp/b0deb9e4f03e5bbcb337d3a689bb7693 to your computer and use it in GitHub Desktop.

Select an option

Save dictcp/b0deb9e4f03e5bbcb337d3a689bb7693 to your computer and use it in GitHub Desktop.
Automating Kubernetes with GitOps Workshop

Automating Kubernetes with GitOps Workshop

@dictcp (https://dictcp.men)

About the workshop

Session at HKOSCon 2020: https://hkoscon.org/2020/topics/automating-kubernetes-gitops

Slide: https://docs.google.com/presentation/d/1rA6bhCGMydP-NOmFu7fv0zbBSzGvK9GLn63H8dHLP2g

Everyone with their clean Ubuntu 18.04 VM in hand (10mins) Install k3s, the lightweight Kubernetes distribution from Rancher (10mins) Install helm3 Prepare the git repository for GitOps (10mins) Install fluxcd via helm3 and playaround (10mins) Playaround Helm operator (bonus)

Hands-on Preparation

You need

  • a GitHub account (to access this material and setup gitops flow)
  • a working Kubernetes in the hands-on session (to s)
    • multipass VM (local installation, recommended)
    • [DigitalOcean VM] (remote installation)

multipass VM

  1. Install multipass on https://multipass.run
  • support Windows 10 Pro+, Mac OS X, Linux
  • Mac OS X (with homebrew installed): brew cask install multipass
  • Ubuntu (or any Linux distro with snap installed): sudo snap install multipass --classic
  1. Start Command prompt / Terminal
  2. Execute multipass launch -d 30G -m 2G --name fluxcd-workshop 18.04
  3. Depends on network condition, you need to wait for 5-20 mins.
  4. Execute multipass shell fluxcd-workshop to obtain shell in the VMs

DigitalOcean VM

Install k3s Kubernetes on your VM

  1. Execute curl -sfL https://get.k3s.io | sh - in the VM
  2. Depends on network condition, you need to wait for 5-10 mins.
  3. You should have your local Kubernetes cluster installed. To verify, execute sudo -i k3s kubectl get nodes, it should give you something like
NAME              STATUS   ROLES    AGE     VERSION
fluxcd-workshop   Ready    master   5m53s   v1.18.3+k3s1`
  1. Make sure the cluster setup is avaiable by the following commands:
$ mkdir .kube
$ sudo cat /etc/rancher/k3s/k3s.yaml > .kube/config

Install Helm & fluxctl

Normally you can install helm and fluxctl with the following 2 commands:

sudo snap install kubectl --classic
sudo snap install helm --classic --channel=3.0/stable
sudo snap install fluxctl --classic

Manual steps (if the above does not work)

  • Helm
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh
$ helm version
version.BuildInfo{Version:"v3.2.3", GitCommit:"8f832046e258e2cb800894579b1b3b50c2d83492", GitTreeState:"clean", GoVersion:"go1.13.12"}
  • fluxctl
wget -O fluxctl https://github.com/fluxcd/flux/releases/download/1.19.0/fluxctl_linux_amd64
chmod +x fluxctl
sudo mv fluxctl /usr/local/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment