Alfred Sabitzer

K8s Applications mit MicroK8S auf Raspberry PI


Скачать книгу

Exit Code: 0

       Started: Sun, 03 Oct 2021 20:56:08 +0200

       Finished: Sun, 03 Oct 2021 20:56:08 +0200

       Ready: False

       Restart Count: 1

       Limits:

       cpu: 1

       memory: 64Mi

       Requests:

       cpu: 500m

       memory: 24Mi

       Liveness: exec [/hello-world] delay=5s timeout=1s period=10s #success=1 #failure=3

       Readiness: exec [/hello-world] delay=3s timeout=1s period=3s #success=1 #failure=3

       Environment:

       FOO: bar

       Mounts:

       /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-vtwl2 (ro)

      Conditions:

       Type Status

       Initialized True

       Ready False

       ContainersReady False

       PodScheduled True

      Volumes:

       kube-api-access-vtwl2:

       Type: Projected (a volume that contains injected data from multiple sources)

       TokenExpirationSeconds: 3607

       ConfigMapName: kube-root-ca.crt

       ConfigMapOptional: <nil>

       DownwardAPI: true

      QoS Class: Burstable

      Node-Selectors: <none>

      Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s

       node.kubernetes.io/unreachable:NoExecute op=Exists for 300s

      Events:

       Type Reason Age From Message

       ---- ------ ---- ---- -------

       Normal Scheduled 23s default-scheduler Successfully assigned default/hello-world-6bb7844865-4j5bw to pc5

       Warning BackOff 14s (x4 over 19s) kubelet Back-off restarting failed container

       Normal Pulled 1s (x3 over 22s) kubelet Container image "docker.registry:5000/hello-world:20211003" already present on machine

       Normal Created 1s (x3 over 22s) kubelet Created container hello-world

       Normal Started 1s (x3 over 21s) kubelet Started container hello-world

      alfred@pc1:/opt/cluster/go$

      alfred@pc1:/opt/cluster/go$ kubectl get pod hello-world-6bb7844865-4j5bw

      NAME READY STATUS RESTARTS AGE

      hello-world-6bb7844865-4j5bw 0/1 CrashLoopBackOff 4 108s

      alfred@pc1:/opt/cluster/go$

      alfred@pc1:/opt/cluster/go$ kubectl logs hello-world-6bb7844865-4j5bw

      hello world

      alfred@pc1:/opt/cluster/go$

      Das heist, der Service wird ordnungsgemäß installiert, läuft auch einmal und terminiert dann (so ist das Programm). Aus Kubernetes Sicht wird aber über das Deployment versucht den Service wieder herzustellen. Daher wird er permanent restarted. Für das Hello-World Prinzip reicht das. Für einen richtigen Service aber natürlich nicht.

      Darum löschen wir den Service auch wieder.

      alfred@pc1:/opt/cluster/go$ kubectl delete -f hello-world.yaml

      deployment.apps "hello-world" deleted

      service "hello-world-service" deleted

      alfred@pc1:/opt/cluster/go$

      Aber wir haben nun ein funktionierendes Setup. Können auf der Entwicklungsmaschine docker-Container erzeugen, diese in das Repository am Kubernetes Cluster einspielen, und den Service dann auch starten.

      Golang IDE

      Inspiration:

       https://golang.org/doc/articles/wiki/

       https://github.com/visualfc/liteide

      https://linuxize.com/post/how-to-install-atom-text-editor-on-ubuntu-20-04/

       https://www.gophercoders.com/install/atom/configure/

       https://snapcraft.io/install/liteide-tpaw/ubuntu

      https://elearning.wsldp.com/pcmagazine/install-liteide-on-ubuntu/

      Um vernünftig Go Programme entwicklen zu können, braucht man eine vernünftige IDE. Neben IntelliJ (leider nicht in der Community-Edition) gibt es noch LiteIDE sowie den beliebten Editor Atom (wahrscheinlich gibt es noch viele andere). Ich verwenden den Atom-Editor.

      OEBPS/images/image0012.jpg Abbildung 10: Atom Editor

      Nachdem das Plugin eingerichtet ist, kann man das Projekt bereits editieren.

      Damit alles funktioniert muß natürlich go selbst vorhanden sein.

      OEBPS/images/image0013.jpg Abbildung 11: Atom Konfiguriert

      Man kann aber auch LiteIDE benutzen.

      OEBPS/images/image0014.jpg Abbildung 12: LiteIDE

      Womit man am liebsten arbeitet, muß jeder für sich selbst entscheiden.

      Was auch immer man installiert, meine Rat ist die Applikation nicht über snap zu installieren (wegen des Isolation-Levels), sondern direkt. Die Interaktion zwischen den Snaps (setzen von Variablen usw.) funktioniert sonst unter Umständen nicht wie erwartet.

      Am Beispiel von LiteIDE. Siehe auch https://elearning.wsldp.com/pcmagazine/install-liteide-on-ubuntu/

      Download der richtigen Datei, entpacken nach /usr/local. Danach wird für den bequement Start eine desktop Datei erzeugt.

      [Desktop Entry]

      Version=1.0

      Name=LiteIDE

      Comment="IDE for editing and building projects written in the Go programming language"

      GenericName=GoIDE

      Exec=/usr/local/liteide/bin/liteide

      Terminal=false

      Type=Application

      Icon=/usr/local/liteide/share/liteide/welcome/images/liteide128.xpm

      Categories=Development;

      StartupNotify=true

      Diese Datei wird dann mit dem Statement

      alfred@bureau:~$ cd Schreibtisch/

      alfred@bureau:~/Schreibtisch$ ll

      insgesamt 480

      drwx-----T 2 alfred alfred 4096 Okt 10 09:23 ./