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

pkg/*: use Kubernetes ServiceAccount as service identity #1990

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

shashankram
Copy link
Member

@shashankram shashankram commented Nov 5, 2020

Description:
This change does the following:

  • Uses kubernetes ServiceAccount as service identity for
    proxy service certificates. The service certificate
    CN/SAN will be of the form <svc-account>.<namespace>.<domain>.

  • Refactors SDS to make it easier to share code in its internal
    implementation.

  • Removes the overloaded usage of the certificate's CN for SNI.
    SNI (Server Name Identifier) is based on the service FQDN,
    while the service certificate is derived from the ServiceIdentity
    being used.

  • Removes SAN matching for the downstream/upstream service
    in permissive mode, where there are no SMI TrafficTarget policies.
    In permissive mode, every service within the mesh is allowed to
    reach every other service as long as they use the correct certificate.

  • Refactors sds/response_test.go to make it possible to use
    table-driven testing to test different unit testing scenarios.

Part of #1965

Affected area:

  • New Functionality [ ]
  • Documentation [ ]
  • Install [ ]
  • Control Plane [X]
  • CLI Tool [ ]
  • Certificate Management [X]
  • Networking [ ]
  • Metrics [ ]
  • SMI Policy [ ]
  • Security [X]
  • Tests [X]
  • CI System [ ]
  • Performance [ ]
  • Other [ ]

Please answer the following questions with yes/no.

  • Does this change contain code from or inspired by another project? If so, did you notify the maintainers and provide attribution?
    No

@shashankram shashankram requested a review from a team as a code owner November 5, 2020 00:34
@codecov-io
Copy link

codecov-io commented Nov 5, 2020

Codecov Report

Merging #1990 into main will decrease coverage by 0.02%.
The diff coverage is 45.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1990      +/-   ##
==========================================
- Coverage   56.64%   56.62%   -0.03%     
==========================================
  Files         139      140       +1     
  Lines        5589     5611      +22     
==========================================
+ Hits         3166     3177      +11     
- Misses       2420     2431      +11     
  Partials        3        3              
Impacted Files Coverage Δ
pkg/identity/kubernetes.go 100.00% <ø> (ø)
pkg/identity/types.go 0.00% <0.00%> (ø)
pkg/envoy/sds/response.go 63.41% <32.55%> (-5.40%) ⬇️
pkg/catalog/xds_certificates.go 93.40% <100.00%> (+0.54%) ⬆️
pkg/envoy/cds/cluster.go 96.80% <100.00%> (ø)
pkg/envoy/lds/ingress.go 90.24% <100.00%> (ø)
pkg/envoy/lds/inmesh.go 86.20% <100.00%> (ø)
pkg/service/types.go 87.50% <100.00%> (+6.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2047ca9...74e2215. Read the comment docs.

@shashankram shashankram marked this pull request as draft November 5, 2020 00:52
@shashankram shashankram added the wip Work-in-Progress label Nov 5, 2020
@shashankram shashankram removed the wip Work-in-Progress label Nov 5, 2020
@shashankram shashankram marked this pull request as ready for review November 5, 2020 01:41
snehachhabria
snehachhabria previously approved these changes Nov 5, 2020
This change does the following:

- Uses kubernetes ServiceAccount as service identity for
  proxy service certificates. The service certificate
  CN/SAN will be of the form <svc-account>.<namespace>.<domain>.

- Refactors SDS to make it easier to share code in its internal
  implementation.

- Removes the overloaded usage of the certificate's CN for SNI.
  SNI (Server Name Identifier) is based on the service FQDN,
  while the service certificate is derived from the ServiceIdentity
  being used.

- Refactors sds/response_test.go to make it possible to use
  table-driven testing to test different unit testing scenarios.

Signed-off-by: Shashank Ram <shashank08@gmail.com>
Signed-off-by: Shashank Ram <shashank08@gmail.com>
@shashankram shashankram requested a review from draychev November 5, 2020 18:49
Copy link
Contributor

@draychev draychev left a comment

Choose a reason for hiding this comment

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

Left a few comments that could be addressed in follow-up PRs - feel free to ignore.
Thanks for working on this!

@@ -243,6 +243,7 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.6 h1:GgblEiDzxf5ajlAZY4aC8xp7DwkrGfauFNMGdB2bBv0=
github.com/envoyproxy/go-control-plane v0.9.6/go.mod h1:GFqM7v0B62MraO4PWRedIbhThr/Rf7ev6aHOOPXeaDA=
github.com/envoyproxy/go-control-plane v0.9.7 h1:EARl0OvqMoxq/UMgMSCLnXzkaXbxzskluEBlMQCJPms=
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

return nil, err
}

// Iterate over the list of tasks and create response structs to be
// sent to the proxy that made the discovery request
sdsImpl := newSDSImpl(proxy, meshCatalog, certManager, cfg, svcList, svcAccount)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what impl means here or anywhere below really. I would prefer to use something that reads easily in plain english and helps you understand what's behind this variable.

No need to change this PR - but eventually would be good to add clarity so it is easy to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

I left a comment on what sdsImpl refers to in sds/types.go.

if serviceForProxy != sdsCert.MeshService {
log.Error().Msgf("Proxy %s (service %s) requested service certificate %s; this is not allowed", proxy.GetCommonName(), serviceForProxy, sdsCert.MeshService)
if proxyService != sdsCert.MeshService {
log.Debug().Msgf("Proxy %s (service %s) requested service certificate %s; this is not allowed", s.proxy.GetCommonName(), proxyService, sdsCert.MeshService)
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug makes sense, except I worry that it would hide this message, when I believe it should be emitted with a higher level of urgency. If error seems to high - I'd say warn.

Copy link
Member Author

Choose a reason for hiding this comment

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

Warn seems appropriate for this use case, will address!

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #1995

@shashankram
Copy link
Member Author

Left a few comments that could be addressed in follow-up PRs - feel free to ignore.
Thanks for working on this!

Thanks for the review, will address the nits in a follow-up coming shortly.

@shashankram shashankram merged commit a7c1cee into openservicemesh:main Nov 5, 2020
@shashankram shashankram deleted the use-si branch November 5, 2020 19:22
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.

4 participants