From d61e5698c7c07d8cec1531d19505134fef180cf8 Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Mon, 14 Nov 2016 11:18:44 +0100 Subject: [PATCH] Customizable vagrant rsync args and excludes When using rsync file synchronization with Vagrant, the whole kubernetes repo directory is copied over into the virtual machine. This includes the _output directory, which tends to be gigabytes in size, while often just _output/release-tars (a few hundred MB) would be enough. Furthermore, if the some of the directories contains a recursive symlink, rsync with the default args will keep descending and copying files endlessly until filling up the VM disk. Making the rsync args and excluded dirs/files customizable via KUBERNETES_VAGRANT_RSYNC_ARGS and KUBERNETES_VAGRANT_RSYNC_EXLUDE, respectively, allows the developer to prevent the issues mentioned above. A new KUBERNETES_VAGRANT_USE_RSYNC variable is also added to control whether Vagrant should force usage of rsync as the file synchronization backend. The args/exclude customizations only take effect when KUBERNETES_VAGRANT_USE_RSYNC is 'true'. --- Vagrantfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index f199ee3a7c5..532211d0f5d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -30,6 +30,8 @@ $kube_os = ENV['KUBERNETES_OS'] || "fedora" # Determine whether vagrant should use nfs to sync folders $use_nfs = ENV['KUBERNETES_VAGRANT_USE_NFS'] == 'true' +# Determine whether vagrant should use rsync to sync folders +$use_rsync = ENV['KUBERNETES_VAGRANT_USE_RSYNC'] == 'true' # To override the vagrant provider, use (e.g.): # KUBERNETES_PROVIDER=vagrant VAGRANT_DEFAULT_PROVIDER=... .../cluster/kube-up.sh @@ -156,6 +158,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if $use_nfs then config.vm.synced_folder ".", "/vagrant", nfs: true + elsif $use_rsync then + opts = {} + if ENV['KUBERNETES_VAGRANT_RSYNC_ARGS'] then + opts[:rsync__args] = ENV['KUBERNETES_VAGRANT_RSYNC_ARGS'].split(" ") + end + if ENV['KUBERNETES_VAGRANT_RSYNC_EXCLUDE'] then + opts[:rsync__exclude] = ENV['KUBERNETES_VAGRANT_RSYNC_EXCLUDE'].split(" ") + end + config.vm.synced_folder ".", "/vagrant", opts end # Try VMWare Fusion first (see