Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ramendemo app used for ODR demo #27

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b13cc1f
Keycloack over ODF test app
Aug 23, 2021
b17257d
Switch test yaml to ODF storage class for postgres
Aug 23, 2021
9bb333b
Add README.md
Aug 23, 2021
0631fbb
Simplify route naming
Aug 24, 2021
dfaf715
Final touch to README
Aug 24, 2021
60a1bf9
Change SC name for Annette
Aug 24, 2021
1fec153
Label change added to RBD mirroring branch
Aug 25, 2021
755b07e
Add a simple RBD loop application
Sep 2, 2021
394ba05
Make it NS free float
Sep 2, 2021
4d2a5a3
Add labels to PVCs
Sep 22, 2021
02c1626
Change application from jobs to pods
Nov 24, 2021
2da361c
New test apop with dashboard
Dec 14, 2021
88d8595
Change app label for compatibility
Dec 14, 2021
e71ad03
Fix kust.yaml with relatiuve path
Dec 14, 2021
cecdc70
Create dedicated directory for test app
Dec 14, 2021
20f5142
Tuning
Dec 14, 2021
ca6a8fa
Bla
Dec 14, 2021
83965c2
Bla
Dec 14, 2021
627c6d7
Fix SQL_URL env variable typo
Dec 14, 2021
26e8b7c
Add mysql automation
Dec 14, 2021
d06ebff
Modify mysql default storage class
Dec 14, 2021
785364f
Automate Grafana operator configuration
Dec 15, 2021
a4f5353
Update gist for mysql on perf3 in mysql namespace
Dec 15, 2021
ac780c6
Change Grafana kustomization file order
Dec 15, 2021
671ca61
Make datasource default and change the editable property
Dec 15, 2021
6e5c128
Fix SQL_URL and change to default storage class for ACM hub tresting
Dec 15, 2021
15e7ad5
For Annette WS environment
Dec 15, 2021
dca6d5e
Dashboard fix and switch rbdloop.yaml to Annette AWS
Dec 15, 2021
e7b3090
Fix bar min and max values and add instructions
Dec 15, 2021
1fed0f7
Move README.md file for ramendemoapp
Dec 16, 2021
5f06d5d
Fix min max at the incorrect place
Dec 16, 2021
fb00e81
Convert instructions to markdown
Dec 16, 2021
70e384b
Modified rbdloop.yaml
netzzer Dec 17, 2021
8a61a78
add rbdloop.yaml
netzzer Dec 17, 2021
f2eb6a1
modify kustomization.yaml
netzzer Dec 17, 2021
e279df4
rbdloop image pull Always
netzzer Dec 17, 2021
d741495
change to IP:port
netzzer Dec 18, 2021
9cc55c4
change to back hostname
netzzer Dec 18, 2021
d8d0a9d
new README and delete app diretory
netzzer Dec 18, 2021
53366ec
Merge pull request #1 from netzzer/ramendemo
Dec 18, 2021
7e2564c
More README changes
netzzer Dec 18, 2021
65eab3b
Merge pull request #2 from netzzer/ramendemo
Dec 18, 2021
6fe0e13
Changes for AWS infra in files and README
netzzer Dec 21, 2021
7c46c89
minor change to mysql.yaml
netzzer Dec 21, 2021
a5b3b52
Merge pull request #3 from netzzer/ramendemo
Jan 4, 2022
849ee42
Merge branch 'stolostron:main' into ramendemo
Jan 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,323 changes: 1,323 additions & 0 deletions grafana-mysql-dashboard-for-ramendemo-new.yaml

Large diffs are not rendered by default.

664 changes: 664 additions & 0 deletions grafana-mysql-dashboard-for-ramendemo-old.yaml

Large diffs are not rendered by default.

660 changes: 660 additions & 0 deletions guimou-qui-marche-encore.json

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions keycloak-odf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Demonstrate a sample keycloak application
## Tool Requirements
- OpenShift CLI Version >= 4.3.0<br>_Needed for kustomize_

```bash
oc version
```

- OpenShift Data Foundation Version >= 4.4.0<br>_For general use case_

```bash
oc get csv pn openshift-storage
NAME DISPLAY VERSION REPLACES PHASE
ocs-operator.v4.8.0 OpenShift Container Storage 4.8.0 Succeeded
```

## Summary
Demonstrate a keycloak application (frontend+backend) leveraging Red Hat OpenShift Data Foundation block device capabilites when deployed using ACM. This application offers a WEB UI while using a PostgreSQL database to store its information.

## Prerequisite

- 1+ managed-clusters total
- Those `Managed-Cluster` to target, must have a label with `metadata.labels.usage: development`
- Target clusters must have the PostgreSQL Operator Deployed
- Target clusters must have the Red Hat OpenShift Data Foundation and an operational Ceph cluster deployed

## Application Console: Create a new application
Using the application console, you can easily create an Application to run this demo.

