Openshift创建project时,可以按照设定的模板来创建,这就省去了很多初始化的工作。
文件内容(template.yaml)
apiVersion: v1
kind: Template
metadata:
creationTimestamp: null
name: project-request
objects:
- 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
网友评论