Skip to content

Instantly share code, notes, and snippets.

@tennix
Created February 13, 2019 12:47
Show Gist options
  • Save tennix/41825ab5ffc4be4aa4284e700c5ed596 to your computer and use it in GitHub Desktop.
Save tennix/41825ab5ffc4be4aa4284e700c5ed596 to your computer and use it in GitHub Desktop.
Optimize GKE local SSD disk
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: startup-script
namespace: kube-system
labels:
app: startup-script
spec:
template:
metadata:
labels:
app: startup-script
spec:
hostPID: true
containers:
- name: startup-script
image: gcr.io/google-containers/startup-script:v1
securityContext:
privileged: true
env:
- name: STARTUP_SCRIPT
value: |
#!/usr/bin/env bash
set -euo pipefail
apt-get update
apt-get install -y software-properties-common
apt-add-repository universe
apt-get update
declare -a PKG_LIST=(python-google-compute-engine \
python3-google-compute-engine \
google-compute-engine-oslogin \
gce-compute-image-packages)
for pkg in ${PKG_LIST[@]}; do
apt-get install -y $pkg || echo "Not available: $pkg"
done
mount | grep -v nobarrier | awk '/ssd/{print $1}' | xargs -i mount {} -o remount,nobarrier
volumeMounts:
- mountPath: /mnt/disks
name: local-ssd
mountPropagation: Bidirectional
volumes:
- name: local-ssd
hostPath:
path: /mnt/disks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment