From d3e4b11ea4d2ef03d78142b65cd236831a359bf6 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Wed, 16 Dec 2020 16:23:35 -0500 Subject: [PATCH] making it a little more convient --- .gitignore | 1 + README.md | 58 ++++++++++++++++++++++++++++++++++++++++ manifests/kuard-pod.yaml | 2 +- scripts/profile | 15 +++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100755 scripts/profile diff --git a/.gitignore b/.gitignore index e69de29..19b213b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +kubeconfig.conf diff --git a/README.md b/README.md index 6a1aade..2fbefeb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,63 @@ # 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 diff --git a/manifests/kuard-pod.yaml b/manifests/kuard-pod.yaml index 800fbcd..e01cfe4 100644 --- a/manifests/kuard-pod.yaml +++ b/manifests/kuard-pod.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Pod metadata: - name: kaurd + name: kuard spec: containers: - image: gcr.io/kuar-demo/kuard-amd64:blue diff --git a/scripts/profile b/scripts/profile new file mode 100755 index 0000000..e0ac910 --- /dev/null +++ b/scripts/profile @@ -0,0 +1,15 @@ +#!/bin/bash + +set +ex + +CDIR=$(pwd -P) + +echo "Setting 'kk' as a kubectl alias" +alias kk=kubectl + +if [ -f kubeconfig.conf ]; then + export KUBECONFIG="${CDIR}/kubeconfig.conf" +else + echo "Fail whale. You have no kubeconfig.conf file" + exit 1 +fi