From 9e1b68e5082d5c0dc9eaab6b60e8971e3e6e6b7c Mon Sep 17 00:00:00 2001 From: Tatsinnit Date: Tue, 19 Apr 2022 07:44:36 +0530 Subject: [PATCH] Feature upgrade to adapt ASO v2 (#119) --- resources/yaml/azureoperatorsettings.yaml | 4 +- .../helpers/azureservicehelper.ts | 39 ++++++------------- .../helpers/azureservicehtmlhelper.ts | 14 +++---- .../installAzureServiceOperator.ts | 2 +- .../ui/azureservicebrowser.ts | 9 ++--- 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/resources/yaml/azureoperatorsettings.yaml b/resources/yaml/azureoperatorsettings.yaml index 1d465deb6..85f22d4d0 100644 --- a/resources/yaml/azureoperatorsettings.yaml +++ b/resources/yaml/azureoperatorsettings.yaml @@ -1,8 +1,8 @@ apiVersion: v1 kind: Secret metadata: - name: azureoperatorsettings - namespace: operators + name: aso-controller-settings + namespace: azureserviceoperator-system stringData: AZURE_TENANT_ID: AZURE_SUBSCRIPTION_ID: diff --git a/src/commands/azureServiceOperators/helpers/azureservicehelper.ts b/src/commands/azureServiceOperators/helpers/azureservicehelper.ts index 42c7fa7e7..e22aa066b 100644 --- a/src/commands/azureServiceOperators/helpers/azureservicehelper.ts +++ b/src/commands/azureServiceOperators/helpers/azureservicehelper.ts @@ -27,17 +27,12 @@ export async function startInstallation( return undefined; } - // 1) Install OLM is the pre-requisite of this work, using the apply YAML instructions here: https://github.com/operator-framework/operator-lifecycle-manager/releases/. + // 1) Install Cert-Manager https://azure.github.io/azure-service-operator/. // Also, page to refer: https://operatorhub.io/operator/azure-service-operator (Click Install button as top of the page) - installationResponse.installOlmCrdResult = await longRunning(`Installing Operator Lifecycle Manager CRD resource...`, - () => installOlmCrd(kubectl, clusterKubeConfig.result) + installationResponse.installCertManagerResult = await longRunning(`Installing Cert-Manager resource...`, + () => installCertManager(kubectl, clusterKubeConfig.result) ); - if (!isInstallationSuccessfull(webview, extensionPath, installationResponse.installOlmCrdResult, installationResponse)) return undefined; - - installationResponse.installOlmResult = await longRunning(`Installing Operator Lifecycle Manager resource...`, - () => installOlm(kubectl, clusterKubeConfig.result) - ); - if (!isInstallationSuccessfull(webview, extensionPath, installationResponse.installOlmResult, installationResponse)) return undefined; + if (!isInstallationSuccessfull(webview, extensionPath, installationResponse.installCertManagerResult, installationResponse)) return undefined; installationResponse.installOperatorResult = await longRunning(`Installing Opreator Namespace...`, () => installOperator(kubectl, clusterKubeConfig.result) @@ -50,7 +45,7 @@ export async function startInstallation( ); if (!isInstallationSuccessfull(webview, extensionPath, installationResponse.installOperatorSettingsResult, installationResponse)) return undefined; - // 3) Final step: Get the azure service operator pod. - kubectl get pods -n operators + // 3) Final step: Get the azure service operator pod. - kubectl get pods -n azureserviceoperator-system installationResponse.getOperatorsPodResult = await longRunning(`Getting Azure Service Operator Pod...`, () => getOperatorsPod(kubectl, clusterKubeConfig.result) ); @@ -64,47 +59,35 @@ async function getOperatorsPod( clusterKubeConfig: string ): Promise { // kubectl get pods -n operators - const command = `get pods -n operators`; - const failureDescription = "Get operator pod had following error"; + const command = `get pods -n azureserviceoperator-system`; + const failureDescription = "Get azureserviceoperator-system pod had following error"; const result = await invokeKubectlCommand(kubectl, clusterKubeConfig, command, failureDescription); return result; } -async function installOlmCrd( +async function installCertManager( kubectl: k8s.KubectlV1, clusterKubeConfig: string ): Promise { try { - const asoCrdYamlFile = "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.3/crds.yaml"; + const asoCrdYamlFile = "https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.yaml"; const runResult = await tmpfile.withOptionalTempFile( clusterKubeConfig, "yaml", (f) => kubectl.invokeCommand(`create -f ${asoCrdYamlFile} --kubeconfig="${f}"`)); return runResult; } catch (e) { - vscode.window.showErrorMessage(`Installing operator lifecycle manager CRD resource had following error: ${e}`); + vscode.window.showErrorMessage(`Installing cert-manager resource had following error: ${e}`); return undefined; } } -async function installOlm( - kubectl: k8s.KubectlV1, - clusterKubeConfig: string -): Promise { - const asoOlmYamlFile = "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.3/olm.yaml"; - const command = `create -f ${asoOlmYamlFile}`; - const failureDescription = "Installing operator lifecycle manager resource had following error"; - - const result = await invokeKubectlCommand(kubectl, clusterKubeConfig, command, failureDescription); - return result; -} - async function installOperator( kubectl: k8s.KubectlV1, clusterKubeConfig: string ): Promise { - const asoYamlFile = "https://operatorhub.io/install/azure-service-operator.yaml"; + const asoYamlFile = "https://github.com/Azure/azure-service-operator/releases/download/v2.0.0-beta.0/azureserviceoperator_v2.0.0-beta.0.yaml"; const command = `create -f ${asoYamlFile}`; const failureDescription = "Installing operator resoruce had following error"; diff --git a/src/commands/azureServiceOperators/helpers/azureservicehtmlhelper.ts b/src/commands/azureServiceOperators/helpers/azureservicehtmlhelper.ts index 1023c3e94..07ad79cbe 100644 --- a/src/commands/azureServiceOperators/helpers/azureservicehtmlhelper.ts +++ b/src/commands/azureServiceOperators/helpers/azureservicehtmlhelper.ts @@ -55,13 +55,12 @@ function getOrganisedInstallResult( installationResponse: InstallationResponse ) { const installResults: InstallResult = {}; - const olmCrdResult = installationResponse.installOlmCrdResult; - const olmResult = installationResponse.installOlmResult; + const certManagerResult = installationResponse.installCertManagerResult; const operatorResult = installationResponse.installOperatorSettingsResult; const operatorSettingsResult = installationResponse.installOperatorResult; const getOperatorsPodResult = installationResponse.getOperatorsPodResult; - const installResultCollection = [olmCrdResult, olmResult, operatorResult, operatorSettingsResult, getOperatorsPodResult]; + const installResultCollection = [certManagerResult, operatorResult, operatorSettingsResult, getOperatorsPodResult]; installResults.succeeded = installationExitCodeResponse(installResultCollection); if (installResults.succeeded) { @@ -81,11 +80,10 @@ function installationLogsResponse( const logs: LogSection[] = []; const logsTitle: { [order: number]: string } = { - 0: "Install Operator Lifecycle CRD Output", - 1: "Install Operator Lifecycle Output", - 2: "Install Operator Output", - 3: "Setting Apply Operator Output", - 4: "Operator pod output", + 0: "Install Cert Manager Output", + 1: "Install Operator Output", + 2: "Setting Apply Operator Output", + 3: "Operator pod output", }; installShellResult.filter(Boolean).forEach((sr, index) => { diff --git a/src/commands/azureServiceOperators/installAzureServiceOperator.ts b/src/commands/azureServiceOperators/installAzureServiceOperator.ts index 7de42b941..b73ef99f8 100644 --- a/src/commands/azureServiceOperators/installAzureServiceOperator.ts +++ b/src/commands/azureServiceOperators/installAzureServiceOperator.ts @@ -64,7 +64,7 @@ export async function install( vscode.window.showErrorMessage(extensionPath.error); return undefined; } - + // Create webview with user input required. createASOWebView(webview, extensionPath.result, installationResponse, true); diff --git a/src/commands/azureServiceOperators/ui/azureservicebrowser.ts b/src/commands/azureServiceOperators/ui/azureservicebrowser.ts index 6d3f38717..0762a7e4d 100644 --- a/src/commands/azureServiceOperators/ui/azureservicebrowser.ts +++ b/src/commands/azureServiceOperators/ui/azureservicebrowser.ts @@ -39,7 +39,7 @@ async function getAPIResourceCommandResult(): Promise s.length > 0); + const apiResource = apiResourceLineItem.split('.').filter((s) => s.length > 0); if (apiResource.length === 4) { // name, apigroup, namespaced, kind - return { displayName: apiResource[3], manifestKind: apiResource[3], abbreviation: apiResource[0] }; - } else if (apiResource.length === 5) { - // name, shortnames, apigroup, namespaced, kind - return { displayName: apiResource[4], manifestKind: apiResource[4], abbreviation: apiResource[0] }; + return { displayName: apiResource[0], manifestKind: apiResource[1], abbreviation: apiResource[0] }; } else { vscode.window.showWarningMessage(`Invalid api-resource output from azure service operator.`); return undefined;