'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. I don't know why this error happens and what can I do to solve it



Solution 1:[1]

You need to add command and args in your pod definition that start apache in foreground:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tinh Huynh