继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

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

慕码人8056858
关注TA
已关注
手记 1247
粉丝 350
获赞 1323

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


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP