Skip to content

Commit

Permalink
Scripts for making kind work behind a proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
algogrit committed Aug 9, 2019
1 parent a100749 commit 4865c57
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 27 deletions.
17 changes: 17 additions & 0 deletions code-samples/11-kubernetes/create-cluster.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions code-samples/11-kubernetes/docker-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
15 changes: 0 additions & 15 deletions code-samples/11-kubernetes/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions code-samples/11-kubernetes/setup-proxy.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions code-samples/11-kubernetes/test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4865c57

Please sign in to comment.