Skip to content

Conversation

keeganwitt
Copy link
Contributor

@keeganwitt keeganwitt commented Jan 9, 2023

I looked at all the places using Admin and used that to determine what I probably needed for adding Downstream. I haven't tested that this actually works though.

@keeganwitt keeganwitt force-pushed the support_downstream_entries branch from 81f9a0b to fe2e29d Compare January 9, 2023 18:43
@keeganwitt
Copy link
Contributor Author

keeganwitt commented Jan 9, 2023

This code seems to only support a k8s_psat parent, but if you are using another method (for example x509pop to have secondary SPIRE servers in different K8s clusters), then there's no way to specify the parent in the CRD.

parentID, err := spiffeid.FromPathf(trustDomain, "/spire/agent/k8s_psat/%s/%s", clusterName, node.UID)

I think this would need to be changed in this PR also.

@keeganwitt keeganwitt force-pushed the support_downstream_entries branch 2 times, most recently from 000292a to 7f9644d Compare January 10, 2023 05:46
@faisal-memon
Copy link
Contributor

Do we need to bump the version of the crd for this change?

@faisal-memon
Copy link
Contributor

This code seems to only support a k8s_psat parent, but if you are using another method (for example x509pop to have secondary SPIRE servers in different K8s clusters), then there's no way to specify the parent in the CRD.

parentID, err := spiffeid.FromPathf(trustDomain, "/spire/agent/k8s_psat/%s/%s", clusterName, node.UID)

I think this would need to be changed in this PR also.

Were you able to specify the parent with k8s-workload-registrar?

@keeganwitt
Copy link
Contributor Author

This code seems to only support a k8s_psat parent, but if you are using another method (for example x509pop to have secondary SPIRE servers in different K8s clusters), then there's no way to specify the parent in the CRD.

parentID, err := spiffeid.FromPathf(trustDomain, "/spire/agent/k8s_psat/%s/%s", clusterName, node.UID)

I think this would need to be changed in this PR also.

Were you able to specify the parent with k8s-workload-registrar?

Yes, this is what we're doing today with the Registrar.

@keeganwitt
Copy link
Contributor Author

Do we need to bump the version of the crd for this change?

Yea, I suppose so. Bumped.

@keeganwitt keeganwitt force-pushed the support_downstream_entries branch from 78b5009 to aad2dbe Compare January 12, 2023 01:00
@faisal-memon
Copy link
Contributor

Do we need to bump the version of the crd for this change?

Yea, I suppose so. Bumped.

I think I was mistaken, we don't need to bump the version for just adding a new field. https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#adding-a-field

@keeganwitt
Copy link
Contributor Author

keeganwitt commented Jan 13, 2023

Created #54 for the parentID part.

@keeganwitt keeganwitt force-pushed the support_downstream_entries branch from aad2dbe to 3d5c98b Compare January 13, 2023 15:17
@keeganwitt
Copy link
Contributor Author

Do we need to bump the version of the crd for this change?

Yea, I suppose so. Bumped.

I think I was mistaken, we don't need to bump the version for just adding a new field. https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#adding-a-field

OK. Dropped that commit.

@faisal-memon
Copy link
Contributor

Thanks @keeganwitt for the updates. Changes look good to me.

Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

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

Thanks for opening this contribution, @keeganwitt!

Looks like a spot was missed in api/v1alpha1/clusterspiffeid_webhook.go where the spec is parsed into the ParsedClusterSPIFFEID struct. Downstream is not being set on the parsed spec, which ultimately results in the downstream bit not being set on the registration entry.

I'd encourage you to test out your changes before submitting. It would have found the issue.

@@ -48,6 +48,9 @@ spec:
items:
type: string
type: array
downstream:
description: Downstream indicates that the entry describes a downstream SPIRE server.
Copy link
Member

Choose a reason for hiding this comment

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

Was make manifests run after adding the field to the CRD? The formatting seems different here than what was generated for me locally...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I didn't know about that script. I did this by hand. We should document this in a CONTRIBUTING.md.

@@ -48,6 +48,9 @@ spec:
items:
type: string
type: array
downstream:
Copy link
Member

Choose a reason for hiding this comment

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

This might need to be updated based the answer to my question about make manifests...

@@ -48,6 +48,9 @@ spec:
items:
type: string
type: array
downstream:
Copy link
Member

Choose a reason for hiding this comment

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

This might need to be updated based the answer to my question about make manifests...

@keeganwitt
Copy link
Contributor Author

Thanks for opening this contribution, @keeganwitt!

Looks like a spot was missed in api/v1alpha1/clusterspiffeid_webhook.go where the spec is parsed into the ParsedClusterSPIFFEID struct. Downstream is not being set on the parsed spec, which ultimately results in the downstream bit not being set on the registration entry.

I'd encourage you to test out your changes before submitting. It would have found the issue.

No testing, as noted in the description, this was my best guess what changes were needed. Do you have a recommendation for how to test? I couldn't test with my deployment because we're still using the registrar. Sounds like we could use a CONTRIBUTING.md?

@azdagron
Copy link
Member

We definitely need a CONTRIBUTING.md :)

To test, I normally run make docker-build and then make some changes to the integration test scripts to exercise things. See demo/test.sh.

@keeganwitt keeganwitt force-pushed the support_downstream_entries branch from 3d5c98b to ef4cfeb Compare January 17, 2023 16:25
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

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

Thanks, @keeganwitt. Looks good.

@azdagron azdagron merged commit 426e7b6 into spiffe:main Jan 17, 2023
@keeganwitt keeganwitt deleted the support_downstream_entries branch January 17, 2023 19:45
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.

3 participants