-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from seifrajhi/k8s-exercices
feat: k8s exercices
- Loading branch information
Showing
169 changed files
with
7,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/macos,linux,windows | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,linux,windows | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/macos,linux,windows | ||
|
||
# Yaml extracted from Markdown files | ||
*.md.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
find . -iname "*.md" -exec sh -c "cat {} | sh kubernetes-exercises/.test/parse_k8s_from_md.sh > {}.yaml" \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Select all yaml files, except the Helmsman related ones. These are | ||
# detected by exluding files with filenames starting with "helmfile." or "values-". | ||
KUBERNETES_RESOURCE_FILES=$(find * -type f \( -iname '*.yml' -or -iname '*.yaml' \) -and ! \( -iname "helmfile.yaml" -or -iname "values-*.yaml" -or -iname "*docker-compose*" \)) | ||
|
||
excludes=( | ||
kubernetes-exercises/deployments-ingress/start/frontend-deployment.yaml | ||
kubernetes-exercises/deployments-ingress/start/backend-deployment.yaml | ||
kubernetes-exercises/manifests/start/frontend-pod.yaml | ||
kubernetes-exercises/services/start/backend-svc.yaml | ||
kubernetes-exercises/services/start/frontend-svc.yaml | ||
kubernetes-exercises/kubernetes-exercises/old/support-files/traefik-rbac-serviceaccount.yaml | ||
kubernetes-exercises/old/ingress-nginx/ingress.yml | ||
kubernetes-exercises/old/support-files/traefik-service.yaml | ||
kubernetes-exercises/old/extras/08-ingress-gke.md.yaml | ||
kubernetes-exercises/old/extras/08-ingress-gke.md.yaml | ||
kubernetes-exercises/old/extras/08-ingress-traefik.md.yaml | ||
kubernetes-exercises/old/support-files/traefik-rbac-serviceaccount.yaml | ||
kubernetes-exercises/old/extras/08-ingress-traefik.md.yaml | ||
kubernetes-exercises/old/extras/08-ingress-traefik.md.yaml | ||
kubernetes-exercises/old/extras/08-ingress-traefik.md.yaml | ||
kubernetes-exercises/old/ingress-gke/ingress.yml | ||
kubernetes-exercises/old/ingress-traefik/traefik-rbac.yaml | ||
kubernetes-exercises/old/ingress-traefik/traefik-rbac.yaml | ||
kubernetes-exercises/old/ingress-traefik/traefik-webui-ingress.yaml | ||
kubernetes-exercises/old/ingress-traefik/example-ingress.yaml | ||
kubernetes-exercises/old/ingress-traefik/my-ingress.yml | ||
kubernetes-exercises/old/ingress-traefik/traefik-ingress-controller.yml | ||
) | ||
for exclude in ${excludes[@]} | ||
do | ||
KUBERNETES_RESOURCE_FILES=("${KUBERNETES_RESOURCE_FILES[@]/$exclude}") | ||
done | ||
|
||
# Run all files through kubeconform | ||
docker run --rm -v ${PWD}:/fixtures -w /fixtures ghcr.io/yannh/kubeconform -summary $KUBERNETES_RESOURCE_FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
sed -n '/^```[^\n]*k8s/,/^```/p' | sed '/^```[^\n]*k8s/d' | sed -e 's/```/---/g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Contribution | ||
|
||
## Exercise structure | ||
|
||
The exercise should have the following sections: | ||
|
||
* Learning goals (bullet points on what the student should learn) | ||
* Introduction (cleartext description of the exercise) | ||
* Exercise (Step-by-step instructions on how to solve the exercise) | ||
* Extras and wrap-up (optional) | ||
|
||
When creating a new exercise, you should use the [exercise template](exercise-template.md) as a starting point. | ||
## Best practices | ||
|
||
### Hints | ||
Use :bulb: `:bulb:` to indicate a hint to the exercise. | ||
|
||
### Dealing with text rich content | ||
|
||
When ever you think there is too much text, but that it is necessary, please use the `details` tag to make the text toggleable, by clicking the arrow: | ||
|
||
<details> | ||
<summary>A Hint</summary> | ||
It helps reducing the amount of word overload that we sometimes write | ||
</details> | ||
|
||
The code to make this happen is the following: | ||
|
||
```markdown | ||
<details> | ||
<summary>Hint</summary> | ||
All markdown in here is hidden in an expandable field | ||
</details> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][gitpod] | ||
|
||
# kubernetes-exercises | ||
|
||
A selection of exercises for Kubernetes (k8s). | ||
|
||
The exercises are ordered in the way we think it makes sense to introduce Kubernetes concepts. | ||
|
||
You can find a summary of many of the commands used in the exercises in the | ||
[cheatsheet.md](cheatsheet.md). | ||
|
||
> :exclamation: The exercises expect that you have access to a kubernetes cluster. | ||
> Please have a look at the [Setup](#setup) section if that is not the case. | ||
> There are plenty of free and easy options. | ||
## exercises in suggested order: | ||
|
||
- [intro](intro.md) | ||
- [desired-state](desired-state.md) | ||
- [manifests](manifests.md) | ||
- [accessing-your-application](accessing-your-application.md) | ||
- [services](services.md) | ||
- [deployments-loadbalancing](deployments-loadbalancing.md) | ||
- [rolling-updates](rolling-updates.md) | ||
- [configmaps-secrets](configmaps-secrets.md) | ||
- [persistent-storage](persistent-storage.md) | ||
|
||
## Setup | ||
|
||
There are several ways to get a free Kubernetes cluster for running the exercises. | ||
|
||
[Amazon][eks], [Google][gke], [Microsoft][aks] and [Oracle][oke] provide various degrees of free managed clusters. | ||
|
||
Alternatively, you can set up a local cluster with [Docker | ||
Desktop][docker-desktop] or [Kind][kind]. | ||
|
||
Once you have access to a cluster, the following exercises will help you get setup for running the exercises. | ||
|
||
- [setup-kubectl-linux](old/exercise_setup/00-setup-kubectl-linux.md) - Skip if | ||
you've already installed `kubectl` and have access to a cluster. | ||
- [setup-namespace](old/exercise_setup/00-setup-namespace.md) - Skip if you've | ||
already created a personal namespace and set it as your default. | ||
|
||
### kubectl autocompletion | ||
|
||
On Linux, using bash, run the following commands: | ||
|
||
```shell | ||
echo "source <(kubectl completion bash)" >> ~/.bashrc | ||
. ~/.bashrc | ||
``` | ||
|
||
The commands above will enable kubectl autocompletion when you start a new bash session and source (reload) bashrc i.e. enable kubectl autocompletion in your current session. | ||
|
||
See: [Kubernetes.io - Enabling shell autocompletion][autocompletion] for more info. | ||
|
||
# Cheatsheet | ||
|
||
A collection of useful commands to use throughout the exercises: | ||
|
||
```bash | ||
kubectl api-resources # List resource types | ||
|
||
|
||
kubectl explain <resource> # Show information about a resource | ||
kubectl explain deployment | ||
|
||
|
||
# List resources in cluster | ||
kubectl get <resource> # In current namespace | ||
kubectl get <resource> -n <namespace> # In specific namespace | ||
kubectl get <resource> --all-namespaces # In all namespaces | ||
kubectl get <resource> -o wide # Add extended information | ||
kubectl get <resource> -o yaml # output in YAML format | ||
kubectl get <resource> -o json # output in JSON format | ||
|
||
# Example | ||
kubectl get pods [-n abc|--all-namespaces] [-o wide|yaml|json] | ||
``` | ||
|
||
See: | ||
[kubectl - Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/) | ||
for a more extended overview of the `kubectl` command. | ||
|
||
[eks]: https://aws.amazon.com/ecs/pricing/ | ||
[gke]: https://cloud.google.com/kubernetes-engine/pricing#cluster_management_fee_and_free_tier | ||
[aks]: https://azure.microsoft.com/en-us/pricing/free-services/ | ||
[oke]: https://www.oracle.com/cloud/free/#free-cloud-trial | ||
[docker-desktop]: https://docs.docker.com/desktop/ | ||
[kind]: https://kind.sigs.k8s.io/ | ||
[autocompletion]: https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion |
Oops, something went wrong.