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

First steps with kubectl

Let's start by validating that kubectl has indeed been configured to use your cluster correctly and that we can connect to it:

    kubectl version

You should see some output like this:

    Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.4", GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d", GitTreeState:"clean", BuildDate:"2018-06-18T14:14:00Z", GoVersion:"go1.9.7", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Your output might show slightly different version numbers, but assuming that you see a version number from both the client and the server, you can connect to the cluster.

If you can't see the server version, or you saw some other error message, skip forward to the Troubleshooting Minikube section of this chapter.

Let's start interacting with the cluster with some of the kubectl commands that are going to be useful to us when we interact with our cluster.

The first command that we will explore is the get command. This lets us list basic information about the resources on the cluster. In this case, we are getting a list of all the node resources:

    kubectl get nodes
    NAME       STATUS    AGE       VERSION
    minikube   Ready    20h       v1.10.0

As you can see, on our Minikube installation, this is not very exciting, as we only have one node. But on larger clusters with many nodes, being able to see this information about all the nodes (or some subset) could be very useful.

The next command will allow us to drill down and look at some more detailed information about a particular resource. Try running the following command against your installation to see what you can discover about the Minikube VM:

    $ kubectl describe node/minikube

As you progress through this book, you will discover that being able to get and describe the various resources that the Kubernetes API exposes will become second nature to you whenever you want to discover what is happening on your cluster and why.

Before we move on, kubectl has one more trick to help us. Try running the following command for a description of each of the resource types available on the cluster and some examples:

    kubectl describe -h
主站蜘蛛池模板: 镇原县| 东兰县| 岳阳市| 三门县| 马边| 托克逊县| 新田县| 信阳市| 成都市| 英德市| 文化| 临朐县| 全州县| 克什克腾旗| 延吉市| 河西区| 原平市| 社会| 邛崃市| 庐江县| 南宫市| 尚义县| 泽库县| 繁峙县| 长丰县| 利津县| 广饶县| 北宁市| 涿鹿县| 西昌市| 辽源市| 光山县| 宜宾县| 兴文县| 广丰县| 马关县| 丰镇市| 静乐县| 华亭县| 崇明县| 永宁县|