Skip to content

Commit

Permalink
add kindnet network plugin
Browse files Browse the repository at this point in the history
Change-Id: Ica436d9debe1efb63a572cb8e8c68432ec2ffd35
  • Loading branch information
aojea committed Dec 31, 2024
1 parent 8063d83 commit 44e8540
Show file tree
Hide file tree
Showing 62 changed files with 9,196 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.EtcdStorageType, "etcd-storage-type", options.EtcdStorageType, "The default storage type for etcd members")
cmd.RegisterFlagCompletionFunc("etcd-storage-type", completeStorageType)

cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode. kubenet, external, flannel-vxlan (or flannel), flannel-udp, calico, canal, kube-router, amazonvpc, cilium, cilium-etcd, cni.")
cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode. kubenet, external, flannel-vxlan (or flannel), flannel-udp, calico, canal, kube-router, amazonvpc, cilium, cilium-etcd, kindnet, cni.")
cmd.RegisterFlagCompletionFunc("networking", completeNetworking(options))

cmd.Flags().StringVar(&options.DNSZone, "dns-zone", options.DNSZone, "DNS hosted zone (defaults to longest matching zone)")
Expand Down Expand Up @@ -983,6 +983,7 @@ func completeNetworking(options *CreateClusterOptions) func(cmd *cobra.Command,
"cilium",
"cilium-eni",
"cilium-etcd",
"kindnet",
}

