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

Command line

The kubectl script has commands for exploring our cluster and the workloads running on it. You can find it in the /kubernetes/client/bin folder. We will be using this command throughout the book, so let's take a second to set up our environment. We can do so by putting the binaries folder on our PATH, in the following manner:

$ export PATH=$PATH:/<Path where you downloaded K8s>/kubernetes/client/bin
$ chmod +x /<Path where you downloaded K8s>/kubernetes/client/bin
You may choose to download the kubernetes folder outside your home folder, so modify the preceding command as appropriate. It is also a good idea to make the changes permanent by adding the export command to the end of your .bashrc file in your home directory.

Now that we have kubectl on our path, we can start working with it. It has quite a few commands. Since we have not spun up any applications yet, most of these commands will not be very interesting. However, we can explore two commands right away.

First, we have already seen the cluster-info command during initialization, but we can run it again at any time with the following command:

$ kubectl cluster-info

Another useful command is get. It can be used to see currently running services, pods, replication controllers, and a lot more. Here are the three examples that are useful right out of the gate:

  • Lists the nodes in our cluster:
    $ kubectl get nodes
  • Lists cluster events:
    $ kubectl get events
  • Finally, we can see any services that are running in the cluster, as follows:
    $ kubectl get services

To start with, we will only see one service, named kubernetes. This service is the core API server for the cluster.

For any of the preceding commands, you can always add a -h flag on the end to understand the intended usage.

主站蜘蛛池模板: 永川市| 伊金霍洛旗| 额济纳旗| 泸定县| 阜平县| 铅山县| 冷水江市| 仁布县| 昌平区| 措勤县| 轮台县| 个旧市| 宾阳县| 岳池县| 湛江市| 龙川县| 龙川县| 富顺县| 松溪县| 大宁县| 滦南县| 伊通| 辽宁省| 定兴县| 辽宁省| 嘉荫县| 吉林省| 图木舒克市| 文化| 稻城县| 呼伦贝尔市| 垫江县| 沭阳县| 迁西县| 江油市| 大兴区| 长垣县| 什邡市| 平泉县| 大悟县| 丹凤县|