Git Product home page Git Product logo

kubernetes-katas's Introduction

Open in Gitpod

kubernetes-katas

A selection of katas 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.

❗ The katas expect that you have access to a kubernetes cluster. Please have a look at the Setup section if that is not the case. There are plenty of free and easy options.

Katas in suggested order:

Setup

There are several ways to get a free Kubernetes cluster for running the exercises.

Amazon, Google, Microsoft and Oracle provide various degrees of free managed clusters.

Alternatively, you can set up a local cluster with Docker Desktop or Kind.

Once you have access to a cluster, the following exercises will help you get setup for running the katas.

  • setup-kubectl-linux - Skip if you've already installed kubectl and have access to a cluster.
  • setup-namespace - 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:

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 for more info.

Cheatsheet

A collection of useful commands to use throughout the exercises:

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 for a more extended overview of the kubectl command.

kubernetes-katas's People

Contributors

addono avatar alexchiri avatar amo13 avatar amrutashety avatar atombrella avatar bechhansen avatar bicschneider avatar cgorshing avatar dwawrzkiewicz-eficode avatar efikiri avatar figaw avatar haraldreingruber-dedalus avatar hi-fi avatar jbrejner avatar jkrag avatar michaelin avatar michaelvl avatar moberghammer avatar mpobrien avatar nadeemja avatar nyvanga avatar olehau avatar raithdk avatar samuel-enderwitz-eficode avatar sofusalbertsen avatar turkmenkaan avatar zanderhavgaard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kubernetes-katas's Issues

configmap-secrets exercise have inconsitencies in service or svc

$ tree -L 2
.
├── done
│   ├── backend-deployment.yaml
│   ├── backend-svc.yaml
│   ├── frontend-deployment.yaml
│   ├── frontend-svc.yaml
│   ├── postgres-configmap.yaml
│   ├── postgres-deployment.yaml
│   ├── postgres-secret.yaml
│   └── postgres-service.yaml
└── start
    ├── backend-deployment.yaml
    ├── backend-svc.yaml
    ├── frontend-deployment.yaml
    ├── frontend-svc.yaml
    ├── postgres-deployment.yaml
    └── postgres-service.yaml

Add "cleanup" step in each of the exercises.

After running 1-4, I end up with the following deployments:

kubectl get deployment
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
customnginx        4         4         4            4           3h
envtest            1         1         1            1           1h
multitool          1         1         1            1           4h
nginx              4         4         4            4           3h
nginx-deployment   1         1         1            1           43m

I clutters the image for the student that there are things laying around which is not part of the current exercise.

exercise 04 has deprecated options for --dry-run

[ubuntu@k8s-instance13 kubernetes-katas ]$ kubectl create configmap language --from-literal=LANGUAGE=Elvish -o yaml --dry-run | kubectl replace -f -
W0827 12:12:45.975372   17506 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
configmap/language replaced
[ubuntu@k8s-instance13 kubernetes-katas ]$ kubectl create secret generic apikey --from-literal=API_KEY=andinthedarknessbindthem -o yaml --dry-run | kubectl replace -f -
W0827 12:13:23.380586   17528 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
secret/apikey replaced
[ubuntu@k8s-instance13 kubernetes-katas ]$

Frontend cache-control TTL

In some of the labs, you use the NodePort to connect to the frontend. If done through a PROXY the dynamic content is cached. The frontend should set appropriate headers to fix this.

05-storage.md have too much repetition.

I find the exercise having too much repetition with nodeport and multitool etc.
I acknowledge the benefits of having to redo some of the old exercises, but it makes the bar too steep for some people.
I would like to have a yaml file with a public LB IP attached and then having the option to either go with repetition, or jump ahead and use the public IP for simplicity.

Error during ingress controller exercises

Hi.
I have recently been going through the training exercises you've made here. During 06-traefik-ingress exercises, I ran into issues with deploying the traefik ingress controller to my kubernetes cluster.
From inspecting the logs of the pod, it provided some information regarding configuration flags:

$ kubectl logs traefik-ingress-controller-b85d96bd6-nb2mf -n kube-system
2021/10/13 14:33:48 command traefik error: failed to decode configuration from flags: field not found, node: kubernetes

From inspecting the manifest file ./ingress-traefik/traefik-deployment.yaml, I discovered that the 'traefik-ingress-controller' deployment does not refer to a specific tag of the traefik container image.
This makes it use the latest tag by default which, at the time of writing this bug report, refers to v2.5.3 of traefik.

I then modified the above mentioned manifest file, changing the deployment's specification to use traefik:v1.7 as the container image instead, after which the pod was created successfully.

I suggest that the manifest is updated to use a specific tag of the traefik container image.

apiVersion on resources, extensions/ is deprecated

"Some" of the resources in our training material uses e.g. the extensions/v1beta1 apiVersion. That's deprecated in K8s v1.16 (can be enabled with flags..) and will be removed in v1.18.

We should "probably" upgrade our resources to use the apps/.. apiVersions.

Use ingressClassName instead of annotations

In exercise frontend-ingress.md you get a warning when applying frontend-ingress.yaml:

Warning: annotation "kubernetes.io/ingress.class" is deprecated, please use 'spec.ingressClassName' instead

We should make the change in the exercise files.

health-check exercise could use an update.

Previously the latter half went like this:

(Optional) Creating your own App with a Health Check

Any (http) code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.

Let's go back to our applications, and create a custom health check.

Create an endpoint that does something customized, and returns 200. (Make sure it can fail and return an error above 500 if you want to test).

Push the container, and create a deployment for it and include:

  livenessProbe:
      httpGet:
        path: /healthz #Your endpoint for health check.
        port: 8080
        httpHeaders:
        - name: X-Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3

Verify that the healthcheck fails when conditions are not met.

This concludes the exercise for health checks!

Supposedly it was part of a bigger set of exercises? It would probably be nice to provide them with a demo application, that they could make fail in some way.

I'm removing for now because it leaves the exercise in a weird state, and the first half actually seems to be a nice little taster.

08-helm-package-manager.md - Using helm v3 but guide is using helm v2

In today training, the training machine was using the following version:

$ helm version
version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}

However, the guide is considering the previous major version, so its asking to execute:

$ helm init

It would be needed to replace it or at least add info for helm v3 with the commands below:

$ helm repo add stable https://kubernetes-charts.storage.googleapis.com
$ helm install invinvible-serval stable/mysql

Update yaml examples to recent Kubernetes API

E.g.

apiVersion: extensions/v1beta1
kind: Deployment

This is no longer correct - going back several version, deployments have been in 'apps/v1'

The same may apply to other resource types.

Split exercise 01-pods-deployments into two

The first exercise is too extensive and should be split into two parts.

  1. simple creation using the create command
  2. creating and applying a manifest

The explanation needed during trainings for crating a manifest is rather extensive, and it is better to simply get started with manual creation, and then take the manifest part afterwards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.