Notes: BuildKite and Kubernetes Rolling Update

This is kind of a textbook case that container is much more efficient than VM. The CI pipeline in comparison uses AWS CloudFormation to build new VMs and drain old VMs to do a rolling update, which takes around 10 minutes for everything even if it’s just 1 line of code changed. I did a new pipeline with BuildKite and Kubernetes and a deploy is done within 2 minutes.

The key points to make the pipeline fast are:

  1. In the Dockerfile, the part that changes more frequently should be put at the bottom of the file, so that docker can maximise its build speed by using cached intermediate images.
  2. Reload Kubernetes config maps with this:
    kubectl create configmap nginx-config --from-file path/to/nginx.conf -o yaml --dry-run |kubectl replace -f -
  3. Reload containers with this(I use ECR):
    $BUILDKITE_BUILD_NUMBER obviously is the build number environment variable provided by BuildKite.

    kubectl set image deployment/my_deployment \$BUILDKITE_BUILD_NUMBER \$BUILDKITE_BUILD_NUMBER
  4. Finally watch rolling update progress with this command:
    kubectl rollout status deployment/my_deployment


Install Shutter in Arch Linux

It’s quite unexpected that in Arch Linux’s package database I couldn’t find Shutter, which is generally available in other Linux distributions. Although, it’s still possible to install Shutter in Arch.

First I use pacaur as my AUR helper. Installation of pacaur can refer to this. Then it’s quite easy to get Shutter installed because it’s in AUR already(thanks heaps).

pacaur -S perl-goo-canvas shutter

The package perl-goo-canvas is needed when I want to edit screenshots, eg. adding text, etc…


Kubernetes Tips: ConfigMap

This is how to update a config map with 1 line:

kubectl create configmap foo --from-file -o yaml --dry-run | kubectl replace -f -

I found it here:

And this is how to mount a config map created from a file as file(not super intuitive but a config map can only be mounted as a volume, and the mount point has to be a directory):

- volumeMounts:
 - name: demo-config
 mountPath: /app/settings.json
 subPath: settings.json
- name: demo-config
 name: demo

I think this is because when creating a config map from a file, the file name becomes the key and the content becomes the value. A config map can have multiple key-value pairs just like a directory can have more than 1 file. So by using the subPath the key will be mounted as a file.

Found it here: