我是靠谱客的博主 怡然钢笔,最近开发中收集的这篇文章主要介绍Kubernetes基础:CLI与Restful API:节点信息获取环境准备kubectl 方式curl方式Restful API方式常见问题其他基础,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在这里插入图片描述
使用CLI方式可以通过kubectl对Kubernetes进行操作,同时也使用Restful API直接进行操作。这篇文章介绍一下两种方式下节点信息的获取。

环境准备

快速环境搭建建议使用单机版Kubernetes的安装脚本,一键安装,详情可参看:

  • Kubernetes单机版快速安装(Ansible脚本版)

kubectl 方式

使用kubectl可以直接使用如下命令获取node节点列表的详细信息

kubectl命令:kubectl get node -o wide

执行示例信息

[root@host132 ~]# kubectl get nodes -o wide
NAME              STATUS   ROLES    AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION          CONTAINER-RUNTIME
192.168.163.132   Ready    <none>   66m   v1.15.0   192.168.163.132   <none>        CentOS Linux 7 (Core)   3.10.0-957.el7.x86_64   docker://18.9.7
[root@host132 ~]#

curl方式

使用curl可以直接使用如下命令获取node节点列表的详细信息

curl命令示例:curl https://192.168.163.132:6443/api/v1/nodes --cacert /etc/ssl/ca/ca.pem --key /etc/ssl/k8s/kubeadmin-key.pem --cert /etc/ssl/k8s/kubeadmin.pem

执行示例详细信息

[root@host132 ~]# curl https://192.168.163.132:6443/api/v1/nodes --cacert /etc/ssl/ca/ca.pem --key /etc/ssl/k8s/kubeadmin-key.pem --cert /etc/ssl/k8s/kubeadmin.pem 
{
  "kind": "NodeList",
  "apiVersion": "v1",
  "metadata": {
    "selfLink": "/api/v1/nodes",
    "resourceVersion": "5276"
  },
  "items": [
    {
      "metadata": {
        "name": "192.168.163.132",
        "selfLink": "/api/v1/nodes/192.168.163.132",
        "uid": "eb980ea1-4ba8-4036-acf5-15215ab5a90f",
        "resourceVersion": "5272",
        "creationTimestamp": "2019-08-30T19:03:55Z",
        "labels": {
          "beta.kubernetes.io/arch": "amd64",
          "beta.kubernetes.io/os": "linux",
          "kubernetes.io/arch": "amd64",
          "kubernetes.io/hostname": "192.168.163.132",
          "kubernetes.io/os": "linux"
        },
        "annotations": {
          "node.alpha.kubernetes.io/ttl": "0",
          "volumes.kubernetes.io/controller-managed-attach-detach": "true"
        }
      },
      "spec": {
        
      },
      "status": {
        "capacity": {
          "cpu": "1",
          "ephemeral-storage": "27245572Ki",
          "hugepages-2Mi": "0",
          "memory": "4045484Ki",
          "pods": "2k"
        },
        "allocatable": {
          "cpu": "1",
          "ephemeral-storage": "25109519114",
          "hugepages-2Mi": "0",
          "memory": "3943084Ki",
          "pods": "2k"
        },
        "conditions": [
          {
            "type": "MemoryPressure",
            "status": "False",
            "lastHeartbeatTime": "2019-08-30T20:10:09Z",
            "lastTransitionTime": "2019-08-30T19:03:55Z",
            "reason": "KubeletHasSufficientMemory",
            "message": "kubelet has sufficient memory available"
          },
          {
            "type": "DiskPressure",
            "status": "False",
            "lastHeartbeatTime": "2019-08-30T20:10:09Z",
            "lastTransitionTime": "2019-08-30T19:03:55Z",
            "reason": "KubeletHasNoDiskPressure",
            "message": "kubelet has no disk pressure"
          },
          {
            "type": "PIDPressure",
            "status": "False",
            "lastHeartbeatTime": "2019-08-30T20:10:09Z",
            "lastTransitionTime": "2019-08-30T19:03:55Z",
            "reason": "KubeletHasSufficientPID",
            "message": "kubelet has sufficient PID available"
          },
          {
            "type": "Ready",
            "status": "True",
            "lastHeartbeatTime": "2019-08-30T20:10:09Z",
            "lastTransitionTime": "2019-08-30T19:04:06Z",
            "reason": "KubeletReady",
            "message": "kubelet is posting ready status"
          }
        ],
        "addresses": [
          {
            "type": "InternalIP",
            "address": "192.168.163.132"
          },
          {
            "type": "Hostname",
            "address": "192.168.163.132"
          }
        ],
        "daemonEndpoints": {
          "kubeletEndpoint": {
            "Port": 10250
          }
        },
        "nodeInfo": {
          "machineID": "58cfdd600fea402eb6daf3e09c7a44e3",
          "systemUUID": "58CFDD60-0FEA-402E-B6DA-F3E09C7A44E3",
          "bootID": "955461bf-1eb7-48ab-871e-ba7bd79b6a67",
          "kernelVersion": "3.10.0-957.el7.x86_64",
          "osImage": "CentOS Linux 7 (Core)",
          "containerRuntimeVersion": "docker://18.9.7",
          "kubeletVersion": "v1.15.0",
          "kubeProxyVersion": "v1.15.0",
          "operatingSystem": "linux",
          "architecture": "amd64"
        },
        "images": [
          {
            "names": [
              "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1"
            ],
            "sizeBytes": 121711221
          },
          {
            "names": [
              "k8s.gcr.io/coredns:1.2.6"
            ],
            "sizeBytes": 40017418
          },
          {
            "names": [
              "gcr.io/google_containers/pause-amd64:3.1"
            ],
            "sizeBytes": 742472
          }
        ]
      }
    }
  ]
}[root@host132 ~]# 

Restful API方式常见问题

  • https://liumiaocn.blog.csdn.net/article/details/100518110

其他基础

  • 再探kubernetes

最后

以上就是怡然钢笔为你收集整理的Kubernetes基础:CLI与Restful API:节点信息获取环境准备kubectl 方式curl方式Restful API方式常见问题其他基础的全部内容,希望文章能够帮你解决Kubernetes基础:CLI与Restful API:节点信息获取环境准备kubectl 方式curl方式Restful API方式常见问题其他基础所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部