[英]Exposing kubernetes service using elastic ip address on aws
I'm trying to figure out how to run openvpn server running inside a pod using UDP protocol. 我试图弄清楚如何使用UDP协议运行在pod内运行的openvpn服务器。
Since it's easier to test using http than openvpn connections, I have also nginx-container running inside that same pod as openvpn-container is. 因为使用http比openvpn连接更容易测试,所以我也在openvpn-container的同一个pod内运行nginx-container。
I can get everything working inside the cluster but I cannot expose this nginx service to Internet using my elastic ip. 我可以在集群内部完成所有工作但我无法使用弹性IP将此nginx服务暴露给Internet。
Network is Weave. 网络是Weave。
Kubernetes version is 1.6 Kubernetes版本是1.6
I have set the externalIPs-field in the service.yaml to my elastic ip address. 我已将service.yaml中的externalIPs-field设置为弹性ip地址。 I cannot use type LoadBalancer since my protocol is UDP. 我不能使用类型LoadBalancer,因为我的协议是UDP。
Service: 服务:
# kubectl describe service openvpn
Name: openvpn
Namespace: default
Labels: name=openvpn
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"name":"openvpn"},"name":"openvpn","namespace":"default"},"spec":{"externalI...
Selector: name=openvpn
Type: NodePort
IP: 100.71.93.74
External IPs: <my_elastic_ip>
Port: openvpn 1194/UDP
NodePort: openvpn 30726/UDP
Endpoints: 100.120.0.1:1194
Port: http 80/TCP
NodePort: http 30000/TCP
Endpoints: 100.120.0.1:80
Session Affinity: None
Events: <none>
Endpoints 端点
# kubectl get endpoints openvpn
NAME ENDPOINTS AGE
openvpn 100.120.0.1:80,100.120.0.1:1194 20h
I have followed through the https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/ and everything works inside the cluster. 我已经跟进了https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/ ,一切都在集群内部运行。
I have allocated the elastic ip to this specific instance manually using AWS Console. 我已使用AWS Console手动将弹性IP分配给此特定实例。 All security groups are updated. 所有安全组都会更新。
So is it even possible to connect to a pod inside a kubernetes cluster using a elastic ip attached to that host node? 那么甚至可以使用连接到该主机节点的弹性IP连接到kubernetes集群内的pod? If it is, how to do that? 如果是,怎么做?
Rather than use an IP address you could get K8S to use the type: LoadBalancer
which will setup a Classic AWS ELB. 您可以让K8S使用类型: LoadBalancer
来设置Classic AWS ELB,而不是使用IP地址。 From there you could CNAME a domain / sub-domain to the ELB and access the service that way? 从那里你可以CNAME域/子域到ELB并以这种方式访问服务?
A quick example: 一个简单的例子:
apiVersion: v1
kind: Service
metadata:
name: MyApp
labels:
app: MyApp
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
name: MyApp
selector:
app: MyApp
You can try NodePort
type. 您可以尝试NodePort
类型。 With the following then you can access the service via <node-ip>:30080
通过以下内容,您可以通过<node-ip>:30080
访问该服务
apiVersion: v1
kind: Service
metadata:
labels:
app: app
name: app-service
namespace: default
spec:
ports:
- name: ext
nodePort: 30080
protocol: UDP
port: 80
selector:
app: app
type: NodePort
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.