Mounting XFS on GKE
Update Sept 6 2017: As of Aug 8 2017, GKE has released the ubuntu
image to replace container-vm
. This image has xfsprogs
pre-installed. Use this instead.
We had a mongo replicaset cluster setup in Google Container Engine that was using the default ext
filesystem when creating PersistentVolumes
. The recommendation by mongo is that the xfs
should be used instead.
- The default image on GKE is
gci
, based on ChromiumOS, which does not have a straightforward method for installing packages forxfs
. container-vm
does havexfsprogs
, but is not installed by default- Custom images are not supported on GKE.
- There’s no standard/recommended method for running node startup scripts.
Initially, we were headed in the direction of editing the Instance Templates the GKE was using and adding in apt-get install xfsprogs
, but the problem was that it was not portable enough. If I added a new node-pool or upgraded an existing one, the changes to the Instance Template would not get carried over.
Our only option was container-vm
for OS image so that we could just apt-get install xfsprogs
on the node, preferably at init time, but how?
The solution turned out to be to use Kubernetes daemonsets
. daemonsets
run on every node, including newly created nodes. The recommendation even is briefly described on the Kubernetes docs and an example on kubernetes/contrib.
Putting it together
- Create a node-pool using the
container-vm
image. - Build the startup script Docker image
- Create a startup-script
daemonset
based on Kubernetes' startup-script example. - Add the daemonset to kubernetes
- Create an
empty disk
on GCE. - Create a
PersistentVolume
withfsType:xfs
. - Apply the
PersistentVolume
and Kubernetes will format the disk toxfs
on mount.
Originally published at blog.helveticode.com on January 1, 2017.