average-jelly-41765
05/29/2024, 1:26 PMmodern-zebra-45309
05/29/2024, 1:55 PMaverage-jelly-41765
05/30/2024, 7:48 AM<name>.<namespace>.svc.cluster.local
, we want to structure our IaC so as to not have global logic around namings and rather expect sub components to expose this information in their objectsmodern-zebra-45309
05/30/2024, 8:03 AMimport pulumi
import pulumi_kubernetes as k8s
service_name = "my-service" # define a 'programming-language-native' variable (or config value)
service_namespace = k8s.core.v1.Namespace(...)
policy = some.Policy("my-policy-resource",
env_vars={"SERVICE_HOST": pulumi.Output.concat(service_name, ".", service_namespace.metadata.name, ".svc.cluster.local")} # use variable to assemble the FQDN
...)
deployment = k8s.apps.v1.Deployment("my-deployment-resource",
# reference policy here
...)
service = k8s.core.v1.Service("my-service-resource",
metadata=k8s.meta.v1.ObjectMetaArgs(name=service_name, namespace=service_namespace.metadata.name), # use variable to set service name
...)
Curious to see if there are other/better patterns for this 🙂miniature-leather-70472
05/30/2024, 1:08 PM