forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Upstream TLS Support (envoyproxy#2247)
* add upstream tls support Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * update backendtlspolicy status Signed-off-by: TasdidurRahman <tasdid@appscode.com> * cleanup Signed-off-by: TasdidurRahman <tasdid@appscode.com> * ignore ca check in secrets Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * fix status condition Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * update error handling Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * add test for backendtlspolicy Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * rebase Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * update test for backendtlspolicy Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * reuse tls structures Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * remove mtls Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * move CA config to destination settings Signed-off-by: TasdidurRahman <tasdid@appscode.com> * update alias Signed-off-by: TasdidurRahman <tasdid@appscode.com> * add upstream tls support Signed-off-by: TasdidurRahman <tasdid@appscode.com> * fix linter Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * fix rbac for backendtlspolicy Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> * fix testdata Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> --------- Signed-off-by: Tasdidur Rahman <tasdidurrahmannahyan@gmail.com> Signed-off-by: TasdidurRahman <tasdid@appscode.com>
- Loading branch information
1 parent
e8a2b5e
commit ce1eb54
Showing
30 changed files
with
1,511 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package gatewayapi | ||
|
||
import ( | ||
"sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
) | ||
|
||
func (t *Translator) ProcessBackendTLSPoliciesAncestorRef(backendTLSPolicies []*v1alpha2.BackendTLSPolicy, gateways []*GatewayContext) []*v1alpha2.BackendTLSPolicy { | ||
|
||
var res []*v1alpha2.BackendTLSPolicy | ||
|
||
for _, btlsPolicy := range backendTLSPolicies { | ||
|
||
policy := btlsPolicy.DeepCopy() | ||
res = append(res, policy) | ||
|
||
if policy.Status.Ancestors != nil { | ||
for k, status := range policy.Status.Ancestors { | ||
exist := false | ||
for _, gwContext := range gateways { | ||
gw := gwContext.Gateway | ||
if gw.Name == string(status.AncestorRef.Name) && gw.Namespace == NamespaceDerefOrAlpha(status.AncestorRef.Namespace, "default") { | ||
for _, lis := range gw.Spec.Listeners { | ||
if lis.Name == *status.AncestorRef.SectionName { | ||
exist = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
if !exist { | ||
policy.Status.Ancestors = append(policy.Status.Ancestors[:k], policy.Status.Ancestors[k+1:]...) | ||
} | ||
} | ||
} else { | ||
policy.Status.Ancestors = []v1alpha2.PolicyAncestorStatus{} | ||
} | ||
} | ||
|
||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
internal/gatewayapi/testdata/backendtlspolicy-ca-only.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: gateway-btls | ||
namespace: envoy-gateway | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: httproute-btls | ||
namespace: envoy-gateway | ||
spec: | ||
parentRefs: | ||
- namespace: envoy-gateway | ||
name: gateway-btls | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- path: | ||
type: Exact | ||
value: "/exact" | ||
backendRefs: | ||
- name: http-backend | ||
namespace: backends | ||
port: 8080 | ||
|
||
referenceGrants: | ||
- apiVersion: gateway.networking.k8s.io/v1alpha2 | ||
kind: ReferenceGrant | ||
metadata: | ||
name: refg-route-svc | ||
namespace: backends | ||
spec: | ||
from: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
namespace: envoy-gateway | ||
- group: gateway.networking.k8s.io | ||
kind: Gateway | ||
namespace: envoy-gateway | ||
- group: gateway.networking.k8s.io | ||
kind: BackendTLSPolicy | ||
namespace: policies | ||
to: | ||
- group: "" | ||
kind: Service | ||
|
||
services: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: http-backend | ||
namespace: backends | ||
spec: | ||
clusterIP: 10.11.12.13 | ||
ports: | ||
- port: 8080 | ||
name: http | ||
protocol: TCP | ||
targetPort: 8080 | ||
|
||
|
||
endpointSlices: | ||
- apiVersion: discovery.k8s.io/v1 | ||
kind: EndpointSlice | ||
metadata: | ||
name: endpointslice-http-backend | ||
namespace: backends | ||
labels: | ||
kubernetes.io/service-name: http-backend | ||
addressType: IPv4 | ||
ports: | ||
- name: http | ||
protocol: TCP | ||
port: 8080 | ||
endpoints: | ||
- addresses: | ||
- "10.244.0.11" | ||
conditions: | ||
ready: true | ||
|
||
configMaps: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ca-cmap | ||
namespace: policies | ||
data: | ||
ca.crt: | | ||
-----BEGIN CERTIFICATE----- | ||
MIIDJzCCAg+gAwIBAgIUAl6UKIuKmzte81cllz5PfdN2IlIwDQYJKoZIhvcNAQEL | ||
BQAwIzEQMA4GA1UEAwwHbXljaWVudDEPMA0GA1UECgwGa3ViZWRiMB4XDTIzMTAw | ||
MjA1NDE1N1oXDTI0MTAwMTA1NDE1N1owIzEQMA4GA1UEAwwHbXljaWVudDEPMA0G | ||
A1UECgwGa3ViZWRiMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwSTc | ||
1yj8HW62nynkFbXo4VXKv2jC0PM7dPVky87FweZcTKLoWQVPQE2p2kLDK6OEszmM | ||
yyr+xxWtyiveremrWqnKkNTYhLfYPhgQkczib7eUalmFjUbhWdLvHakbEgCodn3b | ||
kz57mInX2VpiDOKg4kyHfiuXWpiBqrCx0KNLpxo3DEQcFcsQTeTHzh4752GV04RU | ||
Ti/GEWyzIsl4Rg7tGtAwmcIPgUNUfY2Q390FGqdH4ahn+mw/6aFbW31W63d9YJVq | ||
ioyOVcaMIpM5B/c7Qc8SuhCI1YGhUyg4cRHLEw5VtikioyE3X04kna3jQAj54YbR | ||
bpEhc35apKLB21HOUQIDAQABo1MwUTAdBgNVHQ4EFgQUyvl0VI5vJVSuYFXu7B48 | ||
6PbMEAowHwYDVR0jBBgwFoAUyvl0VI5vJVSuYFXu7B486PbMEAowDwYDVR0TAQH/ | ||
BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAMLxrgFVMuNRq2wAwcBt7SnNR5Cfz | ||
2MvXq5EUmuawIUi9kaYjwdViDREGSjk7JW17vl576HjDkdfRwi4E28SydRInZf6J | ||
i8HZcZ7caH6DxR335fgHVzLi5NiTce/OjNBQzQ2MJXVDd8DBmG5fyatJiOJQ4bWE | ||
A7FlP0RdP3CO3GWE0M5iXOB2m1qWkE2eyO4UHvwTqNQLdrdAXgDQlbam9e4BG3Gg | ||
d/6thAkWDbt/QNT+EJHDCvhDRKh1RuGHyg+Y+/nebTWWrFWsktRrbOoHCZiCpXI1 | ||
3eXE6nt0YkgtDxG22KqnhpAg9gUSs2hlhoxyvkzyF0mu6NhPlwAgnq7+/Q== | ||
-----END CERTIFICATE----- | ||
backendTLSPolicies: | ||
- apiVersion: gateway.networking.k8s.io/v1alpha2 | ||
kind: BackendTLSPolicy | ||
metadata: | ||
name: policy-btls | ||
namespace: policies | ||
spec: | ||
targetRef: | ||
group: '' | ||
kind: Service | ||
name: http-backend | ||
namespace: backends | ||
sectionName: "8080" | ||
tls: | ||
caCertRefs: | ||
- name: ca-cmap | ||
group: '' | ||
kind: ConfigMap | ||
hostname: example.com |
Oops, something went wrong.