From 73e72e8aa70493f3b563d00922b99b015b16000a Mon Sep 17 00:00:00 2001 From: Simon Murray Date: Wed, 11 Dec 2024 10:16:10 +0000 Subject: [PATCH] Allow SSH Access to Compute --- charts/ui/Chart.yaml | 4 +-- .../compute/models/ComputeClusterStatus.ts | 8 ++++++ .../openapi/region/.openapi-generator/FILES | 1 - .../region/models/IdentitySpecOpenStack.ts | 8 ++++++ src/lib/openapi/region/models/ServerImage.ts | 20 +++------------ src/lib/openapi/region/models/index.ts | 1 - .../computeclusters/+page.svelte | 25 +++++++++++++++++++ .../computeclusters/create/+page.svelte | 14 ++++++++--- 8 files changed, 57 insertions(+), 24 deletions(-) diff --git a/charts/ui/Chart.yaml b/charts/ui/Chart.yaml index 1bf5c89..ff9af33 100644 --- a/charts/ui/Chart.yaml +++ b/charts/ui/Chart.yaml @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn UI type: application -version: v0.2.41 -appVersion: v0.2.41 +version: v0.2.42-rc1 +appVersion: v0.2.42-rc1 icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png diff --git a/src/lib/openapi/compute/models/ComputeClusterStatus.ts b/src/lib/openapi/compute/models/ComputeClusterStatus.ts index cb5bd4f..6576838 100644 --- a/src/lib/openapi/compute/models/ComputeClusterStatus.ts +++ b/src/lib/openapi/compute/models/ComputeClusterStatus.ts @@ -26,6 +26,12 @@ import { * @interface ComputeClusterStatus */ export interface ComputeClusterStatus { + /** + * SSH private key that allows access to the cluster. + * @type {string} + * @memberof ComputeClusterStatus + */ + sshPrivateKey?: string; /** * A list of Compute cluster workload pools status. * @type {Array} @@ -53,6 +59,7 @@ export function ComputeClusterStatusFromJSONTyped(json: any, ignoreDiscriminator } return { + 'sshPrivateKey': !exists(json, 'sshPrivateKey') ? undefined : json['sshPrivateKey'], 'workloadPools': !exists(json, 'workloadPools') ? undefined : ((json['workloadPools'] as Array).map(ComputeClusterWorkloadPoolStatusFromJSON)), }; } @@ -66,6 +73,7 @@ export function ComputeClusterStatusToJSON(value?: ComputeClusterStatus | null): } return { + 'sshPrivateKey': value.sshPrivateKey, 'workloadPools': value.workloadPools === undefined ? undefined : ((value.workloadPools as Array).map(ComputeClusterWorkloadPoolStatusToJSON)), }; } diff --git a/src/lib/openapi/region/.openapi-generator/FILES b/src/lib/openapi/region/.openapi-generator/FILES index 5b21928..96b55c2 100644 --- a/src/lib/openapi/region/.openapi-generator/FILES +++ b/src/lib/openapi/region/.openapi-generator/FILES @@ -47,7 +47,6 @@ models/SecurityGroupRuleWrite.ts models/SecurityGroupRuleWriteSpec.ts models/SecurityGroupWrite.ts models/ServerImage.ts -models/ServerImageSelector.ts models/ServerNetwork.ts models/ServerPublicIPAllocation.ts models/ServerRead.ts diff --git a/src/lib/openapi/region/models/IdentitySpecOpenStack.ts b/src/lib/openapi/region/models/IdentitySpecOpenStack.ts index d14731f..3de4094 100644 --- a/src/lib/openapi/region/models/IdentitySpecOpenStack.ts +++ b/src/lib/openapi/region/models/IdentitySpecOpenStack.ts @@ -55,6 +55,12 @@ export interface IdentitySpecOpenStack { * @memberof IdentitySpecOpenStack */ sshKeyName?: string; + /** + * Ephemeral SSH private key to be used by higher order services. + * @type {string} + * @memberof IdentitySpecOpenStack + */ + sshPrivateKey?: string; } /** @@ -82,6 +88,7 @@ export function IdentitySpecOpenStackFromJSONTyped(json: any, ignoreDiscriminato 'projectId': !exists(json, 'projectId') ? undefined : json['projectId'], 'serverGroupId': !exists(json, 'serverGroupId') ? undefined : json['serverGroupId'], 'sshKeyName': !exists(json, 'sshKeyName') ? undefined : json['sshKeyName'], + 'sshPrivateKey': !exists(json, 'sshPrivateKey') ? undefined : json['sshPrivateKey'], }; } @@ -100,6 +107,7 @@ export function IdentitySpecOpenStackToJSON(value?: IdentitySpecOpenStack | null 'projectId': value.projectId, 'serverGroupId': value.serverGroupId, 'sshKeyName': value.sshKeyName, + 'sshPrivateKey': value.sshPrivateKey, }; } diff --git a/src/lib/openapi/region/models/ServerImage.ts b/src/lib/openapi/region/models/ServerImage.ts index 071a32f..80ab8e2 100644 --- a/src/lib/openapi/region/models/ServerImage.ts +++ b/src/lib/openapi/region/models/ServerImage.ts @@ -13,13 +13,6 @@ */ import { exists, mapValues } from '../runtime'; -import type { ServerImageSelector } from './ServerImageSelector'; -import { - ServerImageSelectorFromJSON, - ServerImageSelectorFromJSONTyped, - ServerImageSelectorToJSON, -} from './ServerImageSelector'; - /** * The image to use for the server. * @export @@ -31,13 +24,7 @@ export interface ServerImage { * @type {string} * @memberof ServerImage */ - id?: string; - /** - * - * @type {ServerImageSelector} - * @memberof ServerImage - */ - selector?: ServerImageSelector; + id: string; } /** @@ -45,6 +32,7 @@ export interface ServerImage { */ export function instanceOfServerImage(value: object): boolean { let isInstance = true; + isInstance = isInstance && "id" in value; return isInstance; } @@ -59,8 +47,7 @@ export function ServerImageFromJSONTyped(json: any, ignoreDiscriminator: boolean } return { - 'id': !exists(json, 'id') ? undefined : json['id'], - 'selector': !exists(json, 'selector') ? undefined : ServerImageSelectorFromJSON(json['selector']), + 'id': json['id'], }; } @@ -74,7 +61,6 @@ export function ServerImageToJSON(value?: ServerImage | null): any { return { 'id': value.id, - 'selector': ServerImageSelectorToJSON(value.selector), }; } diff --git a/src/lib/openapi/region/models/index.ts b/src/lib/openapi/region/models/index.ts index ef6ecc4..56d335c 100644 --- a/src/lib/openapi/region/models/index.ts +++ b/src/lib/openapi/region/models/index.ts @@ -46,7 +46,6 @@ export * from './SecurityGroupRuleWrite'; export * from './SecurityGroupRuleWriteSpec'; export * from './SecurityGroupWrite'; export * from './ServerImage'; -export * from './ServerImageSelector'; export * from './ServerNetwork'; export * from './ServerPublicIPAllocation'; export * from './ServerRead'; diff --git a/src/routes/(shell)/infrastructure/computeclusters/+page.svelte b/src/routes/(shell)/infrastructure/computeclusters/+page.svelte index f585077..3349134 100644 --- a/src/routes/(shell)/infrastructure/computeclusters/+page.svelte +++ b/src/routes/(shell)/infrastructure/computeclusters/+page.svelte @@ -35,6 +35,8 @@ import { getToastStore } from '@skeletonlabs/skeleton'; const toastStore = getToastStore(); + import { browser } from '$app/environment'; + let at: InternalToken; let resources: Array; @@ -102,6 +104,22 @@ modalStore.trigger(modal); } + + function getSSHKey(resource: Compute.ComputeClusterRead): void { + if (browser && resource.status?.sshPrivateKey) { + const url = window.URL.createObjectURL(new Blob([resource.status.sshPrivateKey])); + + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = `id_${resource.metadata.name}`; + + document.body.appendChild(a); + a.click(); + + window.URL.revokeObjectURL(url); + } + } @@ -138,6 +156,13 @@ > Delete + getSSHKey(resource)} + on:keypress={() => getSSHKey(resource)} + icon="mdi:download" + > + SSH Key + diff --git a/src/routes/(shell)/infrastructure/computeclusters/create/+page.svelte b/src/routes/(shell)/infrastructure/computeclusters/create/+page.svelte index bb1a866..9541784 100644 --- a/src/routes/(shell)/infrastructure/computeclusters/create/+page.svelte +++ b/src/routes/(shell)/infrastructure/computeclusters/create/+page.svelte @@ -52,15 +52,23 @@ { name: 'default', machine: { - replicas: 3, + replicas: 1, flavorId: '', image: { distro: Compute.OsDistro.Ubuntu, version: '24.04' }, publicIPAllocation: { - enabled: false - } + enabled: true + }, + firewall: [ + { + direction: Compute.FirewallRuleDirectionEnum.Ingress, + protocol: Compute.FirewallRuleProtocolEnum.Tcp, + port: 22, + prefixes: ['0.0.0.0/0'] + } + ] } } ]