Service catalog command-line interface (CLI)
You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see
The basic workflow of interacting with the service catalog is that:
The cluster administrator installs and registers a broker server to make available its services.
The users use those services by instantiating them in an OpenShift project and linking those service instances to their pods.
The Service Catalog command-line interface (CLI) utility called svcat
is available to handle these user related tasks. While oc
commands can perform the same tasks, you can use svcat
for easier interaction with Service Catalog resources. svcat
communicates with the Service Catalog API by using the aggregated API endpoint on an OpenShift cluster.
You can install svcat
as an RPM by using Red Hat Subscription Management (RHSM) if you have an active OpenShift Enterprise subscription on your Red Hat account:
Google Compute Engine For Google Cloud Platform, run the following command to setup firewall rules to allow incoming traffic:
$ gcloud compute firewall-rules create allow-service-catalog-secure --allow tcp:30443 --description "Allow incoming traffic on 30443 port."
This section includes common commands to handle the user associated tasks listed in . Use the svcat --help
command to get more information and view other available command-line options. The sample output in this section assumes that the Ansible Service Broker is already installed on the cluster.
Get broker details
You can view a list available brokers, sync the broker catalog, and get details about brokers deployed in the service catalog.
Find brokers
To view all the brokers installed on the cluster:
$ svcat get brokers
NAME URL STATUS
+-------------------------+-------------------------------------------------------------------------------------------+--------+
ansible-service-broker https://asb.openshift-ansible-service-broker.svc:1338/ansible-service-broker Ready
template-service-broker https://apiserver.openshift-template-service-broker.svc:443/brokers/template.openshift.io Ready
Sync broker catalog
To refresh the catalog metadata from the broker:
$ svcat sync broker ansible-service-broker
Synchronization requested for broker: ansible-service-broker
View broker details
$ svcat describe broker ansible-service-broker
Name: ansible-service-broker
URL: https://openshift-automation-service-broker.openshift-automation-service-broker.svc:1338/openshift-automation-service-broker/
Status: Ready - Successfully fetched catalog entries from broker @ 2018-06-07 00:32:59 +0000 UTC
When you create a ClusterServiceBroker
resource, the service catalog controller queries the broker server to find all services it offers and creates a service class (ClusterServiceClass
) for each of those services. Additionally, it also creates service plans (ClusterServicePlan
) for each of the broker’s services.
View service classes
To view the available ClusterServiceClass resources:
$ svcat get classes
NAME DESCRIPTION
+-------------------+--------------------------------+
rh-mediawiki-apb Mediawiki apb implementation
...
rh-mariadb-apb Mariadb apb implementation
rh-mysql-apb Software Collections MySQL APB
rh-postgresql-apb SCL PostgreSQL apb
implementation
To view details of a service class:
$ svcat describe class rh-postgresql-apb
Name: rh-postgresql-apb
Description: SCL PostgreSQL apb implementation
UUID: d5915e05b253df421efe6e41fb6a66ba
Status: Active
Tags: database, postgresql
Broker: ansible-service-broker
Plans:
NAME DESCRIPTION
+------+--------------------------------+
prod A single DB server with
persistent storage
dev A single DB server with no
storage
View service plans
To view the ClusterServicePlan resources available in the cluster:
View details of a plan:
$ svcat describe plan rh-postgresql-apb/dev
Name: dev
Description: A single DB server with no storage
UUID: 9783fc2e859f9179833a7dd003baa841
Status: Active
Free: true
Instances:
No instances defined
$schema: http://json-schema.org/draft-04/schema
additionalProperties: false
properties:
postgresql_database:
default: admin
pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
title: PostgreSQL Database Name
type: string
postgresql_password:
pattern: ^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$
title: PostgreSQL Password
type: string
postgresql_user:
default: admin
maxLength: 63
pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
title: PostgreSQL User
type: string
postgresql_version:
default: "9.6"
enum:
- "9.6"
- "9.5"
- "9.4"
title: PostgreSQL Version
type: string
required:
- postgresql_database
- postgresql_user
- postgresql_password
- postgresql_version
type: object
Instance Update Parameter Schema:
$schema: http://json-schema.org/draft-04/schema
additionalProperties: false
properties:
postgresql_version:
default: "9.6"
enum:
- "9.6"
- "9.5"
- "9.4"
title: PostgreSQL Version
type: string
required:
- postgresql_version
type: object
Binding Create Parameter Schema:
$schema: http://json-schema.org/draft-04/schema
additionalProperties: false
type: object
Provision services
Provisioning means to make the service available for consumption. To provision a service, you need to create a service instance and then bind to it.
Create ServiceInstance
Create a new project.
$ oc new-project <project-name> (1)
Create service instance using the command:
$ svcat provision postgresql-instance --class rh-postgresql-apb --plan dev --params-json '{"postgresql_database":"admin","postgresql_password":"admin","postgresql_user":"admin","postgresql_version":"9.6"}' -n szh-project
Name: postgresql-instance
Namespace: szh-project
Status:
Class: rh-postgresql-apb
Parameters:
postgresql_database: admin
postgresql_password: admin
postgresql_user: admin
postgresql_version: "9.6"
View service instance details
To view service instance details:
$ svcat get instance
NAME NAMESPACE CLASS PLAN STATUS
+---------------------+-------------+-------------------+------+--------+
postgresql-instance szh-project rh-postgresql-apb dev Ready
Create ServiceBinding
When you create a ServiceBinding
resource:
The broker server create credentials and issue them to the service catalog controller.
The service catalog controller adds those credentials as secrets to the project.
Create the service binding using the command:
$ svcat bind postgresql-instance --name mediawiki-postgresql-binding
Name: mediawiki-postgresql-binding
Namespace: szh-project
Status:
Instance: postgresql-instance
Parameters:
{}
View service binding details
To view service binding details:
$ svcat get bindings
NAME NAMESPACE INSTANCE STATUS
+------------------------------+-------------+---------------------+--------+
mediawiki-postgresql-binding szh-project postgresql-instance Ready
Verify the instance details after binding the service:
To delete service catalog related resources, you need to unbind service bindings and deprovision the service instances.
To delete all service bindings, associated with a service instance:
$ svcat unbind -n <project-name> (1)
\ <instance-name> (2)
For example:
$ svcat unbind -n szh-project postgresql-instance
deleted mediawiki-postgresql-binding
$ svcat get bindings
NAME NAMESPACE INSTANCE STATUS
+------+-----------+----------+--------+
Verify that the associated secret is deleted.
$ oc get secret -n szh-project
NAME TYPE DATA AGE
builder-dockercfg-jxk48 kubernetes.io/dockercfg 1 9m
builder-token-92jrf kubernetes.io/service-account-token 4 9m
builder-token-b4sm6 kubernetes.io/service-account-token 4 9m
default-dockercfg-cggcr kubernetes.io/dockercfg 1 9m
default-token-g4sg7 kubernetes.io/service-account-token 4 9m
default-token-hvdpq kubernetes.io/service-account-token 4 9m
deployer-dockercfg-wm8th kubernetes.io/dockercfg 1 9m
deployer-token-hnk5w kubernetes.io/service-account-token 4 9m
deployer-token-xfr7c kubernetes.io/service-account-token 4 9m
Deleting service instances
Deprovision the service instance:
$ svcat deprovision postgresql-instance
deleted postgresql-instance
$ svcat get instance
NAME NAMESPACE CLASS PLAN STATUS
+------+-----------+-------+------+--------+
-
$ oc delete clusterservicebrokers template-service-broker
clusterservicebroker "template-service-broker" deleted
$ svcat get brokers
NAME URL STATUS
+-------------------------+-------------------------------------------------------------------------------------------+--------+
ansible-service-broker https://asb.openshift-ansible-service-broker.svc:1338/ansible-service-broker Ready
View the
ClusterServiceClass
resources for the broker, to verify that the broker is removed:$ svcat get classes
NAME DESCRIPTION
+------+-------------+