https://pulumi.com logo
#python
Title
# python
l

little-river-49422

04/02/2019, 7:58 AM
hey folks, found something that looks weird. when using reference to configmap thats being created by pulumi when creating job it fails with:
Copy code
Plan apply failed: Job.batch "dbseed" is invalid: spec.template.spec.containers[0].envFrom[0].configMapRef.name: Invalid value: "develop/baseconfigmap-wwykveez": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. '<http://example.com|example.com>', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
which doesnt make a lot of sense. develop - is the namespace, everything after
/
is real configmap name. this works for deployments, but not for jobs? I can work around with this bad boy:
Copy code
config_map.metadata.apply(
    lambda metadata: metadata['name'].split('/')[-1]
)
but this doesnt look right
i

incalculable-sundown-82514

04/02/2019, 5:20 PM
I’m not sure, is this a Kubernetes thing? enforcing the names of a subdomain?
g

gorgeous-egg-16927

04/02/2019, 5:24 PM
Yeah, that error is coming from the k8s API server.
l

little-river-49422

04/02/2019, 8:48 PM
yeah, but the same works for deployments
so i think pulumi is doing some processing on configmap name
i

incalculable-sundown-82514

04/02/2019, 8:54 PM
it is, but it’s not putting the slash in there I don’t think, which I think is what kubernetes is complaining about
it’s putting the random suffix on the end
what’s the code that creates this job?
l

little-river-49422

04/02/2019, 8:57 PM
hm, interesting. i noticed something, let me check
i've noticed i'm doing this for deployments:
Copy code
config_map_name = config_map.metadata.apply(lambda resource: resource['name'])
i think this worked for job as well
just passing config_map didnt work
yeah, i think its working like this
sorry for bothering
i

incalculable-sundown-82514

04/02/2019, 9:05 PM
No worries! You can also write
Copy code
config_map.metadata["name"]
instead of doing the explicit apply here, this is just some syntax sugar on top of what you’re doing
3 Views