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

feat(openshift): add Configuring Cryostat Quickstart #668

Merged
merged 9 commits into from
Nov 23, 2023

Conversation

Josh-Matsuoka
Copy link
Contributor

Initial PR for adding the configuring cryostat quickstart to the operator.

Opening as a draft for the moment while I sort out text formatting and adding icons.

Since this quickstart is installed with the operator we shouldn't need to worry too much about constraining it to only appear when the operator is installed, but there's an extra sanity check to make sure the user has permissions to create a cryostat object.

@andrewazores
Copy link
Member

I think this should also be added somehow to the operator bundle - I would hazard a guess that the cryostat-quickstart.yaml should be moved into bundle/manifests/? Otherwise, as this PR sits now, the quickstart document is only available to users who are installing by manually cloning this upstream source repo, not to users who install via the build artifacts from OperatorHub.

@andrewazores
Copy link
Member

I took a quick stab at fixing up some multiline string formatting:

diff --git a/bundle/manifests/cryostat-quickstart.yaml b/bundle/manifests/cryostat-quickstart.yaml
new file mode 100644
index 0000000..a9b948b
--- /dev/null
+++ b/bundle/manifests/cryostat-quickstart.yaml
@@ -0,0 +1,85 @@
+apiVersion: console.openshift.io/v1
+kind: ConsoleQuickStart
+metadata:
+  annotations:
+    capability.openshift.io/name: Console
+  name: configuring-cryostat
+spec:
+  title: Configure Java applications with the Red Hat build of Cryostat
+  conclusion: Your Java application has now been configured to be detected by Cryostat. To profile your Java applications with Cryostat, please follow this documentation.
+  description: Configure your Java applications on OpenShift to be profiled and monitored using the Red Hat build of Cryostat.
+  durationMinutes: 10
+  displayName: Configuring Cryostat
+  introduction: |-
+    Cryostat is a container-native Java application based on JDK Flight Recorder (JFR). You can use it to monitor the performance of the Java Virtual Machine (JVM) for containerized workloads that run on an OpenShift cluster.
+    To enable Cryostat to gather, store, and analyze Java Flight Recorder (JFR) data about target applications that run on Java Virtual Machine (JVM)s, you must configure the applications so that Cryostat can detect and connect to them. This requires you to configure your Java applications to allow Java Management Extensions (JMX) connections and use an OpenShift Service for detection and JMX for connectivity.
+    JMX is a standard feature on a JVM with which you can monitor and manage target applications that run on the JVM. For Cryostat to use JMX, you must enable and configure JMX when you start the JVM because Cryostat requires the target applications to expose a JMX port. Cryostat communicates with the target applications over this JMX port to start and stop JFR recordings and to pull JFR data over the network, enabling Cryostat to store and analyze this JFR data.
+    If you have not yet installed the Cryostat operator, start with the “Get started with the Red Hat build of Cryostat” quick start.
+
+    In this quick start, you will complete the following tasks:
+    Enable remote Java Management Extensions (JMX) connections on your Java application
+    Update Red Hat OpenShift Services with the remote JMX port
+    View your Java application as a target in the Cryostat web application
+    Note: The quickstart uses a sample Quarkus application. You can deploy your own Quarkus application or follow this quick start.
+  tasks:
+  - description: |-
+      To enable remote JMX connections:
+      Click on the perspective switcher at the top of the navigation, and select Administrator.
+      In the navigation menu, click Workloads > Deployments.
+      Click on the quarkus-quickstarts deployment name (or your application’s deployment name).
+      Click Environment.
+      Add a single value entry environment variable where
+      Name: JAVA_OPTS_APPEND
+      Value: -Dcom.sun.management.jmxremote.port=9091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
+      Note: This method enables remote JMX without authentication. Reference Configuring Java applications for details on configuring authentication with SSL/TLS for Remote JMX.
+      Click Save.
+    review:
+      failedTaskHelp: "This task isn’t verified yet. Try the task again."
+      instructions: |-
+        "Click Reload at the bottom of the Environment tab.
+        1. Do you see a single values entry for JAVA_OPTS_APPEND?
+        Yes/No"
+      summary:
+        failed: This task isn’t verified yet. Try the task again.
+        success: You have enabled remote JMX connections.
+    title: Enable remote Java Management Extensions (JMX) connections on your Java application
+  - description: |-
+      To update Red Hat OpenShift Service with the remote JMX port:
+      Click on the perspective switcher at the top of the navigation, and select Administrator.
+      In the navigation menu, click Networking > Services.
+      Click on the quarkus-quickstarts service name (or your application’s service name).
+      Click the “YAML” tab to bring up the YAML editor.
+      In the spec > ports section, add a new port for jfr-jmx
+      /code
+      - name: jfr-jmx
+            protocol: TCP
+            port: 9091
+            targetPort: 9091
+      Click Save.
+    review:
+      failedTaskHelp: "This task isn’t verified yet. Try the task again, or read more about this topic."
+      instructions: |-
+        Click on the perspective switcher at the top of the navigation, and select Developer.
+        In the navigation menu, click Topology.
+        Click on the Cryostat-sample pod > Resources.
+        Do you see Service port: jfr-jmx -> Pod port: 9091 in the cryostat-sample service?
+      summary:
+        failed: "This task isn’t verified yet. Try the task again, or read more about this topic."
+        success: "You have updated the Red Hat Openshift Service with the remote JMX port."
+      title: "Update the Red Hat Openshift Service with the remote JMX port."
+  - description: |-
+      View your Java application as a target in Cryostat:
+      Click on the perspective switcher at the top of the navigation, and select Developer.
+      In the navigation menu, click Topology.
+      The external link icon on the top right quadrant of the cryostat-sample deployment represents the route URL. Click on the external link icon to open the URL and run the Cryostat web application in a new browser tab.
+      Enter your OpenShift credentials to log in to the Cryostat web application.
+      In the Cryostat web application, click on Recordings in the left navigation menu.
+      View quarkus-quickstarts (or your deployed application) in the Targets list.
+      Your Java application has now been configured to be detected by Cryostat. To profile your Java applications with Cryostat, please follow this documentation.
+accessReviewResources:
+  - group: operator.cryostat.io
+    resource: cryostat
+    verb: create
+  - group: operators.coreos.com
+    resource: cryostat-operator
+    verb: create
diff --git a/quickstart/cryostat-quickstart.yaml b/quickstart/cryostat-quickstart.yaml
deleted file mode 100644
index 2d0a4b4..0000000
--- a/quickstart/cryostat-quickstart.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
-apiVersion: console.openshift.io/v1
-kind: ConsoleQuickStart
-metadata:
-  annotations: 
-    capability.openshift.io/name: Console
-  name: configuring-cryostat
-spec:
-  title: Configure Java applications with the Red Hat build of Cryostat 
-  conclusion: Your Java application has now been configured to be detected by Cryostat. To profile your Java applications with Cryostat, please follow this documentation.
-  description: Configure your Java applications on OpenShift to be profiled and monitored using the Red Hat build of Cryostat.
-  durationMinutes: 10
-  displayName: Configuring Cryostat
-  introduction: "Cryostat is a container-native Java application based on JDK Flight Recorder (JFR). You can use it to monitor the performance of the Java Virtual Machine (JVM) for containerized workloads that run on an OpenShift cluster.
-To enable Cryostat to gather, store, and analyze Java Flight Recorder (JFR) data about target applications that run on Java Virtual Machine (JVM)s, you must configure the applications so that Cryostat can detect and connect to them. This requires you to configure your Java applications to allow Java Management Extensions (JMX) connections and use an OpenShift Service for detection and JMX for connectivity.
-JMX is a standard feature on a JVM with which you can monitor and manage target applications that run on the JVM. For Cryostat to use JMX, you must enable and configure JMX when you start the JVM because Cryostat requires the target applications to expose a JMX port. Cryostat communicates with the target applications over this JMX port to start and stop JFR recordings and to pull JFR data over the network, enabling Cryostat to store and analyze this JFR data. 
-If you have not yet installed the Cryostat operator, start with the “Get started with the Red Hat build of Cryostat” quick start.
-
-
-In this quick start, you will complete the following tasks:
-Enable remote Java Management Extensions (JMX) connections on your Java application
-Update Red Hat OpenShift Services with the remote JMX port
-View your Java application as a target in the Cryostat web application
-Note: The quickstart uses a sample Quarkus application. You can deploy your own Quarkus application or follow this quick start."
-  tasks:
-  - description: "To enable remote JMX connections:
-Click on the perspective switcher at the top of the navigation, and select Administrator.
-In the navigation menu, click Workloads > Deployments.
-Click on the quarkus-quickstarts deployment name (or your application’s deployment name).
-Click Environment.
-Add a single value entry environment variable where 
-Name: JAVA_OPTS_APPEND
-Value: -Dcom.sun.management.jmxremote.port=9091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
-Note: This method enables remote JMX without authentication. Reference Configuring Java applications for details on configuring authentication with SSL/TLS for Remote JMX.
-Click Save."
-    review: 
-      failedTaskHelp: "This task isn’t verified yet. Try the task again."
-      instructions: |-
-        "Click Reload at the bottom of the Environment tab.
-        1. Do you see a single values entry for JAVA_OPTS_APPEND?
-        Yes/No"
-      summary:
-        failed: This task isn’t verified yet. Try the task again.
-        success: You have enabled remote JMX connections.
-    title: Enable remote Java Management Extensions (JMX) connections on your Java application
-  - description: "To update Red Hat OpenShift Service with the remote JMX port:
-Click on the perspective switcher at the top of the navigation, and select Administrator.
-In the navigation menu, click Networking > Services.
-Click on the quarkus-quickstarts service name (or your application’s service name).
-Click the “YAML” tab to bring up the YAML editor.
-In the spec > ports section, add a new port for jfr-jmx
-/code    
-- name: jfr-jmx
-      protocol: TCP
-      port: 9091
-      targetPort: 9091
-Click Save."
-    review: 
-      failedTaskHelp: "This task isn’t verified yet. Try the task again, or read more about this topic."
-      instructions: |-
-        "Click on the perspective switcher at the top of the navigation, and select Developer.
-	In the navigation menu, click Topology.
-	Click on the Cryostat-sample pod > Resources.
-	Do you see Service port: jfr-jmx -> Pod port: 9091 in the cryostat-sample service?"
-      summary:
-        failed: "This task isn’t verified yet. Try the task again, or read more about this topic."
-        success: "You have updated the Red Hat Openshift Service with the remote JMX port."
-      title: "Update the Red Hat Openshift Service with the remote JMX port."
-  - description: "View your Java application as a target in Cryostat:
-Click on the perspective switcher at the top of the navigation, and select Developer.
-In the navigation menu, click Topology.
-The external link icon on the top right quadrant of the cryostat-sample deployment represents the route URL. Click on the external link icon to open the URL and run the Cryostat web application in a new browser tab.
-Enter your OpenShift credentials to log in to the Cryostat web application.
-In the Cryostat web application, click on Recordings in the left navigation menu.
-View quarkus-quickstarts (or your deployed application) in the Targets list.
-Your Java application has now been configured to be detected by Cryostat. To profile your Java applications with Cryostat, please follow this documentation."
-accessReviewResources:
-  - group: operator.cryostat.io
-    resource: cryostat
-    verb: create
-  - group: operators.coreos.com
-    resource: cryostat-operator
-    verb: create

