Skip to content

Instantly share code, notes, and snippets.

@tudorfil9
Forked from lizrice/Vagrantfile
Created October 17, 2018 17:29
Show Gist options
  • Save tudorfil9/ac297b690df08e24258ab219ea52ccce to your computer and use it in GitHub Desktop.
Save tudorfil9/ac297b690df08e24258ab219ea52ccce to your computer and use it in GitHub Desktop.

Revisions

  1. @lizrice lizrice revised this gist May 11, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,9 @@ chown $(id -u vagrant):$(id -g vagrant) /home/vagrant/.kube/config
    SCRIPT

    Vagrant.configure("2") do |config|
    config.vm.box = "geerlingguy/ubuntu1604"
    # Specify your hostname if you like
    # config.vm.hostname = "name"
    config.vm.box = "bento/ubuntu-16.04"
    config.vm.network "private_network", type: "dhcp"
    config.vm.provision "docker"
    config.vm.provision "shell", inline: $script
  2. @lizrice lizrice revised this gist May 11, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,8 @@ apt-get install -y kubelet kubeadm kubectl
    # kubelet requires swap off
    swapoff -a
    # keep swap off after reboot
    sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
    # sed -i '/ExecStart=/a Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    sed -i '0,/ExecStart=/s//Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"\n&/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    @@ -24,7 +26,8 @@ IPADDR=`ifconfig enp0s8 | grep Mask | awk '{print $2}'| cut -f2 -d:`
    echo This VM has IP address $IPADDR
    # Set up Kubernetes
    kubeadm init --apiserver-cert-extra-sans=$IPADDR --node-name vagrant
    NODENAME=$(hostname -s)
    kubeadm init --apiserver-cert-extra-sans=$IPADDR --node-name $NODENAME
    # Set up admin creds for the vagrant user
    echo Copying credentials to /home/vagrant...
  3. @lizrice lizrice revised this gist May 11, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,8 @@ apt-get install -y kubelet kubeadm kubectl
    # kubelet requires swap off
    swapoff -a
    # This adds the line twice, but the second time doesn't matter
    sed '/ExecStart=/a Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    # sed -i '/ExecStart=/a Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    sed -i '0,/ExecStart=/s//Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"\n&/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    # Get the IP address that VirtualBox has given this VM
    IPADDR=`ifconfig enp0s8 | grep Mask | awk '{print $2}'| cut -f2 -d:`
  4. @lizrice lizrice revised this gist Apr 2, 2018. No changes.
  5. @lizrice lizrice revised this gist Apr 2, 2018. No changes.
  6. @lizrice lizrice revised this gist Apr 2, 2018. No changes.
  7. @lizrice lizrice revised this gist Apr 2, 2018. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -31,13 +31,6 @@ echo Copying credentials to /home/vagrant...
    sudo --user=vagrant mkdir -p /home/vagrant/.kube
    cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config
    chown $(id -u vagrant):$(id -g vagrant) /home/vagrant/.kube/config
    # User will need to complete the setup:
    echo Add networking with the following command:
    echo kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    echo
    echo Allow pods to run on this master node:
    echo kubectl taint nodes --all node-role.kubernetes.io/master-
    SCRIPT

    Vagrant.configure("2") do |config|
  8. @lizrice lizrice created this gist Apr 2, 2018.
    48 changes: 48 additions & 0 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    # -*- mode: ruby -*-
    # vi: set ft=ruby :

    # This script to install Kubernetes will get executed after we have provisioned the box
    $script = <<-SCRIPT
    # Install kubernetes
    apt-get update && apt-get install -y apt-transport-https
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb http://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    apt-get update
    apt-get install -y kubelet kubeadm kubectl
    # kubelet requires swap off
    swapoff -a
    # This adds the line twice, but the second time doesn't matter
    sed '/ExecStart=/a Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    # Get the IP address that VirtualBox has given this VM
    IPADDR=`ifconfig enp0s8 | grep Mask | awk '{print $2}'| cut -f2 -d:`
    echo This VM has IP address $IPADDR
    # Set up Kubernetes
    kubeadm init --apiserver-cert-extra-sans=$IPADDR --node-name vagrant
    # Set up admin creds for the vagrant user
    echo Copying credentials to /home/vagrant...
    sudo --user=vagrant mkdir -p /home/vagrant/.kube
    cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config
    chown $(id -u vagrant):$(id -g vagrant) /home/vagrant/.kube/config
    # User will need to complete the setup:
    echo Add networking with the following command:
    echo kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    echo
    echo Allow pods to run on this master node:
    echo kubectl taint nodes --all node-role.kubernetes.io/master-
    SCRIPT

    Vagrant.configure("2") do |config|
    config.vm.box = "geerlingguy/ubuntu1604"
    config.vm.network "private_network", type: "dhcp"
    config.vm.provision "docker"
    config.vm.provision "shell", inline: $script
    end