Simple OpenShift Template - Openshift-templates Typing CST Test
Loading…
Simple OpenShift Template — Openshift-templates Code
A simple OpenShift template creating a Deployment, Service, and Route for an Nginx application.
# openshift/demo-template.yaml
apiVersion: v1kind: Template
metadata:
name: nginx-template
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80
- apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- port: 80
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: nginx-route
spec:
to:
kind: Service
name: nginx-serviceOpenshift-templates Language Guide
OpenShift Templates are declarative YAML or JSON definitions used in Red Hat OpenShift to define a set of objects (like deployments, services, routes, and config maps) that can be instantiated repeatedly, enabling standardized application deployment.
Primary Use Cases
- ▸Standardizing deployment of applications and services
- ▸Automating multi-resource creation in OpenShift
- ▸Environment-specific configuration using parameters
- ▸Bootstrapping CI/CD pipelines
- ▸Rapid replication of applications across clusters
Notable Features
- ▸Parameterization of resources for flexible deployments
- ▸Supports multiple OpenShift object types in a single template
- ▸Integration with `oc process` and `oc apply`
- ▸Reusable across projects and clusters
- ▸Can include labels, annotations, and metadata for compliance
Origin & Creator
Developed by Red Hat as part of the OpenShift Container Platform.
Industrial Note
OpenShift Templates are widely used in enterprise DevOps pipelines to standardize application deployment, automate environment setup, and enforce best practices in containerized deployments.