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

chore(*) ExternalServices add CA and Client certificate support #1094

Merged
merged 26 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34b6fe1
chore(*) add CA and Client certificate support code
Oct 19, 2020
c2f8bf9
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 20, 2020
8ace4b5
feat(*) push ExternalService TLS config to Envoy
Oct 20, 2020
1ac997d
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 21, 2020
44d4a63
fix(*) tests
Oct 21, 2020
b14eaa5
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 22, 2020
e685596
fix(*) review
Oct 22, 2020
d07dee2
chore(*) move tls.go and fix for review
Oct 23, 2020
5173c84
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 23, 2020
f5b3d7c
chore(*) update UpstreamTlsContextOutsideMesh
Oct 23, 2020
25bf408
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 23, 2020
8c8d3a0
test(*) e2e for TLS certs
Oct 26, 2020
136eae2
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Oct 30, 2020
1bfe9db
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 2, 2020
a6665b6
fix(*) improve e2e
Nov 2, 2020
53a65d4
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 4, 2020
0ff0123
fix(*) load certificates at BuildEndpointMap
Nov 4, 2020
7c71513
fix(*) have a proper ca_cert thest for ExternalServices
Nov 4, 2020
ccb1766
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 6, 2020
71195ec
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 9, 2020
8d9392e
fix(*) fix review
Nov 9, 2020
45f0086
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 11, 2020
3c2e281
fix(*) review
Nov 11, 2020
2b4ce22
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 11, 2020
355966a
Merge remote-tracking branch 'origin/master' into chore/tls_origination
Nov 12, 2020
eba5a17
fix(*) e2e after upgrading to Ubuntu
Nov 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
Expand Down Expand Up @@ -1204,7 +1202,6 @@ google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func buildRuntime(cfg kuma_cp.Config) (core_runtime.Runtime, error) {
return nil, err
}

builder.WithDataSourceLoader(datasource.NewDataSourceLoader(builder.ResourceManager()))
builder.WithDataSourceLoader(datasource.NewDataSourceLoader(builder.ReadOnlyResourceManager()))

if err := initializeCaManagers(builder); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/datasource/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ type Loader interface {
}

type loader struct {
secretManager manager.ResourceManager
secretManager manager.ReadOnlyResourceManager
}

var _ Loader = &loader{}

func NewDataSourceLoader(secretManager manager.ResourceManager) Loader {
func NewDataSourceLoader(secretManager manager.ReadOnlyResourceManager) Loader {
return &loader{
secretManager: secretManager,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/xds/envoy/clusters/client_side_tls_configurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (c *clientSideTLSConfigurer) Configure(cluster *envoy_api.Cluster) error {
for _, ep := range c.endpoints {
if ep.ExternalService.TLSEnabled {
ca, cert, key := externalServiceTlsCerts(ep.ExternalService)
tlsContext, err := envoy.CreateUpstreamTlsContextNoMetadata(ca, cert, key, ep.Target)
tlsContext, err := envoy.UpstreamTlsContextOutsideMesh(ca, cert, key, ep.Target)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/xds/envoy/clusters/client_side_tls_configurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ var _ = Describe("ClientSideTLSConfigurer", func() {
name: envoy.transport_sockets.tls
typedConfig:
'@type': type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext
sni: httpbin.org
commonTlsContext:
validationContext:
matchSubjectAltNames:
- exact: httpbin.org
type: EDS
`}),
)
Expand Down
13 changes: 10 additions & 3 deletions pkg/xds/envoy/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,19 @@ func ServiceSpiffeIDMatcher(mesh string, service string) *envoy_type_matcher.Str
}
}

func CreateUpstreamTlsContextNoMetadata(ca, cert, key *envoy_core.DataSource, sni string) (*envoy_auth.UpstreamTlsContext, error) {
func UpstreamTlsContextOutsideMesh(ca, cert, key *envoy_core.DataSource, hostname string) (*envoy_auth.UpstreamTlsContext, error) {
var validationContextType *envoy_auth.CommonTlsContext_ValidationContext
if ca != nil {
if ca != nil || len(hostname) > 0 {
validationContextType = &envoy_auth.CommonTlsContext_ValidationContext{
ValidationContext: &envoy_auth.CertificateValidationContext{
TrustedCa: ca,
MatchSubjectAltNames: []*envoy_type_matcher.StringMatcher{
{
MatchPattern: &envoy_type_matcher.StringMatcher_Exact{
Exact: hostname,
},
},
},
},
}
}
Expand All @@ -210,8 +217,8 @@ func CreateUpstreamTlsContextNoMetadata(ca, cert, key *envoy_core.DataSource, sn
ValidationContextType: validationContextType,
}
}

return &envoy_auth.UpstreamTlsContext{
CommonTlsContext: commonTlsContext,
Sni: sni,
}, nil
}
5 changes: 3 additions & 2 deletions pkg/xds/topology/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package topology
import (
"context"

"github.com/kumahq/kuma/pkg/core"

"github.com/pkg/errors"
"github.com/prometheus/common/log"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/core/datasource"
Expand Down Expand Up @@ -58,7 +59,7 @@ func BuildEndpointMap(

externalServiceEndpoint, err := buildExternalServiceEndpoint(externalService, mesh.Meta.GetMesh(), loader)
if err != nil {
log.Info("Unable to create ExternalService endpoint", err)
core.Log.Error(err, "unable to create ExternalService endpoint. Endpoint won't be included in the XDS.", "name", externalService.Meta.GetName(), "mesh", externalService.Meta.GetMesh())
continue
}
outbound[service] = append(outbound[service], *externalServiceEndpoint)
Expand Down