Last active
December 30, 2019 15:04
-
-
Save knabben/aaac38922f165ac315d90eaea8405d14 to your computer and use it in GitHub Desktop.
Kubernetes Development setup (stale version)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| unset DEBUG | |
| function runService() { | |
| SERVICE=$1 | |
| NAME=$1 | |
| CONTAINER=$2 | |
| PARAMS=$3 | |
| if ! helm list ${SERVICE} | grep -q ${SERVICE} ; then | |
| helm install --name ${NAME} ${PARAMS} ${CONTAINER} | |
| else | |
| echo "Service ${SERVICE} already up." | |
| fi | |
| } | |
| # --- PostgreSQL 10 | |
| PSQL_PASS="postgres" | |
| runService "postgis" "stable/postgresql" "--set image=knabben/postgis-sniffer | |
| --set imageTag=latest | |
| --set postgresPassword=${PSQL_PASS}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -x | |
| apt-get update | |
| apt-get -y upgrade | |
| apt-get install -y \ | |
| apt-transport-https \ | |
| ca-certificates \ | |
| curl \ | |
| software-properties-common | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
| add-apt-repository \ | |
| "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \ | |
| $(lsb_release -cs) \ | |
| stable" | |
| apt-get update && apt-get install -y docker-ce | |
| sudo sed -i 's/-H fd:\/\// -H fd:\/\/ -H tcp:\/\/192.168.99.252:2376/g' /lib/systemd/system/docker.service | |
| 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 | |
| sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
| echo 'GRUB_CMDLINE_LINUX="cgroup_enable=memory"' >> /etc/default/grub | |
| sed -i '10,11d' /etc/fstab | |
| swapoff -a | |
| systemctl daemon-reload | |
| systemctl restart kubelet | |
| systemctl restart docker | |
| if [ ! -f go1.10.1.linux-amd64.tar.gz ]; then | |
| curl https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz --output go1.10.1.linux-amd64.tar.gz | |
| tar -C /usr/local -xvf go1.10.1.linux-amd64.tar.gz | |
| fi | |
| if ! grep -Fxq GOPATH /etc/profile | |
| then | |
| echo "export GOPATH=/home/vagrant/go" >> /etc/profile | |
| echo "export PATH=${PATH}:/usr/local/go/bin:/home/vagrant/bin" >> /etc/profile | |
| fi | |
| source /etc/profile | |
| swapoff --all | |
| go get github.com/kubernetes-incubator/cri-tools/cmd/crictl | |
| go install github.com/kubernetes-incubator/cri-tools/cmd/crictl | |
| kubeadm init --apiserver-advertise-address 192.168.99.252 | |
| mkdir -p /home/vagrant/.kube | |
| cp /etc/kubernetes/admin.conf /home/vagrant/.kube/config | |
| chown -R vagrant /home/vagrant/.kube | |
| export kubever=$(kubectl version | base64 | tr -d '\n') | |
| kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever" | |
| kubectl taint nodes --all node-role.kubernetes.io/master- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Initial minikube setup | |
| # | |
| mkdir -p ~/.minikube/config | |
| cat > ~/.minikube/config/config.json <<EOF | |
| { | |
| "WantReportError": true, | |
| "cpus": 4, | |
| "dashboard": false, | |
| "disk-size": "30G", | |
| "vm-driver": "xhyve" | |
| } | |
| EOF | |
| minikube start | |
| minikube addons enable registry-creds | |
| minikube addons disable dashboard | |
| minikube addons configure registry-creds | |
| echo 'eval $(minikube docker-env)' >> ~/.zshrc | |
| echo 'alias sniffer="kubectl exec -i -t $(kubectl get pods -o json -l app=postgis-postgresql | jq ".items[0].metadata.name" -r) ./vc-pgsql-sniffer"' >> ~/.zshrc | |
| helm init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| Vagrant.configure("2") do |config| | |
| config.vm.box = "debian/jessie64" | |
| config.disksize.size = '20GB' | |
| config.vm.network "private_network", ip: "192.168.99.252" | |
| config.vm.synced_folder "~/.projects", "/home/vagrant/projects" | |
| config.vm.provider "virtualbox" do |vb| | |
| vb.gui = true | |
| vb.memory = "2024" | |
| vb.cpus = 4 | |
| end | |
| config.vm.provision "shell", path: "install.sh" | |
| end | |
| © 2019 GitHub, Inc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment