-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow traffic going outside the cluster #1123
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| # Copyright 2018 Google LLC | ||
| # | ||
| # 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 | ||
| # | ||
| # https://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. | ||
|
|
||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: config-network | ||
| namespace: knative-serving-system | ||
| data: | ||
| # Specifies the IP ranges that Istio sidecar will intercept. | ||
| # Replace this with the IP ranges of your cluster (see below for some examples). | ||
| # Separate multiple entries with a comma. | ||
| # Example: "10.4.0.0/14,10.7.240.0/20" | ||
| # | ||
| # If set to "*" Istio will intercept all traffic within | ||
| # the cluster as well as traffic that is going outside the cluster. | ||
| # Traffic going outside the cluster will be blocked unless | ||
| # necessary egress rules are created. | ||
| # | ||
| # If omitted or set to "", value of global.proxy.includeIPRanges | ||
| # provided at Istio deployment time is used. In default Knative serving | ||
| # deployment, global.proxy.includeIPRanges value is set to "*". | ||
| # | ||
| # If an invalid value is used, "" is used. | ||
| # | ||
| # If valid set of IP address ranges are put into this value, | ||
| # Istio will no longer intercept traffic going to IP addresses | ||
| # outside the provided ranges and there is no need to specify | ||
| # egress rules. | ||
| # | ||
| # To determine the IP ranges of your cluster: | ||
| # IBM Cloud Private: cat cluster/config.yaml | grep service_cluster_ip_range | ||
| # IBM Cloud Kubernetes Service: "172.30.0.0/16,172.20.0.0/16,10.10.10.0/24" | ||
| # Google Container Engine (GKE): gcloud container clusters describe XXXXXXX --zone=XXXXXX | grep -e clusterIpv4Cidr -e servicesIpv4Cidr | ||
| # Azure Container Service(ACS): "10.244.0.0/16,10.240.0.0/16" | ||
| # Minikube: "10.0.0.1/24" | ||
| # | ||
| # For more information, visit | ||
| # https://istio.io/docs/tasks/traffic-management/egress/ | ||
| # | ||
| istio.sidecar.includeOutboundIPRanges: "*" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
| /* | ||
| Copyright 2018 Google LLC | ||
|
|
||
| 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 | ||
|
|
||
| https://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 revision | ||
|
|
||
| import ( | ||
| "github.com/knative/serving/pkg" | ||
|
|
||
| "github.com/knative/serving/pkg/controller" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/client-go/kubernetes" | ||
| ) | ||
|
|
||
| const ( | ||
| // IstioOutboundIPRangesKey is the name of the configuration entry | ||
| // that specifies Istio outbound ip ranges. | ||
| IstioOutboundIPRangesKey = "istio.sidecar.includeOutboundIPRanges" | ||
| ) | ||
|
|
||
| // NetworkConfig contains the networking configuration defined in the | ||
| // network config map. | ||
| type NetworkConfig struct { | ||
| // IstioOutboundIPRange specifies the IP ranges to intercept | ||
| // by Istio sidecar. | ||
| IstioOutboundIPRanges string | ||
| } | ||
|
|
||
| // NewNetworkConfig creates a DomainConfig by reading the domain configmap from | ||
| // the supplied client. | ||
| func NewNetworkConfig(kubeClient kubernetes.Interface) (*NetworkConfig, error) { | ||
| m, err := kubeClient.CoreV1().ConfigMaps(pkg.GetServingSystemNamespace()).Get(controller.GetNetworkConfigMapName(), metav1.GetOptions{}) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return NewNetworkConfigFromConfigMap(m), nil | ||
| } | ||
|
|
||
| // NewNetworkConfigFromConfigMap creates a NewNetworkConfig from the supplied ConfigMap | ||
| func NewNetworkConfigFromConfigMap(configMap *corev1.ConfigMap) *NetworkConfig { | ||
| return &NetworkConfig{IstioOutboundIPRanges: configMap.Data[IstioOutboundIPRangesKey]} | ||
| } |
This file contains hidden or 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,72 @@ | ||
| /* | ||
| Copyright 2018 Google LLC. | ||
|
|
||
| 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 revision | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/knative/serving/pkg" | ||
| "github.com/knative/serving/pkg/controller" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| fakekubeclientset "k8s.io/client-go/kubernetes/fake" | ||
| ) | ||
|
|
||
| func TestNewConfigMissingConfigMap(t *testing.T) { | ||
| _, err := NewNetworkConfig(fakekubeclientset.NewSimpleClientset()) | ||
| if err == nil { | ||
| t.Error("Expected an error value when config map doesn't exist.") | ||
| } | ||
| } | ||
|
|
||
| func TestNewConfigNoEntry(t *testing.T) { | ||
| kubeClient := fakekubeclientset.NewSimpleClientset() | ||
| kubeClient.CoreV1().ConfigMaps(pkg.GetServingSystemNamespace()).Create(&corev1.ConfigMap{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: pkg.GetServingSystemNamespace(), | ||
| Name: controller.GetNetworkConfigMapName(), | ||
| }, | ||
| }) | ||
| c, err := NewNetworkConfig(kubeClient) | ||
| if err != nil { | ||
| t.Errorf("Didn't expect an error but got %v", err) | ||
| } else if len(c.IstioOutboundIPRanges) > 0 { | ||
| t.Error("Expected an empty value when config map doesn't have the entry.") | ||
| } | ||
| } | ||
|
|
||
| func TestNewConfig(t *testing.T) { | ||
| kubeClient := fakekubeclientset.NewSimpleClientset() | ||
| want := "10.10.10.10/12" | ||
| kubeClient.CoreV1().ConfigMaps(pkg.GetServingSystemNamespace()).Create(&corev1.ConfigMap{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: pkg.GetServingSystemNamespace(), | ||
| Name: controller.GetNetworkConfigMapName(), | ||
| }, | ||
| Data: map[string]string{ | ||
| IstioOutboundIPRangesKey: want, | ||
| "bar.com": "selector:\n app: bar\n version: beta", | ||
| }, | ||
| }) | ||
| c, err := NewNetworkConfig(kubeClient) | ||
| if err != nil { | ||
| t.Errorf("Didn't expect an error but got %v", err) | ||
| } | ||
| if c.IstioOutboundIPRanges != want { | ||
| t.Errorf("Want %v, got %v", want, c.IstioOutboundIPRanges) | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious where the 5 minutes comes from. Others are in 30 resync so just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With other informers, we end up reconciling everything every 30 seconds. I didn't think that we needed that aggressive reconcilliation for domain configuration or the network configuration - those should change only once in the lifetime of the cluster if ever. Also, the reconcilliation is needed only if we somehow missed the original notification that gets sent when the configuration changes (I don't know how we would miss the notification - may be when there are successive deletes and creates the ordering might cause an issue?).
Let me know if you want me to change this to 30 seconds.