简体   繁体   English

没有负载平衡器的暴露容器

[英]Exposing containers without a load balancer

I'm aiming to deploy a small test application to GCE. 我的目标是将一个小型测试应用程序部署到GCE。 Every guide I've read seems to point to using a LoadBalancer service to expose the pod to the internet. 我阅读的每本指南似乎都指向使用LoadBalancer服务将Pod公开到互联网。 Unfortunately, this comes with a high associated cost and I'd like to be able to expose the containers without creating a load balancer (or using HAProxy / nginx to roll our own). 不幸的是,这带来了很高的相关成本,我希望能够在不创建负载平衡器(或使用HAProxy / nginx自己滚动)的情况下公开容器。

Is it possible to do so? 有可能这样做吗? If so, what are the steps I need to take and possible other associated costs? 如果是这样,我需要采取什么步骤以及可能产生的其他相关费用?

Thanks! 谢谢!

You can do that by choosing a NodePort as the service type. 您可以通过选择NodePort作为服务类型来实现。

apiVersion: v1
kind: Service
metadata: 
  name: myapp-servoce
  labels: 
    name: myapp
    context: mycontext
spec: 
  type: NodePort
  ports:
    # the port that this service should serve on
    - port: 8080
  # label keys and values that must match in order to receive traffic for this service
  selector: 
    name: myapp
    context: mycontext

This would expose that service on port 8080 of each node of the cluster. 这将在群集的每个节点的端口8080上公开该服务。 Now all of your nodes would have externally accessible IP address and you can use the same for testing 现在,您所有的节点都将具有外部可访问的IP地址,您可以将其用于测试

The NGINX ingress controller found at https://github.com/kubernetes/ingress/tree/master/controllers/nginx should satisfy your cost saving requirement. https://github.com/kubernetes/ingress/tree/master/controllers/nginx上找到的NGINX入口控制器应满足您的成本节省要求。 I would not consider this "rolling your own" as this lives beside the GLBC ingress controller. 我不认为这是“自己动手”,因为它位于GLBC入口控制器旁边。

There should be sufficient documentation to satisfy your installation requirements and if there's not please open an issue on https://github.com/kubernetes/ingress 应该有足够的文档来满足您的安装要求,如果没有,请在https://github.com/kubernetes/ingress上打开一个问题

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

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