I have 3 applications.
A Gateway, ServiceA & ServiceB.
Each application sits in its own namespace. Whenever there is a push to the CI/CD server on one of the all the 3. All get deployed based on the branch name.
Example:
feature-1 branch with a unique service name to the Kubernetes cluster.feature-1 if not found defaults to develop. For the gateway it creates a feature-1 from develop and deploys that one.feature-1 in order to be able to call it.So my question is how to do service discovery on the application lvl using kubernetes?
I think there are two ways to achieve that.
1) Query all services from Kubernetes master, with the API equivalent of kubectl get services --all-namespaces. Then you will ned to configure some logic for choosing the right service. For this you can use for example Selector, targetPort or specify ClusterIP. More details can be find in documentation.
2) Put application built from each branch in a new namespace, and let them route within the namespace to their usual names, without requiring any application changes. More information in documentation.