一个伪linux粉丝的blog

  1. 首页
  2. network
  3. 正文

k8s-set-capabilities-for-a-container

14 10 月, 2020 1236点热度 0人点赞 0条评论

1. 问题描述

某客户咨询如何更改某一个容器的系统时间,沟通了一番后才知道不是修改时区,是开发需要固定机器时间,设置时提示没权限,于是我这边做了复现,得到解决方法如下文。

 

2. 原因分析

简单来说,k8s默认不给容器修改时间权限,如果执行类似 "date -s 2020-10-10" 时间修改命令,会提示 “date: can't set date: Operation not permitted“

 

3. 解决方法

 

3.1. 为容器单独添加内核功能

即修改部署Deployment,在containers 字段里面加几行参数

1
2
3
4
5
6
securityContext:
        capabilities:    //该参数用于pod添加或者禁用某项内核功能
          add:
          - SYS_TIME      //添加修改系统时间参数
 
修改部署文件重启后,容器可以随意修改时间了。

 

4.  参考链接

https://kubernetes.io/zh/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container

https://man7.org/linux/man-pages/man7/capabilities.7.html

相关文章:

  1. k8s multi cluster management with kubeconfig
  2. 试用google开源mod_pagespeed 模块
  3. k8s Nameserver limits were exceeded
  4. Container platform disk management solution
标签: capabilities k8s
最后更新:14 10 月, 2020

wanjie

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

This site uses Akismet to reduce spam. Learn how your comment data is processed.

归档
分类
  • network / 332篇
  • Uncategorized / 116篇
  • unix/linux / 122篇
  • 业界资讯 / 38篇
  • 公司杂事 / 11篇
  • 数码影像 / 12篇
  • 美剧 / 3篇
  • 美图共赏 / 21篇
  • 英语学习 / 3篇
标签聚合
postgres 泰国 unveiled today 职责 gitlab nexus dreamhost 邮件归档 Ubuntu VPS k8s Google Voice squid ldap 天翼live 网通 虚拟主机 Linux d90 deepseek Google webhook 刷机 dreamhost空间 brew kernel docker iMac Nginx 网站运营

COPYRIGHT © 2008-2025 wanjie.info. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang