Skip to content

Instantly share code, notes, and snippets.

@atomatt
Last active September 26, 2017 16:24
Show Gist options
  • Select an option

  • Save atomatt/2f0156e670a14827810302ab7ab4b9ec to your computer and use it in GitHub Desktop.

Select an option

Save atomatt/2f0156e670a14827810302ab7ab4b9ec to your computer and use it in GitHub Desktop.
k8s quick start
# Bring up a cluster ...
$ sudo kubeadm init
# Copy config across for your user ...
mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# "Taint" the master node so you can use it as a node ...
$ kubectl taint nodes --all node-role.kubernetes.io/master-
# Install networking (weave) ...
$ kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
# Deploy nginx ...
$ kubectl run nginx --image nginx --port 80
# Expose it as a service ...
$ kubectl expose deployment nginx --type LoadBalancer
# curl it (grab the IP from `kubectl get svc | grep nginx`)
$ curl 10.99.144.193
<!DOCTYPE html>
[...]
# Test cluster DNS, full name and same-cluster service name.
$ kubectl run --rm -i -t --image busybox scratch
If you don't see a command prompt, try pressing enter.
/ # wget -q -O- nginx.default.svc.cluster.local
<!DOCTYPE html>
[...]
/ # wget -q -O- nginx
<!DOCTYPE html>
[...]
# Scale nginx up a bit ...
$ kubectl scale deployment nginx --replicas 5
# Take down the whole cluster
$ sudo kubeadm reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment