K8s Applications mit MicroK8S auf Raspberry PI. Alfred Sabitzer. Читать онлайн. Newlib. NEWLIB.NET

Автор: Alfred Sabitzer
Издательство: Bookwire
Серия:
Жанр произведения: Математика
Год издания: 0
isbn: 9783742770134
Скачать книгу
\",\"CMD [\\\"/hello-world\\\"]\"],\"Image\":\"sha256:c7642e609037b051e03214a85ddc50434de042a6b08c23bcac16dcb92629ee46\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":{}},\"created\":\"2021-10-03T07:40:42.472956387Z\",\"docker_version\":\"20.10.7\",\"id\":\"031921ba69921f2705920021974bfdc500b6f42530f679aa56481bdbf1543d3e\",\"os\":\"linux\",\"parent\":\"91fdfdcec09b0c57e4f28bd9c1d199796b66e5162c2e0432f8a9dc689952e13c\",\"throwaway\":true,\"variant\":\"v8\"}"

       },

       {

       "v1Compatibility": "{\"id\":\"91fdfdcec09b0c57e4f28bd9c1d199796b66e5162c2e0432f8a9dc689952e13c\",\"created\":\"2021-10-03T07:40:35.230309736Z\",\"container_config\":{\"Cmd\":[\"/bin/sh -c #(nop) COPY file:c46bbf237d2238c6f6241fa3c853f5d4861e4981bd19d09a99fa3f1ef76ed73a in / \"]}}"

       }

       ],

       "signatures": [

       {

       "header": {

       "jwk": {

       "crv": "P-256",

       "kid": "AADV:MDEU:C5BD:UTIA:ME3T:42HB:WJUA:GTV4:DHU6:KPQM:OXBY:RRAS",

       "kty": "EC",

       "x": "PEw45Fk1zyjGc6iHHYh6_Ydk3mxLC8UE1mvlo_6XY24",

       "y": "8e-Ad67SUvJMaYHjlyh05hqv7kcekIm6J-jR8It9unA"

       },

       "alg": "ES256"

       },

       "signature": "0iZv8OxENn9Oo_2eTyIQpfxFgBBsIW1z4p0AfkxP-bBxDE-1i5SN76FTwsLdTI9SRHnyY6R0_AoMSB1gWacdeA",

       "protected": "eyJmb3JtYXRMZW5ndGgiOjIxMjUsImZvcm1hdFRhaWwiOiJDbjAiLCJ0aW1lIjoiMjAyMS0xMC0wM1QwODoxNjoxM1oifQ"

       }

       ]

      alfred@monitoring:~/go$

      Somit ist das Image im Repository. Jetzt brauchen wir noch eine Service Definition.

      alfred@pc1:/opt/cluster/go$ cat hello-world.yaml

      ---

      apiVersion: apps/v1

      kind: Deployment

      metadata:

       name: hello-world

       #namespace: default

      spec:

       selector:

       matchLabels:

       app: hello-world

       replicas: 1

       template:

       metadata:

       labels:

       app: hello-world

       annotations:

       sidecar.istio.io/inject: "false"

       spec:

       containers:

       - name: hello-world

       image: docker.registry:5000/hello-world:20211003

       # resource limits

       resources:

       requests:

       memory: "24Mi"

       cpu: "500m" # half vcpu

       limits:

       memory: "64Mi"

       cpu: "1000m" # one vcpu

       env:

       # currently no env vars used for this container

       - name: FOO

       value: bar

       # check for lifetime liveness, restarts if dead

       livenessProbe:

       exec:

       command:

       - /hello-world

       initialDelaySeconds: 5

       periodSeconds: 10

       # check for initial readyness

       readinessProbe:

       exec:

       command:

       - /hello-world

       initialDelaySeconds: 3

       periodSeconds: 3

       restartPolicy: Always

       dnsPolicy: ClusterFirst

      ---

      apiVersion: v1

      kind: Service

      metadata:

       name: hello-world-service

       #namespace: default

       labels:

       app: hello-world

      spec:

       ports:

       # port=available to other containers

       - port: 1234

       name: hello

       # targetPort=exposed from inside container

       targetPort: 1234

       protocol: TCP

       selector:

       app: hello-world

      ---

      alfred@pc1:/opt/cluster/go$

      Nun installieren wir den Service.

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

      deployment.apps/hello-world created

      service/hello-world-service created

      alfred@pc1:/opt/cluster/go$

      Wir kontrollieren ob der Service richtig gestartet wird.

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

      Name: hello-world-6bb7844865-4j5bw

      Namespace: default

      Priority: 0

      Node: pc5/192.168.0.205

      Start Time: Sun, 03 Oct 2021 20:56:03 +0200

      Labels: app=hello-world

       pod-template-hash=6bb7844865

      Annotations: cni.projectcalico.org/podIP: 10.1.80.118/32

       cni.projectcalico.org/podIPs: 10.1.80.118/32

       sidecar.istio.io/inject: false

      Status: Running

      IP: 10.1.80.118

      IPs:

       IP: 10.1.80.118

      Controlled By: ReplicaSet/hello-world-6bb7844865

      Containers:

       hello-world:

       Container ID: containerd://e9d5a90c4ac98c57f9f27bdbe88b0bd5535d4e297ecbb103118a963d554615a9

       Image: docker.registry:5000/hello-world:20211003

       Image ID: docker.registry:5000/hello-world@sha256:1bb9b5564a34689396c097bb410a837d5e074b61caff822cb43921f425b09a50

       Port: <none>

       Host Port: <none>

       State: Waiting

       Reason: CrashLoopBackOff

       Last State: Terminated

       Reason: Completed