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
Kubernetes 准备就绪,但仅在开始时_Kubernetes - Fatal编程技术网

Kubernetes 准备就绪,但仅在开始时

Kubernetes 准备就绪,但仅在开始时,kubernetes,Kubernetes,在K8中,我们有活力和准备。两者都在整个应用程序生命周期中运行。但这对我来说还不够。我想运行一些运行状况检查,但仅在启动时运行,或者将就绪配置为仅在启动时运行。可能吗?看一看,根据您正在执行的健康检查探测的类型,处理程序事件会有所不同。我在一个简单的hello world播客上试过这个。在postStart事件中设置一个命令,当容器构建并运行时,该命令将只运行一次。我的示例yaml文件如下所示: apiVersion: apps/v1 kind: Deployment metadata: n

在K8中,我们有活力和准备。两者都在整个应用程序生命周期中运行。但这对我来说还不够。我想运行一些运行状况检查,但仅在启动时运行,或者将就绪配置为仅在启动时运行。可能吗?

看一看,根据您正在执行的健康检查探测的类型,处理程序事件会有所不同。我在一个简单的hello world播客上试过这个。在postStart事件中设置一个命令,当容器构建并运行时,该命令将只运行一次。我的示例yaml文件如下所示:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  labels:
    app: hello-world
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - image: paulbouwer/hello-kubernetes:1.5
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
        name: hello-world
        ports:
        - containerPort: 8080
          name: http