You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from kubernetes import client, config
|
|
|
|
config.load_kube_config("/app/config")
|
|
apps_v1 = client.AppsV1Api()
|
|
|
|
core_v1 = client.CoreV1Api()
|
|
|
|
|
|
def list_deployment(ns):
|
|
image_list = []
|
|
deploy_list = apps_v1.list_namespaced_deployment(namespace=ns).items
|
|
for item in deploy_list:
|
|
if item.spec.template.spec.containers[0].image.startswith('repository.anxinyun.cn'):
|
|
project_image = get_project(item.spec.template.spec.containers[0].image)
|
|
image_tag = get_image_tag(project_image[2])
|
|
image_list.append({'project': project_image[1], 'name': image_tag[0], 'tag': image_tag[1]})
|
|
return image_list
|
|
|
|
|
|
def get_project(image_url):
|
|
return image_url.split("/")
|
|
|
|
|
|
def get_image_tag(image):
|
|
return image.split(":")
|
|
|
|
|
|
def list_node():
|
|
nodes = core_v1.list_node()
|
|
for node in nodes.items:
|
|
print(node.metadata.name)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
list_deployment()
|
|
# print(get_project('repository.anxinyun.cn/anxinyun/actionview-dashboard:11.21-12-09'))
|
|
|