@andrewazores
Copy link
Member

https://olm.operatorframework.io/docs/tasks/creating-operator-manifests/#packaging-additional-objects-alongside-an-operator

Operators can include additional objects alongside their CSV in the /manifests directory. These objects should be YAML files and valid kubernetes objects. The following objects are supported as of OLM 0.16.0:
... ConsoleQuickStart

@tthvo
Copy link
Member

tthvo commented Nov 1, 2023

https://olm.operatorframework.io/docs/tasks/creating-operator-manifests/#packaging-additional-objects-alongside-an-operator

I guess we will need to consider Quickstart resource unavailable on Kubernetes when generating the bundle manifests?

@Josh-Matsuoka Josh-Matsuoka marked this pull request as ready for review November 7, 2023 15:57
@ebaron
Copy link
Member

ebaron commented Nov 7, 2023

I guess we will need to consider Quickstart resource unavailable on Kubernetes when generating the bundle manifests?

That's a good point @tthvo. I'm not sure, but I wouldn't be surprised if this fails to install with the QuickStart included on Kubernetes. We should give that a try to make sure. If so, I guess it makes sense to exclude this from upstream builds.

@Josh-Matsuoka
Copy link
Contributor Author

What would need to be done to get this in? I'm not sure I follow from the comments so far

@andrewazores
Copy link
Member

