Add support for annotations and labels in spec. (#739)
All checks were successful
Lint Checks / Run linter (push) Successful in 30s
Publish / Build and publish (push) Successful in 1m36s
Webapp Test / Run webapp test suite (push) Successful in 2m38s
Deploy Test / Run deploy test suite (push) Successful in 3m58s
Smoke Test / Run basic test suite (push) Successful in 4m50s
Lint Checks / Run linter (pull_request) Successful in 51s
Webapp Test / Run webapp test suite (pull_request) Successful in 3m12s
Smoke Test / Run basic test suite (pull_request) Successful in 3m36s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m40s
All checks were successful
Lint Checks / Run linter (push) Successful in 30s
Publish / Build and publish (push) Successful in 1m36s
Webapp Test / Run webapp test suite (push) Successful in 2m38s
Deploy Test / Run deploy test suite (push) Successful in 3m58s
Smoke Test / Run basic test suite (push) Successful in 4m50s
Lint Checks / Run linter (pull_request) Successful in 51s
Webapp Test / Run webapp test suite (pull_request) Successful in 3m12s
Smoke Test / Run basic test suite (pull_request) Successful in 3m36s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m40s
``` stack: webapp-deployer-backend deploy-to: k8s annotations: foo.bar.annot/{name}: baz labels: a.b.c/{name}.blah: "value" ``` Reviewed-on: #739 Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com> Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
This commit is contained in:
parent
72ed2eb91a
commit
903f3b10e2
@ -281,13 +281,37 @@ class ClusterInfo:
|
||||
env=envs,
|
||||
ports=[client.V1ContainerPort(container_port=port)],
|
||||
volume_mounts=volume_mounts,
|
||||
security_context=client.V1SecurityContext(
|
||||
privileged=self.spec.get_privileged(),
|
||||
capabilities=client.V1Capabilities(
|
||||
add=self.spec.get_capabilities()
|
||||
) if self.spec.get_capabilities() else None
|
||||
),
|
||||
resources=to_k8s_resource_requirements(resources),
|
||||
)
|
||||
containers.append(container)
|
||||
volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name)
|
||||
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(
|
||||
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.V1DeploymentSpec(
|
||||
|
@ -106,3 +106,15 @@ class Spec:
|
||||
if self.obj and constants.network_key in self.obj
|
||||
and constants.http_proxy_key in self.obj[constants.network_key]
|
||||
else None)
|
||||
|
||||
def get_annotations(self):
|
||||
return self.obj.get("annotations", {})
|
||||
|
||||
def get_labels(self):
|
||||
return self.obj.get("labels", {})
|
||||
|
||||
def get_privileged(self):
|
||||
return "true" == str(self.obj.get("security", {}).get("privileged", "false")).lower()
|
||||
|
||||
def get_capabilities(self):
|
||||
return self.obj.get("security", {}).get("capabilities", [])
|
||||
|
@ -147,6 +147,7 @@ def command(ctx, laconic_config, deployment_parent_dir,
|
||||
|
||||
previous_requests = load_known_requests(state_file)
|
||||
requests.sort(key=lambda r: r.createTime)
|
||||
requests.reverse()
|
||||
|
||||
# Find deployments.
|
||||
deployments = {}
|
||||
|
Loading…
Reference in New Issue
Block a user