Add annotations to spec
This commit is contained in:
parent
72ed2eb91a
commit
d1395d3181
@ -266,7 +266,7 @@ class ClusterInfo:
|
|||||||
merged_envs = merge_envs(
|
merged_envs = merge_envs(
|
||||||
envs_from_compose_file(
|
envs_from_compose_file(
|
||||||
service_info["environment"]), self.environment_variables.map
|
service_info["environment"]), self.environment_variables.map
|
||||||
) if "environment" in service_info else self.environment_variables.map
|
) if "environment" in service_info else self.environment_variables.map
|
||||||
envs = envs_from_environment_variables_map(merged_envs)
|
envs = envs_from_environment_variables_map(merged_envs)
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print(f"Merged envs: {envs}")
|
print(f"Merged envs: {envs}")
|
||||||
@ -286,8 +286,26 @@ class ClusterInfo:
|
|||||||
containers.append(container)
|
containers.append(container)
|
||||||
volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name)
|
volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name)
|
||||||
image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")]
|
image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")]
|
||||||
|
|
||||||
|
annotations = None
|
||||||
|
labels = {"app": self.app_name}
|
||||||
|
|
||||||
|
if self.spec.get_annotations():
|
||||||
|
annotations = {}
|
||||||
|
for key, value in self.spec.get_annotations().items():
|
||||||
|
for service_name in services:
|
||||||
|
annotations[key.replace("{name}", service_name)] = value
|
||||||
|
|
||||||
|
if self.spec.get_labels():
|
||||||
|
for key, value in self.spec.get_labels().items():
|
||||||
|
for service_name in services:
|
||||||
|
labels[key.replace("{name}", service_name)] = value
|
||||||
|
|
||||||
template = client.V1PodTemplateSpec(
|
template = client.V1PodTemplateSpec(
|
||||||
metadata=client.V1ObjectMeta(labels={"app": self.app_name}),
|
metadata=client.V1ObjectMeta(
|
||||||
|
annotations=annotations,
|
||||||
|
labels=labels
|
||||||
|
),
|
||||||
spec=client.V1PodSpec(containers=containers, image_pull_secrets=image_pull_secrets, volumes=volumes),
|
spec=client.V1PodSpec(containers=containers, image_pull_secrets=image_pull_secrets, volumes=volumes),
|
||||||
)
|
)
|
||||||
spec = client.V1DeploymentSpec(
|
spec = client.V1DeploymentSpec(
|
||||||
|
@ -106,3 +106,9 @@ class Spec:
|
|||||||
if self.obj and constants.network_key in self.obj
|
if self.obj and constants.network_key in self.obj
|
||||||
and constants.http_proxy_key in self.obj[constants.network_key]
|
and constants.http_proxy_key in self.obj[constants.network_key]
|
||||||
else None)
|
else None)
|
||||||
|
|
||||||
|
def get_annotations(self):
|
||||||
|
return self.obj.get("annotations", {})
|
||||||
|
|
||||||
|
def get_labels(self):
|
||||||
|
return self.obj.get("annotations", {})
|
||||||
|
Loading…
Reference in New Issue
Block a user