How to create project template on OpenShift
Автор: DevOps Virtual University
Загружено: 2025-01-16
Просмотров: 719
Описание:
An OpenShift project template is a predefined set of configurations and resources that can be automatically applied when a new project is created in OpenShift. It allows administrators to enforce policies, quotas, and other settings for projects based on organizational or team requirements.
When users request a new project using oc new-project or the OpenShift Web Console, OpenShift applies the default project template to create the project and associated resources. This ensures consistency and compliance across all projects.
Components of a Project Template
A project template can include a variety of Kubernetes and OpenShift resources, such as:
ResourceQuota: Limits the amount of compute and storage resources a project can consume.
LimitRange: Defines default and maximum resource requests and limits for containers in the project.
NetworkPolicy: Controls network access to pods within the project.
RoleBinding: Assigns specific roles to users or groups in the project.
ConfigMap/Secrets: Pre-configures settings or provides default data for applications.
Default Project Template
The default project template is configured in the projects.config.openshift.io/cluster resource and is applied to every new project unless overridden by other mechanisms.
Create a new template manifest using command:
oc adm create-bootstrap-project-template -o yaml
[root@lb ~]# cat template.yaml
apiVersion: template.openshift.io/v1
kind: Template
metadata:
creationTimestamp: null
name: project-request
objects:
apiVersion: project.openshift.io/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: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
creationTimestamp: null
name: admin
namespace: ${PROJECT_NAME}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:
apiGroup: rbac.authorization.k8s.io
kind: User
name: ${PROJECT_ADMIN_USER}
apiVersion: v1
kind: ResourceQuota
metadata:
creationTimestamp: null
name: ${PROJECT_NAME}-quota
spec:
hard:
cpu: "1"
memory: 1G
persistentvolumeclaims: "10"
pods: "2"
replicationcontrollers: "2"
resourcequotas: "1"
secrets: "5"
services: "3"
apiVersion: v1
kind: LimitRange
metadata:
name: ${PROJECT_NAME}-mem-limit
namespace: default
spec:
limits:
default:
memory: 512Mi
defaultRequest:
memory: 256Mi
type: Container
status: {}
parameters:
name: PROJECT_NAME
name: PROJECT_DISPLAYNAME
name: PROJECT_DESCRIPTION
name: PROJECT_ADMIN_USER
name: PROJECT_REQUESTING_USER
oc apply -f template.yaml -n openshift-config
You can view and configure the default template using:
oc edit projects.config.openshift.io/cluster
apiVersion: config.openshift.io/v1
kind: Project
metadata:
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
release.openshift.io/create-only: "true"
creationTimestamp: "2025-01-15T08:05:55Z"
generation: 4
name: cluster
ownerReferences:
apiVersion: config.openshift.io/v1
kind: ClusterVersion
name: version
uid: b34e98b6-cf02-4a98-b054-5e1152d73cd5
resourceVersion: "354114"
uid: 0c1a9b1a-972f-4278-bdd8-f39e94bdc558
spec:
projectRequestTemplate:
name: project-request
Check the pods are restarted to apply the new changes:
oc get po -n openshift-apiserver
openshift
how to create openshift catalog template & deploy an app?
openshift commons
red hat openshift
openshift template
openshift tutorial
openshift templates
templates in openshift
openshift container platform
openshift application deployment
what is openshift
template
openshift for beginners
create application into openshift using container registry
openshift lecture
openshift explained
learn openshift
#openshift #redhatopenshift
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: