get deploy
parent
ad891381fd
commit
7a7d53bffe
|
@ -1,5 +1,5 @@
|
|||
'''
|
||||
导出线上deployment + svc 配置
|
||||
导出deployment + svc 配置信息
|
||||
'''
|
||||
from kubernetes import client, config
|
||||
import os
|
||||
|
@ -45,14 +45,22 @@ def sanitize(obj):
|
|||
del obj_yaml['status']
|
||||
if 'managedFields' in obj_yaml['metadata']:
|
||||
del obj_yaml['metadata']['managedFields']
|
||||
|
||||
# 移除strategy字段
|
||||
if 'strategy' in obj_yaml['spec']:
|
||||
del obj_yaml['spec']['strategy']
|
||||
|
||||
# 清空 annotations 和 labels 字段
|
||||
obj_yaml['metadata'].setdefault('annotations', {})
|
||||
obj_yaml['metadata'].setdefault('labels', {})
|
||||
|
||||
# 移除 deployment.kubernetes.io/revision 注解
|
||||
# 移除不需要的注解
|
||||
if 'deployment.kubernetes.io/revision' in obj_yaml['metadata']['annotations']:
|
||||
del obj_yaml['metadata']['annotations']['deployment.kubernetes.io/revision']
|
||||
if 'kubectl.kubernetes.io/restartedAt' in obj_yaml['metadata']['annotations']:
|
||||
del obj_yaml['metadata']['annotations']['kubectl.kubernetes.io/restartedAt']
|
||||
if 'kubectl.kubernetes.io/last-applied-configuration' in obj_yaml['metadata']['annotations']:
|
||||
del obj_yaml['metadata']['annotations']['kubectl.kubernetes.io/last-applied-configuration']
|
||||
|
||||
return obj_yaml
|
||||
|
||||
|
|
Loading…
Reference in New Issue