简体   繁体   English

本地主机上可用的 kube.netes 应用程序

[英]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.我有本地和 dockerized 应用程序,它们在本地主机上运行良好:8080 处的后端 java、4200 处的 angular、8161 处的 activemq 和 5432 处的 postgres 现在,我也在尝试 kube.netize 应用程序以使其在本地主机上运行。 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?据我所知,kube.netes 在集群上提供了随机 Ip,我应该怎么做才能让它们在本地主机上工作以相互倾听? 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 apiVersion: v1 kind: Service metadata: name: backend spec: selector: app: backend type: LoadBalancer ports: - 协议:8080 端口: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部署 apiVersion:apps/v1 kind:部署元数据:名称:后端标签:app:后端规范:副本:3 选择器:matchLabels:app:后端模板:元数据:标签:app:后端规范:容器:-名称:后端图像:端口:-容器端口:8080

Tried port-forwarding, works, but requires lot of manual work ( open few new powershell windows and then do manual port forwarding)尝试端口转发,工作,但需要大量手动工作(打开几个新的 powershell windows 然后进行手动端口转发)

In the kube.netes eco system apps talk to each other through their services.在 kube.netes 生态系统中,应用程序通过它们的服务相互通信。 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如果他们在同一个命名空间中,他们可以直接 go 到服务名称,而不是他们需要指定包括命名空间名称的全名: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 个脚本我已经使用以下步骤编写了一个 .bat 脚本:

  1. kube.netes run all deployments file kube.netes 运行所有部署文件
  2. kube.netes run all services file kube.netes 运行所有服务文件
  3. 15 second timeout to give time to change pod state from pending to running 15 秒超时,以便有时间将 pod state 从挂起更改为运行
  4. { do port forwarding for each service. { 为每个服务做端口转发。 Every forwarding is in new powershell windows without exiting }每次转发都是new powershell windows 不退出}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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