Bootstrap FreeKB - OpenShift - Create group using a YAML template file
OpenShift - Create group using a YAML template file

Updated:   |  OpenShift articles

A JSON or YAML file that contains key value pairs used to create an object, such as a config map, deployment, a project, a pod, a route, a secret, a service, et cetera. These files are known as templates. The oc explain command can be used to get the list of keys that can be used in the JSON or YAML template file.

oc explain pod

 

And then more details on each key can be displayed.

oc explain pod.metadata

 

For example, let's say you have a YAML file named group.yml that contains the following markup. In this example, a group named "my-group" will be created.

apiVersion: user.openshift.io/v1
kind: Group
metadata:
  name: bogus
users:
- jone.doe
- jane.doe

 

The oc apply or oc create command with the -f or --filename option can be used to create the group using the template JSON or YAML file.

The oc replace command can be used to replace a group using a new or updated template JSON or YAML file.

The oc edit command can be used to update a group template YAML file.

~]$ oc apply --filename my_group.yml 
group.user.openshift.io/my_group created

 

The oc get group command can then be used to ensure the group exists.

~]$ oc get group my_group
NAME      USERS
my_group  jone.doe, jane.doe


 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 126097 in the box below so that we can be sure you are a human.