Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
09062b40
Commit
09062b40
authored
Mar 15, 2018
by
Rohit Ramkumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ingress e2e test for multiple TLS (SNI) support
parent
4009cb3b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
2 deletions
+118
-2
ingress_utils.go
test/e2e/framework/ingress_utils.go
+17
-2
ingress.go
test/e2e/network/ingress.go
+36
-0
ing.yaml
test/e2e/testing-manifests/ingress/multiple-certs/ing.yaml
+34
-0
rc.yaml
test/e2e/testing-manifests/ingress/multiple-certs/rc.yaml
+16
-0
svc.yaml
test/e2e/testing-manifests/ingress/multiple-certs/svc.yaml
+15
-0
No files found.
test/e2e/framework/ingress_utils.go
View file @
09062b40
...
@@ -1213,18 +1213,33 @@ func (j *IngressTestJig) Update(update func(ing *extensions.Ingress)) {
...
@@ -1213,18 +1213,33 @@ func (j *IngressTestJig) Update(update func(ing *extensions.Ingress)) {
// AddHTTPS updates the ingress to use this secret for these hosts.
// AddHTTPS updates the ingress to use this secret for these hosts.
func
(
j
*
IngressTestJig
)
AddHTTPS
(
secretName
string
,
hosts
...
string
)
{
func
(
j
*
IngressTestJig
)
AddHTTPS
(
secretName
string
,
hosts
...
string
)
{
j
.
Ingress
.
Spec
.
TLS
=
[]
extensions
.
IngressTLS
{{
Hosts
:
hosts
,
SecretName
:
secretName
}}
// TODO: Just create the secret in GetRootCAs once we're watching secrets in
// TODO: Just create the secret in GetRootCAs once we're watching secrets in
// the ingress controller.
// the ingress controller.
_
,
cert
,
_
,
err
:=
createTLSSecret
(
j
.
Client
,
j
.
Ingress
.
Namespace
,
secretName
,
hosts
...
)
_
,
cert
,
_
,
err
:=
createTLSSecret
(
j
.
Client
,
j
.
Ingress
.
Namespace
,
secretName
,
hosts
...
)
ExpectNoError
(
err
)
ExpectNoError
(
err
)
j
.
Logger
.
Infof
(
"Updating ingress %v to use secret %v for TLS termination"
,
j
.
Ingress
.
Name
,
secretName
)
j
.
Logger
.
Infof
(
"Updating ingress %v to use secret %v for TLS termination"
,
j
.
Ingress
.
Name
,
secretName
)
j
.
Update
(
func
(
ing
*
extensions
.
Ingress
)
{
j
.
Update
(
func
(
ing
*
extensions
.
Ingress
)
{
ing
.
Spec
.
TLS
=
[]
extensions
.
IngressTLS
{{
Hosts
:
hosts
,
SecretName
:
secretName
}}
ing
.
Spec
.
TLS
=
append
(
ing
.
Spec
.
TLS
,
extensions
.
IngressTLS
{
Hosts
:
hosts
,
SecretName
:
secretName
})
})
})
j
.
RootCAs
[
secretName
]
=
cert
j
.
RootCAs
[
secretName
]
=
cert
}
}
// RemoveHTTPS updates the ingress to not use this secret for TLS.
// Note: Does not delete the secret.
func
(
j
*
IngressTestJig
)
RemoveHTTPS
(
secretName
string
)
{
newTLS
:=
[]
extensions
.
IngressTLS
{}
for
_
,
ingressTLS
:=
range
j
.
Ingress
.
Spec
.
TLS
{
if
secretName
!=
ingressTLS
.
SecretName
{
newTLS
=
append
(
newTLS
,
ingressTLS
)
}
}
j
.
Logger
.
Infof
(
"Updating ingress %v to not use secret %v for TLS termination"
,
j
.
Ingress
.
Name
,
secretName
)
j
.
Update
(
func
(
ing
*
extensions
.
Ingress
)
{
ing
.
Spec
.
TLS
=
newTLS
})
delete
(
j
.
RootCAs
,
secretName
)
}
// PrepareTLSSecret creates a TLS secret and caches the cert.
// PrepareTLSSecret creates a TLS secret and caches the cert.
func
(
j
*
IngressTestJig
)
PrepareTLSSecret
(
namespace
,
secretName
string
,
hosts
...
string
)
error
{
func
(
j
*
IngressTestJig
)
PrepareTLSSecret
(
namespace
,
secretName
string
,
hosts
...
string
)
error
{
_
,
cert
,
_
,
err
:=
createTLSSecret
(
j
.
Client
,
namespace
,
secretName
,
hosts
...
)
_
,
cert
,
_
,
err
:=
createTLSSecret
(
j
.
Client
,
namespace
,
secretName
,
hosts
...
)
...
...
test/e2e/network/ingress.go
View file @
09062b40
...
@@ -311,6 +311,42 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -311,6 +311,42 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
executeBacksideBacksideHTTPSTest
(
f
,
jig
,
""
)
executeBacksideBacksideHTTPSTest
(
f
,
jig
,
""
)
})
})
It
(
"should support multiple TLS certs [Unreleased]"
,
func
()
{
By
(
"Creating an ingress with no certs."
)
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"multiple-certs"
),
ns
,
map
[
string
]
string
{
framework
.
IngressStaticIPKey
:
ns
,
},
map
[
string
]
string
{})
By
(
"Adding multiple certs to the ingress."
)
hosts
:=
[]
string
{
"test1.ingress.com"
,
"test2.ingress.com"
,
"test3.ingress.com"
,
"test4.ingress.com"
}
secrets
:=
[]
string
{
"tls-secret-1"
,
"tls-secret-2"
,
"tls-secret-3"
,
"tls-secret-4"
}
certs
:=
[][]
byte
{}
for
i
,
host
:=
range
hosts
{
jig
.
AddHTTPS
(
secrets
[
i
],
host
)
certs
=
append
(
certs
,
jig
.
GetRootCA
(
secrets
[
i
]))
}
for
i
,
host
:=
range
hosts
{
err
:=
jig
.
WaitForIngressWithCert
(
true
,
[]
string
{
host
},
certs
[
i
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"Unexpected error while waiting for ingress: %v"
,
err
))
}
By
(
"Remove all but one of the certs on the ingress."
)
jig
.
RemoveHTTPS
(
secrets
[
1
])
jig
.
RemoveHTTPS
(
secrets
[
2
])
jig
.
RemoveHTTPS
(
secrets
[
3
])
By
(
"Test that the remaining cert is properly served."
)
err
:=
jig
.
WaitForIngressWithCert
(
true
,
[]
string
{
hosts
[
0
]},
certs
[
0
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"Unexpected error while waiting for ingress: %v"
,
err
))
By
(
"Add back one of the certs that was removed and check that all certs are served."
)
jig
.
AddHTTPS
(
secrets
[
1
],
hosts
[
1
])
for
i
,
host
:=
range
hosts
[
:
2
]
{
err
:=
jig
.
WaitForIngressWithCert
(
true
,
[]
string
{
host
},
certs
[
i
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"Unexpected error while waiting for ingress: %v"
,
err
))
}
})
It
(
"multicluster ingress should get instance group annotation"
,
func
()
{
It
(
"multicluster ingress should get instance group annotation"
,
func
()
{
name
:=
"echomap"
name
:=
"echomap"
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"http"
),
ns
,
map
[
string
]
string
{
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"http"
),
ns
,
map
[
string
]
string
{
...
...
test/e2e/testing-manifests/ingress/multiple-certs/ing.yaml
0 → 100644
View file @
09062b40
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
name
:
multiple-certs
spec
:
rules
:
-
host
:
test1.ingress.com
http
:
paths
:
-
path
:
/test
backend
:
serviceName
:
echoheaders-https
servicePort
:
80
-
host
:
test2.ingress.com
http
:
paths
:
-
path
:
/test
backend
:
serviceName
:
echoheaders-https
servicePort
:
80
-
host
:
test3.ingress.com
http
:
paths
:
-
path
:
/test
backend
:
serviceName
:
echoheaders-https
servicePort
:
80
-
host
:
test4.ingress.com
http
:
paths
:
-
path
:
/test
backend
:
serviceName
:
echoheaders-https
servicePort
:
80
test/e2e/testing-manifests/ingress/multiple-certs/rc.yaml
0 → 100644
View file @
09062b40
apiVersion
:
v1
kind
:
ReplicationController
metadata
:
name
:
echoheaders-https
spec
:
replicas
:
2
template
:
metadata
:
labels
:
app
:
echoheaders-https
spec
:
containers
:
-
name
:
echoheaders-https
image
:
gcr.io/google_containers/echoserver:1.10
ports
:
-
containerPort
:
8080
test/e2e/testing-manifests/ingress/multiple-certs/svc.yaml
0 → 100644
View file @
09062b40
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
echoheaders-https
labels
:
app
:
echoheaders-https
spec
:
type
:
NodePort
ports
:
-
port
:
80
targetPort
:
8080
protocol
:
TCP
name
:
http
selector
:
app
:
echoheaders-https
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment