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

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
主站蜘蛛池模板: 都匀市| 龙陵县| 沁源县| 满城县| 玛曲县| 延津县| 南投县| 乳山市| 新源县| 会昌县| 通山县| 天镇县| 白山市| 涡阳县| 晋江市| 涟源市| 清水县| 阿鲁科尔沁旗| 雷山县| 成都市| 德钦县| 长武县| 阿坝| 环江| 中超| 永泰县| 兰西县| 盐山县| 石林| 乐昌市| 多伦县| 开远市| 漳州市| 白水县| 阿城市| 高雄县| 九江县| 图片| 贵溪市| 巴青县| 五华县|