Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Adding support for whitelisting of user-defined managed identities #431

Merged
merged 13 commits into from
Nov 4, 2019

Conversation

dmeytin
Copy link
Contributor

@dmeytin dmeytin commented Oct 23, 2019

Reason for Change:
In some cases a user-defined managed identity could be removed from the AAD

Issue Fixed:
This PR is adding whitelist of user defined managed identities what will never be removed from AAD

Notes for Reviewers:
The change is as following:

  • mic main accepts new cmd parameter whiteListedIdentitiesParam - comma separated list of identities that shouldn't be deleted from AAD
  • at updateUserMSI function we compare removeUserAssignedMSIIDs and whiteListedIdentities and only missing values are removed from AAD
  • helm chart and Readme are changed accordingly

This feature is extremely important for migrating existing production clusters to aad-pod-identity.
In particular, all our existing deployments will use user-defined identity as one per team.
Reuse of the same identity to multiple pods caused the identity to be deleted from AAD when it still in use.
This change will solve the issue.

Best regards,
Dmitry

@msftclas
Copy link

msftclas commented Oct 23, 2019

CLA assistant check
All CLA requirements met.

pkg/mic/mic.go Outdated Show resolved Hide resolved
pkg/mic/mic_test.go Outdated Show resolved Hide resolved
charts/aad-pod-identity/README.md Outdated Show resolved Hide resolved
charts/aad-pod-identity/README.md Outdated Show resolved Hide resolved
charts/aad-pod-identity/README.md Outdated Show resolved Hide resolved
cmd/mic/main.go Outdated Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
pkg/mic/mic.go Outdated Show resolved Hide resolved
pkg/mic/mic.go Outdated Show resolved Hide resolved
pkg/mic/mic.go Outdated Show resolved Hide resolved
pkg/mic/mic.go Outdated Show resolved Hide resolved
> Available from 1.5.4 release

Aad-pod-identity has a new flag immutableUserMSIs which can be used to prevent deletetion of spcecified identitites from VM/VMSS.
The list is comma separated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please show a simple example - /subscription/00000000-000... like that.. you can check the main README for example of the user identity pattern.

Copy link
Contributor Author

@dmeytin dmeytin Oct 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is added: Example: 00000000-0000-0000-0000-000000000000,11111111-1111-1111-1111-111111111111

charts/aad-pod-identity/README.md Outdated Show resolved Hide resolved
charts/aad-pod-identity/values.yaml Outdated Show resolved Hide resolved
@@ -133,6 +134,21 @@ var _ = Describe("Kubernetes cluster using aad-pod-identity", func() {
deleteAllIdentityValidator()
})

It("should not delete the Immutable Identity from vmss when the deployment is deleted", func() {
setUpIdentityAndDeployment(immutableIdentity, "", "1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the e2e could:

  1. Assign the immutable identity explicitly to the vmss/vm
  2. Create an azure identity with the same immutable identity
  3. Run the identity validator check(ensure that a cycle has completed)
  4. Now the identity validator is deleted (so it goes through a cycle of deletion) .
  5. Check that count of azureassignedidentity is 0 (confirming that the reconcile cycle is complete)
  6. Check that the immutable identity is still present on the vm/vmss.

@kkmsft
Copy link
Contributor

kkmsft commented Nov 1, 2019

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -98,7 +103,10 @@ func main() {
config.Burst = int(clientQPS)
glog.Infof("Client QPS set to: %v. Burst to: %v", config.QPS, config.Burst)

micClient, err := mic.NewMICClient(cloudconfig, config, forceNamespaced, syncRetryDuration, &leaderElectionCfg, enableScaleFeatures, createDeleteBatch)
immutableUserMSIsList := strings.Split(immutableUserMSIs, ",")
glog.Infof("immutable identities are %v", immutableUserMSIsList)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit0: Can you please make this conditional, If the parameter is given, then only print.
nit1: Can we have the first letter with caps.

@kkmsft
Copy link
Contributor

kkmsft commented Nov 4, 2019

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kkmsft kkmsft merged commit 668af16 into Azure:master Nov 4, 2019
@aramase aramase mentioned this pull request Nov 21, 2019
statbit pushed a commit to adobe-platform/aad-pod-identity that referenced this pull request Sep 30, 2021
…zure#431)

* Adding support for whitelisting of user-defined managed identities

* Fixing pull request comments

* adding example for immutableUserMSIs flags readme

* fixing rebase

* improving helm chart to be more convenient

* improving readme file

* fixing remarks in Readme file

* reverting go.sum changes

* adding e2e test for immutable identity

* refactoring immutable identity test

* fixing e2e test for immutable identity
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants