Skip to content

Commit

Permalink
pkg/*: issue service cert directly via cert manager api (openservicem…
Browse files Browse the repository at this point in the history
…esh#1970)

This change allows SDS to directly use the IssueCertificate api
implemented by the certificate manager in use, instead of going
through MeshCatalog. This simplifies certificate issuance and code
duplication (such as catalog previously checking cert cache which
the IssueCertificate api implements within itself).

The tests are updated to reflect this change.

Part of openservicemesh#1965
  • Loading branch information
shashankram authored Nov 2, 2020
1 parent 9cc4f75 commit 4f68a78
Show file tree
Hide file tree
Showing 19 changed files with 247 additions and 122 deletions.
6 changes: 1 addition & 5 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ would require:

In the previous section, we proposed implementation of the `StreamAggregatedResources` method. This provides
connected Envoy proxies with a list of clusters, mapping of service name to list of routable IP addresses, list of permitted routes, listeners and secrets for CDS, EDS, RDS, LDS and SDS respectively.
The `ListEndpointsForService`, `ListTrafficPolicies` and `GetCertificateForService` methods will be provided by the OSM component, which we refer to
The `ListEndpointsForService`, `ListTrafficPolicies` methods will be provided by the OSM component, which we refer to
as the **Mesh Catalog** in this document.

The Mesh Catalog will have access to the `MeshSpec`, `CertificateManager`, and the list of `EndpointsProvider`s.
Expand All @@ -315,10 +315,6 @@ type MeshCataloger interface {
// ListEndpointsForService returns the list of provider endpoints corresponding to a service
ListEndpointsForService(service.MeshService) ([]endpoint.Endpoint, error)
// GetCertificateForService returns the SSL Certificate for the given service.
// This certificate will be used for service-to-service mTLS.
GetCertificateForService(service.MeshService) (certificate.Certificater, error)
// ExpectProxy catalogs the fact that a certificate was issued for an Envoy proxy and this is expected to connect to XDS.
ExpectProxy(certificate.CommonName)
Expand Down
2 changes: 1 addition & 1 deletion cmd/osm-controller/osm-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func main() {
}

// Create and start the ADS gRPC service
xdsServer := ads.NewADSServer(meshCatalog, cfg.IsDebugServerEnabled(), osmNamespace, cfg)
xdsServer := ads.NewADSServer(meshCatalog, cfg.IsDebugServerEnabled(), osmNamespace, cfg, certManager)
if err := xdsServer.Start(ctx, cancel, *port, adsCert); err != nil {
events.GenericEventRecorder().FatalEvent(err, events.InitializationError, "Error initializing ADS server")
}
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
23 changes: 0 additions & 23 deletions pkg/catalog/certificates.go

This file was deleted.

57 changes: 0 additions & 57 deletions pkg/catalog/certificates_test.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/catalog/mock_catalog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions pkg/catalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ type MeshCataloger interface {
// If no LB/virtual IPs are assigned to the service, GetResolvableServiceEndpoints will return ListEndpointsForService
GetResolvableServiceEndpoints(service.MeshService) ([]endpoint.Endpoint, error)

// GetCertificateForService returns the SSL Certificate for the given service.
// This certificate will be used for service-to-service mTLS.
GetCertificateForService(service.MeshService) (certificate.Certificater, error)

// ExpectProxy catalogs the fact that a certificate was issued for an Envoy proxy and this is expected to connect to XDS.
ExpectProxy(certificate.CommonName)

Expand Down
217 changes: 217 additions & 0 deletions pkg/certificate/mock_certificate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/envoy/ads/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *Server) newAggregatedDiscoveryResponse(proxy *envoy.Proxy, request *xds
}

log.Trace().Msgf("Invoking handler for %s with request: %+v", typeURL, request)
response, err := handler(s.catalog, proxy, request, cfg)
response, err := handler(s.catalog, proxy, request, cfg, s.certManager)
if err != nil {
log.Error().Msgf("Responder for TypeUrl %s is not implemented", request.TypeUrl)
return nil, errCreatingResponse
Expand Down
Loading

0 comments on commit 4f68a78

Please sign in to comment.