Skip to content

Commit

Permalink
Added use admin creds option for helm deploy task (#10867)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabasnidhi authored Jul 11, 2019
1 parent 724eaf3 commit 293c22c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"loc.input.help.azureResourceGroup": "Select an Azure Resource Group.",
"loc.input.label.kubernetesCluster": "Kubernetes cluster",
"loc.input.help.kubernetesCluster": "Select an Azure Managed Cluster.",
"loc.input.label.useClusterAdmin": "Use cluster admin credentials",
"loc.input.help.useClusterAdmin": "Use cluster administrator credentials instead of default cluster user credentials.",
"loc.input.label.kubernetesServiceEndpoint": "Kubernetes Service Connection",
"loc.input.help.kubernetesServiceEndpoint": "Select a Kubernetes service connection.",
"loc.input.label.namespace": "Namespace",
Expand Down
7 changes: 4 additions & 3 deletions Tasks/HelmDeployV0/src/clusters/armkubernetescluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { AzureRMEndpoint } from 'azure-arm-rest-v2/azure-arm-endpoint';
import { AzureEndpoint, AKSCluster, AKSClusterAccessProfile} from 'azure-arm-rest-v2/azureModels';

// get kubeconfig file content
async function getKubeConfigFromAKS(azureSubscriptionEndpoint: string, resourceGroup: string, clusterName: string) : Promise<string> {
async function getKubeConfigFromAKS(azureSubscriptionEndpoint: string, resourceGroup: string, clusterName: string, useClusterAdmin?: boolean) : Promise<string> {
var azureEndpoint: AzureEndpoint = await (new AzureRMEndpoint(azureSubscriptionEndpoint)).getEndpoint();
var aks = new AzureAksService(azureEndpoint);

tl.debug(tl.loc("KubernetesClusterResourceGroup", clusterName, resourceGroup));

var clusterInfo : AKSClusterAccessProfile = await aks.getAccessProfile(resourceGroup, clusterName);
var clusterInfo : AKSClusterAccessProfile = await aks.getAccessProfile(resourceGroup, clusterName, useClusterAdmin);
var base64Kubeconfig = Buffer.from(clusterInfo.properties.kubeConfig, 'base64');
return base64Kubeconfig.toString();
}
Expand All @@ -21,5 +21,6 @@ export async function getKubeConfig(): Promise<string> {
var clusterName : string = tl.getInput("kubernetesCluster", true);
var azureSubscriptionEndpoint : string = tl.getInput("azureSubscriptionEndpoint", true);
var resourceGroup : string = tl.getInput("azureResourceGroup", true);
return getKubeConfigFromAKS(azureSubscriptionEndpoint, resourceGroup, clusterName);
var useClusterAdmin: boolean = tl.getBoolInput('useClusterAdmin');
return getKubeConfigFromAKS(azureSubscriptionEndpoint, resourceGroup, clusterName, useClusterAdmin);
}
13 changes: 11 additions & 2 deletions Tasks/HelmDeployV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 154,
"Patch": 4
"Minor": 155,
"Patch": 0
},
"demands": [],
"groups": [
Expand Down Expand Up @@ -96,6 +96,15 @@
"EditableOptions": "True"
}
},
{
"name": "useClusterAdmin",
"type": "boolean",
"label": "Use cluster admin credentials",
"defaultValue": "false",
"visibleRule": "connectionType = Azure Resource Manager",
"groupName": "cluster",
"helpMarkDown": "Use cluster administrator credentials instead of default cluster user credentials."
},
{
"name": "kubernetesServiceEndpoint",
"aliases": [
Expand Down
15 changes: 12 additions & 3 deletions Tasks/HelmDeployV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 154,
"Patch": 4
"Minor": 155,
"Patch": 0
},
"demands": [],
"groups": [
Expand Down Expand Up @@ -96,6 +96,15 @@
"EditableOptions": "True"
}
},
{
"name": "useClusterAdmin",
"type": "boolean",
"label": "ms-resource:loc.input.label.useClusterAdmin",
"defaultValue": "false",
"visibleRule": "connectionType = Azure Resource Manager",
"groupName": "cluster",
"helpMarkDown": "ms-resource:loc.input.help.useClusterAdmin"
},
{
"name": "kubernetesServiceEndpoint",
"aliases": [
Expand Down Expand Up @@ -432,4 +441,4 @@
"KubernetesServiceConnectionNotFound": "ms-resource:loc.messages.KubernetesServiceConnectionNotFound",
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
}
}
}

0 comments on commit 293c22c

Please sign in to comment.