One of the goals of any developer in the hybrid cloud world is to create solutions, quickly, that enable enterprises to react to evolving ecosystems. Red Hat Marketplace offers a unified experience to purchase containerized software from a comprehensive catalog backed by leading cloud vendors, deploy that software across all clouds using the Red Hat OpenShift Container Platform, monitor software spend, and track license usage and expirations.
This article will walk through the process of account registration, cluster setup, and installation of a trial of CockroachDB using Red Hat Marketplace.
Setup Marketplace account
Start by visiting Red Hat Marketplace to view the catalog of containerized software that is ready to install into your Red Hat OpenShift cluster. If you have an existing IBM ID or Red Hat ID, begin this exercise by clicking the Login link provided at the top right corner of the page. Otherwise, click on the Create account button if you do not have one. (The Create account process will provision an IBM ID.)
Fill in the information requested at the registration page. For Account type, select Company if you are registering the account for business purposes; otherwise, select Personal. Click Next.
Payment options can be set up with either a credit card or an invoice. Using the invoice option requires you to have an IBM Customer number and a Purchase order number. Click Next and complete the registration.
Add a cluster to OpenShift
OpenShift clusters must be added to your Marketplace workspace prior to deploying software from the marketplace. Marketplace provides you the flexibility to use any OpenShift cluster irrespective of its location. The cluster's location can be public or private as long as the cluster can communicate with the Marketplace server.
Prerequisites
1. An existing OpenShift cluster: For this article we have chosen to use a managed OpenShift cluster on IBM Cloud. If you do not have a cluster, provision OpenShift Container Platform on the public or private cloud of your choice. During setup, choose OpenShift version 4.3 or higher.
2. Deployment Key: A deployment key is required to link your OpenShift cluster to the Marketplace. Select the drop-down from the top right corner and go to the My Account page.
Note that this page provides you access to all the account management functions for Marketplace, such as account information, access permissions, spending, offers and keys. Select Deployment keys and then click on Create key.
Copy the key and save it in a secure place for later use prior to clicking the Save button.
Now, let's proceed with adding the OpenShift cluster. Select Workspace > Clusters and click on Add cluster
Enter a name that best represents the cluster you want to add (e.g. Database)
Install the additional prerequisites (CLIs and jq JSON processor) required to run the install script. Log in to your cluster using the oc login
command with the administrator credentials.
Run the operator install script and provide the deployment key created in the prior step as the input parameter. Note that account-id and cluster-uuid is pre-populated.
curl -sL https://marketplace.redhat.com/provisioning/v1/scripts/install-rhm-operator | bash -s <account-id> <cluster-uuid> <deployment-key>
You should see the following output on a successful completion:
================================================================================== [INFO] Installing Red Hat Marketplace Operator... ================================================================================== STEP 1/6: Creating Namespace... namespace/redhat-marketplace-operator created STEP 2/6: Creating Red Hat Marketplace Operator Group... operatorgroup.operators.coreos.com/redhat-marketplace-operator created STEP 3/6: Creating Red Hat Marketplace Operator Subscription... Checking for Cluster Service Version... Checking for Custom Resource Definition... subscription.operators.coreos.com/redhat-marketplace-operator created STEP 4/6: Applying global pull secret... secret/pull-secret data updated STEP 5/6: Applying Red Hat Marketplace Operator Secret... secret/rhm-operator-secret created STEP 6/6: Creating Red Hat Marketplace Operator Config Custom Resource... marketplaceconfig.marketplace.redhat.com/marketplaceconfig created Red Hat Marketplace Operator successfully installed
Click on the Add cluster button to complete this step to add the cluster. The cluster should appear in the Clusters page with the status as Registered. You may need to wait up to 15 minutes for the registration to complete if the status shows Agent not installed.
Check the list of installed operators in your OpenShift cluster. The Red Hat Marketplace Operator should now be one of them.
One last step: if your cluster is running on IBM Cloud then run the following command to reload the worker nodes. This step may take 20-30 minutes.
ibmcloud ks worker reload --cluster <cluster-id> --worker <worker-node-name>
Use ibmcloud ks clusters and ibmcloud ks workers --cluster <cluster-id>
to determine the cluster id and node names.
Example output:
Reload worker? [kube-bqegbk1w00v8gmbt37l0-rhmtestcluster-default-000001d8] [y/N]> y Reloading workers for cluster rhm-test-cluster... Processing kube-bqegbk1w00v8gmbt37l0-rhmtestcluster-default-000001d8... Processing on kube-bqegbk1w00v8gmbt37l0-rhmtestcluster-default-000001d8 complete.
Now you are ready to try any software from the catalog.
Reach out to the Marketplace technical support if you encounter an error and need assistance to resolve the issue.
Try software
Let's see how the Free Trial option works by selecting an SQL database Operator. CockroachDB is a cloud-native database—scalable, distributed SQL for Kubernetes. It is a great choice for OpenShift because it offers the familiarity and power of SQL with the comfort of your existing ORMs—and automated sharding ensures great performance as you scale your applications.
Go to the Marketplace catalog and search for CockroachDB. Select the CockroachDB tile.
The CockroachDB product page gives you an overview, documentation, and pricing options associated with the product. Click on the Free Trial button.
Next, the purchase summary will show the Subscription term and total cost is $0.00. Click Start trial. Go back to Workspace > My Software to view your list of purchased software.
Create a project in your OpenShift cluster where you want the operator to be installed.You can do this at the command line using the following command:
oc new-project cockroachdb-test
Back in the web dashboard, select the CockroachDB tile and then select the Operators tab. Click on the Install Operator button. Leave the default selection for Update channel and Approval strategy. Select the cluster and namespace scope as cockroachdb-test for the operator and click Install.
A message as shown below appears at the top of your screen indicating the install process initiated in the cluster.
Log into your OpenShift cluster and look under Operators > Installed Operators to confirm the install was successful. The operator should list under the project cockroachdb-test.
Create database instance
From the installed Operators page for CockroachDB, click on the link CockroachDB under Provided APIs.
Click on the Create Cockroachdb button. Accept the default YAML and click on the Create button.
Before proceeding, review these directions on how to set up the database in a secure mode, then return to this article to complete the Operator setup.
CockroachDB pods should come up when the database install completes. Run the following commands to check the status.
oc project cockroachdb-test
You should get a result similar to the following:
Now using project "cockroachdb-test" on server "https://c100-e.us-east.containers.cloud.ibm.com:32345".
You can use the kubectl get pods
command to view the status of the CockroachDB pods to see when everything is ready. All of pods must have a status of either "Running" or "Completed":
kubectl get pods
NAME READY STATUS RESTARTS AGE cockroachdb-7486949c78-kdvcm 1/1 Running 0 46m example-cockroachdb-0 1/1 Running 0 36m example-cockroachdb-1 1/1 Running 0 36m example-cockroachdb-2 1/1 Running 0 36m example-cockroachdb-init-l5m56 0/1 Completed 0 36m
Now, let's create a user and a database. We will use the following command to spin up a CockroachDB client:
kubectl run -it --rm cockroach-client \
--image=cockroachdb/cockroach \
--restart=Never \
--command -- \
./cockroach sql --insecure --host=example-cockroachdb-public.cockroachdb-test
This should take you to a command prompt similar to the following, running the CockroachDB client. If you don't see a command prompt, try pressing enter.
root@example-cockroachdb-public.cockroachdb-test:26257/defaultdb>
From the client command prompt, run the following SQL commands:
CREATE USER IF NOT EXISTS maxroach;
This creates the user account we'll be using, maxroach.
CREATE DATABASE bank;
This creates the database named bank.
GRANT ALL ON DATABASE bank TO maxroach;
This gives our user account, maxroach, permission to update our database, bank.
At this point we have a user account and a database. Type \q
to quit the client console.
Now, let's view the results of the commands we ran in the earlier steps via the admin console. The console can be accessed at localhost with port forwarding.
kubectl port-forward example-cockroachdb-0 8080
Forwarding from [::1]:8080 -> 8080
The page should load the cluster overview
Click on DATABASES from the left navigation panel.
If you run into problems installing the Operator or working with any products and have exhausted the provided self-help options, the Marketplace Central Support Triage team is ready and available to assist as needed. Go to https://marketplace.redhat.com/en-us/support and submit a support case with product and problem details and we'll get back to you quickly.
Conclusion
In the follow-on series, we will dive deeper into how Marketplace helps you rapidly take an idea from a proof-of-concept or pilot to a production scale application. You will also get to see the benefits of having a single place to manage the software consumption for your hybrid cloud applications.
Last updated: April 21, 2021