Alfred Sabitzer - K8s Applications mit MicroK8S auf Raspberry PI

Здесь есть возможность читать онлайн «Alfred Sabitzer - K8s Applications mit MicroK8S auf Raspberry PI» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на немецком языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

K8s Applications mit MicroK8S auf Raspberry PI: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «K8s Applications mit MicroK8S auf Raspberry PI»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Beispiele für das Entwickeln und Betreiben von Anwendungen auf einem MicroK8s Kubernetes Cluster auf Raspberry PI Basis. Es werden die folgenden Elemente beschrieben
Infrastrukturservices
◦ Repository
◦ NTP
◦ LDAP
◦ Secretmanagement
Monitoringservices
◦ Prometheus
◦ Grafana
◦ Alert-Agent
Storage und Backup
◦ Longhorn
◦ Externe Storage
Webservice – Stateful
◦ Joomla
◦ PostgresDB
Gitlab
◦ Build-Pipelines
◦ GitRunner
Buildautomatisierung
◦ Eigene einfache Buildpipeline
◦ kpt
◦ kustomize
Servicemesh Linkerd
Alle Services werden als yaml-File beschrieben.

K8s Applications mit MicroK8S auf Raspberry PI — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «K8s Applications mit MicroK8S auf Raspberry PI», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

#

# Eintragen des Endpoints in die Docker-Registry

#

#shopt -o -s errexit #—Terminates the shell script if a command returns an error code.

#shopt -o -s xtrace #—Displays each command before it’s executed.

shopt -o -s nounset #-No Variables without definition

FILENAME="/var/snap/microk8s/current/args/containerd-template.toml"

sudo sed --in-place '/docker.registry:5000/d' \${FILENAME}

text=' [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.registry:5000"]'

echo "\${text}" | tee -a \${FILENAME}

text=' endpoint = ["http://docker.registry:5000"]'

echo "\${text}" | tee -a \${FILENAME}

EOF

#

chmod 755 ${wd}/do_docker.sh

ansible pc -m shell -a ${id}'/do_docker.sh '

#

# Und jetzt für den Docker selbst

#

cat < ${wd}/do_pull.sh

#!/bin/bash

#

# \$Date: 2021-11-23 21:37:19 +0100 (Di, 23. Nov 2021) $

# \$Revision: 1285 $

# \$Author: alfred $

# \$HeadURL: https://monitoring.slainte.at/svn/slainte/trunk/k8s/k8s/K13_registry.sh $

# \$Id: K13_registry.sh 1285 2021-11-23 20:37:19Z alfred $

#

# Konfiguration damit das docker-pull funktioniert

#

#shopt -o -s errexit #—Terminates the shell script if a command returns an error code.

#shopt -o -s xtrace #—Displays each command before it’s executed.

shopt -o -s nounset #-No Variables without definition

sudo mkdir -p /etc/docker

sudo rm -f /etc/docker/daemon.json

tfile=\$(mktemp /tmp/daemon.XXXXXXXXX)

sudo cat < \${tfile}

{

"insecure-registries" : ["docker.registry:5000"]

}

AllOver

sudo cp -f \${tfile} /etc/docker/daemon.json

sudo chmod 666 /etc/docker/daemon.json

#

EOF

#

chmod 755 ${wd}/do_pull.sh

ansible pc -m shell -a ${id}'/do_pull.sh '

##

## Jetzt ist die Docker-Registry online und verfügbar

##

Dieses Skript konfiguriert die Registry als LoadBalancer Service. Damit bekommt die Registry eine fixe IP-Adresse, die von aussen erreichbar ist. Somit können wir den Cluster ansprechen und sind nicht an einen bestimmten Node gebunden. Durch die Verwendung einer Clusterdisk (gesteuert durch Longhorn) ist diese Registry auch ausfallsicher. Der Service sieht dann so aus:

alfred@pc1:~$ k -n container-registry get service

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

registry LoadBalancer 10.152.183.118 192.168.0.213 5000:5000/TCP 7h32m

alfred@pc1:~$

Das Skript trägt weiters die Registry in die Host-Dateien ein:

alfred@pc1:~$ cat /etc/hosts

192.168.0.201 pc1

192.168.0.202 pc2

192.168.0.203 pc3

192.168.0.204 pc4

192.168.0.205 pc5

192.168.0.2 monitoring

192.168.0.2 ntp

127.0.0.1 localhost pc1

# The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

192.168.0.2 monitoring

192.168.0.213 docker.registry

alfred@pc1:~$

Es wird auch der Eintrag für das unsafe Repository gemacht:

alfred@pc1:~$ tail /var/snap/microk8s/current/args/containerd-template.toml

[plugins."io.containerd.grpc.v1.cri".registry]

# 'plugins."io.containerd.grpc.v1.cri".registry.mirrors' are namespace to mirror mapping for all namespaces.

