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

Adds basic federation status health check #35

Merged
merged 16 commits into from
Nov 22, 2024
Merged

Conversation

jsnctl
Copy link
Contributor

@jsnctl jsnctl commented Nov 17, 2024

This PR adds a simple check for a given Federation pair, ensuring equality between the bundles on both sides. For each trust zone it will:

  • Query the SPIRE server for the "server CA bundle" of the host trust zone (i.e. runs /opt/spire/bin/spire-server bundle show)
  • Query the SPIRE server for any federated trust domain bundles (i.e runs /opt/spire/bin/spire-server bundle list)
  • Format and store (in memory) the results in string format
  • Compare the requisite values to each side of the federation, returning "Healthy" if equal but "Unhealthy" otherwise

Note this currently relies on a bump to go 1.23 to make use of slices.Chunk

This might not be the full story for federation health. We could feasibly check:

  • ClusterFederatedTrustDomain entries on both sides
  • ClusterSPIFFEID FederatesWith values on both sides (although we'd need to specify which ones to check, perhaps via bound attestation-policy entries?)
  • Something like the attest-me pattern as mooted in previous discussions

@jsnctl jsnctl self-assigned this Nov 17, 2024
@jsnctl jsnctl marked this pull request as draft November 17, 2024 21:30
@jsnctl jsnctl marked this pull request as ready for review November 17, 2024 22:13
@jsnctl
Copy link
Contributor Author

jsnctl commented Nov 17, 2024

Seems to work pretty well

💤 cofidectl/ ./cofidectl federation list                                                                                          (jsnctl/federation-status)
  FROM TRUST ZONE | TO TRUST ZONE | STATUS   
------------------+---------------+----------
  alpha           | beta          | Healthy  
  beta            | alpha         | Healthy  
💤 cofidectl/ rprompt                                                                                                              (jsnctl/federation-status)
💤 cofidectl/ k delete clusterfederatedtrustdomains.spire.spiffe.io spire-spire-alpha                                                    ⎈(kind-beta/default)
clusterfederatedtrustdomain.spire.spiffe.io "spire-spire-alpha" deleted
💤 cofidectl/ k exec -n spire spire-server-0 -- /opt/spire/bin/spire-server bundle delete -id alpha.test                                 ⎈(kind-beta/default)



bundle deleted.
💤 cofidectl/ ./cofidectl federation list                                                                                                ⎈(kind-beta/default)
  FROM TRUST ZONE | TO TRUST ZONE |  STATUS    
------------------+---------------+------------
  alpha           | beta          | Unhealthy  
  beta            | alpha         | Unhealthy  

cmd/cofidectl/cmd/federation/federation.go Outdated Show resolved Hide resolved
cmd/cofidectl/cmd/federation/federation.go Outdated Show resolved Hide resolved
internal/pkg/spire/spire.go Outdated Show resolved Hide resolved
@markgoddard
Copy link
Contributor

It might also be nice to add the federation list command to the federation integration test.

@jsnctl
Copy link
Contributor Author

jsnctl commented Nov 20, 2024

Added this post deploy fn as it feels like we might add to these sorts of post-deploy commands down the line

function post_deploy() {
if ./cofidectl federation list | grep Healthy; then
return
fi
exit 1
}

@jsnctl jsnctl requested a review from markgoddard November 20, 2024 22:20
tests/integration/federation/test.sh Outdated Show resolved Hide resolved
cmd/cofidectl/cmd/federation/federation.go Outdated Show resolved Hide resolved
@jsnctl jsnctl requested a review from markgoddard November 21, 2024 14:50
@jsnctl jsnctl requested a review from markgoddard November 22, 2024 09:08
@jsnctl jsnctl merged commit c7c2622 into main Nov 22, 2024
5 checks passed
@jsnctl jsnctl deleted the jsnctl/federation-status branch November 22, 2024 11:36
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.

2 participants