我一直在研究一个简单的Node.js应用程序,该应用程序使用Istio来设置和获取来自etcd的密钥以将两个服务连接在一起。我尝试了一些变化,但一直看到同样的错误。
nodeAppTesting失败(etcd-operator) - > {"错误":[{"服务器":" http://etcd-operator:2379",&# 34; httperror":null," httpstatus":503," httpbody":"上游连接错误或断开/重置在标题之前","响应":{" statusCode":503,"正文":"上游连接错误或断开/重置之前标题","标题&#34 ;:{"内容长度":" 57""内容类型":" text / plain的""日期& #34;:"星期四,08六月2017 17:17:04 GMT","服务器":" envoy"," x-envoy-upstream -service时间":" 5"}"请求" {" URI" {"协议":&#34 ; HTTP:""斜线":真," AUTH":空,"主机":" ETCD运算符:2379&#34 ;,"端口":" 2379""主机名":" ETCD-操作""散列":空"搜索":空,"查询":空,"路径名":" / V2 /键/密押""路径":" / V2 /键/密押"" HREF&#34 ;: " http://etcd-operator:2379/v2/keys/testKey"}"方法":" GET""头" {"接受&#34 ;:"应用/ JSON"}}}"时间戳":" 2017-06-08T17:17:04.544Z"}],"&重试#34;:0}
查看代理日志,我可以看到通信中涉及客户端和服务器代理(这在我看到服务器头中的envoy时已经过验证。)
附加Node.js应用程序和deployment.yaml。 的 server.js
var http = require('http');
var Etcd = require('node-etcd');
var fs = require('fs');
var httpClient = require('request');
var handleRequest = function(request, response) {
var scheme = "http";
var ipAddress = "etcd-operator"
var port = "2379";
var connectionAddress = scheme +"://" + ipAddress +":" + port;
console.log('Received request for URL: ' + request.url + " connecting to " + connectionAddress);
var etcd = new Etcd([connectionAddress] /*, options */);
etcd.set("testKey" , "foo");
etcd.get("testKey", function(err, res){
if(!err){
response.writeHead(200);
response.write("nodeAppTesting("+ ipAddress+") ->"+ JSON.stringify(res) ) ;
response.end();
}else{
response.writeHead(500);
response.write("nodeAppTesting failed("+ ipAddress+") ->"+ JSON.stringify(err) ) ;
console.log("Encountered error during runtime", JSON.stringify(err));
response.end();
}
});
}
var www = http.createServer(handleRequest);
www.listen(8080);
console.log("App up and running on port 8080")
deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: etcd-node
labels:
app: etcd-node
spec:
ports:
- port: 8080
name: http
selector:
app: etcd-node
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: etcd-node-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: etcd-node
spec:
containers:
- name: etcd-node
image: todkap/etcd-node:v1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
---
##################################################################################################
# etcd service
##################################################################################################
apiVersion: v1
kind: Service
metadata:
name: etcd-operator
labels:
app: etcd-operator
spec:
ports:
- port: 2379
targetPort: 2379
name: http
selector:
app: etcd-operator
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: etcd-operator
spec:
replicas: 1
template:
metadata:
labels:
name: etcd-operator
app: etcd-operator
version: v1
spec:
containers:
- name: etcd-operator
image: quay.io/coreos/etcd-operator:v0.2.6
imagePullPolicy: IfNotPresent
env:
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- containerPort: 2379
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gateway2
annotations:
kubernetes.io/ingress.class: "istio"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: etcd-node
servicePort: 8080
- http:
paths:
- path: /
backend:
serviceName: etcd-operator
servicePort: 2379
- path: /v2/keys/*
backend:
serviceName: etcd-operator
servicePort: 2379
---
答案 0 :(得分:1)
我能够解决此处报告的问题。我将在本周的某个时候发布展示流程的食谱。目前,我们可以认为这是封闭的。将来,我将转到论坛或发布问题。请留意这篇文章(如果有的话,我会用链接更新这篇文章)。 感谢您的帮助,指导和建议。
主要问题是引用etcd服务的一致性,将我的节点应用程序引用为Deployment,Service和Ingress的一致性,然后最终暴露NodePort。
<强>更新强>
答案 1 :(得分:0)
对于https://groups.google.com/forum/#!forum/istio-users或https://github.com/istio/issues/issues
,这可能是一个更好的问题但看起来你的应用程序没有启动 - 你能查一下吗?
kubectl get pods
并且看不到任何内容仍在审理中?