1

我一直在开发一个简单的 Node.js 应用程序,该应用程序使用 Istio 从 etcd 中设置和获取密钥以将两个服务连接在一起。我尝试了一些变体,但仍然看到返回相同的错误。

nodeAppTesting failed(etcd-operator) ->{"errors":[{"server":" http://etcd-operator:2379 ","httperror":null,"httpstatus":503,"httpbody":"upstream连接错误或在 headers 之前断开/重置","re​​sponse":{"statusCode":503,"body":"上游连接错误或在 headers 之前断开/重置","headers":{"content-length":"57 ","content-type":"text/plain","date":"Thu, 08 Jun 2017 17:17:04 GMT","server":"envoy","x-envoy-upstream-service-time ":"5"},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"etcd-operator:2379","port":"2379","hostname":"etcd-operator","hash":null,"search":null,"query":null,"pathname":"/v2/keys/testKey ","路径":"/v2/keys/testKey","href":" http://etcd-operator:2379/v2/keys/testKey"},"method":"GET","headers":{"accept":"application/json"}}},"timestamp":"2017-06-08T17:17:04.544Z"}],"重试“:0}

查看代理日志,我可以看到客户端和服务器代理参与了通信(我认为在服务器标头中看到 envoy 时验证了这一点)。

附加 Node.js 应用程序和 deployment.yaml。 服务器.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")

部署.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

---
4

2 回答 2

2

我能够解决这里报告的问题。我将在本周的某个时候发布一个展示流程的食谱。目前,我们可以认为这是关闭的。将来,我将转到论坛或发布问题。请留意这篇文章(我将在可用时使用链接更新这篇文章)。感谢您的帮助、指导和建议。

主要问题是引用 etcd 服务的一致性,将我的节点应用程序引用为 Deployment、Service 和 Ingress 的一致性,最后是公开 NodePort。

更新

发表了一篇文章演示了工作流程。

于 2017-06-11T00:24:06.170 回答
0

这对于https://groups.google.com/forum/#!forum/istio-usershttps://github.com/istio/issues/issues可能是一个更好的问题

但看起来您的应用程序没有启动 - 您可以检查 kubectl get pods并看到没有任何待处理的内容吗?

于 2017-06-09T17:09:25.587 回答