https://pulumi.com logo
Title
c

clean-engineer-75963

10/04/2019, 11:18 PM
I've noticed in two cases today that typos in my Kubernetes configuration have just silently omitted the misconfigured part of the spec, instead of warning or erroring on
pulumi up
.
First, in a pod spec, I had the following for an env var:
{
                                "name": "VAULT_REDIRECT_ADDR",
                                "valueFrom:": {
                                    "configMapKeyRef": {
                                        "name": "config",
                                        "key": "vault-addr",
                                    }
                                },
                            },
Notice that there's an extra colon in
"valueFrom:"
just a silly typo.
pulumi up
worked fine, and what I ended up with was an empty env var in my pod.
spec:
  containers:
  - env:
    - name: VAULT_REDIRECT_ADDR
Like that.
The other case was me trying to abstract a pod spec
affinity
statement out into a function.
def self_antiaffinity(namespace, component):
    """Returns a pod spec affinity block specifying antiaffinity with other pods
    with this component."""

    return {
        "affinity": {
            "podAntiAffinity": {
                "requiredDuringSchedulingIgnoredDuringExecution": [
                    {
                        "labelSelector": {
                            "matchExpressions": [
                                {
                                    "key": "component",
                                    "operator": "In",
                                    "values": [
                                        component,
                                    ],
                                },
                            ],
                        },
                        "namespaces": [
                            namespace,
                        ],
                        "topologyKey": "<http://kubernetes.io/hostname|kubernetes.io/hostname>",
                    },
                ],
            },
        }
    }
And then I use it in my spec like so:
vault_deployment = appsv1.Deployment(
    "vault",
    spec={
        "affinity": self_antiaffinity(namespace, "vault")
    }
)
The mistake I've made here is that there's an extra
"affinity"
key, so I end up with nested
{"affinity": {"affinity": ...}}
, which is incorrect.
But again,
pulumi up
worked, and what I actually got in my spec was
affinity: {}
.
c

creamy-potato-29402

10/04/2019, 11:24 PM
@clean-engineer-75963 the API server, bizarrely, does not reject certain classes of errors, like this
I’m not sure why. It’s very odd indeeed.
we depend on it to do the validation, and over time I’ve just kind of hoped they fix this, but they haven’t.
c

clean-engineer-75963

10/04/2019, 11:25 PM
Okay. Thanks for clarifying.
c

creamy-potato-29402

10/04/2019, 11:25 PM
I’m not entirely sure, yet, how we’d fix this downstream
If you use TypeScript, this is “solved” by the fact that TS types don’t allow you to have random extra fields,
For Python there might not be a good answer