I'm trying to migrate applications based on the Netflix OSS to Kubernetes so the ideal way I found was to create a service of type NodePort and register the applications to Eureka. So i'm doing eureka.hostname=hostIP and eureka.nonSecurePort=nodePort
Here's what I've done -
Create a service for sample-app-service with service type NodePort.
Inject the nodeport in to a ConfigMap by running the command kubectl create configmap saas-event-reception-config --from-literal=nodePort=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services sample-app-service) (Question: Is there a way I can specify this as a yaml?)
Refer the nodePort using the configMapKeyRef in the deployment yaml.
The problem I'm facing is during the automated deployment. So ideally I'd like deploy the application using a single deployment file which includes Service, ConfigMap and Deployment. Is there a way I can do this gracefully? Or are there any alternate suggestion for doing this.
I'm also looking at helm but even if I use --set to pass the nodePort to ConfigMap by running the command (kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services sample-app-service) the Service has to be deployed first so that the ConfigMap gets the nodePort value. Is there a way I can do this?
What you can do is to specify a port from the service-node-port-range (by default 30000-32767) in your Service yaml file under ports
with the name nodePort
. Then you'll know the nodePort in advance. You could use helm to pass in the nodePort to use as a parameter so that this parameter is used in the Service yaml and also your ConfigMap and Deployment.