为了账号安全,请及时绑定邮箱和手机立即绑定

Openshift模板之项目创建模板(资源限制)

标签:
Kubernetes

Openshift创建project时,可以按照设定的模板来创建,这就省去了很多初始化的工作。

文件内容(template.yaml)

apiVersion: v1kind: Templatemetadata:
  creationTimestamp: null  name: project-requestobjects:- apiVersion: v1  kind: Project  metadata:
    annotations:
      openshift.io/description: ${PROJECT_DESCRIPTION}
      openshift.io/display-name: ${PROJECT_DISPLAYNAME}
      openshift.io/requester: ${PROJECT_REQUESTING_USER}    creationTimestamp: null    name: ${PROJECT_NAME}  spec: {}  status: {}
- apiVersion: v1  kind: ResourceQuota  metadata:
    name: ${PROJECT_NAME}-quota  spec:
    hard:
      pods: 10
      requests.cpu: 4000m
      requests.memory: 8Gi      resourcequotas: 1
      requests.storage: 25Gi      persistentvolumeclaims: 5- apiVersion: v1  kind: LimitRange  metadata: 
    name: ${PROJECT_NAME}-limits    creationTimestamp: null  spec: 
    limits: 
      - 
        type: Container        max: 
          cpu: 4000m          memory: 1024Mi        min: 
          cpu: 10m          memory: 5Mi        default: 
          cpu: 4000m          memory: 1024Mi        defaultRequest:
          cpu: 100m          memory: 512Mi
- apiVersion: v1  groupNames:
  - system:serviceaccounts:${PROJECT_NAME}  kind: RoleBinding  metadata:
    creationTimestamp: null    name: system:image-pullers    namespace: ${PROJECT_NAME}  roleRef:
    name: system:image-puller  subjects:
  - kind: SystemGroup    name: system:serviceaccounts:${PROJECT_NAME}  userNames: null
- apiVersion: v1  groupNames: null  kind: RoleBinding  metadata:
    creationTimestamp: null    name: system:image-builders    namespace: ${PROJECT_NAME}  roleRef:
    name: system:image-builder  subjects:
  - kind: ServiceAccount    name: builder  userNames:
  - system:serviceaccount:${PROJECT_NAME}:builder- apiVersion: v1  groupNames: null  kind: RoleBinding  metadata:
    creationTimestamp: null    name: system:deployers    namespace: ${PROJECT_NAME}  roleRef:
    name: system:deployer  subjects:
  - kind: ServiceAccount    name: deployer  userNames:
  - system:serviceaccount:${PROJECT_NAME}:deployer- apiVersion: v1  groupNames: null  kind: RoleBinding  metadata:
    creationTimestamp: null    name: admin    namespace: ${PROJECT_NAME}  roleRef:
    name: admin  subjects:
  - kind: User    name: ${PROJECT_ADMIN_USER}  userNames:
  - ${PROJECT_ADMIN_USER}parameters:- name: PROJECT_NAME
- name: PROJECT_DISPLAYNAME
- name: PROJECT_DESCRIPTION
- name: PROJECT_ADMIN_USER
- name: PROJECT_REQUESTING_USER

将它导入模板

oc create -f template.yaml -n default

将它设为Project默认配置

#/etc/origin/master/master-config.yaml...
projectConfig:
  projectRequestTemplate: "default/project-request"
  ...

重启Master,使配置生效

sudo systemctl restart atomic-openshift-master

验证

oc new-project tem-test



作者:潘晓华Michael
链接:https://www.jianshu.com/p/1d16ef4ee866


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消