configmaps created via `kubectl apply` may have annotations that are too large: use `create` and `delete/create`
K8s resources created via kubectl apply automatically have annotations attached; in the case of a configmap, this annotation contains the full data as json, and may easily be larger than the annotation size limit of 256k, resulting in kubectl apply failing with:
The ConfigMap "my-config" is invalid: metadata.annotations: Too long: must have atmost 262144 characters
configmaps created via kubectl create don't get this same annotation. Tilt should consider using kubectl create (and to update, kubectl delete && kubectl create) instead of apply for configmaps.
@npuc85 has already run into the problem of having a configmap that is too large to fit in its own annotations (i.e. to be created with kubectl apply), but works fine with kubectl create.
A replace or create approach may also work. Use kubectl create if it does not exist, use kubectl replace if it does exist (instead of delete/create).
It could potentially be done at once: kubectl replace -f configmap.yaml || kubectl create configmap -f configmap.yaml
replace, or delete/create, either way is fine as long as Tilt is able to detect changes, update the configmap, and not blow up from 256k annotation size.
Our kubectl apply code already has a fallback mechanism to try to figure out if it should try to use kubectl replace instead. Maybe we could try to use the same strategy here? https://github.com/windmilleng/tilt/blob/master/internal/k8s/client.go#L285