First would be git mv quickstart/cryostat-quickstart.yml bundle/manifests/cryostat-quickstart.yml: this should make it so that the Quickstart resource gets included in the Operator Bundle manifest thing, so that the Quickstart gets shipped along with the packaged form of the Operator as distributed in the OperatorHub. Right now it's only available/visible for users who actually clone this repo and install the Operator manually.

However, the problem with this is that the Quickstart is an OpenShift resource type, so on non-OpenShift Kubernetes installations, this type is probably meaningless. It may make the Operator fail to install since the Bundle will try to create this Quickstart and presumably fail, but we aren't sure if it will block installation or what exactly will happen. Maybe it will silently fail or just emit a warning and things are generally OK, or maybe not and we need to find a way to only include this Quickstart in the Bundle manifest for OpenShift distributions.

So I'd say go ahead and move the Quickstart YAML file into the bundle/manifests/ directory, then try building an Operator Bundle out of it and try deploying that on an OpenShift instance (ex. crc). See that the Quickstart actually gets installed when you go that installation route.

Once you see that that works, try it again on a non-OpenShift Kubernetes and see what it does. I don't think any of us actually know what the outcome will be yet here, so we'll have to see what happens and figure out where to go from there.

@ebaron
Copy link
Member

ebaron commented Nov 14, 2023

