Skip to content

Commit 9e9f70f

Browse files
committed
Add README
1 parent 31616dd commit 9e9f70f

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

pkg/i2gw/providers/gce/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# GCE Provider
2+
3+
The project supports translating ingress-gce specific annotations.
4+
5+
Currently supported annotations:
6+
`kubernetes.io/ingress.class`: Though it is a deprecated annotation for most providers, GCE still uses this annotation to specify the specific type of load balancers created by GKE Ingress.
7+
8+
## Implementation-specific features
9+
10+
The following implementation-specific features are supported:
11+
12+
- Ingress path with type `ImplementationSpecific` will:
13+
- Translate to equivalent Gateway Prefix path but dropping `/*`, if `/*` exists
14+
- Translate to equivalent Exact path otherwise.
15+
16+
Examples:
17+
| Ingress `ImplementationSpecific` Path | map to Gateway Path |
18+
| ------------------------------------- | -------------------------------------- |
19+
| /* | / Prefix |
20+
| /v1/* | /v1 Prefix |
21+
| /v1 | /v1 Exact |
22+
| /v1/ | /v1/ Exact |
23+
24+
Note: For Ingress `ImplementationSpecific` path with `/v1/*`, it will map to
25+
`/v1/` or `/v1/v2` but not `/v1`. If you want to avoid such "overmapping",
26+
please consider switching to `Prefix`, `Exact`, or an `ImplementationSpecific`
27+
path without `*` before converting Ingress to Gateway.
28+
29+
## Feature list
30+
Currently supported:
31+
- [Basic Internal Ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-internal-basic)
32+
- [Basic external Ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-external-basic)
33+
- [Ingress with custom default backend](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-custom-default-backend)
34+
35+
To be supported:
36+
- [Ingress with custom HTTP health check](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-custom-http-health-check)
37+
- [IAP enabled ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-iap)
38+
- [Google Cloud Armor enabled ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/blob/main/ingress/single-cluster/ingress-cloudarmor/README.md)
39+
- [Ingress with HTTPS redirect](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-https)
40+
41+
## Summary of GKE Ingress annotation
42+
External Ingress:
43+
https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress#summary_of_external_ingress_annotations
44+
45+
Internal Ingress:
46+
https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balance-ingress#summary_of_internal_ingress_annotations
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package gce
18+
19+
import (
20+
"strings"
21+
22+
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
23+
"k8s.io/klog/v2"
24+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
25+
)
26+
27+
// implementationSpecificHTTPPathTypeMatch maps the Implementation Specific
28+
// HTTP path and type to the corresponding Gateway HTTP ones.
29+
func implementationSpecificHTTPPathTypeMatch(path *gatewayv1.HTTPPathMatch) {
30+
pmExact := gatewayv1.PathMatchExact
31+
pmPrefix := gatewayv1.PathMatchPathPrefix
32+
33+
if *path.Value == "/*" {
34+
path.Type = &pmPrefix
35+
path.Value = common.PtrTo("/")
36+
return
37+
}
38+
if !strings.HasSuffix(*path.Value, "/*") {
39+
path.Type = &pmExact
40+
return
41+
}
42+
43+
currentValue := *path.Value
44+
path.Type = &pmPrefix
45+
path.Value = common.PtrTo(strings.TrimSuffix(*path.Value, "/*"))
46+
klog.Warningf("After conversion, ImplementationSpecific Path %s will additionally map to %s. See README.md for details.", currentValue, *path.Value)
47+
}

0 commit comments

Comments
 (0)