2022-02-08:k8s安装centos,yaml如何写? 注意:如果不配置参数,centos容器会处于terminated状态。如何让容器处于running状态?

2022-02-08:k8s安装centos,yaml如何写?
注意:如果不配置参数,centos容器会处于terminated状态。如何让容器处于running状态?

答案2022-02-08:

加上命令行参数即可。

yaml如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: centos
  name: centos
  namespace: moonfdd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: centos
  template:
    metadata:
      labels:
        app: centos
    spec:
      containers:
        - args:
            - while true; do sleep 30; done;
          command:
            - /bin/bash
            - '-c'
            - '--'
          image: centos:centos7.9.2009
          imagePullPolicy: IfNotPresent
          name: centos
          securityContext:
            privileged: true

结果如下:
图片


centos的yaml

posted @ 2022-02-08 21:18  福大大架构师每日一题  阅读(5)  评论(0编辑  收藏  举报  来源