Creating a Golden Path in Backstage: Deploying Python Applications to OpenShift
Table of Contents
Golden Paths - This article is part of a series.
Introduction #
In the previous post, we discussed the concept of Golden Paths in the context of Platform Engineering, Internal Developer Platforms (IDPs), and OpenShift/Kubernetes. Now, let’s dive into the technical specifics and create a Golden Path using Backstage, an open-source IDP, to deploy a Python application to an OpenShift cluster.
This post will guide you through the process of defining a Golden Path within Backstage, setting up the necessary configuration, and finally, deploying a Python application using the Golden Path.
Setting up Backstage #
Firstly, you need to have Backstage set up in your environment. If you haven’t done this yet, follow the Backstage installation guide.
Defining the Golden Path #
To define a Golden Path within Backstage, you need to create a Software Template. This serves as a blueprint for creating new software components. Here’s how to create a Software Template for deploying a Python application to OpenShift:
- Navigate to your Backstage repository and go to the
templates
directory. - Create a new directory for your template, for example,
python-openshift
. - In this directory, create a new
template.yaml
file.
This file should contain metadata about the template and the steps required to create a new component from the template.
Creating the Software Template #
Here’s an example of a template.yaml
file for a Python application that can be deployed to OpenShift:
apiVersion: backstage.io/v1alpha1
kind: Template
metadata:
name: python-openshift
title: Python Application
description: A simple Python application for OpenShift
spec:
owner: team-platform
type: service
steps:
- id: fetch-base
name: Fetch Base
action: fetch:cookiecutter
input:
url: https://github.com/openshift/python-ex
- id: publish
name: Publish to OpenShift
action: openshift:publish
input:
repoUrl: '{{cookiecutter.github.repoUrl}}'
output:
fetchUrl: '{{cookiecutter.github.repoUrl}}'
This template fetches a base Python application from a GitHub repository using the fetch:cookiecutter
action. It then publishes the application to an OpenShift cluster using the openshift:publish
action.
Deploying a Python Application #
Once the template is in place, developers can use it to deploy a Python application to OpenShift via Backstage. They would simply:
- Navigate to the ‘Create’ page in Backstage.
- Select the ‘Python Application’ template.
- Fill in the necessary details.
- Click on ‘Create’.
Backstage will then use the template to create and deploy the Python application to OpenShift.
Conclusion #
In this post, we explored the technical specifics of creating a Golden Path in Backstage for deploying Python applications to OpenShift. This process not only standardizes the deployment process but also makes it significantly easier for developers.
By integrating Backstage with OpenShift, we can leverage the power of both platforms to create a streamlined, efficient, and effective deployment pipeline.
Remember, this is just a basic example, and you can customize this process to suit your specific requirements. Stay tuned for more posts on using Backstage and OpenShift to simplify your deployment processes, especially with Red Hat’s new project Janus!
References #
- Backstage Software Templates
- Backstage Installation Guide
- raffaelespazzoli/backstage-demo
- Janus IDP Backstage Showcase
- Deploying Backstage onto OpenShift Using the Backstage Helm Chart | Janus
- A developer’s guide to Red Hat Developer Hub and Janus | Red Hat Developer
- Red Hat Unveils Red Hat Developer Hub to Help Fuel Developer Productivity