diff --git a/ci/README.md b/ci/README.md index 49203c169..5f98ecb27 100644 --- a/ci/README.md +++ b/ci/README.md @@ -8,8 +8,9 @@ Scripts and tools to run Forklift console plugin on top of Openshift console web | K8S_AUTH_BEARER_TOKEN | k8s cluster token (example: `abcdef.0123456789abcdef` ) | | CONSOLE_IMAGE | The console image to run ( example: `quay.io/openshift/origin-console:4.12` )| | FORKLIFT_PLUGIN_IMAGE | The plugin image to build and use ( example: `localhost:5001/forklift-console-plugin:latest` )| -| INVENTORY_SERVER_HOST | URL of Forklift inventory server ( default `http://localhost:30088` )| -| MUST_GATHER_API_SERVER_HOST | URL of Forklift must gather server ( default `http://localhost:30089` )| +| INVENTORY_SERVER_HOST | URL of Forklift inventory server ( default `http://localhost:30444` )| +| MUST_GATHER_API_SERVER_HOST | URL of Forklift must gather server ( default `http://localhost:30445` )| +| SERVICES_API_SERVER_HOST | URL of Forklift services server ( default `https://localhost:30446` )| | PLUGIN_URL | plugin dev server URL ( default `http://localhost:9001` } | | CONTAINER_NETWORK_TYPE | Podman network for running Openshift console ( default `host` ) | diff --git a/ci/deploy-cluster.sh b/ci/deploy-cluster.sh index 616f7d38b..81c1bfdc8 100644 --- a/ci/deploy-cluster.sh +++ b/ci/deploy-cluster.sh @@ -52,6 +52,8 @@ nodes: hostPort: 30443 - containerPort: 30444 hostPort: 30444 + - containerPort: 30446 + hostPort: 30446 containerdConfigPatches: - |- [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"] diff --git a/ci/deploy-forklift.sh b/ci/deploy-forklift.sh index 0facaeb41..8b44fba12 100755 --- a/ci/deploy-forklift.sh +++ b/ci/deploy-forklift.sh @@ -93,11 +93,17 @@ spec: api_container_requests_cpu: "50m" EOF -# Wait for forklift inventory service, then expose it on port 30088 +# Wait for forklift inventory service, then expose it on port 30444 while ! kubectl get service -n ${FORKLIFT_NAMESPACE} forklift-inventory; do sleep 30; done kubectl patch service -n ${FORKLIFT_NAMESPACE} forklift-inventory --type='merge' \ -p '{"spec":{"type":"NodePort","ports":[{"name":"api-https","protocol":"TCP","targetPort":8443,"port":8443,"nodePort":30444}]}}' +# Wait for forklift services service, then expose it on port 30446 +while ! kubectl get service -n ${FORKLIFT_NAMESPACE} forklift-services; do sleep 30; done +kubectl patch service -n ${FORKLIFT_NAMESPACE} forklift-services --type='merge' \ + -p '{"spec":{"type":"NodePort","ports":[{"name":"api-https","protocol":"TCP","targetPort":8443,"port":8443,"nodePort":30446}]}}' + + # secondary namespace used in test data cat << EOF | kubectl apply -f - --- diff --git a/ci/start-console.sh b/ci/start-console.sh index 6b042589a..87e4556af 100755 --- a/ci/start-console.sh +++ b/ci/start-console.sh @@ -14,6 +14,7 @@ CONSOLE_IMAGE=${CONSOLE_IMAGE:-"quay.io/openshift/origin-console:latest"} CONSOLE_PORT=${CONSOLE_PORT:-9000} INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-"https://localhost:30444"} MUST_GATHER_API_SERVER_HOST=${MUST_GATHER_API_SERVER_HOST:-"https://localhost:30445"} +SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-"https://localhost:30446"} if [[ ${CONSOLE_IMAGE} =~ ^localhost/ ]]; then PULL_POLICY="never" @@ -51,6 +52,11 @@ BRIDGE_PLUGIN_PROXY=$(cat << END | jq -c . "consoleAPIPath":"/api/proxy/plugin/${PLUGIN_NAME}/forklift-must-gather-api/", "endpoint":"${MUST_GATHER_API_SERVER_HOST}", "authorize":true + }, + { + "consoleAPIPath":"/api/proxy/plugin/${PLUGIN_NAME}/forklift-services/", + "endpoint":"${SERVICES_API_SERVER_HOST}", + "authorize":true } ]} END @@ -78,6 +84,7 @@ Container pull policy: ${PULL_POLICY} Plugins: ${BRIDGE_PLUGINS} Inventory server URL: ${INVENTORY_SERVER_HOST} Must gather API server URL: ${MUST_GATHER_API_SERVER_HOST} +Services server URL: ${SERVICES_API_SERVER_HOST} Plugin proxy: $(echo ${BRIDGE_PLUGIN_PROXY} | jq .) " diff --git a/docs/start-dev-server.md b/docs/start-dev-server.md index f39bc04d3..f3283d270 100644 --- a/docs/start-dev-server.md +++ b/docs/start-dev-server.md @@ -58,18 +58,19 @@ npm run cluster:up -- --with-all-providers npm run cluster:delete ``` -## Avaliable environment variables +## Available environment variables -| Environment varialbles | Description | +| Environment variables | Description | | -------|--------------| | CONSOLE_IMAGE | The console image to run ( default `quay.io/openshift/origin-console:latest` )| | CONSOLE_PORT | Expose the console web application on port ( default `9000` )| | INVENTORY_SERVER_HOST | URL of Forklift inventory server ( default `https://localhost:30444` )| | MUST_GATHER_API_SERVER_HOST | URL of Forklift must gather server ( default `https://localhost:30445` )| +| SERVICES_API_SERVER_HOST | URL of Forklift services server ( default `https://localhost:30446` )| | BRIDGE_K8S_AUTH_BEARER_TOKEN | Bearer token of user account ( on openshift token default to `$(oc whoami -t)` )| | BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT | Kubernetes API servere URL (default, guess useing kubeconfig file) | -Scripts for pre-setting this environment varialbles are available in the [configure](./configure) directory. +Scripts for pre-setting this environment variables are available in the [configure](./configure) directory. ## Finding the API server URL @@ -104,4 +105,4 @@ export INVENTORY_SERVER_HOST=https:// ### KinD -The development cluster using kind will expose the inventory server on port 30443 `https://loclhost:30443`. +The development cluster using kind will expose the inventory server on port 30444 `https://loclhost:30444`. diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getApiUrl.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getApiUrl.ts new file mode 100644 index 000000000..78db9a169 --- /dev/null +++ b/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getApiUrl.ts @@ -0,0 +1,32 @@ +/** + * Provides API url for getting inventory. + * + * @param {string} relativePath - An optional relative path to append to the URL + * @returns {string} - The API URL for getting inventory + */ +export const getInventoryApiUrl = (relativePath = ''): string => { + const inventoryPath = 'forklift-inventory'; + return `${getApiUrl(inventoryPath)}/${relativePath}`; +}; + +/** + * Provides API url for getting services. + * + * @param {string} relativePath - An optional relative path to append to the URL + * @returns {string} - The API URL for getting services + */ +export const getServicesApiUrl = (relativePath = ''): string => { + const path = 'forklift-services'; + return `${getApiUrl(path)}/${relativePath}`; +}; + +/** + * Provides API url. + * + * @param {string} relativePath - An optional relative path to append to the URL + * @returns {string} - The API URL + */ +export const getApiUrl = (relativePath = ''): string => { + const pluginPath = `/api/proxy/plugin/${process.env.PLUGIN_NAME}`; + return `${pluginPath}/${relativePath}`; +}; diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getInventoryApiUrl.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getInventoryApiUrl.ts deleted file mode 100644 index f323e3523..000000000 --- a/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/getInventoryApiUrl.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Provides API url for getting inventory. - * - * @param {string} relativePath - An optional relative path to append to the URL - * @returns {string} - The API URL for getting inventory - */ -export const getInventoryApiUrl = (relativePath = ''): string => { - const pluginPath = `/api/proxy/plugin/${process.env.PLUGIN_NAME}`; - const inventoryPath = '/forklift-inventory'; - - return `${pluginPath}${inventoryPath}/${relativePath}`; -}; diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/index.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/index.ts index e4d03306e..70e5fa4b2 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/index.ts +++ b/packages/forklift-console-plugin/src/modules/Providers/utils/helpers/index.ts @@ -1,7 +1,7 @@ // @index(['./*.tsx', './*.ts', /__/g], f => `export * from '${f.path}';`) export * from './findInventoryByID'; +export * from './getApiUrl'; export * from './getCachedData'; -export * from './getInventoryApiUrl'; export * from './getIsManaged'; export * from './getIsTarget'; export * from './getResourceUrl';