# Kubernetes up and Running ## Setting your kubeconfig To make it easier on you copy your kube config file to the root of this project and name it kubeconfig.conf. Then just remember to run source `scripts/profile` to start using the kubectl command. I am just setting the KUBECONFIG envar to the kubeconfig.conf file for the bash session. ## Accessing a pod from your laptop Portforwarding ``` kubectl port-forward : ``` ## Basic logging ``` kubectl logs ``` Stream logs with `-f` ``` kubectl logs -f ``` To view logs from the previous pod. Useful if the pod instances keep restarting. ``` kubectl logs --previous ``` ## Running commands in your container with exec One off commands ``` kubectl exec kubectl exec kuard date ``` Interactive sessions ``` kubectl exec -it ``` ## Copying files to and from a running container ``` kubectl cp : ``` ``` kubectl cp : ``` ## Demo app https://github.com/kubernetes-up-and-running/kuard Here is an example of using the cgroups access to limit container resources to 200mb of ram and 1G of swap. If these resources are exceed, which you can test with the kuard application, the container will be terminated. ``` docker run -d --name kuard -p 8080:8080 --memory 200m --memory-swap 1G docker1.runcible.io:5151/kuard:latest ``` If we wanted to limit cpu you could use ``` docker run -d --name kuard -p 8080:8080 --memory 200m --memory-swap 1G --cpu-shares 1024 docker1.runcible.io:5151/kuard:latest ```