1、Kubernetes API使用
1.1 API是什么?
API(Application Programming Interface,应用程序接口): 是一些预先定义的接口(如函数、HTTP接口),或指软件系统不同组成部分衔接的约定。 用来提供应用程序与开发人员基于某软件或硬件得以访问的一组例程,而又无需访问源码,或理解内部工作机制的细节。
K8s也提供API接口,提供这个接口的是管理节点的apiserver组件,apiserver服务负责提供HTTP API,以便用户、其他组件相互通信。
有两种方式可以操作K8s中的资源:
- HTTP API:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/
- 客户端库: https://kubernetes.io/zh/docs/reference/using-api/client-libraries/
1.2 K8s认证方式
K8s支持三种客户端身份认证:
- HTTPS 证书认证:基于CA证书签名的数字证书认证(kubeconfig文件)
实际上官方使用kubeconfig 文件,也是用的里面的token,这个方式不建议,因为带了根证书。自己开发跳过这块逻辑,所以可以用这个文件登录了。
- HTTP Token认证:通过一个Token来识别用户(ServiceAccount)
- HTTP Base认证:用户名+密码的方式认证(1.19+已经弃用)
安装Kubernetes客户端库:
pip install kubernetes -i https://pypi.tuna.tsinghua.edu.cn/simple
HTTPS证书认证(kubeconfig):
# 默认使用: cat ./kube/config
from kubernetes import client, config
import os
kubeconfig = os.path.join(os.getcwd(),"kubeconfig") # 获取当前目录并拼接文件
config.load_kube_config(kubeconfig) # 指定kubeconfig配置文件(/root/.kube/config)
apps_api = client.AppsV1Api() # 资源接口类实例化
#通过 kubectl api-resources | grep deploy 判断是哪个资源接口
for dp in apps_api.list_deployment_for_all_namespaces().items:
print(dp) # 打印Deployment对象详细信息
证书认证太麻烦,还需要我复制文件内容,这里我选择token认证比较方便,只需要创建一次即可。
HTTP Token认证(ServiceAccount):
获取Token字符串:创建service account并绑定默认cluster-admin管理员集群角色:
# 创建用户
kubectl create serviceaccount k8s-api-admin -n kube-system
# 用户授权
kubectl create clusterrolebinding k8s-api-admin --clusterrole=cluster-admin --serviceaccount=kube-system:k8s-api-admin
# 获取用户Token
#1)先查看secret
kubectl -n kube-system get secret
#2)再查看具体token
kubectl describe secrets -n kube-system k8s-api-admin-token-rwb69
这步如果没有做就会报错
Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. endpoints "xxx" is forbidden: User "system:serviceaccount:xxx:default" cannot get resource "endpoints" in API group "" in the namespace "xxx".
Pod内部环境应用程序在访问Kubernetes的Api Server的时候的权限验证就是通过serviceaccount实现的。
当你创建namespace的时候,会默认为该namespace创建一个名为default的serviceaccount。可以通过命令查看:
kubectl get sa -n 你的namespace
正如报错所示“system:serviceaccount:xxx:default”,这个就是pod内部的用到的默认的serviceaccount,xxx代表你的namespace,default则是namespace的默认serviceaccount名字,前面system:serviceaccount代表k8s中的serviceaccount用户组。
所以这个的错误的信息代表的意思是,pod用namespace默认的serviceaccout是没有权限访问K8s的 API group的。
全部代码,基于Python3实现
from kubernetes.client import api_client
from kubernetes.client.api import core_v1_api
from kubernetes import client
class kubernetestools(object):
def __init__(self):
self.k8s_url = 'https://192.168.42.135:6443'
def get_token(self):
"""
获取token
:return:
"""
# with open(r'd:\users\jackhe\pycharmprojects\jj\k8s\auth\token', 'r') as file:
# token = file.read().strip('\n')
# return token
token = "eyJhbGciOiJSUzI1NiIsImtpZCI6Ijg4dVFMQUZkd0RqMWxlVjlpRlYtcDZwemEwSzcxbnc1RWtRekxDamR4eW8ifQ" \
".eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrOHMtYXBpLWFkbWluLXRva2VuLXJ3YjY5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Ims4cy1hcGktYWRtaW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4MDIzMjg5NS03ZDZkLTQxMjMtYjQwYi1kNjBkY2M1Y2NhMzEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06azhzLWFwaS1hZG1pbiJ9.AlCfBdzL56rcdGHEwYE7MIsgLS42iOVms16MEUXXnr7gzRFGaF280ofShcCeoIHxaf0sjdGhyPvqm6Mte9OJB_aJYdHLLGvuzQiC2fbWwgSLa7ucM7LhqCzRZQ1fkASp8FC8ii4zkoJCfEcAY12iSgYq78k5VcgTFDZHm1VuG0wSwi7ffj3pIO9LDXwGcs3zmTM3S5V8e4_5rLQJaZ02vv9CMS14smUeNvGd7-SOM0ux_QuS1tM13bn_2gigbQdJEcKGexSzavsy4_bT8ztkyh3Cbxi8w4kViYW1YWV_Bgn7SkC6AjHMbISkQbcB5F4yR7rJvtZxkz5LdBz2ND087g "
return token
def get_api(self):
"""
获取api的corev1api版本对象
:return:
"""
configuration = client.Configuration()
configuration.host = self.k8s_url
configuration.verify_ssl = False
configuration.api_key = {"authorization": "Bearer " + self.get_token()}
client1 = api_client.ApiClient(configuration=configuration)
api = core_v1_api.CoreV1Api(client1)
return api
def get_namespace_list(self):
"""
获取命名空间列表
:return:
"""
api = self.get_api()
print(api.list_node())
namespace_list = []
for ns in api.list_namespace().items:
# print(ns.metadata.name)
namespace_list.append(ns.metadata.name)
return namespace_list
def get_pod_list(self):
api = self.get_api()
print("listing pods with their ips:")
ret = api.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
def get_service_list(self):
api = self.get_api()
ret = api.list_service_for_all_namespaces(watch=False)
for i in ret.items:
print("%s \t%s \t%s \t%s \t%s \n" % (
i.kind, i.metadata.namespace, i.metadata.name, i.spec.cluster_ip, i.spec.ports))
if __name__ == '__main__':
#print(kubernetestools().get_api())
namespace_list = kubernetestools().get_namespace_list()
print(namespace_list)
kubernetestools().get_pod_list()
kubernetestools().get_service_list()
pycharm运行结果:
D:\PycharmProjects\L2221\venv\Scripts\python.exe D:/PycharmProjects/L2221/k8s_API/k8s_test.py
D:\PycharmProjects\L2221\venv\lib\site-packages\urllib3\connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.42.135'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
{'api_version': 'v1',
'items': [{'api_version': None,
'kind': None,
'metadata': {'annotations': {'flannel.alpha.coreos.com/backend-data': '{"VNI":1,"VtepMAC":"32:a2:d7:4e:bd:1c"}',
'flannel.alpha.coreos.com/backend-type': 'vxlan',
'flannel.alpha.coreos.com/kube-subnet-manager': 'true',
'flannel.alpha.coreos.com/public-ip': '192.168.42.135',
'kubeadm.alpha.kubernetes.io/cri-socket': '/var/run/dockershim.sock',
'node.alpha.kubernetes.io/ttl': '0',
'volumes.kubernetes.io/controller-managed-attach-detach': 'true'},
'creation_timestamp': datetime.datetime(2022, 9, 18, 2, 39, 16, tzinfo=tzutc()),
'deletion_grace_period_seconds': None,
'deletion_timestamp': None,
'finalizers': None,
'generate_name': None,
'generation': None,
'labels': {'beta.kubernetes.io/arch': 'amd64',
'beta.kubernetes.io/os': 'linux',
'kubernetes.io/arch': 'amd64',
'kubernetes.io/hostname': 'k8s-master',
'kubernetes.io/os': 'linux',
'node-role.kubernetes.io/master': ''},
'managed_fields': None,
'name': 'k8s-master',
'namespace': None,
'owner_references': None,
'resource_version': '1557555',
'self_link': '/api/v1/nodes/k8s-master',
'uid': 'f4fa14cc-2989-4399-8481-fc6c2b298f8d'},
'spec': {'config_source': None,
'external_id': None,
'pod_cid_rs': ['10.244.0.0/24'],
'pod_cidr': '10.244.0.0/24',
'provider_id': None,
'taints': None,
'unschedulable': None},
'status': {'addresses': [{'address': '192.168.42.135',
'type': 'InternalIP'},
{'address': 'k8s-master',
'type': 'Hostname'}],
'allocatable': {'cpu': '2',
'ephemeral-storage': '16415037823',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '2441812Ki',
'pods': '110'},
'capacity': {'cpu': '2',
'ephemeral-storage': '17394Mi',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '2544212Ki',
'pods': '110'},
'conditions': [{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 9, 2, 20, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 29, 9, 2, 20, tzinfo=tzutc()),
'message': 'Flannel is running on this '
'node',
'reason': 'FlannelIsUp',
'status': 'False',
'type': 'NetworkUnavailable'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 10, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 10, 2, 3, 15, 54, tzinfo=tzutc()),
'message': 'kubelet has sufficient '
'memory available',
'reason': 'KubeletHasSufficientMemory',
'status': 'False',
'type': 'MemoryPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 10, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 10, 2, 3, 15, 54, tzinfo=tzutc()),
'message': 'kubelet has no disk '
'pressure',
'reason': 'KubeletHasNoDiskPressure',
'status': 'False',
'type': 'DiskPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 10, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 10, 2, 3, 15, 54, tzinfo=tzutc()),
'message': 'kubelet has sufficient PID '
'available',
'reason': 'KubeletHasSufficientPID',
'status': 'False',
'type': 'PIDPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 10, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 10, 2, 3, 15, 54, tzinfo=tzutc()),
'message': 'kubelet is posting ready '
'status',
'reason': 'KubeletReady',
'status': 'True',
'type': 'Ready'}],
'config': None,
'daemon_endpoints': {'kubelet_endpoint': {'port': 10250}},
'images': [{'names': ['registry.aliyuncs.com/google_containers/etcd@sha256:4afb99b4690b418ffc2ceb67e1a17376457e441c1f09ab55447f0aaf992fa646',
'registry.aliyuncs.com/google_containers/etcd:3.4.3-0'],
'size_bytes': 288426917},
{'names': ['httpd@sha256:ff734d5b9bfc1d33936211a9564e1811665ee9487d7ab38732ae38180dd613b9',
'httpd:2.4.17'],
'size_bytes': 193400403},
{'names': ['httpd@sha256:bcfcee1fe86942a96c0b1ee9c2f1aaaca9c5d0f9d261ed48dff50f41ad31e1ac',
'httpd:2.4.18'],
'size_bytes': 193364202},
{'names': ['httpd@sha256:a28a1a54ee7c4e03249b5eb3fed0c387399ffa5bb422ab50cbb19ffde76e58e7',
'httpd:2.2.32'],
'size_bytes': 171334168},
{'names': ['registry.aliyuncs.com/google_containers/kube-apiserver@sha256:e3ec33d533257902ad9ebe3d399c17710e62009201a7202aec941e351545d662',
'registry.aliyuncs.com/google_containers/kube-apiserver:v1.17.0'],
'size_bytes': 170957331},
{'names': ['httpd@sha256:f3f1dfb2b45b6a4fb90f4644a505262f631a18f83c3acf7d426621b592a1411f',
'httpd:2.2.31'],
'size_bytes': 169935384},
{'names': ['httpd@sha256:c725ac3661a472b54e10bfb02bb4c490c00c29d0979357fb82fb6f7bb9788999',
'httpd:2.4.16'],
'size_bytes': 162003398},
{'names': ['registry.aliyuncs.com/google_containers/kube-controller-manager@sha256:0438efb5098a2ca634ea8c6b0d804742b733d0d13fd53cf62c73e32c659a3c39',
'registry.aliyuncs.com/google_containers/kube-controller-manager:v1.17.0'],
'size_bytes': 160877075},
{'names': ['nginx:v1'],
'size_bytes': 143375730},
{'names': ['nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31',
'nginx:latest'],
'size_bytes': 141479488},
{'names': ['nginx@sha256:5411d8897c3da841a1f45f895b43ad4526eb62d3393c3287124a56be49962d41',
'nginx:1.17.2'],
'size_bytes': 125850912},
{'names': ['registry.aliyuncs.com/google_containers/kube-proxy@sha256:b2ba9441af30261465e5c41be63e462d0050b09ad280001ae731f399b2b00b75',
'registry.aliyuncs.com/google_containers/kube-proxy:v1.17.0'],
'size_bytes': 115960823},
{'names': ['nginx@sha256:b4b9b3eee194703fc2fa8afa5b7510c77ae70cfba567af1376a573a967c03dbb',
'nginx:1.17.1'],
'size_bytes': 109357455},
{'names': ['registry.aliyuncs.com/google_containers/kube-scheduler@sha256:5215c4216a65f7e76c1895ba951a12dc1c947904a91810fc66a544ff1d7e87db',
'registry.aliyuncs.com/google_containers/kube-scheduler:v1.17.0'],
'size_bytes': 94431763},
{'names': ['weaveworks/scope@sha256:2f063422cd74d6b0cc6a4c7a26aeb531a69d719de1fa039ca592877662051446',
'weaveworks/scope:1.12.0'],
'size_bytes': 84748858},
{'names': ['quay.io/metallb/speaker@sha256:40e0373788f3ea5e21a42b302a0ae4fd537646eb4b485e02b7ae52dc71da230c',
'quay.io/metallb/speaker:v0.12.1'],
'size_bytes': 70013162},
{'names': ['rancher/mirrored-flannelcni-flannel@sha256:c9786f434d4663c924aeca1a2e479786d63df0d56c5d6bd62a64915f81d62ff0',
'rancher/mirrored-flannelcni-flannel:v0.19.2'],
'size_bytes': 62313830},
{'names': ['metallb/speaker@sha256:f1941498a28cdb332429e25d18233683da6949ecfc4f6dacf12b1416d7d38263',
'metallb/speaker:v0.8.2'],
'size_bytes': 43496121},
{'names': ['registry.aliyuncs.com/google_containers/coredns@sha256:7ec975f167d815311a7136c32e70735f0d00b73781365df1befd46ed35bd4fe7',
'registry.aliyuncs.com/google_containers/coredns:1.6.5'],
'size_bytes': 41578211},
{'names': ['registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64@sha256:c9c4e95068b51d6b33a9dccc61875df07dc650abbf4ac1a19d58b4628f89288b',
'registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6'],
'size_bytes': 39944451},
{'names': ['prom/node-exporter@sha256:cf66a6bbd573fd819ea09c72e21b528e9252d58d01ae13564a29749de1e48e0f',
'prom/node-exporter:v1.0.1'],
'size_bytes': 26430341},
{'names': ['rancher/mirrored-flannelcni-flannel-cni-plugin@sha256:28d3a6be9f450282bf42e4dad143d41da23e3d91f66f19c01ee7fd21fd17cb2b',
'rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0'],
'size_bytes': 8087907},
{'names': ['busybox@sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678',
'busybox:latest'],
'size_bytes': 1239820},
{'names': ['busybox@sha256:ad9bd57a3a57cc95515c537b89aaa69d83a6df54c4050fcf2b41ad367bec0cd5'],
'size_bytes': 1239764},
{'names': ['busybox@sha256:4b6ad3a68d34da29bf7c8ccb5d355ba8b4babcad1f99798204e7abb43e54ee3d',
'busybox:1.30'],
'size_bytes': 1199418},
{'names': ['registry.aliyuncs.com/google_containers/pause@sha256:f78411e19d84a252e53bff71a4407a5686c46983a2c2eeed83929b888179acea',
'registry.aliyuncs.com/google_containers/pause:3.1'],
'size_bytes': 742472},
{'names': ['<none>@<none>', '<none>:<none>'],
'size_bytes': None},
{'names': ['centos:v1'], 'size_bytes': None}],
'node_info': {'architecture': 'amd64',
'boot_id': 'a20946a7-c041-43de-b5cc-54fecbc47fde',
'container_runtime_version': 'docker://19.3.15',
'kernel_version': '3.10.0-957.el7.x86_64',
'kube_proxy_version': 'v1.17.0',
'kubelet_version': 'v1.17.0',
'machine_id': '31b5beb9a3a64a8eaf4621088aa5389f',
'operating_system': 'linux',
'os_image': 'CentOS Linux 7 (Core)',
'system_uuid': '42734D56-15D3-8551-28EE-DD2BD2641E46'},
'phase': None,
'volumes_attached': None,
'volumes_in_use': None}},
{'api_version': None,
'kind': None,
'metadata': {'annotations': {'flannel.alpha.coreos.com/backend-data': '{"VNI":1,"VtepMAC":"b6:c9:00:ce:42:15"}',
'flannel.alpha.coreos.com/backend-type': 'vxlan',
'flannel.alpha.coreos.com/kube-subnet-manager': 'true',
'flannel.alpha.coreos.com/public-ip': '192.168.42.136',
'kubeadm.alpha.kubernetes.io/cri-socket': '/var/run/dockershim.sock',
'node.alpha.kubernetes.io/ttl': '0',
'volumes.kubernetes.io/controller-managed-attach-detach': 'true'},
'creation_timestamp': datetime.datetime(2022, 9, 18, 3, 4, 58, tzinfo=tzutc()),
'deletion_grace_period_seconds': None,
'deletion_timestamp': None,
'finalizers': None,
'generate_name': None,
'generation': None,
'labels': {'beta.kubernetes.io/arch': 'amd64',
'beta.kubernetes.io/os': 'linux',
'kubernetes.io/arch': 'amd64',
'kubernetes.io/hostname': 'k8s-node01',
'kubernetes.io/os': 'linux'},
'managed_fields': None,
'name': 'k8s-node01',
'namespace': None,
'owner_references': None,
'resource_version': '1557556',
'self_link': '/api/v1/nodes/k8s-node01',
'uid': 'e780c7d6-9623-4b6a-bef2-b2fff0358d66'},
'spec': {'config_source': None,
'external_id': None,
'pod_cid_rs': ['10.244.1.0/24'],
'pod_cidr': '10.244.1.0/24',
'provider_id': None,
'taints': None,
'unschedulable': None},
'status': {'addresses': [{'address': '192.168.42.136',
'type': 'InternalIP'},
{'address': 'k8s-node01',
'type': 'Hostname'}],
'allocatable': {'cpu': '2',
'ephemeral-storage': '16415037823',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '1925716Ki',
'pods': '110'},
'capacity': {'cpu': '2',
'ephemeral-storage': '17394Mi',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '2028116Ki',
'pods': '110'},
'conditions': [{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 9, 2, 4, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 29, 9, 2, 4, tzinfo=tzutc()),
'message': 'Flannel is running on this '
'node',
'reason': 'FlannelIsUp',
'status': 'False',
'type': 'NetworkUnavailable'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 11, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 24, 6, 39, 46, tzinfo=tzutc()),
'message': 'kubelet has sufficient '
'memory available',
'reason': 'KubeletHasSufficientMemory',
'status': 'False',
'type': 'MemoryPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 11, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 24, 6, 39, 46, tzinfo=tzutc()),
'message': 'kubelet has no disk '
'pressure',
'reason': 'KubeletHasNoDiskPressure',
'status': 'False',
'type': 'DiskPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 11, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 24, 6, 39, 46, tzinfo=tzutc()),
'message': 'kubelet has sufficient PID '
'available',
'reason': 'KubeletHasSufficientPID',
'status': 'False',
'type': 'PIDPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 11, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 29, 1, 0, 15, tzinfo=tzutc()),
'message': 'kubelet is posting ready '
'status',
'reason': 'KubeletReady',
'status': 'True',
'type': 'Ready'}],
'config': None,
'daemon_endpoints': {'kubelet_endpoint': {'port': 10250}},
'images': [{'names': ['mysql@sha256:32f9d9a069f7a735e28fd44ea944d53c61f990ba71460c5c183e610854ca4854',
'mysql:5.7.30'],
'size_bytes': 448102503},
{'names': ['tomcat@sha256:15d530cd2186678cd170b1b8416a0c9688f4c89ce7be74202843687e542479c1',
'tomcat:8.5-jre10-slim'],
'size_bytes': 315280498},
{'names': ['httpd@sha256:ff734d5b9bfc1d33936211a9564e1811665ee9487d7ab38732ae38180dd613b9',
'httpd:2.4.17'],
'size_bytes': 193400403},
{'names': ['httpd@sha256:bcfcee1fe86942a96c0b1ee9c2f1aaaca9c5d0f9d261ed48dff50f41ad31e1ac',
'httpd:2.4.18'],
'size_bytes': 193364202},
{'names': ['httpd@sha256:a28a1a54ee7c4e03249b5eb3fed0c387399ffa5bb422ab50cbb19ffde76e58e7',
'httpd:2.2.32'],
'size_bytes': 171334168},
{'names': ['httpd@sha256:f3f1dfb2b45b6a4fb90f4644a505262f631a18f83c3acf7d426621b592a1411f',
'httpd:2.2.31'],
'size_bytes': 169935384},
{'names': ['httpd@sha256:c725ac3661a472b54e10bfb02bb4c490c00c29d0979357fb82fb6f7bb9788999',
'httpd:2.4.16'],
'size_bytes': 162003398},
{'names': ['httpd@sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32',
'httpd:latest'],
'size_bytes': 143541188},
{'names': ['nginx:v1'],
'size_bytes': 143375730},
{'names': ['nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31',
'nginx:1',
'nginx:latest'],
'size_bytes': 141479488},
{'names': ['ubuntu@sha256:0f71fa8d4d2d4292c3c617fda2b36f6dabe5c8b6e34c3dc5b0d17d4e704bd39c',
'ubuntu:16.04'],
'size_bytes': 134821261},
{'names': ['nginx@sha256:df13abe416e37eb3db4722840dd479b00ba193ac6606e7902331dcea50f4f1f2',
'nginx:1.19'],
'size_bytes': 133122553},
{'names': ['nginx@sha256:6fff55753e3b34e36e24e37039ee9eae1fe38a6420d8ae16ef37c92d1eb26699',
'nginx:1.17'],
'size_bytes': 126773960},
{'names': ['nginx@sha256:5411d8897c3da841a1f45f895b43ad4526eb62d3393c3287124a56be49962d41',
'nginx:1.17.2'],
'size_bytes': 125850912},
{'names': ['registry.aliyuncs.com/google_containers/kube-proxy@sha256:b2ba9441af30261465e5c41be63e462d0050b09ad280001ae731f399b2b00b75',
'registry.aliyuncs.com/google_containers/kube-proxy:v1.17.0'],
'size_bytes': 115960823},
{'names': ['nginx@sha256:b4b9b3eee194703fc2fa8afa5b7510c77ae70cfba567af1376a573a967c03dbb',
'nginx:1.17.1'],
'size_bytes': 109357455},
{'names': ['weaveworks/scope@sha256:2f063422cd74d6b0cc6a4c7a26aeb531a69d719de1fa039ca592877662051446',
'weaveworks/scope:1.12.0'],
'size_bytes': 84748858},
{'names': ['quay.io/metallb/speaker@sha256:40e0373788f3ea5e21a42b302a0ae4fd537646eb4b485e02b7ae52dc71da230c',
'quay.io/metallb/speaker:v0.12.1'],
'size_bytes': 70013162},
{'names': ['rancher/mirrored-flannelcni-flannel@sha256:c9786f434d4663c924aeca1a2e479786d63df0d56c5d6bd62a64915f81d62ff0',
'rancher/mirrored-flannelcni-flannel:v0.19.2'],
'size_bytes': 62313830},
{'names': ['quay.io/external_storage/nfs-client-provisioner@sha256:cdbccbf53d100b36eae744c1cb07be3d0d22a8e64bb038b7a3808dd29c174661',
'quay.io/external_storage/nfs-client-provisioner:v3.1.0-k8s1.11'],
'size_bytes': 45478559},
{'names': ['metallb/speaker@sha256:f1941498a28cdb332429e25d18233683da6949ecfc4f6dacf12b1416d7d38263',
'metallb/speaker:v0.8.2'],
'size_bytes': 43496121},
{'names': ['metallb/controller@sha256:5c050e59074e152711737d2bb9ede96dff67016c80cf25cdf5fc46109718a583',
'metallb/controller:v0.8.2'],
'size_bytes': 42517225},
{'names': ['registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64@sha256:c9c4e95068b51d6b33a9dccc61875df07dc650abbf4ac1a19d58b4628f89288b',
'registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6'],
'size_bytes': 39944451},
{'names': ['registry.cn-beijing.aliyuncs.com/minminmsn/addon-resizer@sha256:455eb18aa7a658db4f21c1f2b901c6a274afa7db4b73f4402a26fe9b3993c205',
'registry.cn-beijing.aliyuncs.com/minminmsn/addon-resizer:1.8.4'],
'size_bytes': 38349857},
{'names': ['quay.io/coreos/kube-state-metrics@sha256:f96f4907d6d39e5179a4395e4b12aaa21c4c12bbae63ceaa64b43f56316e338b',
'quay.io/coreos/kube-state-metrics:v2.0.0-beta'],
'size_bytes': 33113620},
{'names': ['prom/alertmanager@sha256:2ff45fb2704a387347aa34f154f450d4ad86a8f47bcf72437761267ebdf45efb',
'prom/alertmanager:v0.14.0'],
'size_bytes': 31928798},
{'names': ['prom/node-exporter@sha256:cf66a6bbd573fd819ea09c72e21b528e9252d58d01ae13564a29749de1e48e0f',
'prom/node-exporter:v1.0.1'],
'size_bytes': 26430341},
{'names': ['wangyanglinux/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513',
'wangyanglinux/myapp:v1'],
'size_bytes': 15504557},
{'names': ['radial/busyboxplus@sha256:f26b8738e52cd1dba801eb1978804e663c48e1e9cff128ac9423218be83c55b8',
'radial/busyboxplus:latest'],
'size_bytes': 12855024},
{'names': ['sequenceiq/busybox@sha256:30f857963151f713009eb40d8d094233de7bfa769c4f32b2466fefa3e3f83e1f',
'sequenceiq/busybox:latest'],
'size_bytes': 11592062},
{'names': ['rancher/mirrored-flannelcni-flannel-cni-plugin@sha256:28d3a6be9f450282bf42e4dad143d41da23e3d91f66f19c01ee7fd21fd17cb2b',
'rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0'],
'size_bytes': 8087907},
{'names': ['busybox@sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678',
'busybox:latest'],
'size_bytes': 1239820},
{'names': ['busybox@sha256:ad9bd57a3a57cc95515c537b89aaa69d83a6df54c4050fcf2b41ad367bec0cd5'],
'size_bytes': 1239764},
{'names': ['busybox@sha256:ae39a6f5c07297d7ab64dbd4f82c77c874cc6a94cea29fdec309d0992574b4f7',
'busybox:1.32'],
'size_bytes': 1231733},
{'names': ['busybox@sha256:4b6ad3a68d34da29bf7c8ccb5d355ba8b4babcad1f99798204e7abb43e54ee3d',
'busybox:1.30'],
'size_bytes': 1199418},
{'names': ['registry.aliyuncs.com/google_containers/pause@sha256:f78411e19d84a252e53bff71a4407a5686c46983a2c2eeed83929b888179acea',
'registry.aliyuncs.com/google_containers/pause:3.1'],
'size_bytes': 742472},
{'names': ['<none>@<none>', '<none>:<none>'],
'size_bytes': None},
{'names': ['centos:v1'], 'size_bytes': None}],
'node_info': {'architecture': 'amd64',
'boot_id': '6eca5c04-3930-422f-9705-805bb467336a',
'container_runtime_version': 'docker://19.3.15',
'kernel_version': '3.10.0-957.el7.x86_64',
'kube_proxy_version': 'v1.17.0',
'kubelet_version': 'v1.17.0',
'machine_id': '31b5beb9a3a64a8eaf4621088aa5389f',
'operating_system': 'linux',
'os_image': 'CentOS Linux 7 (Core)',
'system_uuid': '74924D56-667C-6277-20F8-7927FF382118'},
'phase': None,
'volumes_attached': None,
'volumes_in_use': None}},
{'api_version': None,
'kind': None,
'metadata': {'annotations': {'flannel.alpha.coreos.com/backend-data': '{"VNI":1,"VtepMAC":"e2:12:ec:ad:43:ee"}',
'flannel.alpha.coreos.com/backend-type': 'vxlan',
'flannel.alpha.coreos.com/kube-subnet-manager': 'true',
'flannel.alpha.coreos.com/public-ip': '192.168.42.137',
'kubeadm.alpha.kubernetes.io/cri-socket': '/var/run/dockershim.sock',
'node.alpha.kubernetes.io/ttl': '0',
'volumes.kubernetes.io/controller-managed-attach-detach': 'true'},
'creation_timestamp': datetime.datetime(2022, 9, 18, 3, 5, 1, tzinfo=tzutc()),
'deletion_grace_period_seconds': None,
'deletion_timestamp': None,
'finalizers': None,
'generate_name': None,
'generation': None,
'labels': {'beta.kubernetes.io/arch': 'amd64',
'beta.kubernetes.io/os': 'linux',
'kubernetes.io/arch': 'amd64',
'kubernetes.io/hostname': 'k8s-node02',
'kubernetes.io/os': 'linux'},
'managed_fields': None,
'name': 'k8s-node02',
'namespace': None,
'owner_references': None,
'resource_version': '1557619',
'self_link': '/api/v1/nodes/k8s-node02',
'uid': '79e904fe-6f5b-410c-bae7-30893c370dfe'},
'spec': {'config_source': None,
'external_id': None,
'pod_cid_rs': ['10.244.2.0/24'],
'pod_cidr': '10.244.2.0/24',
'provider_id': None,
'taints': None,
'unschedulable': None},
'status': {'addresses': [{'address': '192.168.42.137',
'type': 'InternalIP'},
{'address': 'k8s-node02',
'type': 'Hostname'}],
'allocatable': {'cpu': '2',
'ephemeral-storage': '16415037823',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '1925716Ki',
'pods': '110'},
'capacity': {'cpu': '2',
'ephemeral-storage': '17394Mi',
'hugepages-1Gi': '0',
'hugepages-2Mi': '0',
'memory': '2028116Ki',
'pods': '110'},
'conditions': [{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 9, 2, 25, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 29, 9, 2, 25, tzinfo=tzutc()),
'message': 'Flannel is running on this '
'node',
'reason': 'FlannelIsUp',
'status': 'False',
'type': 'NetworkUnavailable'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 32, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 9, 30, 4, 27, 50, tzinfo=tzutc()),
'message': 'kubelet has sufficient '
'memory available',
'reason': 'KubeletHasSufficientMemory',
'status': 'False',
'type': 'MemoryPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 32, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 9, 30, 4, 27, 50, tzinfo=tzutc()),
'message': 'kubelet has no disk '
'pressure',
'reason': 'KubeletHasNoDiskPressure',
'status': 'False',
'type': 'DiskPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 32, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2022, 9, 30, 4, 27, 50, tzinfo=tzutc()),
'message': 'kubelet has sufficient PID '
'available',
'reason': 'KubeletHasSufficientPID',
'status': 'False',
'type': 'PIDPressure'},
{'last_heartbeat_time': datetime.datetime(2023, 3, 29, 10, 1, 32, tzinfo=tzutc()),
'last_transition_time': datetime.datetime(2023, 3, 29, 9, 1, 14, tzinfo=tzutc()),
'message': 'kubelet is posting ready '
'status',
'reason': 'KubeletReady',
'status': 'True',
'type': 'Ready'}],
'config': None,
'daemon_endpoints': {'kubelet_endpoint': {'port': 10250}},
'images': [{'names': ['quay.io/kubernetes-ingress-controller/nginx-ingress-controller@sha256:b312c91d0de688a21075078982b5e3a48b13b46eda4df743317d3059fc3ca0d9',
'quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0'],
'size_bytes': 322915865},
{'names': ['tomcat@sha256:15d530cd2186678cd170b1b8416a0c9688f4c89ce7be74202843687e542479c1',
'tomcat:8.5-jre10-slim'],
'size_bytes': 315280498},
{'names': ['httpd@sha256:ff734d5b9bfc1d33936211a9564e1811665ee9487d7ab38732ae38180dd613b9',
'httpd:2.4.17'],
'size_bytes': 193400403},
{'names': ['httpd@sha256:bcfcee1fe86942a96c0b1ee9c2f1aaaca9c5d0f9d261ed48dff50f41ad31e1ac',
'httpd:2.4.18'],
'size_bytes': 193364202},
{'names': ['prom/prometheus@sha256:943c7c57115a449353e0158dcba4eaab2e56de07b7d552b5145cb6c0d1cbab19',
'prom/prometheus:v2.24.0'],
'size_bytes': 172597596},
{'names': ['httpd@sha256:a28a1a54ee7c4e03249b5eb3fed0c387399ffa5bb422ab50cbb19ffde76e58e7',
'httpd:2.2.32'],
'size_bytes': 171334168},
{'names': ['registry.cn-hangzhou.aliyuncs.com/mirror_googlecontainers/heapster-grafana-amd64@sha256:09faae5805b1ee1901472876224aa3e7f55951b0b8e47752d6bd202600a318fa',
'registry.cn-hangzhou.aliyuncs.com/mirror_googlecontainers/heapster-grafana-amd64:v5.0.4'],
'size_bytes': 170981547},
{'names': ['httpd@sha256:f3f1dfb2b45b6a4fb90f4644a505262f631a18f83c3acf7d426621b592a1411f',
'httpd:2.2.31'],
'size_bytes': 169935384},
{'names': ['httpd@sha256:c725ac3661a472b54e10bfb02bb4c490c00c29d0979357fb82fb6f7bb9788999',
'httpd:2.4.16'],
'size_bytes': 162003398},
{'names': ['httpd@sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32',
'httpd:latest'],
'size_bytes': 143541188},
{'names': ['nginx:v1'],
'size_bytes': 143375730},
{'names': ['nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31',
'nginx:1',
'nginx:latest'],
'size_bytes': 141479488},
{'names': ['nginx@sha256:6fff55753e3b34e36e24e37039ee9eae1fe38a6420d8ae16ef37c92d1eb26699',
'nginx:1.17'],
'size_bytes': 126773960},
{'names': ['nginx@sha256:5411d8897c3da841a1f45f895b43ad4526eb62d3393c3287124a56be49962d41',
'nginx:1.17.2'],
'size_bytes': 125850912},
{'names': ['registry.aliyuncs.com/google_containers/kube-proxy@sha256:b2ba9441af30261465e5c41be63e462d0050b09ad280001ae731f399b2b00b75',
'registry.aliyuncs.com/google_containers/kube-proxy:v1.17.0'],
'size_bytes': 115960823},
{'names': ['nginx@sha256:b4b9b3eee194703fc2fa8afa5b7510c77ae70cfba567af1376a573a967c03dbb',
'nginx:1.17.1'],
'size_bytes': 109357455},
{'names': ['nginx@sha256:bdbf36b7f1f77ffe7bd2a32e59235dff6ecf131e3b6b5b96061c652f30685f3a',
'nginx:1.17.0'],
'size_bytes': 109258867},
{'names': ['weaveworks/scope@sha256:2f063422cd74d6b0cc6a4c7a26aeb531a69d719de1fa039ca592877662051446',
'weaveworks/scope:1.12.0'],
'size_bytes': 84748858},
{'names': ['quay.io/metallb/speaker@sha256:40e0373788f3ea5e21a42b302a0ae4fd537646eb4b485e02b7ae52dc71da230c',
'quay.io/metallb/speaker:v0.12.1'],
'size_bytes': 70013162},
{'names': ['rancher/mirrored-flannelcni-flannel@sha256:c9786f434d4663c924aeca1a2e479786d63df0d56c5d6bd62a64915f81d62ff0',
'rancher/mirrored-flannelcni-flannel:v0.19.2'],
'size_bytes': 62313830},
{'names': ['quay.io/metallb/controller@sha256:4db40890faff645102d33a04fbb736265fad2259425f5a01cbb84df524eae53a',
'quay.io/metallb/controller:v0.12.1'],
'size_bytes': 47841664},
{'names': ['metallb/speaker@sha256:f1941498a28cdb332429e25d18233683da6949ecfc4f6dacf12b1416d7d38263',
'metallb/speaker:v0.8.2'],
'size_bytes': 43496121},
{'names': ['metallb/controller@sha256:5c050e59074e152711737d2bb9ede96dff67016c80cf25cdf5fc46109718a583',
'metallb/controller:v0.8.2'],
'size_bytes': 42517225},
{'names': ['registry.aliyuncs.com/google_containers/coredns@sha256:7ec975f167d815311a7136c32e70735f0d00b73781365df1befd46ed35bd4fe7',
'registry.aliyuncs.com/google_containers/coredns:1.6.5'],
'size_bytes': 41578211},
{'names': ['prom/alertmanager@sha256:2ff45fb2704a387347aa34f154f450d4ad86a8f47bcf72437761267ebdf45efb',
'prom/alertmanager:v0.14.0'],
'size_bytes': 31928798},
{'names': ['prom/node-exporter@sha256:cf66a6bbd573fd819ea09c72e21b528e9252d58d01ae13564a29749de1e48e0f',
'prom/node-exporter:v1.0.1'],
'size_bytes': 26430341},
{'names': ['radial/busyboxplus@sha256:f26b8738e52cd1dba801eb1978804e663c48e1e9cff128ac9423218be83c55b8',
'radial/busyboxplus:latest'],
'size_bytes': 12855024},
{'names': ['rancher/mirrored-flannelcni-flannel-cni-plugin@sha256:28d3a6be9f450282bf42e4dad143d41da23e3d91f66f19c01ee7fd21fd17cb2b',
'rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0'],
'size_bytes': 8087907},
{'names': ['busybox@sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678',
'busybox:latest'],
'size_bytes': 1239820},
{'names': ['busybox@sha256:ad9bd57a3a57cc95515c537b89aaa69d83a6df54c4050fcf2b41ad367bec0cd5'],
'size_bytes': 1239764},
{'names': ['busybox@sha256:4b6ad3a68d34da29bf7c8ccb5d355ba8b4babcad1f99798204e7abb43e54ee3d',
'busybox:1.30'],
'size_bytes': 1199418},
{'names': ['registry.aliyuncs.com/google_containers/pause@sha256:f78411e19d84a252e53bff71a4407a5686c46983a2c2eeed83929b888179acea',
'registry.aliyuncs.com/google_containers/pause:3.1'],
'size_bytes': 742472},
{'names': ['<none>@<none>', '<none>:<none>'],
'size_bytes': None},
{'names': ['centos:v1'], 'size_bytes': None}],
'node_info': {'architecture': 'amd64',
'boot_id': '07e3a4ab-d358-4baf-9935-a226b2bd411f',
'container_runtime_version': 'docker://19.3.15',
'kernel_version': '3.10.0-957.el7.x86_64',
'kube_proxy_version': 'v1.17.0',
'kubelet_version': 'v1.17.0',
'machine_id': '31b5beb9a3a64a8eaf4621088aa5389f',
'operating_system': 'linux',
'os_image': 'CentOS Linux 7 (Core)',
'system_uuid': 'A3044D56-AD1F-8EF0-2114-412D563F04B3'},
'phase': None,
'volumes_attached': None,
'volumes_in_use': None}}],
'kind': 'NodeList',
'metadata': {'_continue': None,
'remaining_item_count': None,
'resource_version': '1558426',
'self_link': '/api/v1/nodes'}}
D:\PycharmProjects\L2221\venv\lib\site-packages\urllib3\connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.42.135'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
['default', 'dev', 'kube-flannel', 'kube-node-lease', 'kube-public', 'kube-system', 'metallb-system']
listing pods with their ips:
D:\PycharmProjects\L2221\venv\lib\site-packages\urllib3\connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.42.135'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
10.244.1.39 default affinity
10.244.1.36 default httpd-5bb9749d96-f986l
10.244.2.243 default httpd-5bb9749d96-j9w2k
10.244.0.80 default httpd-5bb9749d96-xw4zk
10.244.1.40 default my-nfsclient-nfs-client-provisioner-7b595c848c-fvr82
10.244.1.33 default nginx
10.244.0.79 default nginx-7b766dbb7-75g45
10.244.1.38 default node01
10.244.1.37 default pc-replicaset-8f5z6
10.244.0.81 default pc-replicaset-pg49f
10.244.2.244 default pc-replicaset-wl2jb
10.244.1.34 default pc-statefulset-0
10.244.2.245 default pc-statefulset-1
10.244.0.83 default pc-statefulset-2
10.244.1.43 default pod-3
10.244.1.35 default pod1
10.244.1.32 default pod2
10.244.1.31 default self-mysql-cdc5d8cf7-5lwpk
10.244.2.252 default sh-6fd6b9ff57-zb9bq
10.244.2.250 default test-projected-volume
10.244.0.82 default volume-hostpath
10.244.2.249 default volume-nfs
192.168.42.137 default weave-scope-agent-ui-4ldsr
192.168.42.136 default weave-scope-agent-ui-6nmfg
192.168.42.135 default weave-scope-agent-ui-zfw4m
10.244.2.248 default weave-scope-cluster-agent-ui-6cd95f9f76-sjpzr
10.244.2.253 default weave-scope-frontend-ui-66dff7b5c6-2zkmx
10.244.1.42 dev nginx-6db489d4b7-cld2p
10.244.2.251 dev nginx-6db489d4b7-p9s85
192.168.42.135 kube-flannel kube-flannel-ds-kwnmp
192.168.42.137 kube-flannel kube-flannel-ds-s4m8r
192.168.42.136 kube-flannel kube-flannel-ds-xnz65
10.244.1.41 kube-system alertmanager-68857fb6c-mbhdb
10.244.2.247 kube-system coredns-9d85f5447-bb9jk
10.244.2.246 kube-system coredns-9d85f5447-rbd2d
192.168.42.135 kube-system etcd-k8s-master
192.168.42.135 kube-system kube-apiserver-k8s-master
192.168.42.135 kube-system kube-controller-manager-k8s-master
192.168.42.136 kube-system kube-proxy-bjm24
192.168.42.135 kube-system kube-proxy-r8svd
192.168.42.137 kube-system kube-proxy-xzd88
192.168.42.135 kube-system kube-scheduler-k8s-master
10.244.1.44 kube-system kube-state-metrics-59cf8547d6-sxtd7
192.168.42.135 kube-system metrics-server-6b976979db-cx6x9
10.244.2.242 kube-system monitoring-grafana-68d9c5bc4f-69mxt
192.168.42.136 kube-system node-exporter-4xmzc
192.168.42.137 kube-system node-exporter-7gzdc
192.168.42.135 kube-system node-exporter-gjwvb
10.244.2.241 kube-system prometheus-0
10.244.2.254 metallb-system controller-65895b47d4-qt9h5
192.168.42.136 metallb-system speaker-6hc8b
192.168.42.135 metallb-system speaker-78vcj
192.168.42.137 metallb-system speaker-k7m54
D:\PycharmProjects\L2221\venv\lib\site-packages\urllib3\connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.42.135'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
None default db-mysql 10.96.89.177 [{'app_protocol': None,
'name': 'mysql',
'node_port': None,
'port': 3306,
'protocol': 'TCP',
'target_port': 'mysql'}]
None default kubernetes 10.96.0.1 [{'app_protocol': None,
'name': 'https',
'node_port': None,
'port': 443,
'protocol': 'TCP',
'target_port': 6443}]
None default nginx 10.96.20.177 [{'app_protocol': None,
'name': 'http',
'node_port': 32267,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default nginx-deployment 10.96.0.188 [{'app_protocol': None,
'name': None,
'node_port': 30362,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default nginx-nodeport 10.96.9.29 [{'app_protocol': None,
'name': None,
'node_port': 31609,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default nginx-nodeport1 10.96.242.45 [{'app_protocol': None,
'name': None,
'node_port': 31681,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default self-mysql 10.96.189.50 [{'app_protocol': None,
'name': 'mysql',
'node_port': None,
'port': 3306,
'protocol': 'TCP',
'target_port': 'mysql'}]
None default service-clusterip 10.96.99.203 [{'app_protocol': None,
'name': None,
'node_port': None,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default service-headliness None [{'app_protocol': None,
'name': None,
'node_port': None,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default svc-nginx1 10.96.187.29 [{'app_protocol': None,
'name': None,
'node_port': None,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default svc-nginx2 10.96.127.23 [{'app_protocol': None,
'name': None,
'node_port': None,
'port': 80,
'protocol': 'TCP',
'target_port': 80}]
None default ui-weave-scope 10.96.243.31 [{'app_protocol': None,
'name': 'http',
'node_port': 32618,
'port': 80,
'protocol': 'TCP',
'target_port': 'http'}]
None kube-system alertmanager 10.96.130.211 [{'app_protocol': None,
'name': 'http',
'node_port': 30093,
'port': 80,
'protocol': 'TCP',
'target_port': 9093}]
None kube-system kube-dns 10.96.0.10 [{'app_protocol': None,
'name': 'dns',
'node_port': None,
'port': 53,
'protocol': 'UDP',
'target_port': 53}, {'app_protocol': None,
'name': 'dns-tcp',
'node_port': None,
'port': 53,
'protocol': 'TCP',
'target_port': 53}, {'app_protocol': None,
'name': 'metrics',
'node_port': None,
'port': 9153,
'protocol': 'TCP',
'target_port': 9153}]
None kube-system kube-state-metrics 10.96.84.34 [{'app_protocol': None,
'name': 'http-metrics',
'node_port': None,
'port': 8080,
'protocol': 'TCP',
'target_port': 'http-metrics'}, {'app_protocol': None,
'name': 'telemetry',
'node_port': None,
'port': 8081,
'protocol': 'TCP',
'target_port': 'telemetry'}]
None kube-system metrics-server 10.96.177.218 [{'app_protocol': None,
'name': None,
'node_port': None,
'port': 443,
'protocol': 'TCP',
'target_port': 443}]
None kube-system monitoring-grafana 10.96.239.33 [{'app_protocol': None,
'name': None,
'node_port': 31996,
'port': 80,
'protocol': 'TCP',
'target_port': 3000}]
None kube-system node-exporter None [{'app_protocol': None,
'name': 'metrics',
'node_port': None,
'port': 9100,
'protocol': 'TCP',
'target_port': 9100}]
None kube-system prometheus 10.96.215.254 [{'app_protocol': None,
'name': 'http',
'node_port': 30090,
'port': 9090,
'protocol': 'TCP',
'target_port': 9090}]
Process finished with exit code 0
这里我们访问k8s的API成功,其他API接口可参考官方文档实现:文章来源:https://www.toymoban.com/news/detail-458652.html
Kubernetes API | Kubernetes文章来源地址https://www.toymoban.com/news/detail-458652.html
到了这里,关于k8s之API接口访问的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!