-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 78aa2e4
Showing
33 changed files
with
938 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PRESENTATION_DOMAIN=presentation.example.org | ||
DOCS_DOMAIN=docs.example.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Build docs | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- docs/** | ||
- .github/workflows/docker-docs.yml | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: docker/build-push-action@v1 | ||
with: | ||
dockerfile: docs/Dockerfile-prod | ||
path: docs | ||
username: jamct | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
repository: jamct/kubernetes-training/k8s-docs | ||
registry: docker.pkg.github.com | ||
tags: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Build presentation | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- presentation/** | ||
- .github/workflows/docker-presentation.yml | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: docker/build-push-action@v1 | ||
with: | ||
dockerfile: presentation/Dockerfile-prod | ||
path: presentation | ||
username: jamct | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
repository: jamct/kubernetes-training/k8s-presentation | ||
registry: docker.pkg.github.com | ||
tags: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Kubernetes-Einstieg für Docker-Nutzer | ||
|
||
Dieses Repository ist Teil eines Online-Workshops von c't für [Heise Events](https://heise-events.de). | ||
|
||
|
||
## Materialien im Browser anzeigen | ||
|
||
Um Präsentation und Dokumentation auf einer Entwicklungsmaschine zu starten: | ||
|
||
* installieren Sie Docker | ||
* installieren Sie Docker-Compose | ||
* fahren Sie die Zusammenstellung hoch: `docker-compose up -f docker-compose-dev.yml -d` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.8" | ||
services: | ||
docs: | ||
build: | ||
context: ./docs | ||
dockerfile: Dockerfile-dev | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- ./docs/mkdocs/:/mkdocs | ||
presentation: | ||
build: | ||
context: ./presentation | ||
dockerfile: Dockerfile-dev | ||
ports: | ||
- 8081:8000 | ||
volumes: | ||
- ./presentation/index.html:/var/run/reveal.js/index.html | ||
- ./presentation/slides:/var/run/reveal.js/slides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: "3.7" | ||
services: | ||
traefik: | ||
image: traefik:v2.2 | ||
command: --providers.docker | ||
restart: always | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:rw | ||
- ./traefik/static.yml:/etc/traefik/traefik.yml | ||
- ./traefik/dynamic.yml:/etc/traefik/dynamic/dynamic.yml | ||
- ./traefik/acme.json:/etc/traefik/acme/acme.json | ||
|
||
docs: | ||
image: docker.pkg.github.com/jamct/docker-training/docs:latest | ||
restart: always | ||
labels: | ||
- traefik.http.routers.docs.rule=Host(`${DOCS_DOMAIN}`) | ||
- "traefik.http.routers.docs.tls.certResolver=default" | ||
- "traefik.http.routers.docs.tls=true" | ||
- "com.centurylinklabs.watchtower.enable=true" | ||
|
||
presentation: | ||
image: docker.pkg.github.com/jamct/docker-training/presentation:latest | ||
restart: always | ||
labels: | ||
- traefik.http.routers.presentation.rule=Host(`${PRESENTATION_DOMAIN}`) | ||
- "traefik.http.routers.presentation.tls.certResolver=default" | ||
- "traefik.http.routers.presentation.tls=true" | ||
- "com.centurylinklabs.watchtower.enable=true" | ||
|
||
watchtower: | ||
image: containrrr/watchtower | ||
command: --cleanup --label-enable | ||
restart: always | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ~/.docker/config.json:/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3-alpine | ||
RUN apk add build-base | ||
COPY ./mkdocs/ /mkdocs/ | ||
WORKDIR /mkdocs/ | ||
RUN pip install --upgrade pip && pip install mkdocs mkdocs-bootswatch https://github.com/bmcorser/fontawesome-markdown/archive/master.zip | ||
EXPOSE 8080 | ||
CMD ["mkdocs", "serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3-alpine | ||
RUN apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev | ||
COPY ./mkdocs/ /mkdocs/ | ||
WORKDIR /mkdocs/ | ||
RUN pip install --upgrade pip && pip install mkdocs mkdocs-bootswatch https://github.com/bmcorser/fontawesome-markdown/archive/master.zip mkdocs-pdf-export-plugin mkdocs-material | ||
EXPOSE 8080 | ||
CMD ["mkdocs", "serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#build stage | ||
FROM python:3-alpine AS build | ||
RUN apk add build-base | ||
COPY ./mkdocs/ /mkdocs/ | ||
WORKDIR /mkdocs/ | ||
RUN pip install --upgrade pip && pip install mkdocs mkdocs-bootswatch https://github.com/bmcorser/fontawesome-markdown/archive/master.zip | ||
RUN mkdocs build | ||
|
||
#web server stage | ||
FROM nginx:alpine | ||
COPY --from=0 /mkdocs/site/ /usr/share/nginx/html | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Über diese Anleitung | ||
|
||
Diese Dokumente sind Teil des Online-Workshops "Docker und Container in der Praxis" von c't-Redakteur Jan Mahn für Heise Events. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@page { | ||
size: a4 portrait; | ||
margin: 25mm 10mm 25mm 10mm; | ||
counter-increment: page; | ||
font-family: Helvetica,Arial,sans-serif; | ||
white-space: pre; | ||
color: grey; | ||
} | ||
|
||
@media print{ | ||
|
||
img{ | ||
width: 90%; | ||
} | ||
|
||
.noprint{ | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Kubernetes-Einstieg für Docker-Nutzer | ||
|
||
 | ||
|
||
Herzlich Willkommen zum Workshop "Kubernetes-Einstieg für Docker-Nutzer" | ||
|
||
|
||
## Geplanter Zeitplan | ||
|
||
### Tag 1 | ||
|
||
|Zeit| | | ||
|---|---| | ||
|9:00|Begrüßung, Einführung in die Technik| | ||
| |Impuls: Was Kubernetes anders macht| | ||
| |Ihre Erfahrungen mit Docker, Ihre Erwartungen an K8S| | ||
| |[Praxis: Docker installieren](setup/index.md)| | ||
| |[Lab 1: Erste Schritte](lab1/index.md)| | ||
| |[Lab 2: Arbeiten mit Images](lab2/index.md)| | ||
| |Impuls: Images im Docker-Hub finden| | ||
|12:00|Fragen zu Tag 1| | ||
|12:30|Ende Tag 1| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# :fa-flask: Lab 1: Das erste Cluster | ||
|
||
In diesem Lab entsteht ein kleines Cluster, das auf zwei Maschinen läuft. | ||
|
||
|
||
|
||
Ein Cluster besteht aus einem oder mehreren `nodes`. Zwei Rollen gibt es in einem Cluster: | ||
|
||
* `master` verwalten das System und stellen u.a. das API bereit | ||
* `worker` betreiben die Arbeitslasten, also die Container | ||
|
||
Ein `node` kann beide Rollen ausfüllen. In großen Systemen sollte man die Rollen trennen. Im Hintergrund sprechen die Master mit einer Datenbank, zum Beispiel der Key-Value-Datenbank etcd, die redundant auf allen Mastern laufen kann (oder auch auf Maschinen außerhalb). | ||
|
||
Die Mindestanzahl an Nodes hängt von der Kubernetes-Distribution und der verwendeten Datenbank ab. Für den Workshop kommt die kleine Distro K3S zum Einsatz, die von Rancher erfunden wurde. Rancher wiederum gehört neuerdings zu SuSe. | ||
|
||
K3S läuft zur Not auch auf einer Maschine und ist eine ideale Lösung für alle, die in das Thema einsteigen möchten. Beschaffen Sie sich 1 bis 3 Linux-Maschinen bei einem Hoster des Vertrauens und stecken Sie diese in ein internes Netzwerk. Wenn Sie eine kostengünstigere Lösung suchen: K3S läuft auch auf ARM-Prozessoren. Drei Raspis sind ein brauchbares Übungs-Cluster! | ||
|
||
Für den Workshop haben Sie zwei x64-Maschinen erhalten. Loggen Sie sich am besten mit zwei Fenstern nebeneinander ein. | ||
|
||
## Netzwerk vorbereiten | ||
|
||
Finden Sie nacheinander die IP-Adresse im internen Netz heraus: | ||
|
||
``` | ||
hostname -I | ||
``` | ||
|
||
Die Ausgabe sieht etwa so aus: | ||
|
||
``` | ||
159.69.0.189 10.20.0.3 10.42.0.0 10.42.0.1 2a01:4f8:c2c:3d59::1 | ||
``` | ||
|
||
Die erste Adresse ist die externe Adresse, die zweite (aus dem 10er-Netz, zum Beispiel 10.20.0.3) ist die Gesuchte Adresse des lokalen Netzes Ihrer beiden Maschinen. Wiederholen Sie den Schritt für die zweite Maschine. | ||
|
||
|
||
## K3S beschaffen | ||
|
||
Die Installation von K3S haben die Entwickler in ein Installations-Skript verpackt. Per Umgebungsvariable übergeben Sie Einstellungen. Auf der ersten Maschine (zum Beispiel demo-00-1) soll das Cluster initialisiert werden. | ||
|
||
Vor der Installation müssen Sie sich ein Token ausdenken, das alle Kubernetes-Nodes kennen müssen. Ändern Sie das Token in der folgenden Zeile ab und führen Sie den Einzeiler auf der ersten Maschine aus: | ||
|
||
``` | ||
curl -sfL https://get.k3s.io | K3S_TOKEN=verySecretToken INSTALL_K3S_EXEC="--disable traefik --write-kubeconfig-mode 644 --cluster-init" sh - | ||
``` | ||
|
||
Im Hintergrund wird K3S heruntergeladen. Nach etwa 3 Minuten dürfte der Assistent fertig sein. Drei Anmerkungen zu den Parametern: | ||
|
||
* `--disable-traefik` deaktivert den HTTP-Router Træfik. Diesen installieren Sie später im Cluster und lernen an diesem Beispiel viele Grundfunktionen kennen. | ||
* `write-kubeconfig-mode 644` erlaubt Ihnen das lokale Arbeiten mit der Kommandozeile `kubectl`. | ||
* `--cluster-init` legt das Cluster an. | ||
|
||
Auf der zweiten Maschine müssen Sie ebenfalls K3S herunterladen und zwei Werte übergeben: | ||
|
||
* das Token von Server 1 | ||
* die IP-Adresse von Server 1 | ||
|
||
Ändern Sie diese beiden Angaben in der folgenden Zeile: | ||
|
||
``` | ||
curl -sfL https://get.k3s.io | K3S_TOKEN=verySecretToken INSTALL_K3S_EXEC="--server https://10.20.0.3:6443" sh - | ||
``` | ||
|
||
Nach weiteren drei Minuten ist Ihr Cluster einsatzbereit. | ||
|
||
## Zustand prüfen | ||
|
||
Mit dem Kommandozeilenprogramm `kubectl` prüfen Sie, ob die Nodes zusammenarbeiten: | ||
|
||
``` | ||
kubectl get nodes | ||
``` | ||
|
||
Auf beiden Maschinen sollten Sie eine Ausgabe wie die Folgende sehen: | ||
|
||
``` | ||
NAME STATUS ROLES AGE VERSION | ||
demo-0-1 Ready master 4m14s v1.18.8+k3s1 | ||
demo-0-2 Ready master 18s v1.18.8+k3s1 | ||
``` | ||
|
||
Im [zweiten Lab](../lab2) lernen Sie Ihren neuen Freund `kubectl` näher kennen. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.