From 33c6cc4e976d0fa8ce19836db76631982895ecf3 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Tue, 25 Jun 2019 11:10:35 -0700 Subject: [PATCH] local SSD provision: reduce network traffic * use a single install command * reduce the number of repositories that are updated --- manifests/gke/local-ssd-optimize.yaml | 20 +++++++++------- .../local-ssd-provision.yaml | 24 +++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/manifests/gke/local-ssd-optimize.yaml b/manifests/gke/local-ssd-optimize.yaml index edbdfa3da1..9d5f4384f9 100644 --- a/manifests/gke/local-ssd-optimize.yaml +++ b/manifests/gke/local-ssd-optimize.yaml @@ -32,17 +32,19 @@ spec: value: | #!/usr/bin/env bash set -euo pipefail + export DEBIAN_FRONTEND=noninteractive + # Fix any issues + dpkg --configure -a + apt-get -y autoremove apt-get update - apt-get install -y software-properties-common - apt-add-repository universe + # Avoid unecessary repository listings + test -f /etc/apt/sources.list.orig || cp /etc/apt/sources.list /etc/apt/sources.list.orig + cat /etc/apt/sources.list.orig | awk '/bionic main|bionic-updates main|bionic-updates universe/' > /etc/apt/sources.list 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 + # Install required packages + apt-get install -y lvm2 python-google-compute-engine python3-google-compute-engine google-compute-engine-oslogin gce-compute-image-packages + # Restore original repository listings + cp /etc/apt/sources.list.orig /etc/apt/sources.list mount | grep -v nobarrier | awk '/ssd/{print $1}' | xargs -i mount {} -o remount,nobarrier volumeMounts: - mountPath: /mnt/disks diff --git a/manifests/gke/local-ssd-provision/local-ssd-provision.yaml b/manifests/gke/local-ssd-provision/local-ssd-provision.yaml index 9d197a4c21..9c03c90898 100644 --- a/manifests/gke/local-ssd-provision/local-ssd-provision.yaml +++ b/manifests/gke/local-ssd-provision/local-ssd-provision.yaml @@ -58,24 +58,18 @@ spec: # Install the linux guest environment tools export DEBIAN_FRONTEND=noninteractive - cat /etc/apt/sources.list + # Fix any issues dpkg --configure -a - apt-get update - apt-get install -y software-properties-common || echo "could not install 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 - - apt-get install -y lvm2 apt-get -y autoremove + # Avoid unecessary repository listings + test -f /etc/apt/sources.list.orig || cp /etc/apt/sources.list /etc/apt/sources.list.orig + cat /etc/apt/sources.list.orig | awk '/bionic main|bionic-updates main|bionic-updates universe/' > /etc/apt/sources.list + apt-get update + # Install required packages + apt-get install -y lvm2 python-google-compute-engine python3-google-compute-engine google-compute-engine-oslogin gce-compute-image-packages + # Restore original repository listings + cp /etc/apt/sources.list.orig /etc/apt/sources.list - set -x if ! findmnt -n -a -l | grep /mnt/disks/ssd ; then if test -f /etc/ssd_mounts ; then ssd_mounts=$(cat /etc/ssd_mounts)