Giter Site home page Giter Site logo

kapernikov / skaffold-helm-tutorial Goto Github PK

View Code? Open in Web Editor NEW
65.0 7.0 25.0 15.91 MB

Hands on tutorial to learn docker, kubernetes, helm and skaffold. Ideal as a next step in your learning experience after getting some theory

License: Apache License 2.0

JavaScript 10.62% HTML 14.90% Vue 14.56% Python 38.16% Shell 0.37% TypeScript 21.39%
tutorial kubernetes helm skaffold

skaffold-helm-tutorial's Introduction

skaffold-helm-tutorial

This tutorial gives you hands on docker, kubernetes, helm and skaffold experience. This is done using a very simple application: vue on the frontend and fastapi python on the backend. The only functionality is to get the time!

How to work with this tutorial

You can set up a hetzner cloud environment if you don't want to work on a local machine. You can do this using the pulumi stack here.

As an alternative, you can work locally. Make sure you have a recent linux distribution with docker installed (eg ubuntu 20.04 with the docker.io package). In order to follow this tutorial in a comfortable way, adhere to:

  • At least 8GB of ram (16 will be even more comfortable, especially if you want to run a heavy IDE)
  • At least 40GB of disk space. When disk space is getting low, kubernetes taints your nodes and your pods won't run anymore!
  • Don't use a hard disk, use a SSD or kubernetes will be horribly slow. Preferably a nvme ssd, not a SATA one.

If you decided to work remotely, you probably want to use Visual studio code remote SSH extension

To get started with the tutorial, clone this repository locally:

git clone https://github.com/Kapernikov/skaffold-helm-tutorial

Then, work in this directory skaffold-helm-tutorial for all the rest of the tutorial.

Prerequisites

This tutorial assumes some knowledge beforehand. You will have trouble following if you don't have the following:

  • A basic understanding of docker. (You must have built a docker image and have written a Dockerfile already). There are lots of tutorials on docker.
  • Some knowledge on linux shell (bash) scripting. Linux shell is used everywhere to glue all kind of stuff together. Go here for a tutorial on using the linux terminal, and here for a tutorial on writing shell scripts (however, you won't need all of the advanced stuff mentioned in that tutorial, so a couple of chapters will do fine).

Software requirements

Note: If you work on a remote machine provided by Kapernikov, the software requirements are already ok, so no need to do anything here!

This tutorial assumes the use of linux. You can also use a virtual machine on windows or WSL2 (avoid WSL1, it won't work). For WSL2, you need to take into account some caveats. See specific instructions here.

This tutorial requires docker! So you need to install docker on your linux machine. On ubuntu, it's as simple as

sudo apt install docker.io

This will install the bundled version of docker, which is not totally up to date. If you want to use newer features (like buildx) you need to install docker ce according to the official instructions.

In addition to this, some frequently used tools are also needed:

sudo apt install wget curl vim zip git

The tutorial: table of contents:

skaffold-helm-tutorial's People

Contributors

janfrederik avatar kapersyx avatar kervel avatar stegololz 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

skaffold-helm-tutorial's Issues

ProcessCellCallback

I am having some trouble creating my excel file because I have a lot of nested properties.

Say I want the value of the column with identifier 'machineName' to be value.name

How do I accomplisch this with processCellCallback?

Calls to install might not be correct

```shell
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
sudo install kubectl /usr/local/bin
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
curl -Lo kubeseal.tgz https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.17.5/kubeseal-0.17.5-linux-amd64.tar.gz && \
tar -f kubeseal.tgz -x kubeseal && sudo install kubeseal /usr/local/bin && rm -f kubeseal.tgz kubeseal
curl -Lo k9s.tgz https://github.com/derailed/k9s/releases/download/v0.26.7/k9s_Linux_x86_64.tar.gz && \
tar -xf k9s.tgz && sudo install k9s /usr/local/bin/
curl -Lo kubectx https://github.com/ahmetb/kubectx/releases/download/v0.9.3/kubectx && \
sudo install kubectx /usr/local/bin/
cat << END | sudo tee -a /etc/sysctl.conf
fs.inotify.max_user_watches=1048576
fs.inotify.max_user_instances=1000000
END
sudo sysctl --system
```

The calls to install command need to explicitely put the name of the copied item in the destination path:

export TMP_K8S_DIR="/home/$USER/k8s-tuto-tmp"
export INSTALL_DIR="/usr/local/bin"

mkdir -p "$TMP_K8S_DIR" && cd "$TMP_K8S_DIR"

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
sudo install kubectl "$INSTALL_DIR/kubectl"

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold "$INSTALL_DIR/skaffold"

curl -Lo kubeseal.tgz https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.17.5/kubeseal-0.17.5-linux-amd64.tar.gz && \
tar -f kubeseal.tgz -x kubeseal && \
sudo install kubeseal "$INSTALL_DIR/kubeseal"

curl -Lo k9s.tgz https://github.com/derailed/k9s/releases/download/v0.26.7/k9s_Linux_x86_64.tar.gz && \
tar -xf k9s.tgz  && \
sudo install k9s "$INSTALL_DIR/k9s"

curl -Lo kubectx https://github.com/ahmetb/kubectx/releases/download/v0.9.3/kubectx && \
sudo install kubectx "$INSTALL_DIR/kubectx"

cat << END | sudo tee -a /etc/sysctl.conf
fs.inotify.max_user_watches=1048576
fs.inotify.max_user_instances=1000000

END

sudo sysctl --system

rm -rf "$TMP_K8S_DIR"

In the proposed fix we also propose to put every downloaded artifact into a temp directory, easily removing them at the end and not poluting the home directory.

Fix kube config permission warnings

### Configuring: kube config
Once K3s has finished startup, a file `/etc/rancher/k3s/k3s.yaml` will be created with configuration and credentials for connecting to the kubernetes cluster. This configuration is needed by all our client tools (`helm`, `kubectl`, `k9s`, ...) to make a succesfull connection to kubernetes.
The client tools typically look for a client configuration in `.kube/config` in your homedir, so let's copy the file there. We need to use sudo because by default the file is only readable by root.
```shell
mkdir -p $HOME/.kube
sudo cat /etc/rancher/k3s/k3s.yaml > $HOME/.kube/config
```
Sometimes you will have multiple clusters to manage. You will then have multiple config files. You can use the `KUBECONFIG` environment variable to tell the client tools which config file they should use. Alternatively, you can merge multiple kubeconfigs in one file. [This guide](https://stackoverflow.com/questions/46184125/how-to-merge-kubectl-config-file-with-kube-config) explains how.

In this section, might be useful to mention that one should set permissions properly on $HOME/.kube/config to avoid warnings when calling helm or kubectl.

Here is the command to avoid this:

chmod o-r $HOME/.kube/config && chmod g-r $HOME/.kube/config

nodeJS container won't start in WSL K3S

for some reason, nodejs based containers die with "exec format error" on wsl2, but only when ran in k3s, not in docker. arch=amd64 and the arch looks correct both in docker, k3s and in the docker image metadata. other container images run fine.

Deploy app in other namespace than "default"

Would we better to deploy/run the app in a separate namespace, e.g. "tutorial" or "myapp".

  • Good to learn where to define the namespaces
  • Nicer isolation in case you run this tutorial in an existing k3s installation

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.