First would be git mv quickstart/cryostat-quickstart.yml bundle/manifests/cryostat-quickstart.yml: this should make it so that the Quickstart resource gets included in the Operator Bundle manifest thing, so that the Quickstart gets shipped along with the packaged form of the Operator as distributed in the OperatorHub. Right now it's only available/visible for users who actually clone this repo and install the Operator manually.

The bundle directory is actually generated by make bundle so this might get overwritten. This should be added to the Kustomize build for config/manifests. To keep this organized, I'd create a config/openshift directory with your quickstart and this kustomization.yaml:

resources:
- cryostat-quickstart.yaml

And then reference this directory as a resource in config/manifests/kustomization.yaml:

resources:
- bases/cryostat-operator.clusterserviceversion.yaml
- ../default
- ../samples
- ../scorecard
- ../openshift

[...]

When you run make bundle you should see your quickstart under bundle/manifests/.

However, the problem with this is that the Quickstart is an OpenShift resource type, so on non-OpenShift Kubernetes installations, this type is probably meaningless. It may make the Operator fail to install since the Bundle will try to create this Quickstart and presumably fail, but we aren't sure if it will block installation or what exactly will happen. Maybe it will silently fail or just emit a warning and things are generally OK, or maybe not and we need to find a way to only include this Quickstart in the Bundle manifest for OpenShift distributions.

So I'd say go ahead and move the Quickstart YAML file into the bundle/manifests/ directory, then try building an Operator Bundle out of it and try deploying that on an OpenShift instance (ex. crc). See that the Quickstart actually gets installed when you go that installation route.

Once you see that that works, try it again on a non-OpenShift Kubernetes and see what it does. I don't think any of us actually know what the outcome will be yet here, so we'll have to see what happens and figure out where to go from there.

This one is the big issue here. I would suggest trying Kind or Minikube. Then do:

  1. Install the Operator Lifecycle Manager using steps 1 and 2 from https://cryostat.io/get-started/#install-via-operatorhub.
  2. Double check that bundle/manifests contains your quickstart.
  3. make bundle-build BUNDLE_IMG=quay.io/<your username>/cryostat-operator-bundle:quickstart-01
  4. make cert_manager deploy_bundle BUNDLE_IMG=quay.io/<your username>/cryostat-operator-bundle:quickstart-01
  5. kubectl describe deploy cryostat-operator-controller-manager

