diff --git a/pkg/internal/templates/cloud-init.sh.template b/pkg/internal/templates/cloud-init.sh.template index 8c4e3cc..3f73666 100644 --- a/pkg/internal/templates/cloud-init.sh.template +++ b/pkg/internal/templates/cloud-init.sh.template @@ -44,15 +44,38 @@ mkdir -p '{{ $unit.DropIns.Path }}' {{- end -}} {{- end }} -# Change existing worker to use docker registry-mirror +# Adjust docker config file="/etc/docker/daemon.json" +dockerreload=false + +# Change existing worker to use docker registry-mirror if [ $(jq -r 'has("registry-mirrors")' "${file}") == "false" ]; then contents=$(jq -M '. += {"registry-mirrors": ["https://mirror.gcr.io"]}' ${file}) echo "${contents}" > ${file} + dockerreload=true +fi + +# Change existing worker to use docker registry-mirror +if [ $(jq -r 'has("live-restore")' "${file}") == "false" ]; then + contents=$(jq -M '. += {"live-restore": true}' ${file}) + echo "${contents}" > ${file} + dockerreload=true +fi + +if [ $dockerreload == true ]; then systemctl daemon-reload systemctl reload docker fi +# Remove logrotation from docker due to conflict with gardener's log rotation +if [ $(jq -r 'has("log-opts")' "${file}") == "true" ]; then + contents=$(jq 'del(."log-opts")' ${file}) + echo "${contents}" > ${file} + systemctl daemon-reload + # We need to restart docker because reloading it can not change logging configuration. + systemctl restart docker +fi + {{ if .Bootstrap -}} META_EP=http://100.100.100.200/latest/meta-data PROVIDER_ID=`curl -s $META_EP/region-id`.`curl -s $META_EP/instance-id`