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

Gangams/arc k8s aad msi auth #743

Merged
merged 51 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7815bfe
arc k8s msi
ganga1980 Nov 8, 2021
cb45f3c
wip
ganga1980 Nov 9, 2021
3b16489
extension identity role
ganga1980 Nov 10, 2021
5ce46d0
imds sidecar integration for arc k8s
ganga1980 Nov 10, 2021
f083d0a
imds sidecar integration for arc k8s
ganga1980 Nov 10, 2021
7d5fdbc
imds endpoint for windows
ganga1980 Nov 11, 2021
235c2e1
imds endpoint for windows
ganga1980 Nov 11, 2021
ee7dc5a
wip
ganga1980 Nov 13, 2021
79db836
fix exception
ganga1980 Nov 18, 2021
787909d
merge latest ci_dev
ganga1980 Mar 7, 2022
3359472
merge latest ci_dev changes
ganga1980 Apr 5, 2022
d30d4fd
rename param name
ganga1980 Apr 5, 2022
650f34f
arc msi imdsd container changes
ganga1980 Apr 6, 2022
584b26a
arc msi imdsd container changes
ganga1980 Apr 6, 2022
cf9b3eb
arc msi imdsd container changes
ganga1980 Apr 6, 2022
514f6a3
arc msi imdsd container changes
ganga1980 Apr 6, 2022
8a8ebe9
arc msi imdsd container changes
ganga1980 Apr 6, 2022
2daee1f
revert unneeded yaml changes
ganga1980 Apr 6, 2022
352d75f
revert unneeded yaml changes
ganga1980 Apr 7, 2022
bd42544
wip
ganga1980 Apr 8, 2022
e4f8837
wip
ganga1980 Apr 8, 2022
5ffd60a
working
ganga1980 Apr 8, 2022
d7a0bc1
working
ganga1980 Apr 8, 2022
acc716c
working
ganga1980 Apr 8, 2022
53c0352
Merge branch 'ci_dev' into gangams/arc-k8s-aad-msi-auth
ganga1980 Apr 8, 2022
7cbf26c
add implementation for msi token for windows mdm metrics
ganga1980 Apr 9, 2022
feb5f85
fix comment
ganga1980 Apr 9, 2022
77197b7
arc k8s msi onboarding templates
ganga1980 Apr 9, 2022
d5797d2
fix template bug
ganga1980 Apr 9, 2022
7737ffa
fix template bug
ganga1980 Apr 9, 2022
e489ce4
fix template bug
ganga1980 Apr 9, 2022
2956451
rename flag name
ganga1980 Apr 9, 2022
00e4336
fix template bug
ganga1980 Apr 9, 2022
0b362b1
make useAADAuth specific to arc k8s
ganga1980 Apr 10, 2022
eab121e
set k8sport at machine scope for windows
ganga1980 Apr 10, 2022
1534bd4
fix bug
ganga1980 Apr 11, 2022
5c91066
fix bug
ganga1980 Apr 11, 2022
3046c87
update rbac for arc k8s imds
ganga1980 Apr 11, 2022
dcf60c4
bump chart version for conformance test run
ganga1980 Apr 14, 2022
6bb6978
conf test updates for msi auth
ganga1980 Apr 15, 2022
a1716ea
cli extension whl file
ganga1980 Apr 15, 2022
62240ec
add containerinsights solution in msi auth mode
ganga1980 Apr 17, 2022
0c3be28
Merge branch 'ci_dev' into gangams/arc-k8s-aad-msi-auth
ganga1980 Apr 17, 2022
4574a33
unify tags
ganga1980 Apr 17, 2022
f9d0a7d
revert test chart and image versions
ganga1980 Apr 18, 2022
197a521
remove test whl file and fix conf test
ganga1980 Apr 27, 2022
a8cb5f5
Merge branch 'ci_dev' into gangams/arc-k8s-aad-msi-auth
ganga1980 Apr 27, 2022
a423023
conf test updates for addon-token-adapter
ganga1980 Apr 28, 2022
7fbfdd0
remove container insights solution add for msi auth
ganga1980 May 5, 2022
f9004e5
Merge branch 'ci_dev' into gangams/arc-k8s-aad-msi-auth
ganga1980 May 5, 2022
e4d51d3
add missing arm template param
ganga1980 May 6, 2022
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 @@ -19,8 +19,16 @@ metadata:
name: container-insights-clusteridentityrequest
namespace: azure-arc
spec:
audience: https://monitoring.azure.com/
{{- if eq (.Values.Azure.Cluster.Cloud | lower) "azurepubliccloud" }}
audience: https://monitor.azure.com/
ganga1980 marked this conversation as resolved.
Show resolved Hide resolved
{{- else if eq (.Values.Azure.Cluster.Cloud | lower) "azurechinacloud" }}
audience: https://monitor.azure.cn/
{{- else if eq (.Values.Azure.Cluster.Cloud | lower) "azureusgovernmentcloud" }}
audience: https://monitor.azure.us/
{{- else }}
audience: https://monitor.azure.com/
{{- end }}
{{- if not (empty .Values.Azure.Extension.Name) }}
resourceId: {{ .Values.Azure.Extension.Name }}
resourceId: {{ .Values.Azure.Extension.Name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ spec:
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
- name: USING_AAD_MSI_AUTH
value: {{ .Values.omsagent.useAADAuth | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ spec:
serviceAccountName: omsagent
{{- end }}
containers:
{{- if and (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") (.Values.omsagent.useAADAuth) }}
ganga1980 marked this conversation as resolved.
Show resolved Hide resolved
- name: addon-token-adapter
pfrcks marked this conversation as resolved.
Show resolved Hide resolved
imagePullPolicy: IfNotPresent
env:
- name: AZMON_COLLECT_ENV
value: "false"
- name: TOKEN_NAMESPACE
value: "azure-arc"
{{- .Values.Azure.Identity.MSIAdapterYaml | nindent 7 }}
{{- end }}
- name: omsagent
{{- if eq (.Values.omsagent.domain | lower) "opinsights.azure.cn" }}
image: "mcr.azk8s.cn/azuremonitor/containerinsights/ciprod:{{ .Values.omsagent.image.tag }}"
Expand All @@ -57,6 +67,8 @@ spec:
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
- name: USING_AAD_MSI_AUTH
value: {{ .Values.omsagent.useAADAuth | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
Expand Down Expand Up @@ -159,6 +171,8 @@ spec:
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
- name: USING_AAD_MSI_AUTH
value: {{ .Values.omsagent.useAADAuth | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ spec:
serviceAccountName: omsagent
{{- end }}
containers:
{{- if and (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") (.Values.omsagent.useAADAuth) }}
pfrcks marked this conversation as resolved.
Show resolved Hide resolved
- name: addon-token-adapter
imagePullPolicy: IfNotPresent
env:
- name: AZMON_COLLECT_ENV
value: "false"
- name: TOKEN_NAMESPACE
value: "azure-arc"
{{- .Values.Azure.Identity.MSIAdapterYaml | nindent 7 }}
{{- end }}
- name: omsagent
{{- if eq (.Values.omsagent.domain | lower) "opinsights.azure.cn" }}
image: "mcr.azk8s.cn/azuremonitor/containerinsights/ciprod:{{ .Values.omsagent.image.tag }}"
Expand All @@ -53,6 +63,8 @@ spec:
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
- name: USING_AAD_MSI_AUTH
value: {{ .Values.omsagent.useAADAuth | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
Expand Down
11 changes: 1 addition & 10 deletions charts/azuremonitor-containers/templates/omsagent-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,9 @@ rules:
verbs: ["list"]
- apiGroups: ["clusterconfig.azure.com"]
resources: ["azureclusteridentityrequests", "azureclusteridentityrequests/status"]
resourceNames: ["container-insights-clusteridentityrequest"]
verbs: ["get", "create", "patch"]
verbs: ["get", "create", "patch", "list", "update", "delete"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
#arc k8s extension model grants access as part of the extension msi
#remove this explicit permission once the extension available in public preview
{{- if (empty .Values.Azure.Extension.Name) }}
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["container-insights-clusteridentityrequest-token"]
verbs: ["get"]
{{- end }}
---
kind: ClusterRoleBinding
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }}
Expand Down
4 changes: 4 additions & 0 deletions charts/azuremonitor-containers/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Values of under Azure are being populated by Azure Arc K8s RP during the installation of the extension
Azure:
Cluster:
Cloud: <your_cluster_cloud>
Region: <your_cluster_region>
ResourceId: <your_cluster_id>
Extension:
Expand Down Expand Up @@ -45,6 +46,9 @@ omsagent:
# if set to true additional agent workflow logs will be emitted which are used for e2e and arc k8s conformance testing
ISTEST: false

# This flag used to determine whether to use AAD MSI auth or not for Arc K8s cluster
useAADAuth: false

## To get your workspace id and key do the following
## You can create a Azure Loganalytics workspace from portal.azure.com and get its ID & PRIMARY KEY from 'Advanced Settings' tab in the Ux.

Expand Down
11 changes: 10 additions & 1 deletion kubernetes/windows/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,19 @@ function Set-EnvironmentVariables {
Write-Host "Failed to set environment variable AGENT_VERSION for target 'machine' since it is either null or empty"
}

$kubernetesPort = [System.Environment]::GetEnvironmentVariable("KUBERNETES_PORT_443_TCP_PORT", "process")
if (![string]::IsNullOrEmpty($kubernetesPort)) {
[System.Environment]::SetEnvironmentVariable("KUBERNETES_PORT_443_TCP_PORT", $kubernetesPort, "machine")
Write-Host "Successfully set environment variable KUBERNETES_PORT_443_TCP_PORT - $($kubernetesPort) for target 'machine'..."
}
else {
Write-Host "Failed to set environment variable KUBERNETES_PORT_443_TCP_PORT for target 'machine' since it is either null or empty"
}

# run config parser
ruby /opt/omsagentwindows/scripts/ruby/tomlparser.rb
.\setenv.ps1

#Parse the configmap to set the right environment variables for agent config.
ruby /opt/omsagentwindows/scripts/ruby/tomlparser-agent-config.rb
.\setagentenv.ps1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"description": "Location of the AKS resource e.g. \"East US\""
}
},
"aksResourceTagValues": {
"resourceTagValues": {
"type": "object",
"metadata": {
"description": "Existing all tags on AKS Cluster Resource"
"description": "Existing or new tags to use on AKS, ContainerInsights and DataCollectionRule Resources"
}
},
"workspaceLocation": {
Expand All @@ -31,12 +31,6 @@
"metadata": {
"description": "Full Resource ID of the log analitycs workspace that will be used for data destination. For example /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName/providers/Microsoft.operationalinsights/workspaces/ws_xyz"
}
},
"dcrResourceTagValues": {
"type": "object",
"metadata": {
"description": "Existing or new tags on DCR Resource"
}
}
},
"variables": {
Expand Down Expand Up @@ -70,7 +64,7 @@
"apiVersion": "2019-11-01-preview",
"name": "[variables('dcrName')]",
"location": "[parameters('workspaceLocation')]",
"tags": "[parameters('dcrResourceTagValues')]",
"tags": "[parameters('resourceTagValues')]",
"kind": "Linux",
"properties": {
"dataSources": {
Expand Down Expand Up @@ -184,7 +178,7 @@
"name": "[variables('clusterName')]",
"type": "Microsoft.ContainerService/managedClusters",
"location": "[parameters('aksResourceLocation')]",
"tags": "[parameters('aksResourceTagValues')]",
"tags": "[parameters('resourceTagValues')]",
"apiVersion": "2018-03-31",
"properties": {
"mode": "Incremental",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@
"aksResourceLocation": {
"value": "<aksClusterLocation>"
},
"aksResourceTagValues": {
"value": {
"<existingOrnew-tag-name1>": "<existingOrnew-tag-value1>",
"<existingOrnew-tag-name2>": "<existingOrnew-tag-value2>",
"<existingOrnew-tag-nameN>": "<existingOrnew-tag-valueN>"
}
},
"workspaceResourceId": {
"value": "/subscriptions/<SubscriptionId>/resourceGroups/<ResourceGroup>/providers/Microsoft.OperationalInsights/workspaces/<workspaceName>"
},
"workspaceLocation": {
"value": "<workspaceLocation>"
},
"dcrResourceTagValues": {
"resourceTagValues": {
"value": {
"<existingOrnew-tag-name1>": "<existingOrnew-tag-value1>",
"<existingOrnew-tag-name2>": "<existingOrnew-tag-value2>",
Expand Down
Loading