You are browsing a read-only backup copy of Wikitech. The primary site can be found at wikitech.wikimedia.org

Kubernetes/Kubernetes Workshop: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Wolfgang Kandek
No edit summary
imported>Slavina Stefanova
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The purpose of the Kubernetes Workshop is to provide an introduction to docker, kubernetes (minikube and others) and the path to production use of kubernetes within the foundation. The idea is to be able to step through the exercises on your own a get a basic understanding of these technologies.
== Workshop  Modules ==
[[Kubernetes/Kubernetes Workshop/Set up a batch application on Kubernetes|Module 1: Set up a batch application on Kubernetes]]


== Foreword Introduction ==
[[Kubernetes/Kubernetes Workshop/Build a service application on Kubernetes|Module 2: Build a service application on Kubernetes]]
Kubernetes, often written as K8s (a [[:en:Numeronym|numeronym]], similar to I18n or l8n) is an open-source orchestration system that automates computer application deployment, supports application scaling, and provides facilities for application management.


The goal of this workshop is to provide practical experience in running sample applications on k8s. Good general Linux knowledge is required and basic knowledge with docker and its uses is helpful. If docker knowledge is missing, the appendix has links to docker tutorials that will provide the basic knowledge necessary.
[[Kubernetes/Kubernetes Workshop/Setting up Infrastructure as Code (IaC) in Kubernetes|Module 3: Setting up Infrastructure as Code (IaC) in Kubernetes]]


K8s runs on top of multiple Linux systems that together form a k8s cluster. The cluster is composed of the management systems (control plane) and nodes, dedicated systems that the Linux based applications execute on. Applications are deployed as docker images and run as containers inside pods on the nodes. Application resources are controlled through the cgroups kernel feature. K8s can run containers based on Windows on specialized k8s nodes running the Windows 2019 operating system, where they are controlled by Windows Server Containers
[[Kubernetes/Kubernetes Workshop/Autoscaling in Kubernetes|Module 4: Autoscaling in Kubernetes]]


