一部の読者にとっては日常生活であることが判明するチームもありますが、自分で新しいことを発見し、それによって効果を高める人がいれば、記事の目的は達成されます。
注意:以下にリストされているチームのいくつかは私たちのエンジニアによって編集されましたが、他のチームはインターネット上で見つかりました。後者の場合、それらはテストされ、有用であることがわかりました。
じゃ、行こう!
pod'
- , pod'
--all-namespaces. , —-A( , Kubernetes 1.15). - pod', (..
Running)?
kubectl get pods -A --field-selector=status.phase!=Running | grep -v Complete
,--field-selector(. ). - :
kubectl get no -o json | \ jq -r '.items | sort_by(.status.capacity.memory)[]|[.metadata.name,.status.capacity.memory]| @tsv'

- pod' :
kubectl get po -o json --all-namespaces | \ jq '.items | group_by(.spec.nodeName) | map({"nodeName": .[0].spec.nodeName, "count": length}) | sort_by(.count)'

- , - DaemonSet - . — , - , DaemonSet':
ns=my-namespace pod_template=my-pod kubectl get node | grep -v \"$(kubectl -n ${ns} get pod --all-namespaces -o wide | fgrep ${pod_template} | awk '{print $8}' | xargs -n 1 echo -n "\|" | sed 's/[[:space:]]*//g')\" -
kubectl toppod', :
# cpu kubectl top pods -A | sort --reverse --key 3 --numeric # memory kubectl top pods -A | sort --reverse --key 4 --numeric - pod' — , :
kubectl get pods --sort-by=.status.containerStatuses[0].restartCount
, (. PodStatus ContainerStatus).
- Ingress', pod' . ,
-o wide:
kubectl -n jaeger get svc -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR jaeger-cassandra ClusterIP None <none> 9042/TCP 77d app=cassandracluster,cassandracluster=jaeger-cassandra,cluster=jaeger-cassandra
, , pod'. - pod' limits requests:
kubectl get pods -n my-namespace -o=custom-columns='NAME:spec.containers[*].name,MEMREQ:spec.containers[*].resources.requests.memory,MEMLIM:spec.containers[*].resources.limits.memory,CPUREQ:spec.containers[*].resources.requests.cpu,CPULIM:spec.containers[*].resources.limits.cpu'

-
kubectl run(create,apply,patch) —--dry-run.-o yaml, . :
kubectl run test --image=grafana/grafana --dry-run -o yaml apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: run: test name: test spec: replicas: 1 selector: matchLabels: run: test strategy: {} template: metadata: creationTimestamp: null labels: run: test spec: containers: - image: grafana/grafana name: test resources: {} status: {}
, / . - - :
kubectl explain hpa KIND: HorizontalPodAutoscaler VERSION: autoscaling/v1 DESCRIPTION: configuration of a horizontal pod autoscaler. FIELDS: apiVersion <string> APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources kind <string> Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds metadata <Object> Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata spec <Object> behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status. status <Object> current information about the autoscaler.
!
- IP- :
kubectl get nodes -o json | \ jq -r '.items[].status.addresses[]? | select (.type == "InternalIP") | .address' | \ paste -sd "\n" -

- nodePort, :
kubectl get --all-namespaces svc -o json | \ jq -r '.items[] | [.metadata.name,([.spec.ports[].nodePort | tostring ] | join("|"))]| @tsv'

- , CNI (, Flannel), pod' . pod', :
kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}' | tr " " "\n"

- pod' c timestamp :
kubectl -n my-namespace logs -f my-pod --timestamps 2020-07-08T14:01:59.581788788Z fail: Microsoft.EntityFrameworkCore.Query[10100]
, ? - , pod' —
--tail:
kubectl -n my-namespace logs -f my-pod --tail=50 - pod':
kubectl -n my-namespace logs -f my-pod --all-containers - pod' label':
kubectl -n my-namespace logs -f -l app=nginx - , , , :
kubectl -n my-namespace logs my-pod --previous
- ?
kubectl get secrets -o json --namespace namespace-old | \ jq '.items[].metadata.namespace = "namespace-new"' | \ kubectl create-f - - :
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=grafana.mysite.ru/O=MyOrganization" kubectl -n myapp create secret tls selfsecret --key tls.key --cert tls.crt
結論の代わりに-インターネット上で見つかった同様の資料とコレクションの小さなリスト:
- Kubernetesドキュメントの公式チートシート。
- 意欲的なエンジニアの時間を短縮するのに役立つ、LinuxAcademyの簡単な実践的な紹介と2ページの素敵なタブレット:

- セクションに分割された、BlueMatadorからのコマンドの非常に広範なリスト。
- コマンド、トピックに関する記事、およびいくつかのコマンドを含むテーブルへの要点のリンクの選択。
- 別の愛好家のKubernetes-Cheat-SheetGitHubリポジトリには、カテゴリ別に分類されたコマンドのみが含まれています。
- kubectl-aliases GitHubリポジトリは、略語の楽園です。
PS
私たちのブログも読んでください:
- « Kubernetes kubectl»;
- « Kubernetes kubectl»;
- « Kubernetes».