diff --git a/code-samples/11-kubernetes/create-cluster.sh b/code-samples/11-kubernetes/create-cluster.sh new file mode 100755 index 0000000..d794138 --- /dev/null +++ b/code-samples/11-kubernetes/create-cluster.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +echo "Setting up docker proxy settings..." +mkdir -p ~/.docker +cp docker-config.json ~/.docker/config.json + +echo "Fetching kubernetes source..." +mkdir -p ~/.go/src/k8s.io/kubernetes +export GOPATH=$HOME/.go +git clone https://github.com/kubernetes/kubernetes.git ~/.go/src/k8s.io/kubernetes + +echo "Creating kind cluster..." +# kind delete cluster +kind build node-image +kind create cluster --config kind-config.yml diff --git a/code-samples/11-kubernetes/docker-config.json b/code-samples/11-kubernetes/docker-config.json new file mode 100644 index 0000000..1b939cf --- /dev/null +++ b/code-samples/11-kubernetes/docker-config.json @@ -0,0 +1,11 @@ +{ + "proxies": + { + "default": + { + "httpProxy": "http://10.19.16.165:8080", + "httpsProxy": "http://10.19.16.165:8080", + "noProxy": "localhost,127.0.0.0/8,::1" + } + } +} diff --git a/code-samples/11-kubernetes/install.sh b/code-samples/11-kubernetes/install.sh index 3f6cde0..3958fb8 100755 --- a/code-samples/11-kubernetes/install.sh +++ b/code-samples/11-kubernetes/install.sh @@ -43,21 +43,6 @@ chmod +x kind sudo install kind /usr/local/bin rm kind -echo "Installing go & kubernetes source..." -wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz -tar -xzf go1.12.7.linux-amd64.tar.gz -mv go /usr/local - -mkdir -p ~/.go -echo >> .bash_profile -echo 'export GOPATH=$HOME/.go' >> .bash_profile -echo 'export PATH=$GOPATH/bin:$PATH' >> .bash_profile -echo >> .bashrc -echo 'export GOPATH=$HOME/.go' >> .bashrc -echo 'export PATH=$GOPATH/bin:$PATH' >> .bashrc - -go get -d k8s.io/kubernetes - echo "Installation done! Please verify by running..." echo " minikube version" echo " kubectl version" diff --git a/code-samples/11-kubernetes/setup-proxy.md b/code-samples/11-kubernetes/setup-proxy.md index 3bb4d44..30447bb 100644 --- a/code-samples/11-kubernetes/setup-proxy.md +++ b/code-samples/11-kubernetes/setup-proxy.md @@ -1,30 +1,30 @@ # Setup Docker proxy -1. Create a `.docker` dir in `HOME` +## Step 1: Create a `.docker` dir in `HOME` ``` mkdir ~/.docker ``` -2. Create a file `config.json` with the following content: +## Step 2: Create a file `config.json` with the following content: `cat ~/.docker/config.json` ```json { - "proxies": - { - "default": - { - "httpProxy": "http://10.19.16.165:8080", - "httpsProxy": "http://10.19.16.165:8080", - "noProxy": "localhost,127.0.0.0/8,::1" - } - } + "proxies": + { + "default": + { + "httpProxy": "http://10.19.16.165:8080", + "httpsProxy": "http://10.19.16.165:8080", + "noProxy": "localhost,127.0.0.0/8,::1" + } + } } ``` -3. Environment variables +## Step 3: Environment variables ```bash export NO_PROXY=$no_proxy,172.17.0.0/16 diff --git a/code-samples/11-kubernetes/test.sh b/code-samples/11-kubernetes/test.sh new file mode 100755 index 0000000..0212973 --- /dev/null +++ b/code-samples/11-kubernetes/test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Setup kind cluster +kind create cluster --config kind-config.yml +export KUBECONFIG="$(kind get kubeconfig-path)" +kubectl cluster-info + +# Add kubernetes dashboard +kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml + +# Watch +watch -n 1 kubectl get pods -n kube-system