我正在GCE上使用本教程ingress。本教程在其中使用docker镜像的情况下工作正常,但对于我的docker镜像,我总是得到后端服务的状态异常。 我添加了活跃性和就绪性TCP探针,因为我的应用程序不响应200。 部署yaml如下图所示
app.get('/searchUser/:value', function (req, res) {
let value = req.params.value;
console.log(value + ' <<< value in the server');
user.find({ user: value}, function(err, doc) {
if(err) {
console.log(err);
}else {
// res.json(res);
console.log(doc);
}
});
})
服务Yaml如下所示
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: neg-demo-app # Label for the Deployment
name: neg-demo-app # Name of Deployment
spec: # Deployment's specification
selector:
matchLabels:
run: neg-demo-app
template: # Pod template
metadata:
labels:
run: neg-demo-app # Labels Pods from this Deployment
spec: # Pod specification; each Pod created by this Deployment has this specification
containers:
- image: mohib13/graphene_with_coref:first # Application to run in Deployment's Pods
name: hostname # Container name
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
ports:
- containerPort: 8080
terminationGracePeriodSeconds: 60 # Number of seconds to wait for connections to terminate before shutting down Pods
入口低于下方
apiVersion: v1
kind: Service
metadata:
name: neg-demo-svc # Name of Service
annotations:
cloud.google.com/neg: '{"ingress": true}' # Creates an NEG after an Ingress is created
spec: # Service's specification
type: NodePort
selector:
run: neg-demo-app # Selects Pods labelled run: neg-demo-app
ports:
- port: 8080 # Service's port
targetPort: 8080
更新:描述如下所示的广告连播
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: neg-demo-ing
spec:
backend:
serviceName: neg-demo-svc # Name of the Service targeted by the Ingress
servicePort: 8080 # Should match the port used by the Service