#### Console
1. Open the Red Hat Advanced Cluster Management for Kubernetes console
2. Navigate on the left navigation menu to `Managed applications`
3. Click the `Create application` button
4. Enter the following values:
* **Name:** `keycloak-odf`
* **Namespace:** `keycloak-odf`
* **Repository types:** `Git`
* **URL:** `https://github.com/open-cluster-management/application-samples.git`
* **Branch:** `main`
* **Path:** `keycloak-odf`
* Select `Deploy application resources only on clusters matching specified labels`
* **Label name:** `usage`
* **Label value:** `development`
5. Click `Save`

### Viewing
1. Navigate on the left navigation menu to `Managed applications`
2. Click the `keycloak-odf` Application name.
3. View the Topology
4. Click the `Route` node to obtain the application URL
5. Click the URL to see the keycloak sample application

49 changes: 49 additions & 0 deletions keycloak-odf/keycloak-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: keycloak-odf-app
# namespace: postgres-operator
namespace: keycloak-odf
labels:
app.kubernetes.io/name: keycloak-odf-app
spec:
selector:
matchLabels:
app.kubernetes.io/name: keycloak-odf-app
template:
metadata:
labels:
app.kubernetes.io/name: keycloak-odf-app
spec:
containers:
- image: quay.io/keycloak/keycloak:latest
name: keycloak
env:
- name: DB_VENDOR
value: "postgres"
- name: DB_ADDR
valueFrom: { secretKeyRef: { name: keycloak-odf-db-pguser-keycloak-odf-db, key: host } }
- name: DB_PORT
valueFrom: { secretKeyRef: { name: keycloak-odf-db-pguser-keycloak-odf-db, key: port } }
- name: DB_DATABASE
valueFrom: { secretKeyRef: { name: keycloak-odf-db-pguser-keycloak-odf-db, key: dbname } }
- name: DB_USER
valueFrom: { secretKeyRef: { name: keycloak-odf-db-pguser-keycloak-odf-db, key: user } }
- name: DB_PASSWORD
valueFrom: { secretKeyRef: { name: keycloak-odf-db-pguser-keycloak-odf-db, key: password } }
- name: KEYCLOAK_USER
value: "admin"
- name: KEYCLOAK_PASSWORD
value: "admin"
- name: PROXY_ADDRESS_FORWARDING
value: "true"
ports:
- name: http
containerPort: 8080
- name: https
containerPort: 8443
readinessProbe:
httpGet:
path: /auth/realms/master
port: 8080
restartPolicy: Always
38 changes: 38 additions & 0 deletions keycloak-odf/keycloak-postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: keycloak-odf-db
namespace: keycloak-odf
spec:
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-1
postgresVersion: 13
instances:
- replicas: 1
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 10Gi
storageClassName: ocs-storagecluster-ceph-mirror
metadata:
labels:
"appname": "keycloak-odf-app"
backups:
pgbackrest:
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-1
repoHost:
dedicated: {}
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 100Gi
storageClassName: ocs-storagecluster-ceph-mirror
metadata:
labels:
"appname": "keycloak-odf-app"
10 changes: 10 additions & 0 deletions keycloak-odf/keycloak-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: frontend
spec:
# host: keycloak-odf.apps.ocpacm.ocstraining.com
tls:
termination: passthrough
to:
name: frontend
15 changes: 15 additions & 0 deletions keycloak-odf/keycloak-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
# name: keycloak-odf
name: frontend
labels:
name: frontend
spec:
type: ClusterIP
ports:
- port: 8443
targetPort: 8443
protocol: TCP
selector:
app.kubernetes.io/name: keycloak-odf-app
5 changes: 5 additions & 0 deletions keycloak-odf/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- keycloak-postgres.yaml
- keycloak-app.yaml
- keycloak-service.yaml
- keycloak-route.yaml
22 changes: 22 additions & 0 deletions ramendemo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM registry.access.redhat.com/ubi8/python-38
#FROM docker.io/centos:centos7
ENV ENABLE_MICROPIPENV="1" \
UPGRADE_PIP_TO_LATEST="1"
USER root

RUN yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
RUN wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
RUN yum localinstall mysql80-community-release-el8-1.noarch.rpm -y
RUN yum install python3-mysqlclient mysql-connector-odbc gcc unixODBC-devel -y

RUN python -m pip install --upgrade pip
RUN pip3 install shortuuid mysqlclient mysql-connector mysql-connector-python pyodbc

#RUN yum install gcc unixODBC-devel python3-mysqlclient mysql-connector-odbc -y
#RUN python -m pip install --upgrade pip
#RUN pip3 install shortuuid mysqlclient mysql-connector mysql-connector-python pyodbc

WORKDIR /tmp
ADD *.py .

ENTRYPOINT [ "python3", "/tmp/runloop.py --size --server" ]
174 changes: 174 additions & 0 deletions ramendemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# RBD demo application with dashboard

## Prepare your demo
Fork my repo at `https://github.com/jeanchlopez/application-samples`.

```
git clone https://github.com/{username}/application-samples
cd application-samples
git checkout ramendemo
git fetch
git pull
```
Create a new project on OpenShift cluster with ACM installed:

```
oc new-project ramendemo-mysql
```

