making it a little more convient

master
Drew Bednar 4 years ago
parent 878abe0654
commit d3e4b11ea4

1
.gitignore vendored

@ -0,0 +1 @@
kubeconfig.conf

@ -1,5 +1,63 @@
# Kubernetes up and Running # 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 <pod name> <port>:<pod_port>
```
## Basic logging
```
kubectl logs <pod name>
```
Stream logs with `-f`
```
kubectl logs -f <pod name>
```
To view logs from the previous pod. Useful if the pod instances keep restarting.
```
kubectl logs --previous <pod_name>
```
## Running commands in your container with exec
One off commands
```
kubectl exec <pod name> <cmd>
kubectl exec kuard date
```
Interactive sessions
```
kubectl exec -it <pod name> <cmd>
```
## Copying files to and from a running container
```
kubectl cp <pod name>:<path> <host path>
```
```
kubectl cp <host path> <pod name>:<path>
```
## Demo app ## Demo app
https://github.com/kubernetes-up-and-running/kuard https://github.com/kubernetes-up-and-running/kuard

@ -1,7 +1,7 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
name: kaurd name: kuard
spec: spec:
containers: containers:
- image: gcr.io/kuar-demo/kuard-amd64:blue - image: gcr.io/kuar-demo/kuard-amd64:blue

@ -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
Loading…
Cancel
Save