官术网_书友最值得收藏!

  • DevOps with Kubernetes
  • Hideto Saito Hui Chuan Chloe Lee Cheng Yang Wu
  • 263字
  • 2021-07-02 13:41:53

kubectl

kubectl is the command-line tool to manage Kubernetes clusters. The most general usage of kubectl is to check the version of the cluster:

// check Kubernetes version
# kubectl version

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0", GitCommit:"0ed33881dc4355495f623c6f22e7dd0b7632b7c0", GitTreeState:"clean", BuildDate:"2018-10-01T00:59:42Z", GoVersion:"go1.11", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T17:53:03Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

We then know our server version is upto date, which is the latest at the time of writing—version 1.12.0. The general syntax of kubectl is as follows:

kubectl [command] [type] [name] [flags] 

command indicates the operation you want to perform. If you type kubectl help in Terminal, it'll show the supported commands. type means the resource type. We'll learn about the major resource types in the next section. name is how we name our resources. It's always good practice to have clear and informative names throughout. For the flags, if you type kubectl options, the stdout will show all of the flags you could pass on.

We can always add --help to get more detailed information on specific commands, as in the example:

// show detailed info for logs command
kubectl logs --help
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.

Aliases:
logs, log

Examples:
# Return snapshot logs from pod nginx with only one container
kubectl logs nginx

# Return snapshot logs for the pods defined by label
app=nginx
kubectl logs -lapp=nginx
...
Options
...

We can then get examples and supported options in the kubectl logs command.

主站蜘蛛池模板: 乌审旗| 长寿区| 乌兰县| 吕梁市| 沿河| 蒙山县| 镇沅| 来宾市| 和林格尔县| 阳高县| 大邑县| 宁蒗| 丰镇市| 晋江市| 桂平市| 天全县| 凤庆县| 卓资县| 台中县| 拜泉县| 册亨县| 永善县| 晋江市| 衡阳县| 沾益县| 安康市| 尉犁县| 商河县| 湖北省| 威远县| 芦山县| 海林市| 察雅县| 醴陵市| 绥芬河市| 台安县| 民丰县| 府谷县| 桑日县| 浦江县| 龙胜|