如何在kubernetes pod中初始化systemd服务?

问题描述 投票:0回答:1

我有一个基础os centos / systemd的图像。当我在容器的laucher文件中给出“exec / usr / sbin / init”并使用docker systemd服务创建容器时。但是当我在kubernetes中使用相同的启动器文件创建一个容器时,系统服务器没有启动。如何在kubernetes中运行/ usr / sbin / init,以便在容器创建期间启动systemd服务

docker kubernetes systemd
1个回答
1
投票

要解决此问题,您可以使用kubernetes init容器,该容器在创建主容器之前首先运行并启动必要的服务。

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  initContainers:
  - name: check-system-ready
    image: busybox
    command: ['sh', '-c', 'Your sysntax for systemd']
  containers:
  - your container spec

在这里分享官方kubernetes init容器doc:https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/

© www.soinside.com 2019 - 2024. All rights reserved.