This should indicate whether the installation can proceed with a ConsoleQuickstart on Kubernetes.

@ebaron ebaron changed the title Add Configuring Cryostat Quickstart feat(openshift): add Configuring Cryostat Quickstart Nov 21, 2023
@ebaron ebaron self-requested a review November 21, 2023 16:21
@ebaron ebaron added feat New feature or request backport labels Nov 21, 2023
Copy link
Member

@ebaron ebaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some free time so I also gave this a try in Minikube and unfortunately it fails to install:

$ oc describe ip install-ln7t2
Name:         install-ln7t2
Namespace:    default
Labels:       operators.coreos.com/cryostat-operator.default=
Annotations:  <none>
API Version:  operators.coreos.com/v1alpha1
Kind:         InstallPlan
Metadata:
  Creation Timestamp:  2023-11-21T21:32:17Z
  Generate Name:       install-
  Generation:          2
  Managed Fields:
    [...]
  Owner References:
    API Version:           operators.coreos.com/v1alpha1
    Block Owner Deletion:  false
    Controller:            false
    Kind:                  Subscription
    Name:                  cryostat-operator-v2-5-0-dev-sub
    UID:                   abd8f6c7-575d-4660-8def-0a524f34bf2f
  Resource Version:        1215
  UID:                     2b67b80b-5b82-4082-9b3e-aed4dbbc8ec5
Spec:
  Approval:  Manual
  Approved:  true
  Cluster Service Version Names:
    cryostat-operator.v2.5.0-dev
  Generation:  1
Status:
  Bundle Lookups:
    Catalog Source Ref:
      Name:       cryostat-operator-catalog
      Namespace:  default
    Identifier:   cryostat-operator.v2.5.0-dev
    Path:         quay.io/ebaron/cryostat-operator-bundle:quickstart-01
    Properties:   {"properties":[{"type":"olm.gvk","value":{"group":"operator.cryostat.io","kind":"ClusterCryostat","version":"v1beta1"}},{"type":"olm.gvk","value":{"group":"operator.cryostat.io","kind":"Cryostat","version":"v1beta1"}},{"type":"olm.package","value":{"packageName":"cryostat-operator","version":"2.5.0-dev"}}]}
    Replaces:     
  Catalog Sources:
    cryostat-operator-catalog
  Conditions:
    Last Transition Time:  2023-11-21T21:33:22Z
    Last Update Time:      2023-11-21T21:33:22Z
    Message:               api-server resource not found installing ConsoleQuickStart configuring-cryostat: GroupVersionKind console.openshift.io/v1, Kind=ConsoleQuickStart not found on the cluster. This API may have been deprecated and removed, see https://kubernetes.io/docs/reference/using-api/deprecation-guide/ for more information.
    Reason:                InstallComponentFailed
    Status:                False
    Type:                  Installed

I think we should probably just exclude this from our upstream builds. We can still include it in the Kustomize directory but either comment out or remove this line from config/manifests/kustomization.yaml:

- ../openshift

config/manifests/kustomization.yaml Outdated Show resolved Hide resolved
@ebaron ebaron merged commit 8378ca0 into cryostatio:main Nov 23, 2023
5 checks passed
mergify bot pushed a commit that referenced this pull request Nov 23, 2023
* Initial quickstart content, TODO: Formatting

* Updating quickstart content, adding icon

* Removing broken link

* Move quickstart to config/manifests, update kustomization

* Quickstart content fixes

* Don't include openshift dir

* Fix deploy_bundle

* New line at EOF

---------

Co-authored-by: Elliott Baron <[email protected]>
(cherry picked from commit 8378ca0)
ebaron pushed a commit that referenced this pull request Nov 23, 2023
* Initial quickstart content, TODO: Formatting

* Updating quickstart content, adding icon

* Removing broken link

* Move quickstart to config/manifests, update kustomization

* Quickstart content fixes

* Don't include openshift dir

* Fix deploy_bundle

* New line at EOF

---------

Co-authored-by: Elliott Baron <[email protected]>
(cherry picked from commit 8378ca0)

Co-authored-by: Joshua Matsuoka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport feat New feature or request
Projects
No open projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants