Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 如何在抛出异常时终止janusgraph容器_Kubernetes_Janusgraph_Docker Image - Fatal编程技术网

Kubernetes 如何在抛出异常时终止janusgraph容器

Kubernetes 如何在抛出异常时终止janusgraph容器,kubernetes,janusgraph,docker-image,Kubernetes,Janusgraph,Docker Image,我用的是janusgraph docker图像- 在我的kubernetes部署中,使用装载到docker entrypoint initdb.d的groovy脚本初始化远程图形 这可以按预期工作,但如果远程主机未准备就绪,janusgraph容器将引发异常,并且仍处于运行模式 因此,kubernetes不会再次尝试重新启动容器。是否有任何方法可以将此janusgraph容器配置为在出现任何异常时终止这里可以使用类似于janusgraph show config的命令或类似命令,该命令将以代码-

我用的是janusgraph docker图像- 在我的kubernetes部署中,使用装载到
docker entrypoint initdb.d的groovy脚本初始化远程图形

这可以按预期工作,但如果远程主机未准备就绪,janusgraph容器将引发异常,并且仍处于运行模式

因此,kubernetes不会再次尝试重新启动容器。是否有任何方法可以将此janusgraph容器配置为在出现任何异常时终止

这里可以使用类似于
janusgraph show config
的命令或类似命令,该命令将以代码-1退出

spec:
  containers:
  - name: liveness
    image: janusgraph/janusgraph:latest
    readinessProbe:
      exec:
        command:
        - janusgraph 
        - show-config
如果
readinessProbe
失败,Kubernetes将终止pod。如果远程主机不可用,需要终止此pod,也可以在此处使用


以JanusGraph服务器度量为例,它可以与Prometheus一起用于额外的监控,甚至可以与
livenessProbe
本身一起使用。

正如@Gavin所提到的,您可以使用Probe来检查容器是否正常工作。用于知道容器何时发生故障。如果容器没有响应,它可以重新启动容器

准备就绪探测器通知容器何时可接受流量。readiness probe用于控制哪些POD用作服务的后端。当一个吊舱的所有容器都准备好时,它就被认为准备好了。如果pod未就绪,则会将其从服务端点删除

Kubernetes支持三种机制来实现活动性和就绪性探测:

1)对容器发出HTTP请求 此探测器具有可在
httpGet
上设置的其他字段:

  • 主机
    :要连接的主机名,默认为pod IP。您可能希望在httpHeaders中设置“Host”
  • 方案
    :用于连接主机的方案(HTTP或HTTPS)。默认为HTTP
  • path
    :在HTTP服务器上访问的路径。默认为/
  • httpHeaders
    :要在请求中设置的自定义头。HTTP允许重复的头
  • 端口
    :容器上要访问的端口的名称或编号。编号必须在1到65535之间
阅读更多:

livenessProbe:
httpGet:
路径:/healthz
端口:活动端口
2)打开容器上的TCP套接字

initialDelaySeconds: 15  
livenessProbe: ~  
periodSeconds: 20  
port: 8080  
tcpSocket: ~
livenessProbe:  
  exec:  
    command:  
    - sh  
    - /tmp/status_check.sh  
  initialDelaySeconds: 10  
3)在容器内运行命令

initialDelaySeconds: 15  
livenessProbe: ~  
periodSeconds: 20  
port: 8080  
tcpSocket: ~
livenessProbe:  
  exec:  
    command:  
    - sh  
    - /tmp/status_check.sh  
  initialDelaySeconds: 10  
如果您将获得不同于0的状态代码,则表示探测失败。 您还可以向探测添加其他参数,例如
initialDelaySeconds
:指示容器启动后,在启动活动性或就绪探测之前的秒数。请参阅:

在任何情况下,都要添加
restartPolicy:Never
根据你的豆荚定义。默认情况下,始终为