Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kaitointegrationpoc #47

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
"dependencies": {
"@azure/arm-authorization": "^9.0.0",
"@azure/arm-containerregistry": "^10.1.0",
"@azure/arm-containerservice": "^21.0.0",
"@azure/arm-containerservice": "^21.1.0-beta.1",
"@azure/arm-features": "^3.1.0",
"@azure/arm-monitor": "^7.0.0",
"@azure/arm-resources": "^5.2.0",
Expand Down
30 changes: 11 additions & 19 deletions src/panels/KaitoPanel.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ContainerServiceClient, ManagedCluster } from "@azure/arm-containerservice";
import { FeatureClient } from "@azure/arm-features";
import { ResourceManagementClient } from "@azure/arm-resources";
import { RestError } from "@azure/storage-blob";
import * as vscode from "vscode";
import { ReadyAzureSessionProvider } from "../auth/types";
import { getFeatureClient, getResourceManagementClient } from "../commands/utils/arm";
import { getAksClient, getFeatureClient, getResourceManagementClient } from "../commands/utils/arm";
import { getErrorMessage } from "../commands/utils/errorable";
import { longRunning } from "../commands/utils/host";
import { MessageHandler, MessageSink } from "../webview-contract/messaging";
import { InitialState, ToVsCodeMsgDef, ToWebViewMsgDef } from "../webview-contract/webviewDefinitions/kaito";
import { TelemetryDefinition } from "../webview-contract/webviewTypes";
import { BasePanel, PanelDataProvider } from "./BasePanel";
import { ClusterDeploymentBuilder, ClusterSpec, Preset } from "./utilities/ClusterSpecCreationBuilder";

export class KaitoPanel extends BasePanel<"kaito"> {
constructor(extensionUri: vscode.Uri) {
Expand All @@ -26,7 +26,7 @@ export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
// private readonly containerServiceClient: ContainerServiceClient;
private readonly featureClient: FeatureClient;
private readonly resourceManagementClient: ResourceManagementClient;
// private readonly containerServiceClient: ContainerServiceClient;
private readonly containerServiceClient: ContainerServiceClient;

public constructor(
readonly clusterName: string,
Expand All @@ -41,7 +41,7 @@ export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
this.armId = armId;
this.featureClient = getFeatureClient(sessionProvider, this.subscriptionId);
this.resourceManagementClient = getResourceManagementClient(sessionProvider, this.subscriptionId);
// this.containerServiceClient = getAksClient(sessionProvider, this.subscriptionId);
this.containerServiceClient = getAksClient(sessionProvider, this.subscriptionId);
}
getTitle(): string {
return `KAITO`;
Expand Down Expand Up @@ -174,25 +174,16 @@ export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
});
console.log(currentJson);

const clusterSpec: ClusterSpec = {
const managedClusterSpec: ManagedCluster = {
location: "eastus2euap", //TODO get location from cluster
name: this.clusterName,
resourceGroupName: this.resourceGroupName,
subscriptionId: this.subscriptionId,
kubernetesVersion: "1.28", // TODO k8s version from cluster
aiToolchainOperatorProfile: { enabled: true },
oidcIssuerProfile: { enabled: true },
};

const deploymentName = `${this.clusterName}-${Math.random().toString(36).substring(5)}`;

const deploymentSpec = new ClusterDeploymentBuilder()
.buildCommonParametersForKaito(clusterSpec)
.buildTemplate(Preset.KaitoAddon)
.getDeployment();
try {
const poller = await this.resourceManagementClient.deployments.beginCreateOrUpdate(
const poller = await this.containerServiceClient.managedClusters.beginCreateOrUpdate(
this.resourceGroupName,
deploymentName,
deploymentSpec,
this.clusterName,
managedClusterSpec,
);
// kaito installation in progress
webview.postKaitoInstallProgressUpdate({
Expand All @@ -218,6 +209,7 @@ export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
});
}
});
await poller.pollUntilDone();
} catch (ex) {
const errorMessage = isInvalidTemplateDeploymentError(ex)
? getInvalidTemplateErrorMessage(ex)
Expand Down