Skip to content

Commit

Permalink
Configure forklift-services
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Feb 13, 2024
1 parent d3c6789 commit a4e3906
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 20 deletions.
5 changes: 3 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` ) |

Expand Down
2 changes: 2 additions & 0 deletions ci/deploy-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
Expand Down
8 changes: 7 additions & 1 deletion ci/deploy-forklift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
---
Expand Down
7 changes: 7 additions & 0 deletions ci/start-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 .)
"
Expand Down
9 changes: 5 additions & 4 deletions docs/start-dev-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -104,4 +105,4 @@ export INVENTORY_SERVER_HOST=https://<route found>

### 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`.
Original file line number Diff line number Diff line change
@@ -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}`;
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit a4e3906

Please sign in to comment.