Skip to content

Commit

Permalink
Customizable vagrant rsync args and excludes
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
jistr committed Nov 14, 2016
1 parent 9813048 commit d61e569
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d61e569

Please sign in to comment.