I have local and dockerized apps which are working excelent on localhost : java backend at 8080, angular at 4200, activemq at 8161, and postgres on 5432 Now,I am trying also to kubernetize apps to make them work on localhosts. As far as I know kubernetes provides random Ip on clusters, what should I do do make them work on localhosts to listen to each other ? Is there any way to make them automatically start at those localhosts instead of using port forwariding for each service ? Every service and deployment has similiar structure :
apiVersion: v1 kind: Service metadata: name: backend spec: selector: app: backend type: LoadBalancer ports: - protocol: 8080 port: 8080 targetPort: 8080
Deployment apiVersion: apps/v1 kind: Deployment metadata: name: backend labels: app: backend spec: replicas: 3 selector: matchLabels: app: backend template: metadata: labels: app: backend spec: containers: - name: backend image: ports: - containerPort: 8080
Tried port-forwarding, works, but requires lot of manual work ( open few new powershell windows and then do manual port forwarding)
CodePudding user response:
In the kubernetes eco system apps talk to each other through their services. If they are in the same namespace they can directly go to the service name of not they need to specify the full name which includes the namespace name: my-svc.my-namespace.svc.cluster-domain.example
CodePudding user response:
Never mind, find a way to do it automaticaly with port - forwarding, with simply running 1 script I have wrote a .bat script with these steps:
- kubernetes run all deployments file
- kubernetes run all services file
- 15 second timeout to give time to change pod state from pending to running
- { do port forwarding for each service. Every forwarding is in new powershell windows without exiting }