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

Added use admin creds option for helm deploy task #10867

Merged
merged 3 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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);
dabasnidhi marked this conversation as resolved.
Show resolved Hide resolved
}
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"
}
}
}