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

Add support for TLS Passthrough #2041

Merged
merged 17 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
github.com/vdemeester/k8s-pkg-credentialprovider v1.21.0-1/go.mod h1:l4LxiP0cmEcc5q4BTDE8tZSyIiyXe0T28x37yHpMzoM=
Expand Down Expand Up @@ -1700,6 +1702,8 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
75 changes: 75 additions & 0 deletions internal/parser/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,60 @@ func TestFromTCPIngressV1beta1(t *testing.T) {
},
},
},
// 4
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
{
Port: 9000,
Backend: configurationv1beta1.IngressBackend{
ServiceName: "",
ServicePort: 80,
},
},
},
},
},
// 5
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
{
Port: 0,
Backend: configurationv1beta1.IngressBackend{
ServiceName: "foo-svc",
ServicePort: 80,
},
},
},
},
},
// 6
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: configurationv1beta1.TCPIngressSpec{
Rules: []configurationv1beta1.IngressRule{
{
Port: 9000,
Backend: configurationv1beta1.IngressBackend{
ServiceName: "foo-svc",
ServicePort: 0,
},
},
},
},
},
}
t.Run("no TCPIngress returns empty info", func(t *testing.T) {
parsedInfo := fromTCPIngressV1beta1(logrus.New(), []*configurationv1beta1.TCPIngress{})
Expand Down Expand Up @@ -844,6 +898,27 @@ func TestFromTCPIngressV1beta1(t *testing.T) {
assert.Equal(2, len(parsedInfo.SecretNameToSNIs["default/sooper-secret"]))
assert.Equal(2, len(parsedInfo.SecretNameToSNIs["default/sooper-secret2"]))
})
t.Run("TCPIngress without service name returns empty info", func(t *testing.T) {
parsedInfo := fromTCPIngressV1beta1(logrus.New(), []*configurationv1beta1.TCPIngress{tcpIngressList[4]})
assert.Equal(ingressRules{
ServiceNameToServices: make(map[string]kongstate.Service),
SecretNameToSNIs: make(map[string][]string),
}, parsedInfo)
})
t.Run("TCPIngress with invalid port returns empty info", func(t *testing.T) {
parsedInfo := fromTCPIngressV1beta1(logrus.New(), []*configurationv1beta1.TCPIngress{tcpIngressList[5]})
assert.Equal(ingressRules{
ServiceNameToServices: make(map[string]kongstate.Service),
SecretNameToSNIs: make(map[string][]string),
}, parsedInfo)
})
t.Run("empty TCPIngress with invalid service port returns empty info", func(t *testing.T) {
parsedInfo := fromTCPIngressV1beta1(logrus.New(), []*configurationv1beta1.TCPIngress{tcpIngressList[6]})
assert.Equal(ingressRules{
ServiceNameToServices: make(map[string]kongstate.Service),
SecretNameToSNIs: make(map[string][]string),
}, parsedInfo)
})
}

func TestFromKnativeIngress(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/util/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ func ValidateProtocol(protocol string) bool {
return match
}

var validProtocols = regexp.MustCompile(`\Ahttps$|\Ahttp$|\Agrpc$|\Agrpcs|\Atcp|\Atls$`)
var validProtocols = regexp.MustCompile(`\Ahttps$|\Ahttp$|\Agrpc$|\Agrpcs|\Atcp|\Atls|\Atls_passthrough$`)
3 changes: 3 additions & 0 deletions internal/util/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func TestValidateProtocol(t *testing.T) {
{"https", true},
{"grpc", true},
{"grpcs", true},
{"tls", true},
{"tcp", true},
{"tls_passthrough", true},
{"grcpsfdsafdsfafdshttp", false},
}
for _, testcase := range testTable {
Expand Down
Loading