Skip to content

Commit

Permalink
Release 3.0.0 (#78)
Browse files Browse the repository at this point in the history
* fix: added empty tags array in subnetmeta

* feat: bgp added untagged

* feat: bgp update BGPTransport name regexp pattern

* feat: update go version

* feat: added 'untagged' option in vnet interface

* nat: changed DnatToPort type

* update readme

* update chart.yaml

* update README.md
  • Loading branch information
pogossian authored Feb 2, 2024
1 parent abe360f commit 469ac08
Show file tree
Hide file tree
Showing 26 changed files with 176 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:experimental
# Build the manager binary
FROM golang:1.17 as builder
FROM golang:1.18 as builder

WORKDIR /workspace

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ Netris Operator managing resources samples are available in the `samples/` [fold
| `v0.X` | `v2.9` |
| `v1.X` | `v3.0` |
| `v2.X` | `v3.1+` |
| `v3.X` | `v4.1+` |


## Features
* Managing Netris Controller via CRD
* Automatically creating `L4LB` resource for `type: load-balancer` services
* Integration with CNI:
| | |
| -----------| ---------------------|
| `Calico` | `Ready` |
| `Cilium` | *`In progress`* |
| `Flannel` | *`In progress`* |


* All CNIs are welcome
2 changes: 1 addition & 1 deletion api/v1alpha1/bgp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type BGPMultihop struct {
type BGPTransport struct {
// +kubebuilder:validation:Enum=port;vnet
Type string `json:"type,omitempty"`
// +kubebuilder:validation:Pattern=`(^[a-zA-Z0-9]+@[a-zA-Z0-9-]+$)|(^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$)`
// +kubebuilder:validation:Pattern=`(^[a-zA-Z0-9]+@[a-zA-Z0-9-]+$)|(^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$)`
Name string `json:"name"`
VlanID int `json:"vlanId,omitempty"`
}
Expand Down
6 changes: 2 additions & 4 deletions api/v1alpha1/nat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ type NatSpec struct {
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
DnatToIP string `json:"dnatToIp,omitempty"`

// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
DnatToPort int `json:"dnatToPort,omitempty"`
DnatToPort string `json:"dnatToPort,omitempty"`
}

// NatStatus defines the observed state of Nat
Expand All @@ -85,7 +83,7 @@ type NatStatus struct {
// +kubebuilder:printcolumn:name="SNATToIP",type=string,JSONPath=`.spec.snatToIp`,priority=1
// +kubebuilder:printcolumn:name="SNATToPool",type=string,JSONPath=`.spec.snatToPool`,priority=1
// +kubebuilder:printcolumn:name="DNATToIP",type=string,JSONPath=`.spec.dnatToIp`,priority=1
// +kubebuilder:printcolumn:name="DNATToPort",type=integer,JSONPath=`.spec.dnatToPort`,priority=1
// +kubebuilder:printcolumn:name="DNATToPort",type=string,JSONPath=`.spec.dnatToPort`,priority=1
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/natmeta_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type NatMetaSpec struct {
SnatToIP string `json:"snatToIp,omitempty"`
SnatToPool string `json:"snatToPool,omitempty"`
DnatToIP string `json:"dnatToIp,omitempty"`
DnatToPort int `json:"dnatToPort,omitempty"`
DnatToPort string `json:"dnatToPort,omitempty"`
}

// NatMetaStatus defines the observed state of NatMeta
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/vnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ type VNetSwitchPort struct {
// +kubebuilder:validation:Maximum=4094
VlanID int `json:"vlanId,omitempty"`
State string `json:"state,omitempty"`
// +kubebuilder:validation:Enum=yes;no
Untagged string `json:"untagged,omitempty"`
}

func init() {
Expand Down
13 changes: 7 additions & 6 deletions api/v1alpha1/vnetmeta_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ type VNetMetaSite struct {

// VNetMetaMember .
type VNetMetaMember struct {
Name string `json:"name"`
Access bool `json:"access"`
ID int `json:"id"`
Lacp string `json:"lacp"`
State string `json:"state"`
Vlan string `json:"vlan"`
Name string `json:"name"`
Access bool `json:"access"`
ID int `json:"id"`
Lacp string `json:"lacp"`
State string `json:"state"`
Vlan string `json:"vlan"`
Untagged string `json:"untagged,omitempty"`
}

// VNetMetaGateway .
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/k8s.netris.ai_bgps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ spec:
description: BGPTransport .
properties:
name:
pattern: (^[a-zA-Z0-9]+@[a-zA-Z0-9-]+$)|(^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$)
pattern: (^[a-zA-Z0-9]+@[a-zA-Z0-9-]+$)|(^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$)
type: string
type:
enum:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/k8s.netris.ai_natmeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
dnatToIp:
type: string
dnatToPort:
type: integer
type: string
dstAddress:
type: string
dstPort:
Expand Down
6 changes: 2 additions & 4 deletions config/crd/bases/k8s.netris.ai_nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
- jsonPath: .spec.dnatToPort
name: DNATToPort
priority: 1
type: integer
type: string
- jsonPath: .status.status
name: Status
type: string
Expand Down Expand Up @@ -96,9 +96,7 @@ spec:
pattern: (^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)
type: string
dnatToPort:
maximum: 65535
minimum: 1
type: integer
type: string
dstAddress:
pattern: (^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)
type: string
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/k8s.netris.ai_vnetmeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ spec:
type: string
state:
type: string
untagged:
type: string
vlan:
type: string
required:
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.netris.ai_vnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ spec:
type: string
state:
type: string
untagged:
enum:
- "yes"
- "no"
type: string
vlanId:
maximum: 4094
minimum: 2
Expand Down
30 changes: 19 additions & 11 deletions controllers/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
k8sv1alpha1 "github.com/netrisai/netris-operator/api/v1alpha1"
"github.com/netrisai/netris-operator/configloader"
"github.com/netrisai/netris-operator/netrisstorage"
"github.com/netrisai/netriswebapi/v2/types/vnet"
)

func init() {
Expand All @@ -36,7 +35,7 @@ func init() {

func (r *VNetReconciler) getPortsMeta(portNames []k8sv1alpha1.VNetSwitchPort) ([]k8sv1alpha1.VNetMetaMember, error) {
members := []k8sv1alpha1.VNetMetaMember{}
hwPorts := make(map[string]*vnet.VNetAddPort)
hwPorts := make(map[string]*k8sv1alpha1.VNetMetaMember)
for _, port := range portNames {
vlanID := "1"
if port.VlanID > 1 {
Expand All @@ -50,10 +49,18 @@ func (r *VNetReconciler) getPortsMeta(portNames []k8sv1alpha1.VNetSwitchPort) ([
}
}

hwPorts[port.Name] = &vnet.VNetAddPort{
Vlan: vlanID,
Lacp: "off",
State: state,
untagged := ""
if len(port.Untagged) > 0 {
if port.Untagged == "yes" || port.Untagged == "no" {
untagged = port.Untagged
}
}

hwPorts[port.Name] = &k8sv1alpha1.VNetMetaMember{
Vlan: vlanID,
Lacp: "off",
State: state,
Untagged: untagged,
}

}
Expand All @@ -69,11 +76,12 @@ func (r *VNetReconciler) getPortsMeta(portNames []k8sv1alpha1.VNetSwitchPort) ([

for _, member := range hwPorts {
members = append(members, k8sv1alpha1.VNetMetaMember{
Name: member.Name,
Lacp: member.Lacp,
State: member.State,
ID: member.ID,
Vlan: member.Vlan,
Name: member.Name,
Lacp: member.Lacp,
State: member.State,
ID: member.ID,
Vlan: member.Vlan,
Untagged: member.Untagged,
})
}
return members, nil
Expand Down
14 changes: 11 additions & 3 deletions controllers/bgp_translations.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (r *BGPReconciler) BGPToBGPMeta(bgp *k8sv1alpha1.BGP) (*k8sv1alpha1.BGPMeta
} else if bgp.Spec.Transport.Name != "" {
return nil, fmt.Errorf("coundn't find port %s", bgp.Spec.Transport.Name)
}
vlanID = 1
vlanID = -1
} else {
vnets, err := r.Cred.VNet().Get()
if err != nil {
Expand Down Expand Up @@ -214,6 +214,11 @@ func BGPMetaToNetris(bgpMeta *k8sv1alpha1.BGPMeta) (*bgp.EBGPAdd, error) {
hwID = "auto"
}

var untagged bool = false
if bgpMeta.Spec.Vlan == -1 {
untagged = true
}

bgpAdd := &bgp.EBGPAdd{
AllowAsIn: bgpMeta.Spec.AllowasIn,
BgpPassword: bgpMeta.Spec.BgpPassword,
Expand Down Expand Up @@ -245,6 +250,7 @@ func BGPMetaToNetris(bgpMeta *k8sv1alpha1.BGPMeta) (*bgp.EBGPAdd, error) {
Vlan: bgpMeta.Spec.Vlan,
Weight: bgpMeta.Spec.Weight,
Tags: []string{},
Untagged: untagged,
}

return bgpAdd, nil
Expand Down Expand Up @@ -418,8 +424,10 @@ func compareBGPMetaAPIEBGP(bgpMeta *k8sv1alpha1.BGPMeta, apiBGP *bgp.EBGP, u uni
return false
}
if apiBGP.Vlan != bgpMeta.Spec.Vlan {
u.DebugLogger.Info("Vlan changed", "netrisValue", apiBGP.Vlan, "k8sValue", bgpMeta.Spec.Vlan)
return false
if bgpMeta.Spec.Vlan != -1 {
u.DebugLogger.Info("Vlan changed", "netrisValue", apiBGP.Vlan, "k8sValue", bgpMeta.Spec.Vlan)
return false
}
}
if apiBGP.Weight != bgpMeta.Spec.Weight {
u.DebugLogger.Info("Weight changed", "netrisValue", apiBGP.Weight, "k8sValue", bgpMeta.Spec.Weight)
Expand Down
5 changes: 2 additions & 3 deletions controllers/nat_translations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers

import (
"fmt"
"strconv"
"strings"

k8sv1alpha1 "github.com/netrisai/netris-operator/api/v1alpha1"
Expand Down Expand Up @@ -135,7 +134,7 @@ func NatMetaToNetris(natMeta *k8sv1alpha1.NatMeta) (*nat.NATw, error) {
SnatToIP: natMeta.Spec.SnatToIP,
SnatToPool: natMeta.Spec.SnatToPool,
DnatToIP: natMeta.Spec.DnatToIP,
DnatToPort: strconv.Itoa(natMeta.Spec.DnatToPort),
DnatToPort: natMeta.Spec.DnatToPort,
}

return natAdd, nil
Expand All @@ -157,7 +156,7 @@ func NatMetaToNetrisUpdate(natMeta *k8sv1alpha1.NatMeta) (*nat.NATw, error) {
SnatToIP: natMeta.Spec.SnatToIP,
SnatToPool: natMeta.Spec.SnatToPool,
DnatToIP: natMeta.Spec.DnatToIP,
DnatToPort: strconv.Itoa(natMeta.Spec.DnatToPort),
DnatToPort: natMeta.Spec.DnatToPort,
}

return natAdd, nil
Expand Down
1 change: 1 addition & 0 deletions controllers/subnet_translations.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func SubnetMetaToNetris(subnetMeta *k8sv1alpha1.SubnetMeta) (*ipam.Subnet, error
Purpose: subnetMeta.Spec.Purpose,
DefaultGateway: subnetMeta.Spec.DefaultGateway,
Sites: sites,
Tags: []string{},
}

return subnetAdd, nil
Expand Down
Loading

0 comments on commit 469ac08

Please sign in to comment.