## Deploying MySQL Server

In ACM create new application (**non-AWS**):

- Name = `ramendemo-mysql`
- Namespace = `ramendemo-mysql`
- Git = `https://github.com/{username}/application-samples`
- Branch = `ramendemo`
- Path = `ramendemo/mysql`
- `Deploy on local cluster`

If deploying on **AWS** use this method and YAML file to deploy MySQL.

```
cd ramendemo/mysql
oc project ramendemo-mysql
oc create -f mysql-aws.yaml
```

## Deploying Grafana dashboard

Due to an issue with the Grafana operator (`https://github.com/grafana-operator/grafana-operator/issues/655`)
the dashboard can not be configured via ACM.

You will have to deploy the Grafana dashboard in the same namespace as the one where the MySQl server was deployed.
```
cd ramendemo/grafana
oc project ramendemo-mysql
```

Deploy the Grafana operator:

```
oc create -f operator.yaml
```

Wait for the operator to be deployed and show a `Succeeded` Phase.

```
oc get csv -n ramendemo-mysql
```

Example output:

```
NAME DISPLAY VERSION REPLACES PHASE
grafana-operator.v4.1.1 Grafana Operator 4.1.1 grafana-operator.v4.1.0 Succeeded
```

Once the Grafana operator is deployed, create Grafana resources. Order of yaml files is datasource, next dashboard, then grafana instance.

```
oc create -f grafana-mysql-datasource-for-ramendemo.yaml -n ramendemo-mysql
oc create -f grafana-mysql-dashboard-for-ramendemo.yaml -n ramendemo-mysql
oc create -f grafana-instance.yaml -n ramendemo-mysql
```

Wait for the Grafana pod to restart. If you need to connect with admin privilege use the following credentials.

- User name = `admin`
- Password = `ramendemo`

Do this to find the URL to reach the Grafana UI:

```
oc get route grafana-route in ramendemo-mysql
```

Copy the resulting route into a browser tab to validate you have access to Grafana.

NOTE: Make sure you sure to use `https` for the Grafana route.

NOTE: Login to Grafana and check you have a datasource. If there is a no datasource, you need to `oc apply -f grafana-mysql-datasource-for-ramendemo.yaml` and then check again to see of there is a datasource.

## Configure MySQl address for test application

Update the `rbdloop.yaml` with parameters matching your environment.

To do this find the route for your mysql instance (**non-AWS**):

```
oc get route ramendemo-mysql -n ramendemo-mysql
```
Use the resulting route to modify `rbdloop.yaml`as shown below (example SQL_SERVER value).

NOTE: Make sure you are in the `ramendemo` directory.

```
cat rbdloop.yaml
[…]
- name: SQL_SERVER
value: "ramendemo-mysql-ramendemo-mysql.apps.hub.makestoragegreatagain.com"
- name: SQL_PORT
value: "30136"
[…]
```

If on using **AWS** do this:

```
oc get svc ramendemo-mysql -n ramendemo-mysql
```

Use the resulting `LoadBalancer` service `EXTERNAL-IP` to modify `rbdloop.yaml`as shown below (example SQL_SERVER value).

```
cat rbdloop.yaml
[…]
- name: SQL_SERVER
value: "a0daa32ed84804c9c88924a734218abc-1519604064.us-east-2.elb.amazonaws.com"
- name: SQL_PORT
value: "3306"
[…]
```

Now `rbdloop.yaml` needs to be committed to your forked repo.

```
git add rbdloop.yaml
git commit -m "Modified rbdloop.yaml"
git push origin ramendemo
```

## Deploy the application

Create a new project on OpenShift cluster with ACM installed.

```
oc new-project rbdloop-dashboard
```
NOTE: Make sure you are in the `ramendemo` directory.

You now need to create a DRPlacementControl (DRPC)and PlacementRule for the `rbdloop` application.

NOTE: Make sure to modify the DRPC YAML file and modify `cluster1` to be accurate for your environment. Modify to use the cluster name in ACM for your preferredCluster.

```
oc create -f rbdloop-drpc.yaml -n rbdloop-dashboard
```

Now create the PlacementRule:

```
oc create -f rbdloop-placementrule.yaml -n rbdloop-dashboard
```

In ACM create the new `rbdloop` application.

- Name = `rbdloop`
- Namespace = `rbdloop-dashboard`
- Git = `https://github.com/{username}/application-samples`
- Branch = `ramendemo`
- Path = `ramendemo`
- Select an existing placement configuration = `rbdloop-placement`

Go back to Grafana and navigate to the `Ramen Demo Application Dashboard` to monitor cluster Failover and Relocate operations.
24 changes: 24 additions & 0 deletions ramendemo/grafana/grafana-instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: ramendemo-grafana
spec:
ingress:
enabled: true
config:
auth:
disable_signout_menu: true
auth.anonymous:
enabled: true
log:
level: warn
mode: console
security:
admin_password: ramendemo
admin_user: admin
dashboardLabelSelector:
- matchExpressions:
- key: app
operator: In
values:
- grafana
Loading