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

core: azure kms support #13852

Merged
merged 1 commit into from
Mar 18, 2024
Merged

core: azure kms support #13852

merged 1 commit into from
Mar 18, 2024

Conversation

sp98
Copy link
Contributor

@sp98 sp98 commented Mar 4, 2024

Add support for store OSD encryption Keys in Azure KMS

  • Store OSD encryption key in Azure KMS
  • Fetch OSD encryption key from Azure KMS
  • Delete OSD encryption keys from Azure KMS when the cluster is deleted. (Deleting doesn't purge the OSD, use has to do that manually)

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Copy link

mergify bot commented Mar 4, 2024

This pull request has merge conflicts that must be resolved before it can be merged. @sp98 please rebase it. https://rook.io/docs/rook/latest/Contributing/development-flow/#updating-your-fork

github.com/kubernetes-incubator/external-storage => github.com/libopenstorage/external-storage v0.20.4-openstorage-rc3
// github.com/libopenstorage/secrets => github.com/sp98/secrets v0.0.0-20240220060802-e2bb123d06b9
github.com/libopenstorage/secrets => github.com/sp98/secrets v0.0.0-20240304064404-1ca2f1c12a8b
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3

any reason for this change? As we have put the portworx import in exclude section.

Copy link
Contributor Author

@sp98 sp98 Mar 5, 2024

Choose a reason for hiding this comment

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

We originally had this in the go.mod in Rook

// portworx dependencies are a mess, and we don't use portworx code, so skip it
 github.com/portworx/sched-ops v1.20.4-rc1

The reason for this is that the portworx/sched-ops repo is still referring to this incorrect version of kubernetes-incubator/external-storage. This version dependency needs to be fixed in sched-ops.

sched-ops is only used by Azure KMS. So we excluded it since we were not using Azure.

Now that we are using Azure, we need to use Azure KMS, we need to repo. And solution was the replace it like this, since the issue is still not fixed.

github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3

I need to remove what we have in exclude section. That does not make sense now.

Thanks for pointing this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for explaining the uses.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for explaining. I marked this it as unresolved to make sure that we keep the conversation more easily visible in case we have to reference it in the future. I don't see a way to mark it as resolved but still see the convo.

Comment on lines 150 to 160
if c.IsAzure() {
v, err := InitAzure(c.ClusterInfo.Context, c.context, c.ClusterInfo.Namespace, c.clusterSpec.Security.KeyManagementService.ConnectionDetails)
if err != nil {
return errors.Wrap(err, "failed to init azure key vault")
}
err = put(v, GenerateOSDEncryptionSecretName(secretName), secretValue, map[string]string{})
if err != nil {
return errors.Wrap(err, "failed to put secret in azure key vault")
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I see 3 instances of this same code block. What is the reason for that?

Copy link
Contributor Author

@sp98 sp98 Mar 7, 2024

Choose a reason for hiding this comment

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

They are for put, get and delete operations.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Thanks for explaining.

In general, I see this as a code smell. Methods like put/get shouldn't be doing KMS type checking. I think this is highlighting that our KMS support was hastily implemented and has been clunkily extended over time. I don't think this needs to be resolved in this PR, but it would be good to consider cleaning up the KMS code afterwards.

The better implementation would be to use a Golang interface that defines all the KMS methods, and then have each KMS implement all the methods. That would allow us to implement new KMSes more easily, it would make unit testing easier, and it would allow us to do functional e2e testing of KMSes without having to do a full install of Rook.

@sp98 sp98 force-pushed the support-azure-kms branch 2 times, most recently from 0677351 to bd8d741 Compare March 5, 2024 06:14
@sp98 sp98 marked this pull request as ready for review March 5, 2024 10:11
@sp98 sp98 changed the title core: azure kms support [WIP]core: azure kms support Mar 5, 2024
@sp98 sp98 force-pushed the support-azure-kms branch 2 times, most recently from cfa0af7 to 2fedef3 Compare March 7, 2024 06:40
@sp98 sp98 changed the title [WIP]core: azure kms support core: azure kms support Mar 7, 2024
@sp98 sp98 changed the title core: azure kms support [WIP]core: azure kms support Mar 7, 2024
@sp98 sp98 force-pushed the support-azure-kms branch 4 times, most recently from 2999a5f to 80d6d98 Compare March 7, 2024 07:44
@sp98 sp98 force-pushed the support-azure-kms branch 4 times, most recently from 75bb98d to d99fa19 Compare March 7, 2024 13:43
@sp98 sp98 changed the title [WIP]core: azure kms support core: azure kms support Mar 7, 2024
pkg/daemon/ceph/osd/kms/azure.go Show resolved Hide resolved
pkg/daemon/ceph/osd/kms/azure_test.go Outdated Show resolved Hide resolved
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

some small suggestions

pkg/daemon/ceph/osd/kms/azure.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/osd/kms/envs_test.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/osd/kms/azure.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/osd/kms/kms.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/osd/kms/kms.go Outdated Show resolved Hide resolved
if err != nil && err != secrets.ErrInvalidSecretId && err != secrets.ErrSecretNotFound {
return errors.Wrapf(err, "failed to get secret %q in kms", secretName)
}
if key != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Are updates supported? Or should we return an error if the value doesn't match? If the value changes it looks like the method succeeds, but ignores the new value. The caller will believe the latest value was set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really don't think its supported.
This is an existing function used by hashcorp vault as well. The key is created for each PVC and then stored in the KMS.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we don't need to worry about an update, since we don't expect it to change. How about logging an error if it doesn't match, but don't fail the reconcile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update to code the add error message and return if the new secret value is not same when compared to existing secret value in the KMS. .

@sp98 sp98 force-pushed the support-azure-kms branch 2 times, most recently from 076c834 to 6d7c549 Compare March 8, 2024 13:35
Copy link

mergify bot commented Mar 11, 2024

This pull request has merge conflicts that must be resolved before it can be merged. @sp98 please rebase it. https://rook.io/docs/rook/latest/Contributing/development-flow/#updating-your-fork

@sp98 sp98 requested a review from travisn March 11, 2024 15:09
@sp98 sp98 force-pushed the support-azure-kms branch 4 times, most recently from 3137314 to 0049f48 Compare March 13, 2024 16:00
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

Please add a note about this feature in the PendingReleaseNotes.md. Hopefully we can get traction on the dependent PR soon, but otherwise this looks good.

Copy link

mergify bot commented Mar 14, 2024

This pull request has merge conflicts that must be resolved before it can be merged. @sp98 please rebase it. https://rook.io/docs/rook/latest/Contributing/development-flow/#updating-your-fork

@travisn
Copy link
Member

travisn commented Mar 14, 2024

@sp98 A fork of the libopenstorage/secrets is created now. How about opening your PR against that repo and we can move this forward for the short term? Hopefully this is only temporary.

@sp98
Copy link
Contributor Author

sp98 commented Mar 15, 2024

@sp98 A fork of the libopenstorage/secrets is created now. How about opening your PR against that repo and we can move this forward for the short term? Hopefully this is only temporary.

cherrypicked my PR in the fork - rook/secrets#1

Add support for store OSD encryption Keys in Azure KMS

Signed-off-by: sp98 <sapillai@redhat.com>
@sp98
Copy link
Contributor Author

sp98 commented Mar 15, 2024

@sp98 A fork of the libopenstorage/secrets is created now. How about opening your PR against that repo and we can move this forward for the short term? Hopefully this is only temporary.

Updated the go.mod to use the rook fork of the secrets library. Manually tested it. Looks good. Able store, retrieve and delete OSD encryption keys.

Copy link
Member

@parth-gr parth-gr left a comment

Choose a reason for hiding this comment

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

nit

github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.1
github.com/kubernetes-incubator/external-storage => github.com/libopenstorage/external-storage v0.20.4-openstorage-rc3

// TODO: remove this replace once https://github.com/libopenstorage/secrets/pull/83 is merged
Copy link
Member

Choose a reason for hiding this comment

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

replace once libopenstorage/secrets#83 is merged

@sp98 sp98 requested review from BlaineEXE and iPraveenParihar and removed request for BlaineEXE and iPraveenParihar March 18, 2024 05:01
Copy link
Contributor

@iPraveenParihar iPraveenParihar left a comment

Choose a reason for hiding this comment

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

LGTM

@sp98 sp98 merged commit b8ee8a4 into rook:master Mar 18, 2024
51 checks passed
obnoxxx added a commit to obnoxxx/rook that referenced this pull request May 30, 2024
The build was failing locally for me with a go module checksum mismatch
error:

```console
verifying github.com/portworx/sched-ops@v0.20.4-openstorage-rc3: checksum mismatch
	downloaded: h1:46EZ+vYCJ3qmQolvgDCrGuPz8Tf0vIds41RuF0dqVEw=
	go.sum:     h1:tXnHsjZT2wZ2BCXf8avDoya7zGyCgLNUC8Upt+WEQrY=
``

The last change to go.sum related to this module was from PR rook#13852

This change to go.sum fixes the issue for me.

It is the result of the following commands:

````console
rm go.sum
go mod tidy
``

Signed-off-by: Michael Adam <obnox@samba.org>
obnoxxx added a commit to obnoxxx/rook that referenced this pull request May 30, 2024
The build was failing locally for me with a go module checksum mismatch
error:

```console
verifying github.com/portworx/sched-ops@v0.20.4-openstorage-rc3: checksum mismatch
	downloaded: h1:46EZ+vYCJ3qmQolvgDCrGuPz8Tf0vIds41RuF0dqVEw=
	go.sum:     h1:tXnHsjZT2wZ2BCXf8avDoya7zGyCgLNUC8Upt+WEQrY=
``

The last change to go.sum related to this module was from PR rook#13852

This change to go.sum fixes the issue for me.

Fixes: rook#14282

It is the result of the following commands:

````console
rm go.sum
go mod tidy
``

Signed-off-by: Michael Adam <obnox@samba.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants