无法在互联网上访问AWS上暴露的k8s服务
我在我的AWS ECR上有一个名为hello-node的图像(在post底部有描述)。 如果我在本地运行它并转到localhost:8080我看到“hello world”。
在AWS上我的节点上运行:
kubectl run hello-node --image=xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/hello-node:v1 --port=8080
(帐号被屏蔽)
然后:
kubectl expose deployment hello-node --type="LoadBalancer"
如果我运行:
kubectl describe service hello-node
我看到(信息编辑)
Name: hello-node Namespace: default Labels: run=hello-node Annotations: <none> Selector: run=hello-node Type: LoadBalancer IP: xx.xx.xx.xx LoadBalancer Ingress: xxxxxxxxx-xxxxxx.us-east-1.elb.amazonaws.com Port: <unset> 8080/TCP NodePort: <unset> 32059/TCP Endpoints: xx.xx.xx.xx:8080 Session Affinity: None
我想在线访问我的hello-node服务。 我想在浏览器中访问一些url或IP地址,看看“hello world”。
我试过去上面列出的IP,LoadBalancer Ingress和Endpoints,但是这些站点不会在我的浏览器中加载。 我怎样才能在互联网上访问这项服务? 如果需要,我会提供更多信息。
注意:如果我做kubectl port-forward hello-node-621867969-ztxnr 8080
那么我可以在我的机器上的localhost:8080上访问它,所以至less有一些工作正在进行。
hello-node服务:
在“创build应用程序,将其打包到容器中并发布到Dockerregistry”部分下的源代码
server.js:
var http = require('http'); var handleRequest = function(request, response) { response.writeHead(200); response.end("Hello World!"); } var www = http.createServer(handleRequest); www.listen(8080);
Dockerfile:
FROM node:6.9.2 EXPOSE 8080 COPY server.js . CMD node server.js
运行docker build -t hello-node:v1 .
运行docker tag hello-node:v1 AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/hello-node:v1
运行docker push AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/hello-node:v1
(把我的帐户和区域信息,我确认它上传到我的ECR)
然后我运行了本文kubectl
列出的两个kubectl
命令。
我可以通过<loadbalanceringress>:<port>
访问它。 我真的不记得,如果我已经尝试了或不(我尝试了很多地址:端口组合。