In this article, you’ll learn how to set up the Kubernetes development environment with Red Hat OpenShift Developer Sandbox as Remote Kubernetes Cluster.
If you want to use a remote Kubernetes cluster instead of minikube
then Developer Sandbox for Red Hat OpenShift is one of the best alternatives. Developer Sandbox for Red Hat OpenShift
is a free Kubernetes-as-a-Service platform offered by Red Hat Developers, based on Red Hat OpenShift.
Developer Sandbox allows users access to a pre-created Kubernetes cluster. Access is restricted to two namespaces.
Note: Developer Sandbox deletes pods after eight consecutive hours of running, and limits resources to 7 GB of RAM and 15 GB of persistent storage.
Set Up OpenShift Developer Sandbox as Remote Kubernetes Cluster
Step-1: Set Up OpenShift Developer Sandbox
1.1) Create a Developer Sandbox account
Go to https://developers.redhat.com/developer-sandbox and click Get started in the Sandbox
.
You need a free Red Hat account to use Developer Sandbox. Log in to your Red Hat account, or if you do not have one, then click Create one now
. Fill in the form choosing a Personal
account type, and then click CREATE MY ACCOUNT
. You might need to accept Red Hat terms and conditions to use the Developer Program services.
When the account is ready you will be redirected back to the Developer Sandbox page. Click Launch your Developer Sandbox for Red Hat OpenShift
to log in to Developer Sandbox.
If you just created your account, then you might need to wait some seconds for account approval. You might need to verify your account via 2-factor authentication.
Once the account is approved and verified, Click Start using your sandbox
. You might need to accept Red Hat terms and conditions to use the Developer Sandbox.
Image
In the OpenShift log-in form, click DevSandbox
to select the authentication method.
Image
If requested, then log in using your Red Hat account credentials.
1.2) Start Using Developer Sandbox
The Kubernetes cluster and two namespaces are created for you. Only the username-dev
and username-stage
namespaces are available, and you can not create more.
Image
Step-2: Enabling external access to Ingress.
In this step, we’ll use the external IP and hostname associated with our Kubernetes Ingress to make the application accessible from outside the cluster.
External access to Developer Sandbox is pre-configured to listen to requests sent to any sub-domain for a hostname known as the wildcard domain
. The wildcard domain
is a configuration value set by the administrator during the creation of the cluster.
Providing a sub-domain is a must to enable external access to the service. You can find the wildcard domain associated with the Developer Sandbox instance by following one of the approaches below:
- Get the wildcard domain from the Console URL
When you log into your Developer Sandbox account, you will be redirected to the OpenShift Console of your cluster. The URL for the OpenShift Console is of the form similar like:
https://console-openshift-console.apps.sandbox.x8i5.p1.openshiftapps.com
So, to get the wildcard domain, replace console-openshift-console.apps
subdomain with apps
. i.e. if your console URL is https://console-openshift-console.apps.sandbox.x8i5.p1.openshiftapps.com
, then your wildcard domain is apps.sandbox.x8i5.p1.openshiftapps.com
.
- Get the wildcard domain from the API URL
To get the API URL:
- From your OpenShift Sandbox dashboard website, click on username in the upper right plane of the screen.
- From the dropdown, click on Copy login command. You’ll be redirected to new page. And click on Display Token link. You’ll see an API token and commands.
- In command
oc login --token=sha256~XfnIQ1PjTjs5ynMmI0_STTEc67uG0P2t6n2KT8BAgfk --server=https://api.sandbox.x8i5.p1.openshiftapps.com:6443
, the api server ishttps://api.sandbox.x8i5.p1.openshiftapps.com:6443
Now, after finding API URL, remove https://
and :6443
parts and change api
to apps
. The result is your desired wildcard domain. i.e. for API URL https://api.sandbox.x8i5.p1.openshiftapps.com:6443
, wildcard domain is apps.sandbox.x8i5.p1.openshiftapps.com
.
Using wildcard domain for Developer Sandbox cluster
Now, you have a wildcard domain for your Developer Sandbox cluster, and you can use it to generate sub-domains to be used by your services. Sub-domains must be unique. For eg. you can generate a sub-domain in the following format:
<DEPLOYMENT-NAME>-<NAMESPACE-NAME>.<WILDCARD-DOMAIN>
So, if using the apps.sandbox.x8i5.p1.openshiftapps.com
wildcard domain and assuming a deployment named demo
in a namespace named sbmagar-dev
then you can compose your application hostname as demo-sbmagar-dev.apps.sandbox.x8i5.p1.openshiftapps.com
. Assuming the application is mapped to the path /demoapp
, then your application will be available in the URL http://demo-sbmagar-dev.apps.sandbox.x8i5.p1.openshiftapps.com/demoapp
.
Conclusion
In this article, you learned how to use OpenShift Developer Sandbox as your remote Kubernetes cluster with the wildcard domain set up enabling external access to your cluster ingress.