<p>As a developer, I want to launch a local Kubernetes development environment automatically using kubeadm. I expect to create my environment running "vagrant up", and after that I must be able to login into the Vagrant VM and run kubectl commands.</p>

<p>I want to include a simple Python script that list all the running pods in all the namespaces. Call this script at the end of "vagrant up or provision" process to validate Kubernetes installation. </p>

<p>Finally I want to upload the scripts to GitHub.</p>

Carlos Javier A. Helguero
<p>What i have is a <em>bootstrap</em> script called from my <em>Vagrantfile</em>, for example:</p>

<pre><code>config.vm.provision :shell, path:./bootstrap.sh, privileged: false, :args =&gt; arguments_for_bootstrap
</code></pre>

<p>In such bootstrap script i install the software necessary to run my kubernetes stuff. As this is a vagrant machine, i would suggest standalone <em>minikube</em> "cluster". If using docker technology for containers, i would install, for example <em>docker</em>, <em>kubectl</em> and <em>minikube</em>, and probably, some more things like <em>helm</em> orchestrator, etc.</p>

<p>For example:</p>

<pre><code>### DOCKER ###
sudo apt-get update
# Install packages to allow apt to use a repository over HTTPS
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
# Add Dockers official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update
sudo apt-get update
# Install docker-ce
sudo apt-get install -y docker-ce=18.06.3~ce~3-0~ubuntu
# Add user to group 'docker'
sudo usermod -aG docker $USER

### KUBECTL ###
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.14.8/bin/linux/amd64/kubectl &amp;&amp; chmod +x kubectl &amp;&amp; sudo mv kubectl /usr/local/bin/

### MINIKUBE ###
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.4.0/minikube-linux-amd64 &amp;&amp; chmod +x minikube &amp;&amp; sudo mv minikube /usr/local/bin/
# Start
sudo minikube start --vm-driver=none
# Configure permissions
[ -d /root/.kube ] &amp;&amp; sudo mv /root/.kube $HOME/.kube # this will write over any previous configuration
sudo chown -R $USER $HOME/.kube
sudo chgrp -R $USER $HOME/.kube
[ -d /root/.minikube ] &amp;&amp; sudo mv /root/.minikube $HOME/.minikube # this will write over any previous configuration
sudo chown -R $USER $HOME/.minikube
sudo chgrp -R $USER $HOME/.minikube
</code></pre>

<p>Finally, i would add provision scripts to do whatever checking you need. If you prefer python script, you could use kubectl api for python (i.e. <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">https://github.com/kubernetes-client/python</a>), but i suggest directly bash scripting:</p>

<pre><code>kubectl get pod --all-namespaces 
</code></pre>

<p>The best way to afford tasks on provision, is using <em>scriptlets</em> which you can enable/disable just by giving +x permission:</p>

<pre><code>    @files = Dir.glob(provision.d + "/*").sort
    @files.each do |file|
      next if file == '.' or file == '..'
      next if not File.stat(file).executable?
      config.vm.provision :shell, path:file, privileged: false
    end
</code></pre>

<p>Then, you would have locally a bunch of scriptlets to do things in specific order:</p>

<pre><code>provision.d/K01_helm_install_my_app
...
provision.d/K30_check_k8s_health
</code></pre>

<p>Regarding your third question, i assume that having a <em>github</em> account, all the scripts necessary to recreate your development environment would be your <em>Vagrantfile</em>, bootstrap.sh script, and provision.d directory with <em>scriptlets</em> inside to do all the steps you consider to do on <em>vagrant up</em>.</p>