if !options.IPv6 {
Expand Down
10 changes: 10 additions & 0 deletions cmd/kops/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const (
canalAddon = "networking.projectcalico.org.canal-k8s-1.25"
ciliumAddon = "networking.cilium.io-k8s-1.16"
flannelAddon = "networking.flannel-k8s-1.25"
kindnetAddon = "networking.kindnet-k8s-1.12"

certManagerAddon = "certmanager.io-k8s-1.16"
clusterAutoscalerAddon = "cluster-autoscaler.addons.k8s.io-k8s-1.15"
Expand Down Expand Up @@ -642,6 +643,15 @@ func TestPrivateFlannel(t *testing.T) {
runTestTerraformAWS(t)
}

// TestPrivateKindnet runs the test on a configuration with private topology, flannel networking
func TestPrivateKindnet(t *testing.T) {
newIntegrationTest("privatekindnet.example.com", "privatekindnet").
withPrivate().
withDefaultAddons24().
withAddons(kindnetAddon).
runTestTerraformAWS(t)
}

// TestPrivateCalico runs the test on a configuration with private topology, calico networking
func TestPrivateCalico(t *testing.T) {
newIntegrationTest("privatecalico.example.com", "privatecalico").
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/kops_create_cluster.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions docs/networking/kindnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Kindnet

* [kindnet](http://kindnet.es)

Kindnet focuses on providing essential networking functionality without unnecessary complexity.

## Installing

To install [kindnet](https://github.com/aojea/kindnet) - use `--networking kindnet`.

```sh
export ZONES=mylistofzone
kops create cluster \
--zones $ZONES \
--networking kindnet \
--yes \
--name myclustername.mydns.io
```

## Getting help

For problems with kindnet please post an issue to Github:

- [Kindnet Issues](https://github.com/aojea/kindnet/issues)

You can learn more about the different configurations options in https://kindnet.es/
30 changes: 30 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5773,6 +5773,36 @@ spec:
description: GCPNetworkingSpec is the specification of GCP's native
networking mode, using IP aliases.
type: object
kindnet:
description: KindnetNetworkingSpec configures Kindnet settings.
properties:
adminNetworkPolicies:
type: boolean
baselineAdminNetworkPolicies:
type: boolean
dnsCaching:
type: boolean
fastPathThreshold:
format: int32
type: integer
masquerade:
description: KindnetMasqueradeSpec configures Kindnet masquerading
settings.
properties:
enabled:
type: boolean
nonMasqueradeCIDRs:
items:
type: string
type: array
type: object
nat64:
type: boolean
networkPolicies:
type: boolean
version:
type: string
type: object
kopeio:
description: KopeioNetworkingSpec declares that we want Kopeio
networking
Expand Down
38 changes: 38 additions & 0 deletions nodeup/pkg/model/networking/kindnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package networking

import (
"k8s.io/kops/nodeup/pkg/model"
"k8s.io/kops/upup/pkg/fi"
)

// KindnetBuilder configures the etcd TLS support for Calico
type KindnetBuilder struct {
*model.NodeupModelContext
}

var _ fi.NodeupModelBuilder = &KindnetBuilder{}

// Build is responsible for performing setup for Kindnet.
func (b *KindnetBuilder) Build(c *fi.NodeupModelBuilderContext) error {
if b.NodeupConfig.Networking.Kindnet == nil {
return nil
}

return nil
}
25 changes: 25 additions & 0 deletions pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type NetworkingSpec struct {
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
LyftVPC *LyftVPCNetworkingSpec `json:"lyftvpc,omitempty"`
GCP *GCPNetworkingSpec `json:"gcp,omitempty"`
Kindnet *KindnetNetworkingSpec `json:"kindnet,omitempty"`
}

// UsesKubenet returns true if our networking is derived from kubenet
Expand Down Expand Up @@ -553,3 +554,27 @@ type LyftVPCNetworkingSpec struct {

// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
type GCPNetworkingSpec struct{}

// KindnetNetworkingSpec configures Kindnet settings.
type KindnetNetworkingSpec struct {
// Version is the version of the kindnet agent.
// Default: stable
Version string `json:"version,omitempty"`
// Enable network policies
NetworkPolicies *bool `json:"networkPolicies,omitempty"`
AdminNetworkPolicies *bool `json:"adminNetworkPolicies,omitempty"`
BaselineAdminNetworkPolicies *bool `json:"baselineAdminNetworkPolicies,omitempty"`
// enable dns caching
DNSCaching *bool `json:"dnsCaching,omitempty"`
// enable nat64 on ipv6 clusters
NAT64 *bool `json:"nat64,omitempty"`
// number of packets in a connection to offload it to the fast path
FastPathThreshold *int32 `json:"fastPathThreshold,omitempty"`
// node agent masquerading rules
Masquerade *KindnetMasqueradeSpec `json:"masquerade,omitempty"`
}

type KindnetMasqueradeSpec struct {
Enabled *bool `json:"enabled,omitempty"`
NonMasqueradeCIDRs []string `json:"nonMasqueradeCIDRs,omitempty"`
}
21 changes: 20 additions & 1 deletion pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ type NetworkingSpec struct {
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
LyftVPC *LyftVPCNetworkingSpec `json:"lyftvpc,omitempty"`
GCP *GCPNetworkingSpec `json:"gce,omitempty"`
Kindnet *KindnetNetworkingSpec `json:"kindnet,omitempty"`
}

func (s *NetworkingSpec) IsEmpty() bool {
return s.Classic == nil && s.Kubenet == nil && s.External == nil && s.CNI == nil && s.Kopeio == nil &&
s.Weave == nil && s.Flannel == nil && s.Calico == nil && s.Canal == nil && s.KubeRouter == nil &&
s.Romana == nil && s.AmazonVPC == nil && s.Cilium == nil && s.LyftVPC == nil && s.GCP == nil
s.Romana == nil && s.AmazonVPC == nil && s.Cilium == nil && s.LyftVPC == nil && s.GCP == nil && s.Kindnet == nil
}

// ClassicNetworkingSpec is the specification of classic networking mode, integrated into kubernetes.
Expand Down Expand Up @@ -674,3 +675,21 @@ type LyftVPCNetworkingSpec struct {

// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
type GCPNetworkingSpec struct{}

// KindnetNetworkingSpec configures Kindnet settings.
type KindnetNetworkingSpec struct {
Version string `json:"version,omitempty"`
NetworkPolicies *bool `json:"networkPolicies,omitempty"`
AdminNetworkPolicies *bool `json:"adminNetworkPolicies,omitempty"`
BaselineAdminNetworkPolicies *bool `json:"baselineAdminNetworkPolicies,omitempty"`
DNSCaching *bool `json:"dnsCaching,omitempty"`
NAT64 *bool `json:"nat64,omitempty"`
FastPathThreshold *int32 `json:"fastPathThreshold,omitempty"`
Masquerade *KindnetMasqueradeSpec `json:"masquerade,omitempty"`
}

// KindnetMasqueradeSpec configures Kindnet masquerading settings.
type KindnetMasqueradeSpec struct {
Enabled *bool `json:"enabled,omitempty"`
NonMasqueradeCIDRs []string `json:"nonMasqueradeCIDRs,omitempty"`
}
110 changes: 110 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 44e8540

Please sign in to comment.