From d5589327685c0334068e5e658bb24d957abef7ba Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Mon, 16 Nov 2020 15:07:27 +0100 Subject: [PATCH] Add k8s --- src/SUMMARY.md | 2 ++ src/ops/k8s/kubectl.md | 41 +++++++++++++++++++++++++++++++++++++++++ src/ops/k8s/main.md | 1 + 3 files changed, 44 insertions(+) create mode 100644 src/ops/k8s/kubectl.md create mode 100644 src/ops/k8s/main.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index c94340f..67148f2 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -30,6 +30,8 @@ - [SVN](./dev/tools/svn.md) - [Ops](./ops/main.md) + - [k8s](./ops/k8s/main.md) + - [kubectl](./ops/k8s/kubectl.md) - [macOS](./ops/macos/main.md) - [iterm](./ops/macos/iterm.md) - [GNU/Linux](./ops/gnulinux/main.md) diff --git a/src/ops/k8s/kubectl.md b/src/ops/k8s/kubectl.md new file mode 100644 index 0000000..154a7e4 --- /dev/null +++ b/src/ops/k8s/kubectl.md @@ -0,0 +1,41 @@ +# kubectl + +kubectl is the main command line tool for k8s. See [reference](https://kubernetes.io/docs/reference/kubectl/conventions/) + +## Raw commands + +Sometimes it's handy to just run a container without all the yaml mess. + +### Running a container + +```sh +kubectl run --image=IMAGE name +``` + +### apply is not always the answer + +Even if you see `kubectl apply` everywhere sometimes it's handy to use dedicated commands + +For example, `kubectl create` is used to create a ressource and will throw an error if a ressource already exists. + +### Generating a manifests, blazzing fast way + +```sh +kubectl run app --image=app --dry-run=client -o yaml +``` + +```sh +kubectl create deployment --image=redis redis --dry-run=client -o yaml +``` + +Of course, if you need to write it into a file + +```sh +kubectl create deployment --image=redis redis --dry-run=client -o yaml > deploy-manifest.yml +``` + +### Switching namespaces contexts + +```sh +kubectl config set-config $(kubectl config current-context) --namespace=target +``` diff --git a/src/ops/k8s/main.md b/src/ops/k8s/main.md new file mode 100644 index 0000000..d749e72 --- /dev/null +++ b/src/ops/k8s/main.md @@ -0,0 +1 @@ +# k8s