summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2023-12-29 15:45:39 -0500
committerLouie S <louie@example.com>2023-12-29 15:45:39 -0500
commitb75ce875030134d21d2ede398457b7c1910b11bf (patch)
treebbdddae5548ae9e4b677b513fa4653446730c9ce
parentb1477105319de37088743c4c3ffae7c871189864 (diff)
Watched through ch. 9
-rw-r--r--Makefile11
-rw-r--r--docker_cheat_sheet.md10
-rw-r--r--index.md1
-rw-r--r--kubernetes_cheat_sheet.md71
4 files changed, 85 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index d34007c..4010311 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,9 @@
MARKC=marked
+TARGETS=index.html docker_cheat_sheet.html kubernetes_cheat_sheet.html yaml_cheat_sheet.html
+
.PHONY: all
-all: index.html docker_cheat_sheet.html yaml_cheat_sheet.html
+all: $(TARGETS)
index.html: index.md docker_cheat_sheet.html yaml_cheat_sheet.html
$(MARKC) -o $@ $<
@@ -9,16 +11,19 @@ index.html: index.md docker_cheat_sheet.html yaml_cheat_sheet.html
docker_cheat_sheet.html: docker_cheat_sheet.md yaml_cheat_sheet.html
$(MARKC) -o $@ $<
+kubernetes_cheat_sheet.html: kubernetes_cheat_sheet.md
+ $(MARKC) -o $@ $<
+
yaml_cheat_sheet.html: yaml_cheat_sheet.md
$(MARKC) -o $@ $<
.PHONY: bdist
-bdist: index.html docker_cheat_sheet.html yaml_cheat_sheet.html
+bdist: $(TARGETS)
mkdir -p dist
tar -czf dist/docker_containers_and_kubernetes_fundamentals_personal_notes_$(shell date +%Y%m%d%H%M%S).tar.gz $^
.PHONY: sdist
-sdist: index.md docker_cheat_sheet.md yaml_cheat_sheet.md README
+sdist: index.md docker_cheat_sheet.md kubernetes_cheat_sheet.md yaml_cheat_sheet.md README
mkdir -p dist
tar -czf dist/docker_containers_and_kubernetes_fundamentals_personal_notes_$(shell date +%Y%m%d%H%M%S).src.tar.gz $^ Makefile
diff --git a/docker_cheat_sheet.md b/docker_cheat_sheet.md
index f1d3518..621f9d9 100644
--- a/docker_cheat_sheet.md
+++ b/docker_cheat_sheet.md
@@ -95,7 +95,7 @@
### Running a container
-```
+```sh
# pull and run an nginx server
# `--publish 80:80` maps the host port to the container listening port
# `--name webserver` container local name
@@ -121,7 +121,7 @@ FROM nginx:alpine
COPY . /usr/share/nginx/html
```
-```
+```sh
# build
docker build -t webserver-image:v1 .
@@ -154,7 +154,7 @@ ENTRYPOINT ["node", "./app.js"]
### Mapping a Volume
-```
+```sh
# create a volume
docker volume create myvol
@@ -171,7 +171,7 @@ docker run -d --name devtest -v myvol:/app nginx:latest
#### Mapping to a local folder
-```
+```sh
# run a container with a volume
# `d:/test` specify a folder
docker run -d --name devtest -v d:/test:/app nginx:latest
@@ -218,7 +218,7 @@ services:
### Docker Compose Example
-```
+```sh
# build the service
docker compose build
diff --git a/index.md b/index.md
index 72700b1..2428421 100644
--- a/index.md
+++ b/index.md
@@ -3,4 +3,5 @@
This repository contains my personal set of notes, based on the video lecture series "Docker Containers and Kubernetes Fundamentals - Full Hands-On Course" from FreeCodeCamp.org [kTp5xUtcalw](https://www.youtube.com/watch?v=kTp5xUtcalw). My notes are mostly arranged to serve as cheat sheets for using Docker and Kubernetes. They are broken into the following pages:
- [Docker Cheat Sheet](./docker_cheat_sheet.html)
+- [Kubernetes Cheat Sheet](./kubernetes_cheat_sheet.html)
- [YAML Cheat Sheet](./yaml_cheat_sheet.html)
diff --git a/kubernetes_cheat_sheet.md b/kubernetes_cheat_sheet.md
new file mode 100644
index 0000000..e8c4bd1
--- /dev/null
+++ b/kubernetes_cheat_sheet.md
@@ -0,0 +1,71 @@
+# Kubernetes Cheat Sheet
+
+## kubectl CLI
+
+### Context
+
+| | |
+|--------------------------------------|-----------------------------|
+|`kubectl config current-context` |Get the current context |
+|`kubectl config get-contexts` |List all context |
+|`kubectl config use-context [contextName]`|Set the current context |
+|`kubectl config delete-context [contextName]`|Delete a context from the config file|
+
+### Misc.
+
+| | |
+|--------------------------------------|-----------------------------|
+|`kubectl create -f [YAML file]` |Create an object using YAML |
+
+---
+
+### `kubectx`
+
+- Separate program that acts as an alias for `kubectl config use-context`
+ - *Fast way to switch between clusters and namespaces in kubectl*
+
+---
+
+### Declarative vs Imperative
+
+#### Declarative Example - YAML File
+
+```yaml
+apiVersion: v1
+kind: Pod
+metadata:
+ name: myapp-pod
+ labels:
+ app: myapp
+ type: front-end
+spec:
+ containers:
+ name: nginx-container
+ image: nginx
+```
+
+#### Imperative Example - Series of commands
+
+```sh
+kubectl run mynginx --image=nginx --port=80
+
+kubectl create deploy mynginx --image=nginx --port=80 --replicas=3
+
+kubectl create service nodeport myservice --targetPort=8080
+
+kubectl delete pod nginx
+```
+
+### YAML required properties
+
+- Root level required properties
+ - `apiVersion`
+ - Api version of the object
+ - `kind`
+ - type of object
+ - `metadata.name`
+ - unique name for the object
+ - `metadata.namespace`
+ - scoped environment name (will default to current)
+ - `spec`
+ - object specifications or desired state