mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 02:48:30 -05:00
Ron/bdc script (#4221)
* WIP adding scripting support. * Adding deploy command along with additional env vars needed. * Adding script generation that sets envars, kube context, and mssqlctl * Adding test email for docker email envar until we update UI. * Adding cluster platform detection and disabling generate script after first click. * Fix spacing and adding comment.
This commit is contained in:
@@ -5,23 +5,29 @@
|
||||
'use strict';
|
||||
|
||||
import { TargetClusterType, ClusterPorts, ContainerRegistryInfo, TargetClusterTypeInfo, ToolInfo, ToolInstallationStatus } from '../../interfaces';
|
||||
import { getContexts, KubectlContext } from '../../kubectl/kubectlUtils';
|
||||
import { getContexts, KubectlContext, setContext, inferCurrentClusterType } from '../../kubectl/kubectlUtils';
|
||||
import { Kubectl } from '../../kubectl/kubectl';
|
||||
import { Scriptable, ScriptingDictionary } from '../../scripting/scripting';
|
||||
import { ClusterType} from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class CreateClusterModel {
|
||||
export class CreateClusterModel implements Scriptable {
|
||||
|
||||
private _tmp_tools_installed: boolean = false;
|
||||
|
||||
constructor(private _kubectl: Kubectl) {
|
||||
private scriptingProperties : ScriptingDictionary<string> = {};
|
||||
constructor(private _kubectl : Kubectl) {
|
||||
}
|
||||
|
||||
public async loadClusters(): Promise<KubectlContext[]> {
|
||||
return await getContexts(this._kubectl);
|
||||
}
|
||||
|
||||
public async changeKubernetesContext(targetContext: string): Promise<void> {
|
||||
await setContext(this._kubectl, targetContext)
|
||||
}
|
||||
|
||||
public getDefaultPorts(): Thenable<ClusterPorts> {
|
||||
let promise = new Promise<ClusterPorts>(resolve => {
|
||||
resolve({
|
||||
@@ -135,4 +141,56 @@ export class CreateClusterModel {
|
||||
public containerRegistryUserName: string;
|
||||
|
||||
public containerRegistryPassword: string;
|
||||
|
||||
public async getTargetClusterPlatform(targetContextName : string) : Promise<string> {
|
||||
await setContext(this._kubectl, targetContextName);
|
||||
let clusterType = await inferCurrentClusterType(this._kubectl);
|
||||
|
||||
switch (clusterType) {
|
||||
case ClusterType.AKS:
|
||||
return 'aks';
|
||||
case ClusterType.Minikube:
|
||||
return 'minikube';
|
||||
case ClusterType.Other:
|
||||
default:
|
||||
return 'kubernetes';
|
||||
}
|
||||
}
|
||||
|
||||
public async getScriptProperties() : Promise<ScriptingDictionary<string>> {
|
||||
|
||||
// Cluster settings
|
||||
this.scriptingProperties['CLUSTER_NAME'] = this.selectedCluster.clusterName;
|
||||
this.scriptingProperties['CLUSTER_PLATFORM'] = await this.getTargetClusterPlatform(this.selectedCluster.contextName);
|
||||
|
||||
// Default pool count for now. TODO: Update from user input
|
||||
this.scriptingProperties['CLUSTER_DATA_POOL_REPLICAS'] = '1';
|
||||
this.scriptingProperties['CLUSTER_COMPUTE_POOL_REPLICAS'] = '2';
|
||||
this.scriptingProperties['CLUSTER_STORAGE_POOL_REPLICAS'] = '3';
|
||||
|
||||
// SQL Server settings
|
||||
this.scriptingProperties['CONTROLLER_USERNAME'] = this.adminUserName;
|
||||
this.scriptingProperties['CONTROLLER_PASSWORD'] = this.adminPassword;
|
||||
this.scriptingProperties['KNOX_PASSWORD'] = this.adminPassword;
|
||||
this.scriptingProperties['MSSQL_SA_PASSWORD'] = this.adminPassword;
|
||||
|
||||
// docker settings
|
||||
this.scriptingProperties['DOCKER_REPOSITORY'] = this.containerRepository;
|
||||
this.scriptingProperties['DOCKER_REGISTRY' ] = this.containerRegistry;
|
||||
this.scriptingProperties['DOCKER_PASSWORD'] = this.containerRegistryPassword;
|
||||
this.scriptingProperties['DOCKER_USERNAME'] = this.containerRegistryUserName;
|
||||
this.scriptingProperties['DOCKER_IMAGE_TAG'] = this.containerImageTag;
|
||||
|
||||
// port settings
|
||||
this.scriptingProperties['MASTER_SQL_PORT'] = this.sqlPort;
|
||||
this.scriptingProperties['KNOX_PORT'] = this.knoxPort;
|
||||
this.scriptingProperties['GRAFANA_PORT'] = this.grafanaPort;
|
||||
this.scriptingProperties['KIBANA_PORT'] = this.kibanaPort;
|
||||
|
||||
return this.scriptingProperties;
|
||||
}
|
||||
|
||||
public getTargetKubectlContext() : KubectlContext {
|
||||
return this.selectedCluster;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,15 @@ import { WizardBase } from '../wizardBase';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Kubectl } from '../../kubectl/kubectl';
|
||||
import { SelectTargetClusterTypePage } from './pages/selectTargetClusterTypePage';
|
||||
|
||||
import { ScriptGenerator } from '../../scripting/scripting';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class CreateClusterWizard extends WizardBase<CreateClusterModel, CreateClusterWizard> {
|
||||
private scripter : ScriptGenerator;
|
||||
constructor(context: ExtensionContext, kubectl: Kubectl) {
|
||||
let model = new CreateClusterModel(kubectl);
|
||||
super(model, context, localize('bdc-create.wizardTitle', 'Create a big data cluster'));
|
||||
this.scripter = new ScriptGenerator(kubectl);
|
||||
}
|
||||
|
||||
protected initialize(): void {
|
||||
@@ -32,10 +34,16 @@ export class CreateClusterWizard extends WizardBase<CreateClusterModel, CreateCl
|
||||
this.setPages([targetClusterTypePage, settingsPage, clusterProfilePage, selectTargetClusterPage, summaryPage]);
|
||||
|
||||
this.wizardObject.generateScriptButton.label = localize('bdc-create.generateScriptsButtonText', 'Generate Scripts');
|
||||
this.wizardObject.generateScriptButton.hidden = true;
|
||||
this.wizardObject.generateScriptButton.hidden = false;
|
||||
this.wizardObject.doneButton.label = localize('bdc-create.createClusterButtonText', 'Create');
|
||||
|
||||
this.wizardObject.generateScriptButton.onClick(() => { });
|
||||
this.wizardObject.generateScriptButton.onClick(async () => {
|
||||
this.wizardObject.generateScriptButton.enabled = false;
|
||||
this.scripter.generateDeploymentScript(this.model).then( () => {
|
||||
this.wizardObject.generateScriptButton.enabled = true;
|
||||
//TODO: Add error handling.
|
||||
});
|
||||
});
|
||||
this.wizardObject.doneButton.onClick(() => { });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user