首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >2022-02-08:k8s安装centos,yaml如何写?

2022-02-08:k8s安装centos,yaml如何写?

作者头像
福大大架构师每日一题
发布2022-03-04 15:10:55
发布2022-03-04 15:10:55
4400
举报

2022-02-08:k8s安装centos,yaml如何写?

注意:如果不配置参数,centos容器会处于terminated状态。如何让容器处于running状态?

答案2022-02-08:

加上命令行参数即可。

yaml如下:

代码语言:javascript
复制
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](https://gitee.com/moonfdd/k8syaml/blob/master/moonfdd/centos.yaml)

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-02-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 福大大架构师每日一题 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档