[plugins."io.containerd.grpc.v1.cri".registry.mirrors]

[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]

endpoint = ["https://registry-1.docker.io", ]

[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"]

endpoint = ["http://localhost:5000"]

[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.registry:5000"]

endpoint = ["http://docker.registry:5000"]

alfred@pc1:~$

Somit ist das Repository im Cluster verfügbar.

Verwalten des Sourcerepositorys

Es gibt mehrere Befehle um die Daten im Sourcerepository zu beeinflußen.

docker push ${docker_registry}/${image}:latest

Dieser Befehle fügt ein Image in das Repository ein.

curl ${docker_registry}/v2/${image}/tags/list

Mit diesem Befehl kann man die bereits vorhandene tags-Liste von aussen eingesehen werden.

Wenn man aber die Images die bereits im Kubernetes Cluster sind verwalten möchte, dann wird es ein bisschen schwieriger. Dazu habe ich folgende Skripten:

#!/bin/bash

############################################################################################

# $Date: 2021-11-25 21:57:57 +0100 (Do, 25. Nov 2021) $

# $Revision: 1348 $

# $Author: alfred $

# $HeadURL: https://monitoring.slainte.at/svn/slainte/trunk/k8s/dev/registry_list.sh $

# $Id: registry_list.sh 1348 2021-11-25 20:57:57Z alfred $

#

# Manipulieren der microk8s.registry

# https://gist.github.com/Kevinrob/4c7f1e5dbf6ce4e94d6ba2bfeff37aeb

############################################################################################

#shopt -o -s errexit #—Terminates the shell script if a command returns an error code.

#shopt -o -s xtrace #—Displays each command before it’s executed.

shopt -o -s nounset #-No Variables without definition

docker_registry="docker.registry:5000"

repositories=$(curl -s ${docker_registry}/v2/_catalog)

for repo in $(echo "${repositories}" | jq -r '.repositories[]'); do

echo $repo

tags=$(curl -s "http://${docker_registry}/v2/${repo}/tags/list" | jq -r '.tags[]')

for tag in $tags; do

echo " "$repo:$tag

done

done

#

Dieses Skript zeigt alle Images und deren Tags an, die in der Registry vorhanden sind.

#!/bin/bash

############################################################################################

# $Date: 2021-11-25 21:57:57 +0100 (Do, 25. Nov 2021) $

# $Revision: 1348 $

# $Author: alfred $

# $HeadURL: https://monitoring.slainte.at/svn/slainte/trunk/k8s/dev/registry_delete.sh $

# $Id: registry_delete.sh 1348 2021-11-25 20:57:57Z alfred $

#

# Manipulieren der microk8s.registry

# https://gist.github.com/Kevinrob/4c7f1e5dbf6ce4e94d6ba2bfeff37aeb

#

# webdefault:20211123-1301

#

############################################################################################

#shopt -o -s errexit #—Terminates the shell script if a command returns an error code.

#shopt -o -s xtrace #—Displays each command before it’s executed.

shopt -o -s nounset #-No Variables without definition

docker_registry="docker.registry:5000"

# Prüfung ob gesetzt, sonst liefert die Shell hier eine Fehlermeldung

string="${1}"

#echo "${string}"

prefix=":"

suffix=""

xrepo=${string%"$prefix"*}

#echo "${xrepo}"

xtag=${string#"$xrepo$prefix"}

#echo "${xtag}"

xtag=${xtag%"$suffix"*}

#echo "${xtag}"

tags=$(curl -sSL "http://${docker_registry}/v2/${xrepo}/tags/list" | jq -r '.tags[]')

for tag in $tags; do

if [ "${tag} " = "${xtag} " ] ;

then

echo "Lösche "$xrepo:$tag

curl -v -k -X DELETE "http://${docker_registry}/v2/${xrepo}/manifests/$(

curl -k -s -I \

-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \

"http://${docker_registry}/v2/${xrepo}/manifests/${xtag}" \

| awk '$1 == "Docker-Content-Digest:" { print $2 }' \

| tr -d $'\r' \

)"

fi

done

#

Dieses Skript löscht einen angegeben tag, wenn er gefunden wird.

Ein typischer Löschprozess sieht dann so aus:

alfred@bureau:~$ '/home/alfred/svn/trunk/k8s/dev/registry_list.sh'

chrony

chrony:latest

chrony:20211123-1273

chrony:20211123-1275

hello-world

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «K8s Applications mit MicroK8S auf Raspberry PI»

Представляем Вашему вниманию похожие книги на «K8s Applications mit MicroK8S auf Raspberry PI» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «K8s Applications mit MicroK8S auf Raspberry PI»

Обсуждение, отзывы о книге «K8s Applications mit MicroK8S auf Raspberry PI» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x