diff --git a/slides/k8s/exercise-configmap.md b/slides/k8s/exercise-configmap.md new file mode 100644 index 00000000..c885f157 --- /dev/null +++ b/slides/k8s/exercise-configmap.md @@ -0,0 +1,31 @@ +# Exercise — ConfigMaps + +- In this exercise, we will use a ConfigMap to store static assets + +- While there are some circumstances where this can be useful ... + +- ... It is generally **not** a good idea! + +- Once you've read that warning, check the next slide for instructions :) + +--- + +## Exercise — ConfigMaps + +This will use the wordsmith app. + +We want to store the static files (served by `web`) in a ConfigMap. + +1. Transform the `static` directory into a ConfigMap. + + (https://github.com/jpetazzo/wordsmith/tree/master/web/static) + +2. Find out where that `static` directory is located in `web`. + + (for instance, by using `kubectl exec` to investigate) + +3. Update the definition of the `web` Deployment to use the ConfigMap. + + (note: fonts and images will be broken; that's OK) + +4. Make a minor change in the ConfigMap (e.g. change the text color) diff --git a/slides/k8s/exercise-helm.md b/slides/k8s/exercise-helm.md new file mode 100644 index 00000000..b41e429f --- /dev/null +++ b/slides/k8s/exercise-helm.md @@ -0,0 +1,63 @@ +# Exercise — Helm charts + +Let's write a Helm chart for wordsmith! + +We will need the YAML manifests that we wrote earlier. + +Level 1: create a chart to deploy wordsmith. + +Level 2: make it so that the number of replicas can be set with `--set replicas=X`. + +Level 3: change the colors of the lego bricks. + +(For level 3, fork the repository and use ctr.run to build images.) + +See next slide if you need hints! + +--- + +## Hints + +*Scroll one slide at a time to see hints.* + +-- + +Use `helm create` to create a new chart. + +-- + +Delete the content of the `templates` directory and put your YAML instead. + +-- + +Install the resulting chart. Voilà! + +-- + +Use `{{ .Values.replicas }}` in the YAML manifest for `words`. + +-- + +Also add `replicas: 5` to `values.yaml` to provide a default value. + +--- + +## Changing the color + +- Fork the repository + +- Make sure that your fork has valid Dockerfiles + + (or identify a branch that has valid Dockerfiles) + +- Use the following images: + + ctr.run/yourgithubusername/wordsmith/db:branchname + + (replace db with web and words for the other components) + +- Change the images and/or CSS in `web/static` + +- Commit, push, trigger a rolling update + + (`imagePullPolicy` should be `Always`, which is the default) diff --git a/slides/k8s/exercise-wordsmith.md b/slides/k8s/exercise-wordsmith.md new file mode 100644 index 00000000..4e6f98b7 --- /dev/null +++ b/slides/k8s/exercise-wordsmith.md @@ -0,0 +1,39 @@ +# Exercise — deploying on Kubernetes + +Let's deploy the wordsmith app on Kubernetes! + +As a reminder, we have the following components: + +| Name | Image | Port | +|-------|---------------------------------|------| +| db | jpetazzo/wordsmith-db:latest | 5432 | +| web | jpetazzo/wordsmith-web:latest | 80 | +| words | jpetazzo/wordsmith-words:latest | 8080 | + +We need `web` to be available from outside the cluster. + +See next slide if you need hints! + +--- + +## Hints + +*Scroll one slide at a time to see hints.* + +-- + +- For each component, we need to create a deployment and a service + +-- + +- Deployments can be created with `kubectl create deployment` + +-- + +- Services can be created with `kubectl expose` + +-- + +- Public services (like `web`) need to use a special type + + (e.g. `NodePort`) diff --git a/slides/k8s/exercise-yaml.md b/slides/k8s/exercise-yaml.md new file mode 100644 index 00000000..65db1e33 --- /dev/null +++ b/slides/k8s/exercise-yaml.md @@ -0,0 +1,77 @@ +# Exercise — writing YAML + +Let's write YAML manifests for the wordsmith app! + +It can be a single YAML file or multiple files in a directory. + +See next slides for testing instructions and hints. + +--- + +## How to test our YAML + +If `XYZ` is that YAML file (or directory with YAML files), we should be able to: + +1. Create a new namespace, e.g. `foo123` + +2. Deploy wordsmith with a single command + + (e.g. `kubectl apply --namespace foo123 -f XYZ`) + +3. Find out the connection information for `web` + + (e.g. `kubectl get service web --namespace`) + +4. Connect to it and see the wordsmith app + +See next slide for hints. + +--- + +## Strategies + +There are at least three methods to write our YAML. + +1. Dump the YAML of existing wordsmith deployments and services. + + (we can dump YAML with `kubectl get -o yaml ...`) + +2. Adapt existing YAML (from the docs or dockercoins). + + (for reference, kubercoins is at https://github.com/jpetazzo/kubercoins) + +3. Write it entirely from scratch. + +See next slide for more hints. + +--- + +## Adapting YAML + +*Scroll one slide at a time to see hints.* + +-- + +One option is to start with the YAML from kubercoins. + +(see https://github.com/jpetazzo/kubercoins) + +-- + +Adapt the YAML of a deployment (e.g. worker) to run "web". + +-- + +We need to change the name, labels, selectors, and image. + +-- + +Then adapt the YAML of a service (e.g. webui). + +-- + +We need to change the name, labels, selectors, possibly port number. + +-- + +Repeat for the other components. diff --git a/slides/outreach.yml b/slides/outreach.yml index e216088c..a55c50da 100644 --- a/slides/outreach.yml +++ b/slides/outreach.yml @@ -72,6 +72,7 @@ chapters: - k8s/shippingimages.md - k8s/buildshiprun-dockerhub.md - k8s/ourapponkube.md + - k8s/exercise-wordsmith.md - k8s/yamldeploy.md #- k8s/setup-k8s.md #- k8s/dashboard.md @@ -82,6 +83,7 @@ chapters: - k8s/daemonset.md #- k8s/dryrun.md - k8s/namespaces.md + - k8s/exercise-yaml.md - k8s/localkubeconfig.md - k8s/accessinternal.md #- k8s/kubectlproxy.md @@ -96,6 +98,7 @@ chapters: - k8s/helm-intro.md - k8s/helm-chart-format.md - k8s/helm-create-basic-chart.md + - k8s/exercise-helm.md - k8s/helm-create-better-chart.md - k8s/helm-secrets.md - @@ -109,6 +112,7 @@ chapters: #- k8s/build-with-docker.md #- k8s/build-with-kaniko.md - k8s/configuration.md + - k8s/exercise-configmap.md - - k8s/statefulsets.md - k8s/local-persistent-volumes.md