K8s is widely used for large scale application deployments - take a look at the Kubecon videos on youtube, for example this [https://www.youtube.com/watch?t=155&v=m19D9vZ1QFQ one] by Cruise who talk about their number of clusters and nodes and this [https://www.youtube.com/watch?t=1479&v=m19D9vZ1QFQ one] which looks at the achieved benefits. K8s is not the best solution for all environments, this article gives some interesting points for [https://mbird.biz/writing/do-i-need-kubernetes.html example]
[[Kubernetes/Kubernetes Workshop/Refactoring code using Kubernetes features|Module 5: Refactoring code using Kubernetes features]]


The Wikimedia Foundation uses k8s in a number of scenarios, Wikimedia Cloud Services runs  k8s in Toolforge and SRE ServiceOps runs k8s as a platform for microservices uses.
[[Kubernetes/Kubernetes Workshop/Building a production ready cluster|Module 6: Building a production ready cluster]]


We will be using a local installation of k8s called minikube, store docker image files on dockerhub, use Github, check out hosted k8s on Google Cloud Platform and run a generic k8s cluster on WMCS. In the later part we will use the foundation’s deployment pipeline tools, including gerrit, blubber and the whole CI/CD system.
[[Kubernetes/Kubernetes Workshop/Kubernetes Package Manager|Module 7: Kubernetes Package Manager]]


== Steps ==
[[Kubernetes/Kubernetes Workshop/Manageability and Security|Module 8: Manageability and Security]]
We estimate that each step will take between 2-3 hours to read and execute.


==== Preparation ====
[[Kubernetes/Kubernetes Workshop/Kubernetes at the Wikimedia Foundation (WMF)|Module 9: Kubernetes at the Wikimedia Foundation (WMF)]]
Install docker (<nowiki>https://docs.docker.com/engine/install/ubuntu/</nowiki> for Ubuntu, others are there as well) and run the test docker image (hello-world). Then install minikube on your machine and test it (<nowiki>https://kubernetes.io/docs/tutorials/hello-minikube/</nowiki>). In addition please create an account on dockerhub - <nowiki>https://hub.docker.com/</nowiki>. We have tested mainly on Linux. If you are running on other platforms (Mac or Windows most likely) everything should work, but it might be smoother to run the workshop on a VM, either locally on your machine, at WMCS or other places that you have access to. A VM with 2 CPUs, 4 GB memory and 40 GB disk works nicely.


[[Kubernetes/Kubernetes Workshop/Step 1|Kubernetes Workshop Step 1]] - running a simple batch application on a local k8s installation
[[Kubernetes/Kubernetes Workshop/Using WMF Kubernetes to run your services|Module 10: Using WMF Kubernetes to run your services]]


[[Kubernetes/Kubernetes Workshop/Step 2|Kubernetes Workshop Step 2]] - run a service application on your local k8s
[[Kubernetes/Kubernetes Workshop/Load Testing|Add-on Module: Load Testing]]
== Overview ==
This workshop outlines how to use Kubernetes (minikube) and Docker within the Wikimedia Foundation (WMF). Kubernetes (k8s, a [https://en.wikipedia.org/wiki/Numeronym numeronym] similar to I18n or l8n), is an open-source orchestration system. In practice, Kubernetes is used to automate a computer application deployment, support application scaling, and provide facilities for application management.


[[Kubernetes/Kubernetes Workshop/Step 3|Kubernetes Workshop Step 3]] - Infrastructure as Code in K8s with YAML
The workshop grants you:
* A hands-on understanding of WMF's primary use-cases of Kubernetes.
* An understanding of how WMF employs the tool in the production environment.
* An in-depth review of how to use WMF’s Kubernetes to run your services.
* A practical experience in running sample applications on k8s.


[[Kubernetes/Kubernetes Workshop/Step 4|Kubernetes Workshop Step 4]] - More on Scale and YAML
'''Audience'''


[[Kubernetes/Kubernetes Workshop/Step 5|Kubernetes Workshop Step 5]] - Configurations
This document is aimed at:
* Developers
* Students
* Engineers who are new to Kubernetes and want a basic hands-on introduction to how to use WMF's Kubernetes to run their services.


[[Kubernetes/Kubernetes Workshop/Step 6|Kubernetes Workshop Step 6]] - a "real" cluster
'''What this is not'''


[[Kubernetes/Kubernetes Workshop/Step 7|Kubernetes Workshop Step 7]] - Packages
This workshop is not a complete tutorial on practicing with Kubernetes.


[[Kubernetes/Kubernetes Workshop/Step 8|Kubernetes Workshop Step 8]] - Manageability and Security
'''What this is'''


[[Kubernetes/Kubernetes Workshop/Step 9|Kubernetes Workshop Step 9]] - Wikimedia Foundation Style Kubernetes
This is a living document tailored to outline the specific ways WMF uses Kubernetes.


[[Kubernetes/Kubernetes Workshop/Step 10|Kubernetes Workshop Step 10]] - Running your own service under WMF Kubernetes
== Getting Started ==
Kubernetes (k8s) is an open-source container ''orchestration system''. An orchestration system automates deployment and management of applications. Here are some examples of what Kubernetes can do for you:


[[Kubernetes/Kubernetes Workshop/Load Testing|Kubernetes Workshop Add-on - Load Testing]]
* Deploy your application on any infrastructure (on-premise, hybrid, public cloud...)
* Autoscale it based on demand
* Perform zero-downtime updates and rollbacks
* Restart, replace and reschedule failing containers
* Secret and configuration management
* And much more! 
 
In order for an app to be deployable on Kubernetes, it needs to be packaged as a container. However, Kubernetes can't work with containers directly, but wraps them in an additional layer of functionality, creating a ''Pod''. A Pod is the minimal deployable unit that you can create and manage in Kubernetes. In this workshop, you will get some hands-on experience working with Kubernetes in general, as well as gain an understanding of how it is used in WMF. 
 
[[File:Kubernetes.png|thumb|center|Kubernetes]]
 
When planning for large-scale application deployments, k8s is a viable option. However, k8s is not the best solution for all environments, see the [[Kubernetes/Kubernetes Workshop|Additional Resources]] section for more information.
 
The Wikimedia Foundation uses k8s in several scenarios. The [[Help:Cloud Services introduction|Wikimedia Cloud Services]] (WMCS) team runs k8s in [[Portal:Toolforge|Toolforge]], while the [[SRE/Service_Operations/Team|SRE ServiceOps]] team runs k8s as a microservice platform.
 
 
'''Prerequisites'''
 
To navigate through this workshop, WMF recommends that you possess the following:
* A basic programming and Linux knowledge.
* Basic knowledge of containerization and Docker.
* Some familiarity with automation tools such as Ansible.
* Basic knowledge of [https://docs.github.com/en/get-started/quickstart/hello-world GitHub] and [https://en.wikipedia.org/wiki/Gerrit_(software) Gerrit].
 
'''Hardware requirements'''
 
Using a Linux machine is best for this workshop. The workshop also provides troubleshooting guides for Mac and Windows users.
 
You can use a provisioned Virtual Machine (VM) from any cloud provider or WMCS. An ideal VM should possess the following:
* 2 CPUs
* 4 GB Memory
* 40 GB disk
 
== Setting Up ==
In this workshop, you will use a local installation of k8s, minikube, Docker, and Ansible.
 
'''Installing Docker'''
 
[https://en.wikipedia.org/wiki/Docker_(software) Docker] is a containerization tool used to package applications and their dependencies into containers. This guide outlines steps on how to install Docker on your local machine.
* Linux ([https://docs.docker.com/engine/install/ubuntu Ubuntu]) Installation
* [https://docs.docker.com/desktop/mac/install/ macOS] Installation
* [https://docs.docker.com/get-started/ Windows] Installation
* Allow the current user to run Docker without root permissions by adding your user to the docker group:
<syntaxhighlight lang="bash">
$ sudo usermod -aG docker $USER && newgrp docker
</syntaxhighlight>
 
'''To test your Docker installation, run the hello-world application''':
<syntaxhighlight lang="bash">
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Status: Downloaded newer image for hello-world:latest
 
Hello from Docker!
This message shows that your installation appears to be working correctly.
</syntaxhighlight>
'''Expect a similar output as the code block above if your installation was successful'''.
 
'''Note''': Ensure the Docker daemon is running if you are using a macOS machine. Start the Docker daemon by clicking on your Docker application before running the ''hello-world'' application.
 
'''Installing Ansible'''
 
[https://docs.ansible.com/ansible/latest/index.html Ansible] is an enterprise automation platform. This guide outlines steps on how to [https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html install] Ansible on your local machine.
* Linux ([https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-ubuntu Ubuntu]) Installation
* [http://MacOs macOS] Installation
* [https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-windows Windows] Installation
 
'''[https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#confirming-your-installation Verify] your installation''':
<syntaxhighlight lang="bash">
$ ansible all -m ping --ask-pass
SSH password:
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
</syntaxhighlight>
 
At the prompt for the SSH password, press the ''Enter'' key.
 
'''Note''': macOS you can also install Ansible by running:
<syntaxhighlight lang="bash">
$ brew install ansible
</syntaxhighlight>
 
This method uses the ''[https://brew.sh/ brew]'' installer instead of ''[https://pypi.org/project/pip/ pip]''.
 
'''Installing Kubernetes'''
 
This guide outlines steps to install kubectl, a [[Kubernetes]] CLI tool used to run commands against clusters. To quickly find common kubectl commands, use [https://kubernetes.io/docs/reference/kubectl/cheatsheet/ this] cheat sheet. From the links given below, install Kubernetes on your local machine:
* [https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ Linux] Installation
* [https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/ macOS] Installation
* [https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/ Windows] Installation
 
'''Installing minikube'''
 
[https://minikube.sigs.k8s.io/docs/start/ minikube] is used to run a Kubernetes cluster locally (on personal computers). Highlighted below are ways to install this tool on various operating systems.
* [https://minikube.sigs.k8s.io/docs/start/ Linux] Installation
* [https://minikube.sigs.k8s.io/docs/start/ macOS] Installation
* [https://minikube.sigs.k8s.io/docs/start/ Windows] Installation
 
'''Note''':
 
* Ensure the Docker daemon is running.
* Enable Kubernetes on Docker Desktop: this can be done by:
** Navigating to the settings page.
** Clicking on Kubernetes.
** Ticking the box for the option ''Enable Kubernetes''
 
'''Verify your installation''':
<syntaxhighlight lang="bash">
$ minikube start
😄  minikube v1.25.2 on Darwin 12.3.1
✨  Automatically selected the docker driver
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
💾  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB  100.00% 2.20 MiB
    > gcr.io/k8s-minikube/kicbase: 379.06 MiB / 379.06 MiB  100.00% 1.28 MiB p/
🔥 ……………………………………………………..
namespace by default
 
$ kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:50198
CoreDNS is running at https://127.0.0.1:50198/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
 
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
</syntaxhighlight>
'''Getting a URL response implies that kubectl is correctly configured to access your cluster'''.
 
'''Verify your kubectl installation''':
<syntaxhighlight lang="bash">
$ kubectl get nodes
NAME      STATUS  ROLES                  AGE  VERSION
minikube  Ready    control-plane,master  64s  v1.23.3
$ kubectl run helloworld --image=hello-world
pod/helloworld created
$ kubectl logs helloworld
Hello from Docker!
This message shows that your installation appears to be working correctly.
…………………………………………………………………………
For more examples and ideas, visit:
https://docs.docker.com/get-started/
$ kubectl get pods
NAME        READY  STATUS            RESTARTS      AGE
helloworld  0/1    CrashLoopBackOff  2 (23s ago)  42s
$ minikube stop
✋  Stopping node "minikube"  ...
🛑  Powering off "minikube" via SSH ...
🛑  1 node stopped.
</syntaxhighlight>
 
== Workshop Outline ==
This workshop contains eleven modules to acquaint you with Kubernetes and its use in WMF’s production environments. The workshop introduces the following concepts:
* Executing a generic k8s cluster on Wikimedia Cloud Services ([https://en.wikipedia.org/wiki/Wikipedia:Wikimedia_Cloud_Services WMCS]).
* Using WMF's deployment pipeline tools, namely Gerrit, Blubber, and Continuous Integration/Continuous Deployment (CI/CD) systems.
The appendix contains links to Docker tutorials that provide the necessary foundational knowledge. Each module should take around two or three hours to complete.
 
The workshop presents you with a hands-on coding experience, plenty of examples, and references to unblock you when you experience blockers.
 
'''Verify the following before attempting the workshop''':
 
* Ensure you have ''[https://www.python.org/downloads/ Python]'' running on your machines. Linux OS users can install Python 3 by running the following commands:
<syntaxhighlight lang="bash">
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3
$ python3 --version
Python3.7.3
</syntaxhighlight>
Your Python version output might be different from the above output. However, the output’s format remains the same.
 
* Most virtual machines come preinstalled with [https://en.wikipedia.org/wiki/Git Git]. However, you can install Git on your VM or configure your laptop’s terminal to run git commands. To verify whether you have GitHub installed on your VM, run the following command:
<syntaxhighlight lang="bash">
$ git version
-bash: Git: command not found
</syntaxhighlight>
If you get the above output, you have to install Git; otherwise, you have Git installed on your VM. You can [https://git-scm.com/book/en/v2/Getting-Started-Installing-Git install] Git by running the following commands:
<syntaxhighlight lang="bash">
$ sudo apt update
$ sudo apt install git-all
</syntaxhighlight>
To verify your installation, run:
<syntaxhighlight lang="bash">
$ git version
git version 2.20.1
</syntaxhighlight>
 
* Lastly, install pip on your VM:
<syntaxhighlight lang="bash">
$ sudo apt update
$ sudo apt install python3-pip
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
</syntaxhighlight>
 
* Run the [https://minikube.sigs.k8s.io/docs/start/ hello-minikube] application
Mac users on Big Sur should use [https://gerrit.wikimedia.org/r/plugins/gitiles/releng/local-charts/+/HEAD/bin/mac_prereq.sh. this] for the base setup.


[[Category:Kubernetes]] [[Category: How-To]]
[[Category:Kubernetes]] [[Category: How-To]]


== Previous Work ==
== Previous Work ==
Old draft at: https://docs.google.com/document/d/1bccjDlu3v-6aHTdlMvH1Z3XiJ3lRNGe4hWTMYf3_1Ac/edit
A previous version of this workshop can be found [https://docs.google.com/document/d/1bccjDlu3v-6aHTdlMvH1Z3XiJ3lRNGe4hWTMYf3_1Ac/edit here].
 
== Additional Resources ==
[https://www.youtube.com/watch?v=m19D9vZ1QFQ&t=155s This] video by Cruise, presented at Kubecon, talks about the number of clusters and nodes. At the same time, [https://www.youtube.com/watch?v=m19D9vZ1QFQ&t=1479s this] video highlights the achieved benefits. k8s is not the best solution for all environments, and [https://web.archive.org/web/20200816141303/https://mbird.biz/writing/do-i-need-kubernetes.html this] article gives some interesting points.

Latest revision as of 08:10, 28 July 2022

Workshop Modules

Module 1: Set up a batch application on Kubernetes

Module 2: Build a service application on Kubernetes

Module 3: Setting up Infrastructure as Code (IaC) in Kubernetes

Module 4: Autoscaling in Kubernetes

Module 5: Refactoring code using Kubernetes features

Module 6: Building a production ready cluster

Module 7: Kubernetes Package Manager

Module 8: Manageability and Security

Module 9: Kubernetes at the Wikimedia Foundation (WMF)

Module 10: Using WMF Kubernetes to run your services

Add-on Module: Load Testing

Overview

This workshop outlines how to use Kubernetes (minikube) and Docker within the Wikimedia Foundation (WMF). Kubernetes (k8s, a numeronym similar to I18n or l8n), is an open-source orchestration system. In practice, Kubernetes is used to automate a computer application deployment, support application scaling, and provide facilities for application management.

The workshop grants you:

  • A hands-on understanding of WMF's primary use-cases of Kubernetes.
  • An understanding of how WMF employs the tool in the production environment.
  • An in-depth review of how to use WMF’s Kubernetes to run your services.
  • A practical experience in running sample applications on k8s.

Audience

This document is aimed at:

  • Developers
  • Students
  • Engineers who are new to Kubernetes and want a basic hands-on introduction to how to use WMF's Kubernetes to run their services.

What this is not

This workshop is not a complete tutorial on practicing with Kubernetes.

What this is

This is a living document tailored to outline the specific ways WMF uses Kubernetes.

Getting Started

Kubernetes (k8s) is an open-source container orchestration system. An orchestration system automates deployment and management of applications. Here are some examples of what Kubernetes can do for you:

  • Deploy your application on any infrastructure (on-premise, hybrid, public cloud...)
  • Autoscale it based on demand
  • Perform zero-downtime updates and rollbacks
  • Restart, replace and reschedule failing containers
  • Secret and configuration management
  • And much more!

In order for an app to be deployable on Kubernetes, it needs to be packaged as a container. However, Kubernetes can't work with containers directly, but wraps them in an additional layer of functionality, creating a Pod. A Pod is the minimal deployable unit that you can create and manage in Kubernetes. In this workshop, you will get some hands-on experience working with Kubernetes in general, as well as gain an understanding of how it is used in WMF.

Kubernetes

When planning for large-scale application deployments, k8s is a viable option. However, k8s is not the best solution for all environments, see the Additional Resources section for more information.

The Wikimedia Foundation uses k8s in several scenarios. The Wikimedia Cloud Services (WMCS) team runs k8s in Toolforge, while the SRE ServiceOps team runs k8s as a microservice platform.


Prerequisites

To navigate through this workshop, WMF recommends that you possess the following:

  • A basic programming and Linux knowledge.
  • Basic knowledge of containerization and Docker.
  • Some familiarity with automation tools such as Ansible.
  • Basic knowledge of GitHub and Gerrit.

Hardware requirements

Using a Linux machine is best for this workshop. The workshop also provides troubleshooting guides for Mac and Windows users.

You can use a provisioned Virtual Machine (VM) from any cloud provider or WMCS. An ideal VM should possess the following:

  • 2 CPUs
  • 4 GB Memory
  • 40 GB disk

Setting Up

In this workshop, you will use a local installation of k8s, minikube, Docker, and Ansible.

Installing Docker

Docker is a containerization tool used to package applications and their dependencies into containers. This guide outlines steps on how to install Docker on your local machine.

  • Linux (Ubuntu) Installation
  • macOS Installation
  • Windows Installation
  • Allow the current user to run Docker without root permissions by adding your user to the docker group:
$ sudo usermod -aG docker $USER && newgrp docker

To test your Docker installation, run the hello-world application:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Expect a similar output as the code block above if your installation was successful.

Note: Ensure the Docker daemon is running if you are using a macOS machine. Start the Docker daemon by clicking on your Docker application before running the hello-world application.

Installing Ansible

Ansible is an enterprise automation platform. This guide outlines steps on how to install Ansible on your local machine.

Verify your installation:

$ ansible all -m ping --ask-pass
SSH password:
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

At the prompt for the SSH password, press the Enter key.

Note: macOS you can also install Ansible by running:

$ brew install ansible

This method uses the brew installer instead of pip.

Installing Kubernetes

This guide outlines steps to install kubectl, a Kubernetes CLI tool used to run commands against clusters. To quickly find common kubectl commands, use this cheat sheet. From the links given below, install Kubernetes on your local machine:

Installing minikube

minikube is used to run a Kubernetes cluster locally (on personal computers). Highlighted below are ways to install this tool on various operating systems.

Note:

  • Ensure the Docker daemon is running.
  • Enable Kubernetes on Docker Desktop: this can be done by:
    • Navigating to the settings page.
    • Clicking on Kubernetes.
    • Ticking the box for the option Enable Kubernetes

Verify your installation:

$ minikube start
😄  minikube v1.25.2 on Darwin 12.3.1
✨  Automatically selected the docker driver
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
💾  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB  100.00% 2.20 MiB
    > gcr.io/k8s-minikube/kicbase: 379.06 MiB / 379.06 MiB  100.00% 1.28 MiB p/
🔥 ……………………………………………………..
namespace by default

$ kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:50198
CoreDNS is running at https://127.0.0.1:50198/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Getting a URL response implies that kubectl is correctly configured to access your cluster.

Verify your kubectl installation:

$ kubectl get nodes
NAME       STATUS   ROLES                  AGE   VERSION
minikube   Ready    control-plane,master   64s   v1.23.3 
$ kubectl run helloworld --image=hello-world
pod/helloworld created
$ kubectl logs helloworld
Hello from Docker!
This message shows that your installation appears to be working correctly.
…………………………………………………………………………
For more examples and ideas, visit:
 https://docs.docker.com/get-started/
$ kubectl get pods
NAME         READY   STATUS             RESTARTS      AGE
helloworld   0/1     CrashLoopBackOff   2 (23s ago)   42s
$ minikube stop
✋  Stopping node "minikube"  ...
🛑  Powering off "minikube" via SSH ...
🛑  1 node stopped.

Workshop Outline

This workshop contains eleven modules to acquaint you with Kubernetes and its use in WMF’s production environments. The workshop introduces the following concepts:

  • Executing a generic k8s cluster on Wikimedia Cloud Services (WMCS).
  • Using WMF's deployment pipeline tools, namely Gerrit, Blubber, and Continuous Integration/Continuous Deployment (CI/CD) systems.

The appendix contains links to Docker tutorials that provide the necessary foundational knowledge. Each module should take around two or three hours to complete.

The workshop presents you with a hands-on coding experience, plenty of examples, and references to unblock you when you experience blockers.

Verify the following before attempting the workshop:

  • Ensure you have Python running on your machines. Linux OS users can install Python 3 by running the following commands:
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3
$ python3 --version
Python3.7.3

Your Python version output might be different from the above output. However, the output’s format remains the same.

  • Most virtual machines come preinstalled with Git. However, you can install Git on your VM or configure your laptop’s terminal to run git commands. To verify whether you have GitHub installed on your VM, run the following command:
$ git version
-bash: Git: command not found

If you get the above output, you have to install Git; otherwise, you have Git installed on your VM. You can install Git by running the following commands:

$ sudo apt update
$ sudo apt install git-all

To verify your installation, run:

$ git version
git version 2.20.1
  • Lastly, install pip on your VM:
$ sudo apt update
$ sudo apt install python3-pip
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

Mac users on Big Sur should use this for the base setup.

Previous Work

A previous version of this workshop can be found here.

Additional Resources

This video by Cruise, presented at Kubecon, talks about the number of clusters and nodes. At the same time, this video highlights the achieved benefits. k8s is not the best solution for all environments, and this article gives some interesting points.