Reputation: 23
I have a Openshift template yml which will create the following objects "deploymentconfig, buildconfig, services and imagetag".
To create all the objects in the template , we can use below command,
oc process -f openshift-template.yml | oc apply -f-
Is there any way to create only deploymentconfig or service from the openshift template?
Upvotes: 2
Views: 131
Reputation: 1999
This is possible using label selectors as shown in the example below:
example.com/install: "true"
for the configmap my-username.apiVersion: v1
kind: Template
metadata:
name: user-template
objects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: my-username
labels:
example.com/install: "true"
data:
username: ${USERNAME}
- apiVersion: v1
kind: ConfigMap
metadata:
name: not-installed
data:
username: ${USERNAME}
parameters:
- description: USERNAME for authentication
from: '[A-Z0-9]{8}'
generate: expression
name: USERNAME
oc create
command, for example:$ oc process -f template.yaml -p USERNAME=rmaloku \
| oc create --selector example.com/install=true -f -
configmap/my-username created
From the output, we can see that only the labeled resource is installed.
Description of the selector flag:
--selector='': Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
Upvotes: 4