Git Product home page Git Product logo

kubernetes-workshop's Introduction

Kubernetes workshop

In this workshop, your task is to set up a local Kubernetes cluster, and then configure the resources needed to expose a web service.

Prerequisites

An UNIX-environment/shell with Docker available (Git Bash seems to work)

Kubectl and Kind

Kubectl is the CLI used to communicate with Kubernetes API servers. Kind provides a simple way of running Kubernetes on your local machine. Follow the instructions here: https://kubernetes.io/docs/tasks/tools/

Configure your cluster with an Ingress controller

The Kind cluster needs to be set up in a particular way for this:

cat <<EOF | kind create cluster -n workshop --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 8000
    protocol: TCP
  - containerPort: 443
    hostPort: 8443
    protocol: TCP
EOF

Then set Kubectl to use this cluster:

kubectl config use-context kind-workshop

Now, install the NGINX Ingress Controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

Use the following command to wait for this to be ready:

kubectl wait --namespace ingress-nginx \
  --for=condition=ready pod \
  --selector=app.kubernetes.io/component=controller \
  --timeout=90s

K9s (nice to have)

A TUI (terminal user interface) for managing your Kubernetes clusters. Found here: https://k9scli.io/topics/install/

OpenLens is a GUI alternative: https://github.com/MuhammedKalkan/OpenLens#installation

The Task

As mentioned above, your goal is to deploy a web service. The image can be found here:

ghcr.io/blixhavn/return-version:1.0.0

Use this to apply resources to the cluster:

kubectl apply -f <filename.yaml>

Verify that everything is configured correctly by visiting localhost:8000 in your browser and see that you get a response.

Scale

Horizontally scale your deployment, then use the ./loadtest.sh localhost:8000 script to inspect how requests are routed to different replicas.

Rollout new version

While running the loadtest in a terminal, change the deployment to use version 2.0.0 of the image and apply it. If you have enough replicas you might see that version 1 and version 2 are living side by side for a little period.

kubernetes-workshop's People

Contributors

blixhavn avatar

Watchers

 avatar

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.