Skip to content

Commit

Permalink
chore(frontend): update kubernetes client version to 0.12.1 (#11737)
Browse files Browse the repository at this point in the history
Signed-off-by: droctothorpe <[email protected]>
Co-authored-by: ColeVogs <[email protected]>
  • Loading branch information
droctothorpe and ColeVogs authored Mar 11, 2025
1 parent 0d9a7b0 commit d502687
Show file tree
Hide file tree
Showing 7 changed files with 656 additions and 120 deletions.
2 changes: 1 addition & 1 deletion frontend/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.21.3
v22.14.0
42 changes: 29 additions & 13 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Kubeflow Pipelines Management Frontend
# Kubeflow Pipelines Frontend

## Tools you need
## Node setup

You need `node v22` and `npm`.
Recommend installing `node` and `npm` using https://github.com/nvm-sh/nvm. After installing nvm,
you can install `node v22` by `nvm install 22`.
Install the node version specified in the [.nvmrc](.nvmrc) file. You
can use [nvm](https://github.com/nvm-sh/nvm) or
[fnm](https://github.com/Schniz/fnm) to manage your node installations; fnm is
basically a faster version of nvm implemented in Rust. Installation instructions
are available at their corresponding GitHub repositories.

### fnm

```bash
fnm install 22.14.0
fnm use 22.14.0
```

### nvm

```bash
nvm install 22.14.0
nvm use 22.14.0
```

## Manage dev environment with npm

Expand Down Expand Up @@ -55,7 +71,7 @@ development.
Run `npm run mock:api` to start a mock backend api server handler so it can
serve basic api calls with mock data.

If you want to port real MLMD store to be used for mock backend scenario, you can run the following command. Note that a mock MLMD store doesn't exist yet.
If you want to port real MLMD store to be used for mock backend scenario, you can run the following command. Note that a mock MLMD store doesn't exist yet.

```
kubectl port-forward svc/metadata-envoy-service 9090:9090
Expand Down Expand Up @@ -144,7 +160,7 @@ If you made any changes to protos (see backend/README), you'll need to
regenerate the Typescript client library from swagger. We use
[email protected], which you can get
[here](https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.7/).
Make sure to add the jar file to $PATH with the name swagger-codegen-cli.jar, then run `npm run apis` for
Make sure to add the jar file to $PATH with the name swagger-codegen-cli.jar, then run `npm run apis` for
v1 api or `npm run apis:v2beta1` for v2 api.
```
// add jar file to $PATH
Expand Down Expand Up @@ -176,7 +192,7 @@ If a file in [pipelines/third_party/ml-metadata/ml_metadata/proto](third_party/m

* Add `protoc` ([download](https://github.com/protocolbuffers/protobuf/releases)) to your system
PATH

```bash
# Example:
apt install -y protobuf-compiler=3.15.8
Expand Down Expand Up @@ -233,15 +249,15 @@ See explaination it does below:

Prerequisite: Add `protoc` ([download](https://github.com/protocolbuffers/protobuf/releases)) to your system PATH

Compile pipeline_spec.proto to Typed classes in TypeScript,
Compile pipeline_spec.proto to Typed classes in TypeScript,
so it can convert a payload stream to a PipelineSpec object during runtime.

You can check out the result like `pipeline_spec_pb.js`, `pipeline_spec_pb.d.ts` in [frontend/src/generated/pipeline_spec](/frontend/src/generated/pipeline_spec).

The plugin tool for convertion we currently use is [ts-proto](https://github.com/stephenh/ts-proto). We previously use
[protobuf.js](https://github.com/protobufjs/protobuf.js) but it doesn't natively support Protobuf.Value processing.
The plugin tool for convertion we currently use is [ts-proto](https://github.com/stephenh/ts-proto). We previously use
[protobuf.js](https://github.com/protobufjs/protobuf.js) but it doesn't natively support Protobuf.Value processing.

You can checkout the generated TypeScript interfaces in [frontend/src/generated/pipeline_spec/pipeline_spec.ts](/frontend/src/generated/pipeline_spec/pipeline_spec.ts)
You can checkout the generated TypeScript interfaces in [frontend/src/generated/pipeline_spec/pipeline_spec.ts](/frontend/src/generated/pipeline_spec/pipeline_spec.ts)

<!-- ARCHIVE: We switched to use ts-proto for now.
### Encode plain object to buffer using protobuf.js
Expand All @@ -265,7 +281,7 @@ npm run build:platform-spec:kubernetes-platform

## Large features development

To accommodate KFP v2 development, we create a `frontend feature flag` capability which hides features under development behind a flag. Only when developer explicitly enables these flags, they can see those features. To control the visiblity of these features, check out a webpage similar to pattern http://localhost:3000/#/frontend_features.
To accommodate KFP v2 development, we create a `frontend feature flag` capability which hides features under development behind a flag. Only when developer explicitly enables these flags, they can see those features. To control the visiblity of these features, check out a webpage similar to pattern http://localhost:3000/#/frontend_features.

To manage feature flags default values, visit [frontend/src/feature.ts](frontend/src/feature.ts) for `const features`. To apply the default feature flags locally in your browser, run `localStorage.setItem('flags', "")` in browser console.

Expand Down
1 change: 0 additions & 1 deletion frontend/server/integration-tests/tensorboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,6 @@ describe('/apps/tensorboard', () => {
"test-ns",
"viewers",
"viewer-5e1404e679e27b0f0b8ecee8fe515830eaa736c5",
V1DeleteOptions {},
]
`);
done(err);
Expand Down
15 changes: 6 additions & 9 deletions frontend/server/k8s-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
// limitations under the License.

import {
Core_v1Api,
Custom_objectsApi,
CoreV1Api,
CustomObjectsApi,
KubeConfig,
V1DeleteOptions,
V1Pod,
V1EventList,
V1ConfigMap,
Expand Down Expand Up @@ -55,8 +54,8 @@ if (fs.existsSync(namespaceFilePath)) {
const kc = new KubeConfig();
// This loads kubectl config when not in cluster.
kc.loadFromDefault();
const k8sV1Client = kc.makeApiClient(Core_v1Api);
const k8sV1CustomObjectClient = kc.makeApiClient(Custom_objectsApi);
const k8sV1Client = kc.makeApiClient(CoreV1Api);
const k8sV1CustomObjectClient = kc.makeApiClient(CustomObjectsApi);

function getNameOfViewerResource(logdir: string): string {
// TODO: find some hash function with shorter resulting message.
Expand Down Expand Up @@ -203,15 +202,13 @@ export async function deleteTensorboardInstance(logdir: string, namespace: strin
}

const viewerName = getNameOfViewerResource(logdir);
const deleteOption = new V1DeleteOptions();

await k8sV1CustomObjectClient.deleteNamespacedCustomObject(
viewerGroup,
viewerVersion,
namespace,
viewerPlural,
viewerName,
deleteOption,
);
}

Expand Down Expand Up @@ -346,7 +343,7 @@ export async function getArgoWorkflow(workflowName: string): Promise<PartialArgo
if (res.response.statusCode >= 400) {
throw new Error(`Unable to query workflow:${workflowName}: Access denied.`);
}
return res.body;
return res.body as PartialArgoWorkflow;
}

/**
Expand All @@ -367,7 +364,7 @@ export async function getK8sSecret(name: string, key: string, providedNamespace?
}

const k8sSecret = await k8sV1Client.readNamespacedSecret(name, namespace);
const secretb64 = k8sSecret.body.data[key];
const secretb64 = k8sSecret.body.data?.[key] || '';
const buff = new Buffer(secretb64, 'base64');
return buff.toString('ascii');
}
Expand Down
Loading

0 comments on commit d502687

Please sign in to comment.