| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Kubectl」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
56行目: 56行目:
 
| Podのログ確認
 
| Podのログ確認
 
| $ kubectl logs nginx-pod
 
| $ kubectl logs nginx-pod
 +
|-
 +
! scope="row"|kubectl api-resources
 +
| サポートされているAPIリソースの一覧表示
 +
|
 +
|-
 +
! scope="row"|kubectl
 +
|
 +
|
 
|-
 
|-
 
! scope="row"|kubectl  
 
! scope="row"|kubectl  
74行目: 82行目:
 
|-
 
|-
 
! scope="row"|kubectl  
 
! scope="row"|kubectl  
| api-resources
+
|  
| サポートされているAPIリソースの一覧表示
+
|
 
|-
 
|-
 
|}
 
|}

2021年1月21日 (木) 15:11時点における版

| Kubernetes | MicroK8s | Minikube | Docker |

Kubectl

チートシート

  • 公式なクライアントは、kubectl
  • kubectlを使用してクラスターと対話できるようになります
  • Kubernetes APIと連携するコマンドラインツール
  • minikube から利用する場合
  1. > minikube kubectl version

チートシート

kubectlコマンド

  • Kubernetesでは、クラスタの操作は全て、Kubernetes Masterの APIを介して行われる
  • 手動で操作する場合には、CLIツールの kubectl を利用するのが一般的
  • Kubectl が Kubernetes Master と通信するには、接続先サーバー情報や認証情報が必要となる
  • デフォルトでは、~/.kube/config に書かれている情報を使用して接続を行う
  • https://kubernetes.io/docs/reference/kubectl/overview/
コマンド 内容
kubectl version クライアントkubectlおよびAPIサーバーのバージョンを表示
kubectl get リソースの情報を表示 $ kubectl get nodes

$ kubectl get service -n kube-system

kubectl run イメージをPodで作成、実行 $ kubectl run nginx --image=nginx
kubectl describe リソースの詳細情報 $ kubectl describe nodes

$ kubectl describe service -n kube-system kubernetes-dashboard

kubectl top リソース使用量の確認 $ kubectl top node
kubectl exec Podでコマンドを実行する $ kubectl exec -it nginx-pod -- /bin/sh
kubectl logs Podのログ確認 $ kubectl logs nginx-pod
kubectl api-resources サポートされているAPIリソースの一覧表示
kubectl
kubectl
kubectl
kubectl
kubectl
kubectl
  1. kubectl controls the Kubernetes cluster manager.
  2.  
  3. Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/
  4.  
  5. Basic Commands (Beginner):
  6. create Create a resource from a file or from stdin.
  7. expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  8. run Run a particular image on the cluster
  9. set Set specific features on objects
  10.  
  11. Basic Commands (Intermediate):
  12. explain Documentation of resources
  13. get Display one or many resources
  14. edit Edit a resource on the server
  15. delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
  16.  
  17. Deploy Commands:
  18. rollout Manage the rollout of a resource
  19. scale Set a new size for a Deployment, ReplicaSet or Replication Controller
  20. autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
  21.  
  22. Cluster Management Commands:
  23. certificate Modify certificate resources.
  24. cluster-info Display cluster info
  25. top Display Resource (CPU/Memory/Storage) usage.
  26. cordon Mark node as unschedulable
  27. uncordon Mark node as schedulable
  28. drain Drain node in preparation for maintenance
  29. taint Update the taints on one or more nodes
  30.  
  31. Troubleshooting and Debugging Commands:
  32. describe Show details of a specific resource or group of resources
  33. logs Print the logs for a container in a pod
  34. attach Attach to a running container
  35. exec Execute a command in a container
  36. port-forward Forward one or more local ports to a pod
  37. proxy Run a proxy to the Kubernetes API server
  38. cp Copy files and directories to and from containers.
  39. auth Inspect authorization
  40.  
  41. Advanced Commands:
  42. diff Diff live version against would-be applied version
  43. apply Apply a configuration to a resource by filename or stdin
  44. patch Update field(s) of a resource using strategic merge patch
  45. replace Replace a resource by filename or stdin
  46. wait Experimental: Wait for a specific condition on one or many resources.
  47. convert Convert config files between different API versions
  48. kustomize Build a kustomization target from a directory or a remote url.
  49.  
  50. Settings Commands:
  51. label Update the labels on a resource
  52. annotate Update the annotations on a resource
  53. completion Output shell completion code for the specified shell (bash or zsh)
  54.  
  55. Other Commands:
  56. alpha Commands for features in alpha
  57. api-versions Print the supported API versions on the server, in the form of "group/version"
  58. config Modify kubeconfig files
  59. plugin Provides utilities for interacting with plugins.
  60. version Print the client and server version information
  61.  
  62. Usage:
  63. kubectl [flags] [options]

kubectlインストール

  1. $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  2. $ sudo chmod +x ./kubectl
  3. $ sudo install kubectl /usr/local/bin