Namespace as a service in OpenShift using Software Template Patterns

Introduction

Welcome to this lab, where you will have the chance to learn how to work with Software templates in Red Hat Developer Hub, and create a new OpenShift Project from Red Hat Developer Hub with custom configurations.

This lab will use an existent template to create OpenShift Projects. You will be working to increasing functionality by updating the software template to limit resource quotas. During this lab, you will have the opportunity to explore different projects' customizations across different clusters.

Scenario

Now, imagine for a moment that you need to fullfil a need for the Python Development team. The Python Team’s responsibility is to create a new start prototyping with AI and for this you need a namespace, this new namespace is not part of the Software Development Lifecycle. The request is having a namespace isolated from the rest of the cluster, with resource limits but enough resources to experiment.

Explore the Project template in GitLab

  1. Take the time to review the source code to get familiarize with the content.

    • {gitlab_url}/rhdh/rhads-enablement-l3-st-self-service/-/blob/main/namespace-medium[{gitlab_url}/rhdh/rhads-enablement-l3-st-self-service/-/blob/main/namespace-medium,window=_blank]

      • Login with your user credentials:

      • Username: {gitlab_user}

      • Password: {gitlab_user_password}

    • Component/catalog-info.yaml: This file will represent the object in Developer Hub, such as name and links.

      Project Catalog

    • Developer Hub, powered by GitOps, maintains the desired state as the actual state in the cluster for any template definitions, ensuring system stability.

      Project Manifests

    • GitOps application definitions and necessary secrets to read from the SCM. In this case, the argo-app-dev.yaml is the Argo CD Application pointing to the Namespace manifest’s folder.

    Project GitOps

    • Helm Charts are great for templating. In this case, the Namespace manifests are implemented using Helm.

      Project Helm Charts

    • template.yaml file: Defines the UI experience for the end user and the desired steps to get the software templates, create repositories, create GitOps objects, and more.

      Project template.yaml

Explore the Project template in RHDH

  • Select the plus icon on the top navigation bar to access the Create option or from URL {rhdh_url}/create[Red Hat Developer Hub UI Create^]

    Create UI

  • Click the Register Existing Component button.

    Create UI

{rhdh_url/catalog-import}[Red Hat Developer Hub UI- Catalog^]

  • Enter the following URL in the Select URL field and click Analyze:

    {gitlab_url}/rhdh/rhads-enablement-l3-st-self-service/-/blob/main/namespace-medium/template.yaml
  • Click on the Import button

rhdh register component finish

Congratulations! You now have a new Software template in RHDH. Now, end-users can self-provision Namespaces.

  • We’ll explore the end-user experience by accessing the Software Templates view.

  • From catalog, select Self-service

  • Look for the OpenShift Project Medium Size catalog

    project template

Let’s explore the current catalog:

  • Click on the Choose

  • Review and fill out the information with dummy data until you reach the review screen, without creating the Namespace. DO NOT CLICK ON CREATE.

    project sample

Implement changes in Software Templates.

To accomplish the requirement, we will be updating the quotas definition in the quota.yaml file.

The Python Team will create a new OpenShift project from RHDH. After this, Developer Hub will use the power of GitOps to create a new Project in OpenShift.

Let’s review the information in the new Template.

  • Click on Catalog on the RHDH menu

  • Next, select the filters: Kind:Template and Tags: self-service As shown in the following picture:

self service catalog

  • Select the OpenShift Project Medium Size

  • Access the Source code by clicking on View Source

    namespace edit catalog

    • This action will take you to the template.yaml file. We need to update the Project instance

    • Go to manifests/helm/app/templates/quota.yaml or click on {gitlab_url}/rhdh/rhads-enablement-l3-st-self-service/-/blob/main/namespace-medium/manifests/helm/app/templates/quota.yaml[quota.yaml file^]

    • Increase the quota limit to 2 CPU and memory 2Gi in the current quota.yaml file.

    project file changes

Take the time to review your file with the solution file provided here:

  • Proceed to save your changes.

  • Ensure the template has the latest changes.

    • On RHDH, in the Project template:

{rhdh_url}/catalog/default/template/rhel-vm-medium-template/[Red Hat Developer Hub UI Template^]

  • Click on the entity refresh icon

    rhdh refresh catalog

Test your changes: Explore the user experience as Developer

Let’s create an instance of the new Project defined in the software templates.

  • From catalog, select Self-service, select OpenShift Project Medium Size

  • Click on the Choose

    project template

  • Review the information until you complete the flow and click on Create.

  • You should see a screen like this one:

    namespace updated

  • Open the catalog from the component’s creation page:

catalog open

  • Now, a new component has being created and you should a screen similar like this:

namespace created

  • Watch the following arcade, to explore a similar experience:

  • In case you need to log in to the OpenShift Cluster {openshift_console_url}[Web Console^]

    • Use your user credentials:

      • Username: {openshift_admin_user}

      • Password: {openshift_admin_password}

Conclusion

You have updated a Project software template by increasing the quota limit to fulfill the requirement from the Python Development team.