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

  • Kubernetes on AWS
  • Ed Robinson
  • 347字
  • 2021-06-10 18:41:26

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
主站蜘蛛池模板: 兴隆县| 新丰县| 涞水县| 凉山| 上高县| 剑河县| 广河县| 乐安县| 章丘市| 郸城县| 长汀县| 南部县| 江北区| 南部县| 许昌市| 厦门市| 衢州市| 丹阳市| 闻喜县| 临江市| 资溪县| 葫芦岛市| 黎城县| 高邑县| 五家渠市| 南康市| 寿阳县| 中山市| 张家口市| 富宁县| 明溪县| 甘洛县| 新巴尔虎左旗| 滦平县| 齐河县| 沧源| 微山县| 永平县| 禄劝| 郧西县| 进贤县|