start here: https://kubernetes.io/docs/reference/kubectl/cheatsheet/

Commands to initialize cluster (pay attention to sudo useage):

sudo kubeadm init --pod-network-cidr=10.244.0.0/16

or, if using config file

sudo kubeadm init --config kubeadm-config.yaml

In either case, may need to turn off swap memory to get cluster up:

sudo swapoff -a

...

after thats done do, somehow the mkdir and chown need to be run every time:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

start up cluster networking with one of the following:

requires internet:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

requires the kube-flannel.yml file locally:
kubectl apply -f kube-flannel.yml

check that pods/nodes are up, can take a while due to launch order:

kubectl get pods --all-namespaces

allow pods to run on control-plane node (by removing the taint on all nodes):

kubectl taint nodes --all node-role.kubernetes.io/master-

-----------------------------------------------------

ros_on_kubernetes set up steps:

kubectl create -f ros_on_kubernetes

kubectl get all

kubectl exec -it listener bash (deprech kubectl exec -it listener -- bash)

source .. yadda ya bumdadada

-----------------------------------------------------

turning off nodes:

first drain node (kubectl get nodes, for node name):

kubectl drain <node name> --delete-emptydir-data --force --ignore-daemonsets

reset cluster:

sudo kubeadm reset

reset ipv6 tables and such (seems to work fine without but eh):

iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

another ipvs reset:

ipvsadm -C

now you can finally delete the node(s) in question:

kubectl delete node <node name>

--------------------------------------------------------

handy interaction commands

get into pod bash shell (remove -it and just put command for noninteractive):

kubectl exec <pod_name> -it -- bash
kubectl get service -> good for getting port numbers
kubectl delete -f deployment.yaml -> removes (eventually) pods on the cluster in deployment
kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces

label nodes to force pod to live on specific node:
kubectl label nodes <node_name> <selector_key>=<selector_value>
then in pod spec, add
nodeSelector:
  <selector_key>=<selector_value>

check which pods are running on which nodes:
kubectl get pods --all-namespaces -o wide
