Skip to content

Commit

Permalink
update ConsolePlugin proxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
yapei committed Feb 14, 2022
1 parent c2d16e6 commit dae2209
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
15 changes: 8 additions & 7 deletions dynamic-demo-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ spec:

In case the plugin needs to communicate with some in-cluster service, it can
declare a service proxy in its `ConsolePlugin` resource using the
`spec.proxy.services` array field. A service `name`, `namespace` and `port`
`spec.proxy` array field. Each entry needs to specify type and alias of the proxy, under the `type` and `alias` field. For the `Service` proxy type, a `service` field with `name`, `namespace` and `port`
needs to be specified.

Console backend exposes following endpoint in order to proxy the communication
between plugin and the service:
`/api/proxy/namespace/<service-namespace>/service/<service-name>:<port-number>/<request-path>?<optional-query-parameters>`
`/api/proxy/plugin/<plugin-name>/<proxy-alias>/<request-path>?<optional-query-parameters>`

An example proxy request path from plugin to `helm-charts` service,
in `helm` namespace to list ten helm releases:
`/api/proxy/namespace/helm/service/helm-charts:8443/releases?limit=10`
An example proxy request path from `helm` plugin with a `helm-charts` service to list ten helm releases:
`/api/proxy/plugin/helm/helm-charts/releases?limit=10`

Proxied request will use [service CA bundle](https://access.redhat.com/documentation/en-us/openshift_container_platform/4.9/html/security_and_compliance/certificate-types-and-descriptions#cert-types-service-ca-certificates) by default. The service must use HTTPS.
If the service uses a custom service CA, the `caCertificate` field
Expand All @@ -93,8 +92,10 @@ then passed in the HTTP `Authorization` request header, for example:
# ...
spec:
proxy:
services:
- name: helm-charts
- type: Service
alias: helm-charts
service:
name: helm-charts
namespace: helm
port: 8443
caCertificate: '-----BEGIN CERTIFICATE-----\nMIID....'
Expand Down
12 changes: 7 additions & 5 deletions dynamic-demo-plugin/oc-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ spec:
port: 9001
basePath: '/'
proxy:
services:
- name: thanos-querier
namespace: openshift-monitoring
port: 9091
authorize: true
- type: Service
alias: thanos-querier
service:
name: thanos-querier
namespace: openshift-monitoring
port: 9091
authorize: true
2 changes: 1 addition & 1 deletion dynamic-demo-plugin/src/components/ExampleProxyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ExampleProxyResponse: React.FC = () => {
const [data, setData] = React.useState();

React.useEffect(() => {
consoleFetchJSON('/api/proxy/namespace/openshift-monitoring/service/thanos-querier:9091/api/v1/rules')
consoleFetchJSON('/api/proxy/plugin/console-demo-plugin/thanos-querier/api/v1/rules')
.then((response) => {
setData(response);
})
Expand Down

0 comments on commit dae2209

Please sign in to comment.