Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize systemd services in kubernetes pod?

I have an image from base os centos/systemd.when i give "exec /usr/sbin/init" in the laucher file of the container and creating the container using docker systemd services are up. But when i create a container using the same image in kubernetes with the same launcher file systemd services are not comming up.How to run the /usr/sbin/init in the kubernetes so the systemd services comes up during the container creation

like image 993
jaya rohith Avatar asked Oct 29 '25 06:10

jaya rohith


1 Answers

To solve this issue you can use kubernetes init container which run first before the main container creation and start the necessary services.

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

Sharing here official kubernetes init container doc : https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

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

like image 99
Harsh Manvar Avatar answered Oct 30 '25 23:10

Harsh Manvar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!