|
1 | 1 | # Welcome to the Resource Optimization plugin workspace |
2 | 2 |
|
3 | | -Follow these links to learn more about this plugin: |
| 3 | +## Resource Optimization |
4 | 4 |
|
5 | | -1. [Front-end](./plugins/redhat-resource-optimization/README.md) |
6 | | -2. [Backend-end](./plugins/redhat-resource-optimization-backend/README.md) |
7 | | -3. [Common](./plugins/redhat-resource-optimization-common/README.md) |
8 | | -4. [RBAC](./docs/rbac.md) |
| 5 | +Welcome to the Resource Optimization plugin! |
| 6 | + |
| 7 | +Resource Optimization plugin allows users to visualize usage trends and receive optimization recommendations for workloads running on OpenShift clusters. |
| 8 | +There is also an option to automatically apply recommendations. Refer to [Optimizer App](#optimizer-app) section |
| 9 | + |
| 10 | +## Getting started |
| 11 | + |
| 12 | +### Prerequisite |
| 13 | + |
| 14 | +The plugin consumes services from [Red Hat Hybrid Cloud Console](https://console.redhat.com/openshift/cost-management/optimizations), therefore your clusters [must be configured to receive optimization recommendations](https://docs.redhat.com/en/documentation/cost_management_service/1-latest/html-single/getting_started_with_resource_optimization_for_openshift/index). |
| 15 | + |
| 16 | +#### Service Account Details |
| 17 | + |
| 18 | +You will need to two service accounts from Red Hat Hybrid Cloud Console. |
| 19 | + |
| 20 | +- [Use this link](https://console.redhat.com/iam/service-accounts/) to create service accounts |
| 21 | + |
| 22 | +- [please go through this guide](https://docs.redhat.com/en/documentation/cost_management_service/1-latest/html/limiting_access_to_cost_management_resources/assembly-limiting-access-cost-resources-rbac) and assign below roles to your `service accounts` |
| 23 | + |
| 24 | +1. Service account with `Cloud Administrator` role for configuring `Cost Management Metrics Operator` |
| 25 | +2. Service account with `Cost OpenShift Viewer` role for viewing the optimization data in the RHDH Resource Optimization plugin |
| 26 | + |
| 27 | +## Setup |
| 28 | + |
| 29 | +You can follow one of these options for installing `Resource Optimization` depending on your environment. |
| 30 | + |
| 31 | +### Option 1: Dynamic plugin - on a Red Hat Developer Hub(RHDH) instance |
| 32 | + |
| 33 | +[Follow this link](./docs/dynamic-plugin.md) for installing plugin as Dynamic Plugin |
| 34 | + |
| 35 | +#### Dependency on Orchestrator plugin and Workflow details |
| 36 | + |
| 37 | +The Resource Optimization plugin is dependent on [Orchestrator plugin](https://www.rhdhorchestrator.io/main/docs/) to run the workflow for applying the recommendation. Make sure you have installed the [Orchestrator plugin](https://www.rhdhorchestrator.io/main/docs/) by following one of these options depending on your environment: |
| 38 | + |
| 39 | +- [Install Orchestrator plugin on an exisiting RHDH instance](https://www.rhdhorchestrator.io/main/docs/installation/installation-on-existing-rhdh/) |
| 40 | +- [Install Orchestrator plugin with an RHDH instance](https://www.rhdhorchestrator.io/main/docs/installation/orchestrator/) |
| 41 | + |
| 42 | +This method requires vanilla backstage to be used: |
| 43 | + |
| 44 | +- [Install as a static plugin for local development](https://github.com/redhat-developer/rhdh-plugins/tree/main/workspaces/orchestrator#install-as-a-static-plugin) |
| 45 | + |
| 46 | +**Workflow details** : [Here is the link to the workflow](https://github.com/rhdhorchestrator/serverless-workflows/tree/main/workflows/patch-k8s-resource) which is being used for manually applying the recommendation from the Resource Optimization plugin. |
| 47 | + |
| 48 | +### Option 2: Static plugin - on Vanilla Backstage |
| 49 | + |
| 50 | +1. Add the dependencies |
| 51 | + |
| 52 | + ```sh |
| 53 | + # From your Backstage root directory |
| 54 | + yarn --cwd packages/app add @backstage-community/plugin-redhat-resource-optimization |
| 55 | + yarn --cwd packages/backend add @backstage-community/plugin-redhat-resource-optimization-backend |
| 56 | + ``` |
| 57 | + |
| 58 | +1. Update your `app-config.yaml` file |
| 59 | + |
| 60 | + ```yaml |
| 61 | + # app-config.yaml |
| 62 | + |
| 63 | + proxy: |
| 64 | + endpoints: |
| 65 | + '/cost-management/v1': |
| 66 | + target: https://console.redhat.com/api/cost-management/v1 |
| 67 | + allowedHeaders: ['Authorization'] |
| 68 | + # See: https://backstage.io/docs/releases/v1.28.0/#breaking-proxy-backend-plugin-protected-by-default |
| 69 | + credentials: dangerously-allow-unauthenticated |
| 70 | + |
| 71 | + # Replace `${RHHCC_SA_CLIENT_ID}` and `${RHHCC_SA_CLIENT_SECRET}` with the service account credentials. |
| 72 | + resourceOptimization: |
| 73 | + clientId: ${RHHCC_SA_CLIENT_ID} |
| 74 | + clientSecret: ${RHHCC_SA_CLIENT_SECRET} |
| 75 | + optimizationWorkflowId: 'patch-k8s-resource' |
| 76 | + ``` |
| 77 | +
|
| 78 | +1. Add the back-end plugin to `packages/backend/src/index.ts` |
| 79 | + |
| 80 | + ```ts |
| 81 | + backend.add( |
| 82 | + import('@backstage-community/plugin-redhat-resource-optimization-backend'), |
| 83 | + ); |
| 84 | + ``` |
| 85 | + |
| 86 | +1. Add the `ResourceOptimizationPage` extension to your `App.tsx` routes |
| 87 | + |
| 88 | + ```ts |
| 89 | + // packages/app/src/App.tsx |
| 90 | +
|
| 91 | + import { ResourceOptimizationPage } from '@backstage-community/plugin-redhat-resource-optimization'; |
| 92 | +
|
| 93 | + <FlatRoutes> |
| 94 | + ... |
| 95 | + <Route |
| 96 | + path="/redhat-resource-optimization" |
| 97 | + element={<ResourceOptimizationPage />} |
| 98 | + /> |
| 99 | + ... |
| 100 | + </FlatRoutes>; |
| 101 | + ``` |
| 102 | + |
| 103 | +1. Add a link to the Resource Optimization page in the side bar |
| 104 | + |
| 105 | + ```diff |
| 106 | + // packages/app/src/components/Root/Root.tsx |
| 107 | +
|
| 108 | + + import { ResourceOptimizationIconOutlined } from '@backstage-community/plugin-redhat-resource-optimization'; |
| 109 | +
|
| 110 | + export const Root = ({ children }: PropsWithChildren<{}>) => ( |
| 111 | + <SidebarPage> |
| 112 | + <Sidebar> |
| 113 | + <SidebarLogo /> |
| 114 | + <SidebarGroup label="Search" icon={<SearchIcon />} to="/search"> |
| 115 | + <SidebarSearchModal /> |
| 116 | + </SidebarGroup> |
| 117 | + <SidebarDivider /> |
| 118 | + <SidebarGroup label="Menu" icon={<MenuIcon />}> |
| 119 | + {/* Global nav, not org-specific */} |
| 120 | + <SidebarItem icon={HomeIcon} to="catalog" text="Home" /> |
| 121 | + <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" /> |
| 122 | + <SidebarItem icon={LibraryBooks} to="docs" text="Docs" /> |
| 123 | + <SidebarItem icon={CreateComponentIcon} to="create" text="Create..." /> |
| 124 | + {/* End global nav */} |
| 125 | + <SidebarDivider /> |
| 126 | + <SidebarScrollWrapper> |
| 127 | + <SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" /> |
| 128 | + </SidebarScrollWrapper> |
| 129 | + + <SidebarItem |
| 130 | + + icon={ResourceOptimizationIconOutlined} |
| 131 | + + to="/redhat-resource-optimization" |
| 132 | + + text="Optimizations" |
| 133 | + + /> |
| 134 | + </SidebarGroup> |
| 135 | + <SidebarSpace /> |
| 136 | + <SidebarDivider /> |
| 137 | + <SidebarGroup |
| 138 | + label="Settings" |
| 139 | + icon={<UserSettingsSignInAvatar />} |
| 140 | + to="/settings" |
| 141 | + > |
| 142 | + <SidebarSettings /> |
| 143 | + </SidebarGroup> |
| 144 | + </Sidebar> |
| 145 | + {children} |
| 146 | + </SidebarPage> |
| 147 | + ); |
| 148 | + ``` |
| 149 | + |
| 150 | +## RBAC Permissions |
| 151 | + |
| 152 | +The HTTP endpoints exposed by the redhat-resource-optimization-backend can enforce authorization if the [RBAC plugin](https://github.com/backstage/community-plugins/tree/main/workspaces/rbac/plugins) is deployed. Please refer the RBAC plugin documentation for the setup steps (mind they rely on the [Backstage authentication and identity](https://backstage.io/docs/auth/)). |
| 153 | + |
| 154 | +- More detailed info about Resource Optimization plugin RBAC permissions can be found in [docs/rbac.md](./docs/rbac.md) |
| 155 | +- More detailed info about Orcestrator plugin RBAC for setting up permission for workflow can be [found here](https://github.com/redhat-developer/rhdh-plugins/blob/main/workspaces/orchestrator/docs/Permissions.md). |
| 156 | + |
| 157 | +## Optimizer App |
| 158 | + |
| 159 | +An application for applying the recommendations automatically. The application makes use of OSL (OpenShift Serverless Logic, a.k.a. SonataFlow) which is part of the Orchestrator installation. If you already have the [Orchestrator plugin and the workflow](#dependency-on-orchestrator-plugin-and-workflow-details) installed then you are ready for installing the Optimizer application. Follow the [application instructions](https://github.com/rhdhorchestrator/optimizer/tree/main) for installing and configuring it. |
0 commit comments