Class: VagrantK8s::KustomizeProvisioner

Inherits:
BaseProvisioner show all
Defined in:
lib/vagrant-k8s/kustomize_provisioner.rb

Instance Method Summary collapse

Methods inherited from BaseProvisioner

#initialize

Constructor Details

This class inherits a constructor from VagrantK8s::BaseProvisioner

Instance Method Details

#provisionObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagrant-k8s/kustomize_provisioner.rb', line 50

def provision
  command = Kubeconfig.kubectl_command(@machine, ['apply', '-k', root_path(@config.path)],
                                       namespace: @config.namespace)
  command << '--server-side' if @config.server_side
  command << '--force-conflicts' if @config.force_conflicts
  command += ['--prune', '--selector', @config.prune_selector] if @config.prune
  run(command)
  return unless @config.wait

  # A kustomization may apply only non-pod resources (e.g. a ConfigMap), in
  # which case `kubectl wait pod --all` exits non-zero with "no matching
  # resources found". That's nothing to wait for, not a failure.
  run(Kubeconfig.kubectl_command(@machine, ['wait', '--for=condition=ready', 'pod', '--all', '--timeout=300s'],
                                 namespace: @config.namespace),
      tolerate: /no matching resources found/i,
      tolerate_message: 'No pods to wait for — the kustomization applied no pod-bearing resources.')
end