简体   繁体   English

为什么当我在 Kube.netes 中重新启动 pod 时,我的容器 go 中的服务会停止运行?

[英]Why when I restart a pod in Kubernetes does the service I have in my container go down?

I have created a pod with an apache service inside, and when I restart a node the services that are inside my pods are automatically deactivated and I have to activate them again manually with the /etc/init.d/apache2 start command.我创建了一个带有 apache 服务的 pod,当我重新启动一个节点时,我的 pod 中的服务会自动停用,我必须使用 /etc/init.d/apache2 start 命令手动再次激活它们。 I don't know why this error happens and what can I do to solve it我不知道为什么会发生此错误以及我该怎么做才能解决它

You need to add command and args in your pod definition that start apache in foreground:您需要在 pod 定义中添加在前台开始 apache 的命令和参数:

apiVersion: v1
kind: Pod
metadata:
  name: podname
spec:
  containers:
  - name: containername
    image: yourimage
    command: ["apachectl"]
    args: ["-D", "FOREGROUND"]
  restartPolicy: OnFailure

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我进入 Kubernetes pod 时,为什么我得到 exec failed: container_linux.go:380? - Why I get exec failed: container_linux.go:380 when I go inside Kubernetes pod? 为什么每次我附上容器然后退出时我的docker容器apache服务都会关闭? - Why my docker container apache service will be shut down everytime I attach my container and then exit? Kubernetes允许容器退出而无需重启pod - Kubernetes allow container to exit without pod restart 我有一个 python 脚本在 kubernetes pod 的容器内运行。如何停止与 pod 一起运行的脚本? - I have a python script running inside a container of kubernetes pod.How do i stop the script which runs along with the starting of the pod? 为什么只有当我在容器的 bash 中使用 go 时才能访问我的 Apache 默认页面? - Why can I access my Apache default page ONLY when I go in my container's bash? 如何在 kubernetes 中将具有数据(我需要此数据)的 pod 容器路径挂载到我的本地主机路径 - How to mount pod container path which is having data (I need this data)to my local host path in kubernetes 在以--network host模式运行时,为什么不能从容器主机访问我的服务? - Why can't I access my service from my container host when running with `--network host` mode? Kubernetes ::重新启动终止的Pod - Kubernetes :: Restart terminated pod Kubernetes pod 不需要重启 - Kubernetes pod unwanted restart 我正在学习 Docker 和 Kube.netes,并且刚刚开始我的第一个项目。 当我尝试构建我的第一个容器时,我收到以下错误 - I am learning Docker & Kubernetes and have just started my first project. When I attempt to build my first container I am receiving the below error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM