7,540
edits
Changes
→Pod-ok kezelése
go-demo-2 1/1 Running 0 50s
</pre>
==Pod-ok kezelése==
</pre>
<pre>
# kubectl exec -it -c db dbstack /bin/bash
A '''-f''' -el meg lehet adni a leíró fájlt a describe parancsban. Ez minden Kubernetes elemre működik. Ha nem adunk meg a formátumra paramétert, akkor egy szimpla felsorolást kapunk. A végén pedig egy esemény történet van az adott pod-ról.
<pre>
# kubectl describe -f pod-db.yaml
Start Time: Wed, 13 Mar 2019 20:49:30 +0100
Labels: type=db
...
..
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 21h default-scheduler Successfully assigned default/go-demo-2 to minikube
Normal Pulled 21h kubelet, minikube Container image "mongo:3.3" already present on machine
Normal Created 21h kubelet, minikube Created container
Normal Started 21h kubelet, minikube Started container
</pre>
A '''-o json''' kapcsolóval írhatjuk ki JSON -ban a pod infókat.
<pre>
# kubectl get -f pod-db.yaml -o json
"vendor": "MongoLabs"
},
...
</pre>
{| class="wikitable"|-! scope="col"| Név! scope="col"| Leírás|-|-o=custom-columns=<spec>|Print a table using a comma separated list of custom columns|-|-o=custom-columns-file=<filename>|Print a table using the custom columns template in the <filename> file|-|-o=json|Output a JSON formatted API object|-|-o=jsonpath=<template> |Print the fields defined in a jsonpath expression|-|-o=jsonpath-file=<filename>|Print the fields defined by the jsonpath expression in the <filename> file|-|-o=name|Print only the resource name and nothing else|-|-o=wide|Output in the plain-text format with any additional information, and for pods, the node name is included|-|-o=yaml|Output a YAML formatted API object|} ===Szűrés===Listázzuk ki JSON-ban a pod részleteket. <source lang="json"> "status": { ... "hostIP": "192.168.122.228",...<//source> Szűrni a '''-o jsonpath''' -al lehet. <br>Mindig úgy kell szűrni, hogy a legfelsőbb szintű elem elé teszünk egy .-ot. Majd megadjuk a path-t.
<pre>
# kubectl get -f pod-db.yaml -o jsonpath="{.status.hostIP}"
# kubectl get -f pod-db.yaml -o jsonpath="{.spec.containers[*].name}"
db api
</pre>
első pod a listáról:
<pre>
# kubectl get pods -o name | tail -1
</pre>
//Címke alapján rendeljünk node-hoz.
//címke felrakása