简体   繁体   中英

kubernetes apps avalaible on localhost

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 kube.netize apps to make them work on localhosts. As far as I know kube.netes 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)

In the kube.netes 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

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:

  1. kube.netes run all deployments file
  2. kube.netes run all services file
  3. 15 second timeout to give time to change pod state from pending to running
  4. { do port forwarding for each service. Every forwarding is in new powershell windows without exiting }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM