generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Google GCE provider (#148)
* Initial commit for gce provider. * Add README * Add resource reader for gce * Add converter in gce
- Loading branch information
Showing
19 changed files
with
1,164 additions
and
20 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# GCE Provider | ||
|
||
The project supports translating ingress-gce specific annotations. | ||
|
||
Currently supported annotations: | ||
`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. | ||
|
||
## Implementation-specific features | ||
|
||
The following implementation-specific features are supported: | ||
|
||
- Ingress path with type `ImplementationSpecific` will: | ||
- Translate to equivalent Gateway Prefix path but dropping `/*`, if `/*` exists | ||
- Translate to equivalent Exact path otherwise. | ||
|
||
Examples: | ||
| Ingress `ImplementationSpecific` Path | map to Gateway Path | | ||
| ------------------------------------- | -------------------------------------- | | ||
| /* | / Prefix | | ||
| /v1 | /v1 Exact | | ||
| /v1/ | /v1/ Exact | | ||
| /v1/* | /v1 Prefix | | ||
|
||
Note: For Ingress `ImplementationSpecific` path with `/v1/*`, it will map to | ||
`/v1/` or `/v1/v2` but not `/v1`. If you want to avoid such behavior, | ||
please consider switching to `Prefix`, `Exact`, or an `ImplementationSpecific` | ||
path without `*` before converting Ingress to Gateway. | ||
|
||
## Feature list | ||
Currently supported: | ||
- [Basic Internal Ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-internal-basic) | ||
- [Basic external Ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-external-basic) | ||
- [Ingress with custom default backend](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-custom-default-backend) | ||
|
||
To be supported: | ||
- [Ingress with custom HTTP health check](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-custom-http-health-check) | ||
- [IAP enabled ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-iap) | ||
- [Google Cloud Armor enabled ingress](https://github.com/GoogleCloudPlatform/gke-networking-recipes/blob/main/ingress/single-cluster/ingress-cloudarmor/README.md) | ||
- [Ingress with HTTPS redirect](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-https) | ||
|
||
## Summary of GKE Ingress annotation | ||
External Ingress: | ||
https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress#summary_of_external_ingress_annotations | ||
|
||
Internal Ingress: | ||
https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balance-ingress#summary_of_internal_ingress_annotations |
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,71 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package gce | ||
|
||
import ( | ||
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw" | ||
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common" | ||
networkingv1 "k8s.io/api/networking/v1" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
// converter implements the ToGatewayAPI function of i2gw.ResourceConverter interface. | ||
type converter struct { | ||
conf *i2gw.ProviderConf | ||
|
||
featureParsers []i2gw.FeatureParser | ||
implementationSpecificOptions i2gw.ProviderImplementationSpecificOptions | ||
} | ||
|
||
// newConverter returns an ingress-gce converter instance. | ||
func newConverter(conf *i2gw.ProviderConf) converter { | ||
return converter{ | ||
conf: conf, | ||
featureParsers: []i2gw.FeatureParser{}, | ||
implementationSpecificOptions: i2gw.ProviderImplementationSpecificOptions{ | ||
ToImplementationSpecificHTTPPathTypeMatch: implementationSpecificHTTPPathTypeMatch, | ||
}, | ||
} | ||
} | ||
|
||
func (c *converter) convert(storage *storage) (i2gw.GatewayResources, field.ErrorList) { | ||
ingressList := []networkingv1.Ingress{} | ||
for _, ing := range storage.Ingresses { | ||
ingressList = append(ingressList, *ing) | ||
} | ||
|
||
// Convert plain ingress resources to gateway resources, ignoring all | ||
// provider-specific features. | ||
gatewayResources, errs := common.ToGateway(ingressList, c.implementationSpecificOptions) | ||
if len(errs) > 0 { | ||
return i2gw.GatewayResources{}, errs | ||
} | ||
|
||
errs = setGCEGatewayClasses(ingressList, &gatewayResources) | ||
if len(errs) > 0 { | ||
return i2gw.GatewayResources{}, errs | ||
} | ||
|
||
for _, parseFeatureFunc := range c.featureParsers { | ||
// Apply the feature parsing function to the gateway resources, one by one. | ||
parseErrs := parseFeatureFunc(ingressList, &gatewayResources) | ||
// Append the parsing errors to the error list. | ||
errs = append(errs, parseErrs...) | ||
} | ||
|
||
return gatewayResources, errs | ||
} |
Oops, something went wrong.