I'd like to create a copy of a k8s pod on the fly, and patch it with some custom configurations.
Unfortunately, I don't really know where to start from...
my-service
- kustomization.yaml
- deployment.yaml
And then
kubectl apply -k ./path/to/my-service --override `{ "image": "foo-1", "name": "foo-1" }`
the override I am talking about should supply dynamic informations to the deployment, such as info I only have at build time, etc.
A.C
- [ ] The original
my-service
pod should not be changed, the on-the-fly-deployment should create a new, ephemeral, pod. - [ ] The new ephemeral pod should have all the informations from the
original
You could use a simple base and overlay:
my-service/base/kustomization.yml
:If you don't need a specific name for the ephemeral deployment:
my-service/overlays/ephemeral/kustomization.yml
:If you need a specific name you will have to patch the name in
my-service/overlays/ephemeral/kustomization.yml
. You can then run:To be clear, this will create two deployments: the original and one deployment of a single pod. Not one deployment and one lone pod.