From 0262b79cd21396f8f4df8604d79dd538ce2dabcc Mon Sep 17 00:00:00 2001 From: Johannes Scheerer Date: Tue, 16 Aug 2022 15:46:07 +0200 Subject: [PATCH] Create shoot cluster per default without overlay network for kubernetes >= 1.22. Unless explicitly specified, the overlay network is disabled with a mutating webhook for new clusters. This only works for clusters >= 1.22 due to the source/destinations checks being disabled only for those clusters (see https://github.com/gardener/machine-controller-manager-provider-aws/issues/36 for details). --- go.mod | 1 + go.sum | 2 + pkg/cmd/options.go | 3 + pkg/webhook/network/add.go | 41 +++ pkg/webhook/network/mutate.go | 121 ++++++++ .../LICENSE.md | 283 ++++++++++++++++++ .../NOTICE.md | 15 + .../pkg/apis/calico/doc.go | 20 ++ .../pkg/apis/calico/install/install.go | 43 +++ .../pkg/apis/calico/register.go | 52 ++++ .../pkg/apis/calico/types_network.go | 118 ++++++++ .../pkg/apis/calico/v1alpha1/defaults.go | 23 ++ .../pkg/apis/calico/v1alpha1/doc.go | 24 ++ .../pkg/apis/calico/v1alpha1/helper/decode.go | 54 ++++ .../pkg/apis/calico/v1alpha1/register.go | 55 ++++ .../pkg/apis/calico/v1alpha1/types_network.go | 131 ++++++++ .../v1alpha1/zz_generated.conversion.go | 238 +++++++++++++++ .../calico/v1alpha1/zz_generated.deepcopy.go | 200 +++++++++++++ .../calico/v1alpha1/zz_generated.defaults.go | 33 ++ .../pkg/apis/calico/zz_generated.deepcopy.go | 200 +++++++++++++ .../pkg/calico/predicates.go | 17 ++ .../pkg/calico/types.go | 49 +++ .../extensions/pkg/webhook/network/mutator.go | 76 +++++ .../extensions/pkg/webhook/network/network.go | 91 ++++++ vendor/modules.txt | 8 + 25 files changed, 1898 insertions(+) create mode 100644 pkg/webhook/network/add.go create mode 100644 pkg/webhook/network/mutate.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/LICENSE.md create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/NOTICE.md create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/doc.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install/install.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/register.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/types_network.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/defaults.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/doc.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper/decode.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/register.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/types_network.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.conversion.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.defaults.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/zz_generated.deepcopy.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/predicates.go create mode 100644 vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/types.go create mode 100644 vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/mutator.go create mode 100644 vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/network.go diff --git a/go.mod b/go.mod index 78f88917e..4a70d6ef8 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/coreos/go-systemd/v22 v22.3.2 github.com/gardener/etcd-druid v0.9.0 github.com/gardener/gardener v1.53.0 + github.com/gardener/gardener-extension-networking-calico v1.25.0 github.com/gardener/machine-controller-manager v0.45.0 github.com/go-logr/logr v1.2.3 github.com/golang/mock v1.6.0 diff --git a/go.sum b/go.sum index d8f4f361c..5ba0d4eb5 100644 --- a/go.sum +++ b/go.sum @@ -212,6 +212,8 @@ github.com/gardener/external-dns-management v0.7.18 h1:15uIyFfZSbR8fivnXvqb1Dvv4 github.com/gardener/external-dns-management v0.7.18/go.mod h1:oHhauLQ3/sop0c1urS6n304Wqv/WM4me0geLn9nTAcY= github.com/gardener/gardener v1.53.0 h1:SffBCuyxcPlveZkxFuek+sVwMeF2F5wEjD8F6+EiNvE= github.com/gardener/gardener v1.53.0/go.mod h1:O+59kTQavqxX5nr5jyHqD6o4JxIukHMaW2t5BLiXqmc= +github.com/gardener/gardener-extension-networking-calico v1.25.0 h1:mkdroxXFkMDNgX0wMrqGWKBGuB4YaXnNFIJFSgeyyCk= +github.com/gardener/gardener-extension-networking-calico v1.25.0/go.mod h1:A6pG11WJwT0WD7fY6nNupfm/w9YNla7P9YTcC/Baz5I= github.com/gardener/hvpa-controller/api v0.5.0 h1:f4F3O7YUrenwh4S3TgPREPiB287JjjUiUL18OqPLyAA= github.com/gardener/hvpa-controller/api v0.5.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfvnm0WCGwGJlGmrxJj6lvM= github.com/gardener/machine-controller-manager v0.45.0 h1:rpf0PHRXJMGY93oMruNP+tnMawKJXhhzCACyNJsT8Lo= diff --git a/pkg/cmd/options.go b/pkg/cmd/options.go index a395c2e59..0d8241e75 100644 --- a/pkg/cmd/options.go +++ b/pkg/cmd/options.go @@ -28,6 +28,7 @@ import ( workercontroller "github.com/gardener/gardener-extension-provider-aws/pkg/controller/worker" controlplanewebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/controlplane" controlplaneexposurewebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/controlplaneexposure" + networkwebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/network" shootwebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/shoot" extensionsbackupbucketcontroller "github.com/gardener/gardener/extensions/pkg/controller/backupbucket" @@ -42,6 +43,7 @@ import ( extensionsworkercontroller "github.com/gardener/gardener/extensions/pkg/controller/worker" webhookcmd "github.com/gardener/gardener/extensions/pkg/webhook/cmd" extensioncontrolplanewebhook "github.com/gardener/gardener/extensions/pkg/webhook/controlplane" + extensionsnetworkwebhook "github.com/gardener/gardener/extensions/pkg/webhook/network" extensionshootwebhook "github.com/gardener/gardener/extensions/pkg/webhook/shoot" "github.com/spf13/pflag" "golang.org/x/time/rate" @@ -75,6 +77,7 @@ func ControllerSwitchOptions() *controllercmd.SwitchOptions { // WebhookSwitchOptions are the webhookcmd.SwitchOptions for the provider webhooks. func WebhookSwitchOptions() *webhookcmd.SwitchOptions { return webhookcmd.NewSwitchOptions( + webhookcmd.Switch(extensionsnetworkwebhook.WebhookName, networkwebhook.AddToManager), webhookcmd.Switch(extensioncontrolplanewebhook.WebhookName, controlplanewebhook.AddToManager), webhookcmd.Switch(extensioncontrolplanewebhook.ExposureWebhookName, controlplaneexposurewebhook.AddToManager), webhookcmd.Switch(extensionshootwebhook.WebhookName, shootwebhook.AddToManager), diff --git a/pkg/webhook/network/add.go b/pkg/webhook/network/add.go new file mode 100644 index 000000000..875267661 --- /dev/null +++ b/pkg/webhook/network/add.go @@ -0,0 +1,41 @@ +// Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 network + +import ( + "github.com/gardener/gardener-extension-provider-aws/pkg/aws" + + "github.com/gardener/gardener-extension-networking-calico/pkg/calico" + extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook" + "github.com/gardener/gardener/extensions/pkg/webhook/network" + extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1" + "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/manager" +) + +var logger = log.Log.WithName("networking-calico-webhook") + +// AddToManager creates a webhook and adds it to the manager. +func AddToManager(mgr manager.Manager) (*extensionswebhook.Webhook, error) { + logger.Info("Adding webhook to manager") + return network.New(mgr, network.Args{ + CloudProvider: aws.Type, + NetworkProvider: calico.Type, + Types: []extensionswebhook.Type{ + {Obj: &extensionsv1alpha1.Network{}}, + }, + Mutator: NewMutator(logger), + }) +} diff --git a/pkg/webhook/network/mutate.go b/pkg/webhook/network/mutate.go new file mode 100644 index 000000000..e065c5071 --- /dev/null +++ b/pkg/webhook/network/mutate.go @@ -0,0 +1,121 @@ +// Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 network + +import ( + "context" + + extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook" + "github.com/go-logr/logr" + + calicov1alpha1 "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1" + calicov1alpha1helper "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper" + "github.com/gardener/gardener/extensions/pkg/webhook/network" + extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1" + "github.com/gardener/gardener/pkg/extensions" + versionutils "github.com/gardener/gardener/pkg/utils/version" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/pointer" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// NewMutator creates a new network mutator. +func NewMutator(logger logr.Logger) extensionswebhook.Mutator { + mutator := &mutator{} + mutator.mutator = network.NewMutator(logger, mutator.mutateNetworkConfig) + return mutator +} + +type mutator struct { + client client.Client + mutator extensionswebhook.Mutator +} + +// InjectClient injects the given client into the mutator. +func (m *mutator) InjectClient(client client.Client) error { + m.client = client + return nil +} + +// Mutate validates and if needed mutates the given object. +func (m *mutator) Mutate(ctx context.Context, new, old client.Object) error { + return m.mutator.Mutate(ctx, new, old) +} + +func (m *mutator) mutateNetworkConfig(new, old *extensionsv1alpha1.Network) error { + extensionswebhook.LogMutation(logger, "Network", new.Namespace, new.Name) + + var ( + networkConfig *calicov1alpha1.NetworkConfig + ipv4 = calicov1alpha1.IPv4{Mode: (*calicov1alpha1.IPv4PoolMode)(pointer.StringPtr(string(calicov1alpha1.Never)))} + backendNone = calicov1alpha1.None + ipv4PoolMode = calicov1alpha1.Never + err error + ) + + // do network resource update only for a create operation + if old != nil { + return nil + } + + // source/destination checks are only disabled for kubernetes >= 1.22 + // see https://github.com/gardener/machine-controller-manager-provider-aws/issues/36 for details + if greaterEqual122, err := m.isKubernetesGreaterOrEqual122(new.Namespace); err != nil { + return err + } else if !greaterEqual122 { + return nil + } + + if new.Spec.ProviderConfig != nil { + networkConfig, err = calicov1alpha1helper.CalicoNetworkConfigFromNetworkResource(new) + if err != nil { + return err + } + } else { + networkConfig = &calicov1alpha1.NetworkConfig{ + TypeMeta: metav1.TypeMeta{ + APIVersion: calicov1alpha1.SchemeGroupVersion.String(), + Kind: "NetworkConfig", + }, + } + } + + if networkConfig.IPv4 == nil { + networkConfig.IPv4 = &ipv4 + } + + if networkConfig.IPv4 != nil && networkConfig.IPv4.Mode == nil { + networkConfig.IPv4.Mode = &ipv4PoolMode + } + + if networkConfig.Backend == nil { + networkConfig.Backend = &backendNone + } + + new.Spec.ProviderConfig = &runtime.RawExtension{ + Object: networkConfig, + } + + return nil +} + +func (m *mutator) isKubernetesGreaterOrEqual122(name string) (bool, error) { + cluster, err := extensions.GetCluster(context.TODO(), m.client, name) + if err != nil { + return false, err + } + return versionutils.CompareVersions(cluster.Shoot.Spec.Kubernetes.Version, ">=", "1.22") +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/LICENSE.md b/vendor/github.com/gardener/gardener-extension-networking-calico/LICENSE.md new file mode 100644 index 000000000..a4bf74414 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/LICENSE.md @@ -0,0 +1,283 @@ +``` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. +``` + +## APIs + +This project may include APIs to SAP or third party products or services. The use of these APIs, products and services may be subject to additional agreements. In no event shall the application of the Apache Software License, v.2 to this project grant any rights in or to these APIs, products or services that would alter, expand, be inconsistent with, or supersede any terms of these additional agreements. API means application programming interfaces, as well as their respective specifications and implementing code that allows other software products to communicate with or call on SAP or third party products or services (for example, SAP Enterprise Services, BAPIs, Idocs, RFCs and ABAP calls or other user exits) and may be made available through SAP or third party products, SDKs, documentation or other media. + +## Subcomponents + +This project includes the following subcomponents that are subject to separate license terms. +Your use of these subcomponents is subject to the separate license terms applicable to +each subcomponent. + +Gardener. +https://github.com/gardener/gardener. +Copyright (c) 2019 SAP SE or an SAP affiliate company. +Apache 2 license (https://github.com/gardener/gardener/blob/master/LICENSE.md). + +controller-runtime. +https://sigs.k8s.io/controller-runtime. +Copyright 2019 The Kubernetes Authors. +Apache 2 license (https://sigs.k8s.io/controller-runtime/LICENSE). + +API. +https://git.k8s.io/api. +Copyright 2019 The Kubernetes Authors. +Apache 2 license (https://git.k8s.io/api/LICENSE). + +APIMachinery. +https://git.k8s.io/apimachinery. +Copyright 2019 The Kubernetes Authors. +Apache 2 license (https://git.k8s.io/apimachinery/LICENSE). + +Client-Go. +https://git.k8s.io/client-go. +Copyright 2017 The Kubernetes Authors. +Apache 2 license (https://git.k8s.io/client-go/LICENSE). + +YAML marshaling and unmarshalling support for Go. +gopkg.in/yaml.v2. +Copyright 2011-2016 Canonical Ltd. +Apache 2 license (https://github.com/go-yaml/yaml/blob/v2/LICENSE) + +Cobra. +https://github.com/spf13/cobra +Copyright 2019 Steve Francia. +Apache 2 license (https://github.com/spf13/cobra/blob/master/LICENSE.txt) + +Ginkgo. +https://github.com/onsi/ginkgo. +Copyright (c) 2013-2014 Onsi Fakhouri. +MIT license (https://github.com/onsi/ginkgo/blob/master/LICENSE) + +Gomega. +github.com/onsi/gomega. +Copyright (c) 2013-2014 Onsi Fakhouri. +MIT license (https://github.com/onsi/gomega/blob/master/LICENSE) + +------ +## MIT License + + The MIT License (MIT) + + Copyright (c) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/NOTICE.md b/vendor/github.com/gardener/gardener-extension-networking-calico/NOTICE.md new file mode 100644 index 000000000..4bbe7e82f --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/NOTICE.md @@ -0,0 +1,15 @@ +## Gardener Extensions +Copyright (c) 2017-2019 SAP SE or an SAP affiliate company. All rights reserved. + +## Seed Source + +The source code of this component was seeded based on a copy of the following files from [github.com/kubernetes-sigs](github.com/kubernetes-sigs): + +controller-runtime. +https://sigs.k8s.io/controller-runtime. +Copyright 2018 The Kubernetes Authors. +Apache 2 license (https://sigs.k8s.io/controller-runtime/LICENSE). + +Version: 0.1.9. +Commit-ID: f6f0bc9611363b43664d08fb097ab13243ef621d +Commit-Message: Merge pull request #263 from DirectXMan12/release/v0.1.9 diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/doc.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/doc.go new file mode 100644 index 000000000..92d499149 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/doc.go @@ -0,0 +1,20 @@ +// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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. + +// +k8s:deepcopy-gen=package +// +groupName="calico.networking.extensions.gardener.cloud" + +//go:generate ../../../hack/update-codegen.sh + +package calico // import "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico" diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install/install.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install/install.go new file mode 100644 index 000000000..eb05e8b5b --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install/install.go @@ -0,0 +1,43 @@ +// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 install + +import ( + "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico" + "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1" + + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var ( + schemeBuilder = runtime.NewSchemeBuilder( + v1alpha1.AddToScheme, + calico.AddToScheme, + setVersionPriority, + ) + + // AddToScheme adds all APIs to the scheme. + AddToScheme = schemeBuilder.AddToScheme +) + +func setVersionPriority(scheme *runtime.Scheme) error { + return scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion) +} + +// Install installs all APIs in the scheme. +func Install(scheme *runtime.Scheme) { + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/register.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/register.go new file mode 100644 index 000000000..79ddaaff4 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/register.go @@ -0,0 +1,52 @@ +// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 calico + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "calico.networking.extensions.gardener.cloud" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} + +// Kind takes an unqualified kind and returns a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder used to register the Shoot resource. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a pointer to SchemeBuilder.AddToScheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &NetworkConfig{}, + &NetworkStatus{}, + ) + return nil +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/types_network.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/types_network.go new file mode 100644 index 000000000..f230ed8a0 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/types_network.go @@ -0,0 +1,118 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 calico + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type Backend string + +const ( + Bird Backend = "bird" + None Backend = "none" + VXLan Backend = "vxlan" +) + +type IPv4PoolMode string + +const ( + Always IPv4PoolMode = "Always" + Never IPv4PoolMode = "Never" + CrossSubnet IPv4PoolMode = "CrossSubnet" + Off IPv4PoolMode = "Off" +) + +type CIDR string + +type IPv4Pool string + +const ( + PoolIPIP IPv4Pool = "ipip" + PoolVXLan IPv4Pool = "vxlan" +) + +// IPv4 contains configuration for calico ipv4 specific settings +type IPv4 struct { + // Pool configures the type of ip pool for the tunnel interface. + // https://docs.projectcalico.org/v3.8/reference/node/configuration#environment-variables + Pool *IPv4Pool + // Mode is the mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet) + // ipip pools accept all pool mode values values + // vxlan pools accept only Always and Never (unchecked) + Mode *IPv4PoolMode + // AutoDetectionMethod is the method to use to autodetect the IPv4 address for this host. This is only used when the IPv4 address is being autodetected. + // https://docs.projectcalico.org/v3.8/reference/node/configuration#ip-autodetection-methods + AutoDetectionMethod *string +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkConfig configuration for the calico networking plugin +type NetworkConfig struct { + metav1.TypeMeta + // Backend defines whether a backend should be used or not (e.g., bird or none) + Backend *Backend + // IPAM to use for the Calico Plugin (e.g., host-local or Calico) + IPAM *IPAM + // IPv4 contains configuration for calico ipv4 specific settings + IPv4 *IPv4 + // Typha settings to use for calico-typha component + Typha *Typha + // VethMTU settings used to configure calico port mtu + VethMTU *string + // EbpfDataplane enables the eBPF dataplane mode. + EbpfDataplane *EbpfDataplane + + // DEPRECATED. + // IPIP is the IPIP Mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet) + // It was moved into the IPv4 struct, kept for backwards compatibility. + // Will be removed in a future Gardener release. + IPIP *IPv4PoolMode + // DEPRECATED. + // IPAutoDetectionMethod is the method to use to autodetect the IPv4 address for this host. This is only used when the IPv4 address is being autodetected. + // It was moved into the IPv4 struct, kept for backwards compatibility. + // Will be removed in a future Gardener release. + IPAutoDetectionMethod *string +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkStatus contains information about created Network resources. +type NetworkStatus struct { + metav1.TypeMeta +} + +// IPAM defines the block that configuration for the ip assignment plugin to be used +type IPAM struct { + // Type defines the IPAM plugin type + Type string + // CIDR defines the CIDR block to be used + CIDR *CIDR +} + +// Typha defines the block with configurations for calico typha +type Typha struct { + // Enabled is used to define whether calico-typha is required or not. + // Note, typha is used to offload kubernetes API server, + // thus consider not to disable it for large clusters in terms of node count. + // More info can be found here https://docs.projectcalico.org/v3.9/reference/typha/ + Enabled bool +} + +type EbpfDataplane struct { + // Enabled enables the eBPF dataplane mode. + Enabled bool +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/defaults.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/defaults.go new file mode 100644 index 000000000..8b665d270 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/defaults.go @@ -0,0 +1,23 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime" +) + +func addDefaultingFuncs(scheme *runtime.Scheme) error { + return RegisterDefaults(scheme) +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/doc.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/doc.go new file mode 100644 index 000000000..fc1a873ea --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/doc.go @@ -0,0 +1,24 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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. + +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico +// +k8s:openapi-gen=true +// +k8s:defaulter-gen=TypeMeta + +//go:generate gen-crd-api-reference-docs -api-dir . -config ../../../../hack/api-reference/calico.json -template-dir ../../../../vendor/github.com/gardener/gardener/hack/api-reference/template -out-file ../../../../hack/api-reference/calico.md + +// Package v1alpha1 contains the configuration of the Calico Network Extension. +// +groupName=calico.networking.extensions.gardener.cloud +package v1alpha1 // import "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1" diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper/decode.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper/decode.go new file mode 100644 index 000000000..2cd45e07c --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper/decode.go @@ -0,0 +1,54 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 helper + +import ( + "fmt" + + "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install" + calicov1alpha1 "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1" + + extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var ( + // Scheme is a scheme with the types relevant for Network actuators. + Scheme *runtime.Scheme + + decoder runtime.Decoder +) + +func init() { + Scheme = runtime.NewScheme() + utilruntime.Must(install.AddToScheme(Scheme)) + + decoder = serializer.NewCodecFactory(Scheme, serializer.EnableStrict).UniversalDecoder() +} + +// CalicoNetworkConfigFromNetworkResource extracts the NetworkConfig from the +// ProviderConfig section of the given Network resource. +func CalicoNetworkConfigFromNetworkResource(network *extensionsv1alpha1.Network) (*calicov1alpha1.NetworkConfig, error) { + config := &calicov1alpha1.NetworkConfig{} + if network.Spec.ProviderConfig != nil && network.Spec.ProviderConfig.Raw != nil { + if _, _, err := decoder.Decode(network.Spec.ProviderConfig.Raw, nil, config); err != nil { + return nil, err + } + return config, nil + } + return nil, fmt.Errorf("provider config is not set on the network resource") +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/register.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/register.go new file mode 100644 index 000000000..c7e3004b6 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/register.go @@ -0,0 +1,55 @@ +// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "calico.networking.extensions.gardener.cloud" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder used to register the Shoot resource. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // AddToScheme is a pointer to SchemeBuilder.AddToScheme. + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addDefaultingFuncs, addKnownTypes) +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &NetworkConfig{}, + &NetworkStatus{}, + ) + return nil +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/types_network.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/types_network.go new file mode 100644 index 000000000..26c1b319d --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/types_network.go @@ -0,0 +1,131 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type Backend string + +const ( + Bird Backend = "bird" + None Backend = "none" + VXLan Backend = "vxlan" +) + +type IPv4PoolMode string + +const ( + Always IPv4PoolMode = "Always" + Never IPv4PoolMode = "Never" + CrossSubnet IPv4PoolMode = "CrossSubnet" + Off IPv4PoolMode = "Off" +) + +type CIDR string + +type IPv4Pool string + +const ( + PoolIPIP IPv4Pool = "ipip" + PoolVXLan IPv4Pool = "vxlan" +) + +// IPv4 contains configuration for calico ipv4 specific settings +type IPv4 struct { + // Pool configures the type of ip pool for the tunnel interface + // https://docs.projectcalico.org/v3.8/reference/node/configuration#environment-variables + // +optional + Pool *IPv4Pool `json:"pool,omitempty"` + // Mode is the mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet) + // ipip pools accept all pool mode values values + // vxlan pools accept only Always and Never (unchecked) + // +optional + Mode *IPv4PoolMode `json:"mode,omitempty"` + // AutoDetectionMethod is the method to use to autodetect the IPv4 address for this host. This is only used when the IPv4 address is being autodetected. + // https://docs.projectcalico.org/v3.8/reference/node/configuration#ip-autodetection-methods + // +optional + AutoDetectionMethod *string `json:"autoDetectionMethod,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkConfig configuration for the calico networking plugin +type NetworkConfig struct { + metav1.TypeMeta `json:",inline"` + // Backend defines whether a backend should be used or not (e.g., bird or none) + // +optional + Backend *Backend `json:"backend"` + // IPAM to use for the Calico Plugin (e.g., host-local or Calico) + // +optional + IPAM *IPAM `json:"ipam,omitempty"` + // IPv4 contains configuration for calico ipv4 specific settings + // +optional + IPv4 *IPv4 `json:"ipv4,omitempty"` + // Typha settings to use for calico-typha component + // +optional + Typha *Typha `json:"typha,omitempty"` + // VethMTU settings used to configure calico port mtu + // +optional + VethMTU *string `json:"vethMTU,omitempty"` + // EbpfDataplane enables the eBPF dataplane mode. + // +optional + EbpfDataplane *EbpfDataplane `json:"ebpfDataplane,omitempty"` + + // DEPRECATED. + // IPIP is the IPIP Mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet) + // It was moved into the IPv4 struct, kept for backwards compatibility. + // Will be removed in a future Gardener release. + // +optional + IPIP *IPv4PoolMode `json:"ipip,omitempty"` + // DEPRECATED. + // IPAutoDetectionMethod is the method to use to autodetect the IPv4 address for this host. This is only used when the IPv4 address is being autodetected. + // It was moved into the IPv4 struct, kept for backwards compatibility. + // Will be removed in a future Gardener release. + // +optional + IPAutoDetectionMethod *string `json:"ipAutodetectionMethod,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkStatus contains information about created Network resources. +type NetworkStatus struct { + metav1.TypeMeta `json:",inline"` +} + +// IPAM defines the block that configuration for the ip assignment plugin to be used +type IPAM struct { + // Type defines the IPAM plugin type + Type string `json:"type"` + // CIDR defines the CIDR block to be used + // +optional + CIDR *CIDR `json:"cidr,omitempty"` +} + +// Typha defines the block with configurations for calico typha +type Typha struct { + // Enabled is used to define whether calico-typha is required or not. + // Note, typha is used to offload kubernetes API server, + // thus consider not to disable it for large clusters in terms of node count. + // More info can be found here https://docs.projectcalico.org/v3.9/reference/typha/ + Enabled bool `json:"enabled"` +} + +type EbpfDataplane struct { + // Enabled enables the eBPF dataplane mode. + Enabled bool `json:"enabled"` +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.conversion.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.conversion.go new file mode 100644 index 000000000..bb0c692ab --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,238 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright (c) SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file + +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. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + unsafe "unsafe" + + calico "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*EbpfDataplane)(nil), (*calico.EbpfDataplane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_EbpfDataplane_To_calico_EbpfDataplane(a.(*EbpfDataplane), b.(*calico.EbpfDataplane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.EbpfDataplane)(nil), (*EbpfDataplane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_EbpfDataplane_To_v1alpha1_EbpfDataplane(a.(*calico.EbpfDataplane), b.(*EbpfDataplane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*IPAM)(nil), (*calico.IPAM)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPAM_To_calico_IPAM(a.(*IPAM), b.(*calico.IPAM), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.IPAM)(nil), (*IPAM)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_IPAM_To_v1alpha1_IPAM(a.(*calico.IPAM), b.(*IPAM), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*IPv4)(nil), (*calico.IPv4)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPv4_To_calico_IPv4(a.(*IPv4), b.(*calico.IPv4), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.IPv4)(nil), (*IPv4)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_IPv4_To_v1alpha1_IPv4(a.(*calico.IPv4), b.(*IPv4), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*NetworkConfig)(nil), (*calico.NetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkConfig_To_calico_NetworkConfig(a.(*NetworkConfig), b.(*calico.NetworkConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.NetworkConfig)(nil), (*NetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_NetworkConfig_To_v1alpha1_NetworkConfig(a.(*calico.NetworkConfig), b.(*NetworkConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*NetworkStatus)(nil), (*calico.NetworkStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkStatus_To_calico_NetworkStatus(a.(*NetworkStatus), b.(*calico.NetworkStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.NetworkStatus)(nil), (*NetworkStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_NetworkStatus_To_v1alpha1_NetworkStatus(a.(*calico.NetworkStatus), b.(*NetworkStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Typha)(nil), (*calico.Typha)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Typha_To_calico_Typha(a.(*Typha), b.(*calico.Typha), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*calico.Typha)(nil), (*Typha)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_calico_Typha_To_v1alpha1_Typha(a.(*calico.Typha), b.(*Typha), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_EbpfDataplane_To_calico_EbpfDataplane(in *EbpfDataplane, out *calico.EbpfDataplane, s conversion.Scope) error { + out.Enabled = in.Enabled + return nil +} + +// Convert_v1alpha1_EbpfDataplane_To_calico_EbpfDataplane is an autogenerated conversion function. +func Convert_v1alpha1_EbpfDataplane_To_calico_EbpfDataplane(in *EbpfDataplane, out *calico.EbpfDataplane, s conversion.Scope) error { + return autoConvert_v1alpha1_EbpfDataplane_To_calico_EbpfDataplane(in, out, s) +} + +func autoConvert_calico_EbpfDataplane_To_v1alpha1_EbpfDataplane(in *calico.EbpfDataplane, out *EbpfDataplane, s conversion.Scope) error { + out.Enabled = in.Enabled + return nil +} + +// Convert_calico_EbpfDataplane_To_v1alpha1_EbpfDataplane is an autogenerated conversion function. +func Convert_calico_EbpfDataplane_To_v1alpha1_EbpfDataplane(in *calico.EbpfDataplane, out *EbpfDataplane, s conversion.Scope) error { + return autoConvert_calico_EbpfDataplane_To_v1alpha1_EbpfDataplane(in, out, s) +} + +func autoConvert_v1alpha1_IPAM_To_calico_IPAM(in *IPAM, out *calico.IPAM, s conversion.Scope) error { + out.Type = in.Type + out.CIDR = (*calico.CIDR)(unsafe.Pointer(in.CIDR)) + return nil +} + +// Convert_v1alpha1_IPAM_To_calico_IPAM is an autogenerated conversion function. +func Convert_v1alpha1_IPAM_To_calico_IPAM(in *IPAM, out *calico.IPAM, s conversion.Scope) error { + return autoConvert_v1alpha1_IPAM_To_calico_IPAM(in, out, s) +} + +func autoConvert_calico_IPAM_To_v1alpha1_IPAM(in *calico.IPAM, out *IPAM, s conversion.Scope) error { + out.Type = in.Type + out.CIDR = (*CIDR)(unsafe.Pointer(in.CIDR)) + return nil +} + +// Convert_calico_IPAM_To_v1alpha1_IPAM is an autogenerated conversion function. +func Convert_calico_IPAM_To_v1alpha1_IPAM(in *calico.IPAM, out *IPAM, s conversion.Scope) error { + return autoConvert_calico_IPAM_To_v1alpha1_IPAM(in, out, s) +} + +func autoConvert_v1alpha1_IPv4_To_calico_IPv4(in *IPv4, out *calico.IPv4, s conversion.Scope) error { + out.Pool = (*calico.IPv4Pool)(unsafe.Pointer(in.Pool)) + out.Mode = (*calico.IPv4PoolMode)(unsafe.Pointer(in.Mode)) + out.AutoDetectionMethod = (*string)(unsafe.Pointer(in.AutoDetectionMethod)) + return nil +} + +// Convert_v1alpha1_IPv4_To_calico_IPv4 is an autogenerated conversion function. +func Convert_v1alpha1_IPv4_To_calico_IPv4(in *IPv4, out *calico.IPv4, s conversion.Scope) error { + return autoConvert_v1alpha1_IPv4_To_calico_IPv4(in, out, s) +} + +func autoConvert_calico_IPv4_To_v1alpha1_IPv4(in *calico.IPv4, out *IPv4, s conversion.Scope) error { + out.Pool = (*IPv4Pool)(unsafe.Pointer(in.Pool)) + out.Mode = (*IPv4PoolMode)(unsafe.Pointer(in.Mode)) + out.AutoDetectionMethod = (*string)(unsafe.Pointer(in.AutoDetectionMethod)) + return nil +} + +// Convert_calico_IPv4_To_v1alpha1_IPv4 is an autogenerated conversion function. +func Convert_calico_IPv4_To_v1alpha1_IPv4(in *calico.IPv4, out *IPv4, s conversion.Scope) error { + return autoConvert_calico_IPv4_To_v1alpha1_IPv4(in, out, s) +} + +func autoConvert_v1alpha1_NetworkConfig_To_calico_NetworkConfig(in *NetworkConfig, out *calico.NetworkConfig, s conversion.Scope) error { + out.Backend = (*calico.Backend)(unsafe.Pointer(in.Backend)) + out.IPAM = (*calico.IPAM)(unsafe.Pointer(in.IPAM)) + out.IPv4 = (*calico.IPv4)(unsafe.Pointer(in.IPv4)) + out.Typha = (*calico.Typha)(unsafe.Pointer(in.Typha)) + out.VethMTU = (*string)(unsafe.Pointer(in.VethMTU)) + out.EbpfDataplane = (*calico.EbpfDataplane)(unsafe.Pointer(in.EbpfDataplane)) + out.IPIP = (*calico.IPv4PoolMode)(unsafe.Pointer(in.IPIP)) + out.IPAutoDetectionMethod = (*string)(unsafe.Pointer(in.IPAutoDetectionMethod)) + return nil +} + +// Convert_v1alpha1_NetworkConfig_To_calico_NetworkConfig is an autogenerated conversion function. +func Convert_v1alpha1_NetworkConfig_To_calico_NetworkConfig(in *NetworkConfig, out *calico.NetworkConfig, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkConfig_To_calico_NetworkConfig(in, out, s) +} + +func autoConvert_calico_NetworkConfig_To_v1alpha1_NetworkConfig(in *calico.NetworkConfig, out *NetworkConfig, s conversion.Scope) error { + out.Backend = (*Backend)(unsafe.Pointer(in.Backend)) + out.IPAM = (*IPAM)(unsafe.Pointer(in.IPAM)) + out.IPv4 = (*IPv4)(unsafe.Pointer(in.IPv4)) + out.Typha = (*Typha)(unsafe.Pointer(in.Typha)) + out.VethMTU = (*string)(unsafe.Pointer(in.VethMTU)) + out.EbpfDataplane = (*EbpfDataplane)(unsafe.Pointer(in.EbpfDataplane)) + out.IPIP = (*IPv4PoolMode)(unsafe.Pointer(in.IPIP)) + out.IPAutoDetectionMethod = (*string)(unsafe.Pointer(in.IPAutoDetectionMethod)) + return nil +} + +// Convert_calico_NetworkConfig_To_v1alpha1_NetworkConfig is an autogenerated conversion function. +func Convert_calico_NetworkConfig_To_v1alpha1_NetworkConfig(in *calico.NetworkConfig, out *NetworkConfig, s conversion.Scope) error { + return autoConvert_calico_NetworkConfig_To_v1alpha1_NetworkConfig(in, out, s) +} + +func autoConvert_v1alpha1_NetworkStatus_To_calico_NetworkStatus(in *NetworkStatus, out *calico.NetworkStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_NetworkStatus_To_calico_NetworkStatus is an autogenerated conversion function. +func Convert_v1alpha1_NetworkStatus_To_calico_NetworkStatus(in *NetworkStatus, out *calico.NetworkStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkStatus_To_calico_NetworkStatus(in, out, s) +} + +func autoConvert_calico_NetworkStatus_To_v1alpha1_NetworkStatus(in *calico.NetworkStatus, out *NetworkStatus, s conversion.Scope) error { + return nil +} + +// Convert_calico_NetworkStatus_To_v1alpha1_NetworkStatus is an autogenerated conversion function. +func Convert_calico_NetworkStatus_To_v1alpha1_NetworkStatus(in *calico.NetworkStatus, out *NetworkStatus, s conversion.Scope) error { + return autoConvert_calico_NetworkStatus_To_v1alpha1_NetworkStatus(in, out, s) +} + +func autoConvert_v1alpha1_Typha_To_calico_Typha(in *Typha, out *calico.Typha, s conversion.Scope) error { + out.Enabled = in.Enabled + return nil +} + +// Convert_v1alpha1_Typha_To_calico_Typha is an autogenerated conversion function. +func Convert_v1alpha1_Typha_To_calico_Typha(in *Typha, out *calico.Typha, s conversion.Scope) error { + return autoConvert_v1alpha1_Typha_To_calico_Typha(in, out, s) +} + +func autoConvert_calico_Typha_To_v1alpha1_Typha(in *calico.Typha, out *Typha, s conversion.Scope) error { + out.Enabled = in.Enabled + return nil +} + +// Convert_calico_Typha_To_v1alpha1_Typha is an autogenerated conversion function. +func Convert_calico_Typha_To_v1alpha1_Typha(in *calico.Typha, out *Typha, s conversion.Scope) error { + return autoConvert_calico_Typha_To_v1alpha1_Typha(in, out, s) +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..ecc0ffb72 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,200 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright (c) SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file + +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EbpfDataplane) DeepCopyInto(out *EbpfDataplane) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EbpfDataplane. +func (in *EbpfDataplane) DeepCopy() *EbpfDataplane { + if in == nil { + return nil + } + out := new(EbpfDataplane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAM) DeepCopyInto(out *IPAM) { + *out = *in + if in.CIDR != nil { + in, out := &in.CIDR, &out.CIDR + *out = new(CIDR) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAM. +func (in *IPAM) DeepCopy() *IPAM { + if in == nil { + return nil + } + out := new(IPAM) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPv4) DeepCopyInto(out *IPv4) { + *out = *in + if in.Pool != nil { + in, out := &in.Pool, &out.Pool + *out = new(IPv4Pool) + **out = **in + } + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(IPv4PoolMode) + **out = **in + } + if in.AutoDetectionMethod != nil { + in, out := &in.AutoDetectionMethod, &out.AutoDetectionMethod + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPv4. +func (in *IPv4) DeepCopy() *IPv4 { + if in == nil { + return nil + } + out := new(IPv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Backend != nil { + in, out := &in.Backend, &out.Backend + *out = new(Backend) + **out = **in + } + if in.IPAM != nil { + in, out := &in.IPAM, &out.IPAM + *out = new(IPAM) + (*in).DeepCopyInto(*out) + } + if in.IPv4 != nil { + in, out := &in.IPv4, &out.IPv4 + *out = new(IPv4) + (*in).DeepCopyInto(*out) + } + if in.Typha != nil { + in, out := &in.Typha, &out.Typha + *out = new(Typha) + **out = **in + } + if in.VethMTU != nil { + in, out := &in.VethMTU, &out.VethMTU + *out = new(string) + **out = **in + } + if in.EbpfDataplane != nil { + in, out := &in.EbpfDataplane, &out.EbpfDataplane + *out = new(EbpfDataplane) + **out = **in + } + if in.IPIP != nil { + in, out := &in.IPIP, &out.IPIP + *out = new(IPv4PoolMode) + **out = **in + } + if in.IPAutoDetectionMethod != nil { + in, out := &in.IPAutoDetectionMethod, &out.IPAutoDetectionMethod + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkConfig. +func (in *NetworkConfig) DeepCopy() *NetworkConfig { + if in == nil { + return nil + } + out := new(NetworkConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. +func (in *NetworkStatus) DeepCopy() *NetworkStatus { + if in == nil { + return nil + } + out := new(NetworkStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkStatus) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Typha) DeepCopyInto(out *Typha) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Typha. +func (in *Typha) DeepCopy() *Typha { + if in == nil { + return nil + } + out := new(Typha) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.defaults.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.defaults.go new file mode 100644 index 000000000..f31795e55 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/zz_generated.defaults.go @@ -0,0 +1,33 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright (c) SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file + +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. +*/ + +// Code generated by defaulter-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/zz_generated.deepcopy.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/zz_generated.deepcopy.go new file mode 100644 index 000000000..b5fe1d69a --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/zz_generated.deepcopy.go @@ -0,0 +1,200 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright (c) SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file + +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package calico + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EbpfDataplane) DeepCopyInto(out *EbpfDataplane) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EbpfDataplane. +func (in *EbpfDataplane) DeepCopy() *EbpfDataplane { + if in == nil { + return nil + } + out := new(EbpfDataplane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAM) DeepCopyInto(out *IPAM) { + *out = *in + if in.CIDR != nil { + in, out := &in.CIDR, &out.CIDR + *out = new(CIDR) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAM. +func (in *IPAM) DeepCopy() *IPAM { + if in == nil { + return nil + } + out := new(IPAM) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPv4) DeepCopyInto(out *IPv4) { + *out = *in + if in.Pool != nil { + in, out := &in.Pool, &out.Pool + *out = new(IPv4Pool) + **out = **in + } + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(IPv4PoolMode) + **out = **in + } + if in.AutoDetectionMethod != nil { + in, out := &in.AutoDetectionMethod, &out.AutoDetectionMethod + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPv4. +func (in *IPv4) DeepCopy() *IPv4 { + if in == nil { + return nil + } + out := new(IPv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Backend != nil { + in, out := &in.Backend, &out.Backend + *out = new(Backend) + **out = **in + } + if in.IPAM != nil { + in, out := &in.IPAM, &out.IPAM + *out = new(IPAM) + (*in).DeepCopyInto(*out) + } + if in.IPv4 != nil { + in, out := &in.IPv4, &out.IPv4 + *out = new(IPv4) + (*in).DeepCopyInto(*out) + } + if in.Typha != nil { + in, out := &in.Typha, &out.Typha + *out = new(Typha) + **out = **in + } + if in.VethMTU != nil { + in, out := &in.VethMTU, &out.VethMTU + *out = new(string) + **out = **in + } + if in.EbpfDataplane != nil { + in, out := &in.EbpfDataplane, &out.EbpfDataplane + *out = new(EbpfDataplane) + **out = **in + } + if in.IPIP != nil { + in, out := &in.IPIP, &out.IPIP + *out = new(IPv4PoolMode) + **out = **in + } + if in.IPAutoDetectionMethod != nil { + in, out := &in.IPAutoDetectionMethod, &out.IPAutoDetectionMethod + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkConfig. +func (in *NetworkConfig) DeepCopy() *NetworkConfig { + if in == nil { + return nil + } + out := new(NetworkConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. +func (in *NetworkStatus) DeepCopy() *NetworkStatus { + if in == nil { + return nil + } + out := new(NetworkStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkStatus) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Typha) DeepCopyInto(out *Typha) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Typha. +func (in *Typha) DeepCopy() *Typha { + if in == nil { + return nil + } + out := new(Typha) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/predicates.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/predicates.go new file mode 100644 index 000000000..f9800f89c --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/predicates.go @@ -0,0 +1,17 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 calico + +const Type = "calico" diff --git a/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/types.go b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/types.go new file mode 100644 index 000000000..f21513c18 --- /dev/null +++ b/vendor/github.com/gardener/gardener-extension-networking-calico/pkg/calico/types.go @@ -0,0 +1,49 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 calico + +import "path/filepath" + +const ( + Name = "networking-calico" + + // ImageNames + CNIImageName = "calico-cni" + NodeImageName = "calico-node" + KubeControllersImageName = "calico-kube-controllers" + PodToDaemonFlexVolumeDriverImageName = "calico-podtodaemon-flex" + TyphaImageName = "calico-typha" + CalicoClusterProportionalAutoscalerImageName = "calico-cpa" + ClusterProportionalVerticalAutoscalerImageName = "calico-cpva" + + // MonitoringChartName + MonitoringName = "calico-monitoring-config" + + // ReleaseName is the name of the Calico Release + ReleaseName = "calico" +) + +var ( + // ChartsPath is the path to the charts + ChartsPath = filepath.Join("charts") + // InternalChartsPath is the path to the internal charts + InternalChartsPath = filepath.Join(ChartsPath, "internal") + + // CalicoChartPath path for internal Calico Chart + CalicoChartPath = filepath.Join(InternalChartsPath, "calico") + + // CalicoMonitoringChartPath path for internal Calico monitoring chart + CalicoMonitoringChartPath = filepath.Join(InternalChartsPath, "calico-monitoring") +) diff --git a/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/mutator.go b/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/mutator.go new file mode 100644 index 000000000..44ace0945 --- /dev/null +++ b/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/mutator.go @@ -0,0 +1,76 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 network + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/gardener/gardener/extensions/pkg/webhook" + extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1" +) + +// MutateFn is a function that validates and if needed mutates the given extensionsv1alpha1.Network. +type MutateFn func(new, old *extensionsv1alpha1.Network) error + +// NewMutator creates a new network mutator. +func NewMutator(logger logr.Logger, mutateFn MutateFn) webhook.Mutator { + return &mutator{ + logger: logger.WithName("mutator"), + mutateFunc: mutateFn, + } +} + +type mutator struct { + client client.Client + logger logr.Logger + mutateFunc MutateFn +} + +// InjectClient injects the given client into the ensurer. +func (m *mutator) InjectClient(client client.Client) error { + m.client = client + return nil +} + +// Mutate validates and if needed mutates the given object. +func (m *mutator) Mutate(ctx context.Context, new, old client.Object) error { + var ( + newNetwork, oldNetwork *extensionsv1alpha1.Network + ok bool + ) + + // If the object does have a deletion timestamp then we don't want to mutate anything. + if new.GetDeletionTimestamp() != nil { + return nil + } + + newNetwork, ok = new.(*extensionsv1alpha1.Network) + if !ok { + return fmt.Errorf("could not mutate, object is not of type \"Network\"") + } + + if old != nil { + oldNetwork, ok = old.(*extensionsv1alpha1.Network) + if !ok { + return fmt.Errorf("could not cast old object to extensionsv1alpha1.Network") + } + } + + return m.mutateFunc(newNetwork, oldNetwork) +} diff --git a/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/network.go b/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/network.go new file mode 100644 index 000000000..b9f50d3e2 --- /dev/null +++ b/vendor/github.com/gardener/gardener/extensions/pkg/webhook/network/network.go @@ -0,0 +1,91 @@ +// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 network + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/gardener/gardener/extensions/pkg/webhook" + extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook" + v1beta1constants "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants" +) + +const ( + // WebhookName is the webhook name. + WebhookName = "network" +) + +var logger = log.Log.WithName("network-webhook") + +// Args are arguments for adding a controlplane webhook to a manager. +type Args struct { + // NetworkProvider is the network provider for this webhook + NetworkProvider string + // CloudProvider is the cloud provider of this webhook. + CloudProvider string + // Types is a list of resource types. + Types []extensionswebhook.Type + // Mutator is a mutator to be used by the admission handler. + Mutator webhook.Mutator +} + +// New creates a new network webhook with the given args. +func New(mgr manager.Manager, args Args) (*webhook.Webhook, error) { + logger := logger.WithValues("network-provider", args.NetworkProvider, "cloud-provider", args.CloudProvider) + + // Create handler + handler, err := webhook.NewBuilder(mgr, logger).WithMutator(args.Mutator, args.Types...).Build() + if err != nil { + return nil, err + } + + // Build namespace selector from the webhook kind and provider + namespaceSelector, err := buildSelector(args.NetworkProvider, args.CloudProvider) + if err != nil { + return nil, err + } + + // Create webhook + var ( + name = WebhookName + path = WebhookName + ) + + logger.Info("Creating network webhook", "name", name) + return &extensionswebhook.Webhook{ + Name: name, + Provider: args.NetworkProvider, + Types: args.Types, + Target: extensionswebhook.TargetSeed, + Path: path, + Webhook: &admission.Webhook{Handler: handler}, + Selector: namespaceSelector, + }, nil + +} + +// buildSelector creates and returns a LabelSelector for the given webhook kind and provider. +func buildSelector(networkProvider, cloudProvider string) (*metav1.LabelSelector, error) { + // Create and return LabelSelector + return &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + {Key: v1beta1constants.LabelShootProvider, Operator: metav1.LabelSelectorOpIn, Values: []string{cloudProvider}}, + {Key: v1beta1constants.LabelNetworkingProvider, Operator: metav1.LabelSelectorOpIn, Values: []string{networkProvider}}, + }, + }, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index c07c0f15e..b8955878e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -166,6 +166,7 @@ github.com/gardener/gardener/extensions/pkg/webhook/context github.com/gardener/gardener/extensions/pkg/webhook/controlplane github.com/gardener/gardener/extensions/pkg/webhook/controlplane/genericmutator github.com/gardener/gardener/extensions/pkg/webhook/controlplane/test +github.com/gardener/gardener/extensions/pkg/webhook/network github.com/gardener/gardener/extensions/pkg/webhook/shoot github.com/gardener/gardener/hack github.com/gardener/gardener/hack/.ci @@ -250,6 +251,13 @@ github.com/gardener/gardener/test/framework/reporter github.com/gardener/gardener/test/testmachinery/extensions/generator github.com/gardener/gardener/test/testmachinery/extensions/healthcheck github.com/gardener/gardener/test/testmachinery/extensions/operation +# github.com/gardener/gardener-extension-networking-calico v1.25.0 +## explicit; go 1.18 +github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico +github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/install +github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1 +github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1/helper +github.com/gardener/gardener-extension-networking-calico/pkg/calico # github.com/gardener/hvpa-controller/api v0.5.0 ## explicit; go 1.15 github.com/gardener/hvpa-controller/api/v1alpha1