$ odo login -u developer -p developer
Creating instances of services managed by Operators in `odo` is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/. |
Operators are a method of packaging, deploying, and managing Kubernetes services. With odo
, you can create instances of services from the custom resource definitions (CRDs) provided by the Operators. You can then use these instances in your projects and link them to your components.
To create services from an Operator, you must ensure that the Operator has valid values defined in its metadata
to start the requested service. odo
uses the metadata.annotations.alm-examples
YAML file of an Operator to start
the service. If this YAML has placeholder values or sample values, a service cannot start. You can modify the YAML file and start the service with the modified values. To learn how to modify YAML files and start services from it, see Creating services from YAML files.
Install the oc
CLI and log into the cluster.
Note that the configuration of the cluster determines the services available to you. To access the Operator services, a cluster administrator must install the respective Operator on the cluster first. To learn more, see Adding Operators to the cluster.
Install the odo
CLI.
Enable experimental mode. To enable experimental mode in odo
, run:
odo preference set Experimental true
or use the environment variable odo config set --env ODO_EXPERIMENTAL=true
Create a project to keep your source code, tests, and libraries organized in a separate single unit.
Log in to an OpenShift Container Platform cluster:
$ odo login -u developer -p developer
Create a project:
$ odo project create myproject ✓ Project 'myproject' is ready for use ✓ New project created and now using project : myproject
With odo
, you can display the list of the Operators installed on your cluster, and the services they provide.
To list the Operators installed in current project, run:
$ odo catalog list services
The command lists Operators and the CRDs. The output of the command shows the Operators installed on your cluster. For example:
Operators available in the cluster NAME CRDs etcdoperator.v0.9.4 EtcdCluster, EtcdBackup, EtcdRestore mongodb-enterprise.v1.4.5 MongoDB, MongoDBUser, MongoDBOpsManager
etcdoperator.v0.9.4
is the Operator, EtcdCluster
, EtcdBackup
and EtcdRestore
are the CRDs provided by the Operator.
If an Operator has valid values defined in its metadata
to start the requested service, you can use the service with odo service create
.
Print the YAML of the service as a file on your local drive:
$ oc get csv/etcdoperator.v0.9.4 -o yaml
Verify that the values of the service are valid:
apiVersion: etcd.database.coreos.com/v1beta2 kind: EtcdCluster metadata: name: example spec: size: 3 version: 3.2.13
Start an EtcdCluster
service from the etcdoperator.v0.9.4
Operator:
$ odo service create etcdoperator.v0.9.4 --crd EtcdCluster
Verify that a service has started:
$ oc get EtcdCluster
If the YAML definition of the service or custom resource (CR) has invalid or placeholder data, you can use the --dry-run
flag to get the YAML definition, specify the correct values, and start the service using the corrected YAML definition.
Printing and modifying the YAML used to start a service
odo
provides the feature to print the YAML definition of the service or CR provided by the Operator before starting a service.
To display the YAML of the service, run:
$ odo service create <operator-name> --crd <cr-name> --dry-run
For example, to print YAML definition of EtcdCluster
provided by the etcdoperator.v0.9.4
Operator, run:
$ odo service create etcdoperator.v0.9.4 --crd EtcdCluster --dry-run
The YAML is saved as the etcd.yaml
file.
Modify the etcd.yaml
file:
apiVersion: etcd.database.coreos.com/v1beta2 kind: EtcdCluster metadata: name: my-etcd-cluster (1) spec: size: 1 (2) version: 3.2.13
1 | Change the name from example to my-etcd-cluster |
2 | Reduce the size from 3 to 1 |
Start a service from the YAML file:
$ odo service create --from-file etcd.yaml
Verify that the EtcdCluster
service has started with one pod instead of the pre-configured three pods:
$ oc get pods | grep my-etcd-cluster