Skip to content

Commit

Permalink
Merge pull request #59 from ch007m/bump-plugin-0.1.21
Browse files Browse the repository at this point in the history
Bump the version of the quarkus plugins to 0.1.21
  • Loading branch information
cmoulliard committed Feb 20, 2024
2 parents fb12663 + cadd269 commit db72d63
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 50 deletions.
83 changes: 41 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* [Kubevirt](#kubevirt)
* [GitOps](#gitops)
* [Tekton](#tekton)
* [First step](#first-step)
* [Use Backstage on OCP](#use-backstage-on-ocp)
* [First steps](#first-step)
* [Deploy and use Backstage on OCP](#deploy-and-use-backstage-on-ocp)
* [Run backstage locally](#run-backstage-locally)
* [Clean up](#clean-up)


# Backstage QShift Showcase

The backstage QShift application has been designed to showcase QShift (Quarkus on OpenShift). It is composed of the following plugins and integrated with different backend systems:
Expand All @@ -36,9 +35,14 @@ The backstage QShift application has been designed to showcase QShift (Quarkus o
- [GitHub client](https://cli.github.com/) (optional)
- [argocd client](https://argo-cd.readthedocs.io/en/stable/getting_started/#2-download-argo-cd-cli) (optional)

**Important**: If you need to provision an OpenShift cluster with the required backend systems: ArgoCD, Tekton, etc, then go to the section [Install me](#install-me)

## Instructions

If you plan to install QShift on a new cluster, then check first the section `Install me`. Otherwise, you can go directly to `First step`
This project allows to play with QShift using either **Backstage**:
- Running [locally](#run-backstage-locally) or
- [Deployed](#deploy-and-use-backstage-on-ocp) on an OpenShift cluster


### Install me

Expand Down Expand Up @@ -136,22 +140,27 @@ cd manifest/installation/tekton
kubectl apply -f subscription-pipelines.yml
```

### First step
### First steps

Before to play with QShift backstage, it is needed to perform some steps such as:
Before to install and use our Backstage application, it is needed to perform some steps such as:
- Create an OpenShift project
- Provide your registry credentials (quay.io, docker, etc) as a `config.json` file
- Create a secret of type `kubernetes.io/service-account-token` to get a token that backstage will use to access the cluster and will never expire.

TODO: Review how we introduce the commands to be executed
The commands described hereafter will help you to set up what it is needed:

- Start first by cloning this project locally
```bash
git clone https://github.com/q-shift/backstage-playground.git
cd backstage-playground
```
- Log on to the ocp cluster `oc login --token=sha256 ...` which has been provisioned
- Create an OpenShift project:
```bash
oc new-project <MY_NAMESPACE>
```
**Important**: The commands documented hereafter assume that your use the project created: `oc project <MY_NAMESPACE>`

- Log on to the ocp cluster which has been provisioned and create an OpenShift project that you will use to play: `oc new-project <MY_NAMESPACE>`

**Important**: The commands documented hereafter assume that your current kubernetes context matches the `<MY_NAMESPACE>` namespace.

- Next create the following registry `config.json` file using your Quay and Docker credentials as they are needed to build/push the image of the Quarkus container or to pull images from docker registry without the hassle of the `docker limit`.
- Next create the following registry `config.json` file (or use yours). Provide the following registry: quay.io and docker as they are needed to build/push the image of the Quarkus container or to pull images from docker registry without the hassle of the `docker limit`.
```bash
QUAY_CREDS=$(echo -n "<QUAY_USER>:<QUAY_TOKEN>" | base64)
DOCKER_CREDS=$(echo -n "<DOCKER_USER>:<DOCKER_PWD>" | base64)
Expand All @@ -178,55 +187,45 @@ TODO: Review how we introduce the commands to be executed
```bash
kubectl create secret generic dockerconfig-secret --from-file=config.json
```
- Create now a Secret hosting the backstage's `service-account-token`:
- **Warning**: To let ArgoCD to handle the `Applications` CR within your namespace, it is needed to patch the resource `kind: ArgoCD` to add your namespace using the field: `.spec.sourceNamespaces`. When patched, the ArgoCD operator will roll out automatically the ArgoCD server.
```bash
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
name: backstage-token-secret
annotations:
kubernetes.io/service-account.name: "my-backstage"
EOF
kubectl get argocd/openshift-gitops -n openshift-gitops -o json \
| jq '.spec.sourceNamespaces += ["<MY_NAMESPACE>"]' | kubectl apply -f -
```
**Note**: We will use this secret to get the token needed to set the variable `SERVICE_ACCOUNT_TOKEN` using the [backstage_env_secret.tmpl](manifest%2Ftemplates%2Fbackstage_env_secret.tmpl)
- And finally, create the service account `my-backstage`.
```bash
kubectl create sa my-backstage
```
**Note**: This is needed to create the SA in order to get the secret generated and containing the token that we will use at the step `Deploy and use Backstage on OCP`
### Use Backstage on OCP
We are now ready to deploy and use backstage within your project as documented at the following section.
### Deploy and use Backstage on OCP
A Backstage application uses an app-config.yaml [configuration](https://backstage.io/docs/conf/writing) file to configure its front and backend application like the plugins accessing the backend systems.
Instead of using a local config file, as this is the case when you start backstage locally (`yarn dev`), we will use for ocp a `configMap` and a `secret` to store the sensitive information. This kubernetes secret, which contains k=v pairs, will be mounted as a volume within the backstage's pod and will override the `appo-config.yaml` file mounted also as a volume from a ConfigMap.
As we cannot use a local config file as this is the case when you start backstage locally (`yarn dev`), then we will use for ocp a `configMap` and
define the sensitive information in a kubernetes `secret`.
**Trick**: The [backstage_env_secret.tmpl](manifest/templates/backstage_env_secret.tmpl) file contains what you need to get or set the sensitive information :-)
This kubernetes secret, which contains k=v pairs, will be mounted as a volume within the backstage's pod and will override the `appo-config.yaml` file mounted also as a volume from a ConfigMap.
**Remark**: As the env variables should be substituted within the backstage config file, please review the [configmap.app-config.yaml](manifest%2Fhelm%2Ftemplates%2Fconfigmap.app-config.yaml) file first to understand the purpose of the different parameters !
**Trick**: The [backstage_env_secret.tmpl](manifest/templates/backstage_env_secret.tmpl) file contains what you need to get or set the sensitive information :-)
- Create now the env secret's file from the template and set the sensitive information:
- Copy the template and save it: `backstage_env_secret.env`:
```bash
cp manifest/templates/backstage_env_secret.tmpl backstage_env_secret.env
```
- Create a kubernetes generic secret using the env file:
- Edit the file `backstage_env_secret.env` and set the different values using the commands or information between `<command or trick>`
- Create the kubernetes secret using the env file:
```bash
kubectl create secret generic my-backstage-secrets --from-env-file=backstage_env_secret.env
```
To let ArgoCD to deploy resources in your namespace, it is needed to patch the resource `kind: ArgoCD` to add your namespace using the field: `.spec.sourceNamespaces`. When patched, the ArgoCD operator will rollout automatically the ArgoCD server.
```bash
kubectl get argocd/openshift-gitops -n openshift-gitops -o json \
| jq '.spec.sourceNamespaces += ["<MY_NAMESPACE>"]' | kubectl apply -f -
```
- Deploy backstage using this command able to create an ArgoCD Application CR:
- To deploy backstage, create from the template `manifest/templates/argocd.tmpl` the argocd.yaml file and pass env variables to be substituted:
```bash
cat manifest/templates/argocd.tmpl | NAMESPACE=<MY_NAMESPACE> DOMAIN=<OCP_CLUSTER_DOMAIN> envsubst > argocd.yaml
kubectl apply -f argocd.yaml
```
**Note**: The <OCP_CLUSTER_DOMAIN> corresponds to the OpenShift domain (example: `apps.qshift.snowdrop.dev`, `apps.newqshift.lab.upshift.rdu2.redhat.com`)
Verify if backstage is alive using the URL: `https://backstage-<MY_NAMESPACE>.<OCP_CLUSTER_DOMAIN>` and start to play with the template `Create Quarkus Application`
![scaffold-templates-page.png](docs%2Fscaffold-templates-page.png)
Expand Down
10 changes: 5 additions & 5 deletions manifest/templates/backstage_env_secret.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
BASE_URL=<localhost vs https://openshift_backstage_route>
BACKSTAGE_AUTH_SECRET=<node -p 'require("crypto").randomBytes(24).toString("base64")'>
BASE_URL="https://backstage-<NAMESPACE>.<OCP_CLUSTER_DOMAIN>/" where <OCP_CLUSTER_DOMAIN> corresponds to the OpenShift domain: apps.qshift.snowdrop.dev, apps.newqshift.lab.upshift.rdu2.redhat.com, etc
BACKSTAGE_AUTH_SECRET="Execute this command from a terminal to get a crypto password: node -p 'require("crypto").randomBytes(24).toString("base64")'>"

GITHUB_PERSONAL_ACCESS_TOKEN=<see https://backstage.io/docs/getting-started/configuration/#setting-up-a-github-integration>
GITHUB_PERSONAL_ACCESS_TOKEN="See the GitHub documentation: https://backstage.io/docs/getting-started/configuration/#setting-up-a-github-integration"

TEMPLATE_URL=https://github.com/q-shift/qshift-templates/blob/main/qshift/all.yaml

ARGOCD_SERVER=https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev
ARGOCD_ADMIN_USER=admin
ARGOCD_ADMIN_PASSWORD=<kubectl -n openshift-gitops get secret/openshift-gitops-cluster -ojson | jq -r '.data."admin.password" | @base64d'>
ARGOCD_ADMIN_PASSWORD="Execute this command from a terminal to get the password: kubectl -n openshift-gitops get secret/openshift-gitops-cluster -ojson | jq -r '.data."admin.password" | @base64d'"

KUBERNETES_API_URL=https://kubernetes.default.svc
SERVICE_ACCOUNT_TOKEN=<kubectl get secret backstage-token-secret -o go-template='{{.data.token | base64decode}}'>
SERVICE_ACCOUNT_TOKEN="Execute this command from a terminal to get the token: kubectl get secret $(kubectl get secret | grep my-backstage-token | cut -f1 -d " ") -o go-template='{{.data.token | base64decode}}'>"
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"@janus-idp/backstage-plugin-topology": "^1.18.2",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@qshift/plugin-quarkus": "^0.1.20",
"@qshift/plugin-quarkus-console": "^0.1.20",
"@qshift/plugin-quarkus": "^0.1.21",
"@qshift/plugin-quarkus-console": "^0.1.21",
"@roadiehq/backstage-plugin-argo-cd": "2.4.1",
"history": "^5.0.0",
"react": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@backstage/plugin-search-backend-module-techdocs": "^0.1.12",
"@backstage/plugin-search-backend-node": "^1.2.12",
"@backstage/plugin-techdocs-backend": "^1.9.1",
"@qshift/plugin-quarkus-backend": "^0.1.20",
"@qshift/plugin-quarkus-backend": "^0.1.21",
"@roadiehq/scaffolder-backend-argocd": "^1.1.19",
"@roadiehq/backstage-plugin-argo-cd-backend": "^2.14.0",
"app": "link:../app",
Expand Down

0 comments on commit db72d63

Please sign in to comment.