I am trying to create an architecture where every deployment deploys with a cluster IP and the rule get automatically added to the ingress rule as a new path.
My initial thinking was to give the Deployment
a ServiceAccount
that has access to manage ingress rule and before the main pod would run, an init container would fetch the YAML and add the ruleset, while deleting maybe delete that as well?
But the more I think about it, more loopholes start coming to mind. For eg: What happens when 2 Deployment
's start at the same time?
and things like that.
Any idea on how to tackle this would be appreciated.
My background: I am a cloud engineer trying to shift to DevOps, have beginner-intermediate level knowledge of Kubernetes.
CodePudding user response:
I am trying to create an architecture where every deployment deploys with a cluster IP and the rule gets automatically added to the ingress rule as a new path.
Few options:
Init container (You figured this one out and mentioned it in your question)
- ADd init container to your Deployment which will add the desired rule to your Ingress
Probes
- Add a post-start probe which will be executed once your pod is running and kicking will update the Ingress rules
CronJob
- Add a CronJob which will "scan" for changes and will update the Ingress again