Using a MutatingWebhook/sidecar injection, I'm trying to add a container to my Kubernetes deployment when it is created. I understand that I have to make a JSON patch, but I'm unclear on the syntax that I need to use to add a container. (I've successfully added labels to the deployment, FWIW.)
I know that JSON patch object looks something like this, but I'm unclear about what to put in the "value" field.
}
"op": "add",
"path": "/spec/containers",
"value": "containerName",
}
Here's an example of one of the error messages I get that indicates that something with my syntax is incorrect.
Error creating: Internal error occurred: Internal error occurred: v1.Pod.Spec: v1.PodSpec.Containers: []v1.Container: readObjectStart: expect { or n, but found ", error found in #10 byte of ...|160000}},"{\"name\":|..., bigger context ...|OD","SETGID","SETUID"]},"runAsUser":1000160000}},"{\"name\":\"fluentd\"}"],"dnsPolicy":"ClusterFirst|...