From 9031ca7932ddb05798db8551485a6b5a1572747b Mon Sep 17 00:00:00 2001 From: Guido van der Hart Date: Tue, 24 Oct 2023 13:57:08 +0200 Subject: [PATCH 01/11] feat(net): Add multizone deployment capabilities to subnets --- api/v1beta1/osccluster_validation.go | 10 + api/v1beta1/types.go | 23 +- capm.yaml | 3 + cloud/services/net/mock_net/subnet_mock.go | 8 +- cloud/services/net/subnet.go | 13 +- ...tructure.cluster.x-k8s.io_oscclusters.yaml | 3 + ....cluster.x-k8s.io_oscclustertemplates.yaml | 3 + ...osccluster_bastion_controller_unit_test.go | 19 ++ ...uster_loadbalancer_controller_unit_test.go | 4 + ...cluster_natservice_controller_unit_test.go | 9 +- ...cluster_routetable_controller_unit_test.go | 16 ++ controllers/osccluster_subnet_controller.go | 11 +- .../osccluster_subnet_controller_unit_test.go | 23 +- controllers/oscmachine_vm_controller.go | 2 +- .../oscmachine_vm_controller_unit_test.go | 2 + .../cluster-machine-template-multi-az.yaml | 242 ++++++++++++++++++ helm/clusterapioutscale/templates/crd.yaml | 3 + .../infrastructure-components.yaml | 3 + testenv/osccluster_controller_test.go | 10 +- 19 files changed, 379 insertions(+), 28 deletions(-) create mode 100644 example/cluster-machine-template-multi-az.yaml diff --git a/api/v1beta1/osccluster_validation.go b/api/v1beta1/osccluster_validation.go index 8ec719f1f..2406671a2 100644 --- a/api/v1beta1/osccluster_validation.go +++ b/api/v1beta1/osccluster_validation.go @@ -61,6 +61,16 @@ func ValidateCidr(cidr string) (string, error) { return cidr, nil } +// ValidateSubregionName check that subregionName is a valid az format +func ValidateSubregionName(subregionName string) (string, error) { + switch { + case strings.HasSuffix(subregionName, "1a") || strings.HasSuffix(subregionName, "1b") || strings.HasSuffix(subregionName, "2a") || strings.HasSuffix(subregionName, "2b"): + return subregionName, nil + default: + return subregionName, errors.New("Invalid subregionName") + } +} + // ValidateIpProtocol check that ipProtocol is valid func ValidateIpProtocol(protocol string) (string, error) { switch { diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index e32a4a30c..c2080a43b 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -164,6 +164,9 @@ type OscSubnet struct { // Subnet Ip range with CIDR notation // +optional IpSubnetRange string `json:"ipSubnetRange,omitempty"` + // The subregion name of the Subnet + // +optional + SubregionName string `json:"SubregionName,omitempty"` // The Subnet Id response // +optional ResourceId string `json:"resourceId,omitempty"` @@ -1213,10 +1216,11 @@ func (network *OscNetwork) SetSubnetDefaultValue() { var subnetKcpName string = DefaultSubnetKcpName var subnetKwName string = DefaultSubnetKwName var subnetPublicName string = DefaultSubnetPublicName + if network.ClusterName != "" { - subnetKcpName = strings.Replace(DefaultSubnetKcpName, DefaultClusterName, network.ClusterName, -1) - subnetKwName = strings.Replace(DefaultSubnetKwName, DefaultClusterName, network.ClusterName, -1) - subnetPublicName = strings.Replace(DefaultSubnetPublicName, DefaultClusterName, network.ClusterName, -1) + subnetKcpName = strings.Replace(subnetKcpName, DefaultClusterName, network.ClusterName, -1) + subnetKwName = strings.Replace(subnetKwName, DefaultClusterName, network.ClusterName, -1) + subnetPublicName = strings.Replace(subnetPublicName, DefaultClusterName, network.ClusterName, -1) } subnetKcp := OscSubnet{ Name: subnetKcpName, @@ -1238,6 +1242,19 @@ func (network *OscNetwork) SetSubnetDefaultValue() { } } +// SetSubnetSubregionNameValue set the Subnet Subregion Name values from OscNetwork configuration +func (network *OscNetwork) SetSubnetSubregionNameDefaultValue() { + var defaultSubregionName string = DefaultSubregionName + if network.SubregionName != "" { + defaultSubregionName = network.SubregionName + } + for _, subnet := range network.Subnets { + if subnet.SubregionName == "" { + subnet.SubregionName = defaultSubregionName + } + } +} + // SetDefaultValue set the LoadBalancer Service default values func (lb *OscLoadBalancer) SetDefaultValue() { var subnetPublicName string = DefaultSubnetPublicName diff --git a/capm.yaml b/capm.yaml index 4c79f3334..16ca34a9c 100644 --- a/capm.yaml +++ b/capm.yaml @@ -370,6 +370,9 @@ spec: resourceId: description: The Subnet Id response type: string + subregionName: + description: The subregion name of the Subnet + type: string type: object type: array subregionName: diff --git a/cloud/services/net/mock_net/subnet_mock.go b/cloud/services/net/mock_net/subnet_mock.go index bde952484..50bee1f2c 100644 --- a/cloud/services/net/mock_net/subnet_mock.go +++ b/cloud/services/net/mock_net/subnet_mock.go @@ -36,18 +36,18 @@ func (m *MockOscSubnetInterface) EXPECT() *MockOscSubnetInterfaceMockRecorder { } // CreateSubnet mocks base method. -func (m *MockOscSubnetInterface) CreateSubnet(spec *v1beta1.OscSubnet, netId, clusterName, subnetName, subregionName string) (*osc.Subnet, error) { +func (m *MockOscSubnetInterface) CreateSubnet(spec *v1beta1.OscSubnet, netId, clusterName, subnetName) (*osc.Subnet, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateSubnet", spec, netId, clusterName, subnetName, subregionName) + ret := m.ctrl.Call(m, "CreateSubnet", spec, netId, clusterName, subnetName) ret0, _ := ret[0].(*osc.Subnet) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateSubnet indicates an expected call of CreateSubnet. -func (mr *MockOscSubnetInterfaceMockRecorder) CreateSubnet(spec, netId, clusterName, subnetName, subregionName interface{}) *gomock.Call { +func (mr *MockOscSubnetInterfaceMockRecorder) CreateSubnet(spec, netId, clusterName, subnetName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSubnet", reflect.TypeOf((*MockOscSubnetInterface)(nil).CreateSubnet), spec, netId, clusterName, subnetName, subregionName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSubnet", reflect.TypeOf((*MockOscSubnetInterface)(nil).CreateSubnet), spec, netId, clusterName, subnetName) } // DeleteSubnet mocks base method. diff --git a/cloud/services/net/subnet.go b/cloud/services/net/subnet.go index 54a41cce5..3db590d64 100644 --- a/cloud/services/net/subnet.go +++ b/cloud/services/net/subnet.go @@ -21,32 +21,37 @@ import ( "errors" + _nethttp "net/http" + infrastructurev1beta1 "github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1" tag "github.com/outscale-dev/cluster-api-provider-outscale.git/cloud/tag" "github.com/outscale-dev/cluster-api-provider-outscale.git/util/reconciler" osc "github.com/outscale/osc-sdk-go/v2" "k8s.io/apimachinery/pkg/util/wait" - _nethttp "net/http" ) //go:generate ../../../bin/mockgen -destination mock_net/subnet_mock.go -package mock_net -source ./subnet.go type OscSubnetInterface interface { - CreateSubnet(spec *infrastructurev1beta1.OscSubnet, netId string, clusterName string, subnetName string, subregionName string) (*osc.Subnet, error) + CreateSubnet(spec *infrastructurev1beta1.OscSubnet, netId string, clusterName string, subnetName string) (*osc.Subnet, error) DeleteSubnet(subnetId string) error GetSubnet(subnetId string) (*osc.Subnet, error) GetSubnetIdsFromNetIds(netId string) ([]string, error) } // CreateSubnet create the subnet associate to the net -func (s *Service) CreateSubnet(spec *infrastructurev1beta1.OscSubnet, netId string, clusterName string, subnetName string, subregionName string) (*osc.Subnet, error) { +func (s *Service) CreateSubnet(spec *infrastructurev1beta1.OscSubnet, netId string, clusterName string, subnetName string) (*osc.Subnet, error) { ipSubnetRange, err := infrastructurev1beta1.ValidateCidr(spec.IpSubnetRange) if err != nil { return nil, err } + subregionName, err := infrastructurev1beta1.ValidateSubregionName(spec.SubregionName) + if err != nil { + return nil, err + } subnetRequest := osc.CreateSubnetRequest{ IpRange: ipSubnetRange, NetId: netId, - SubregionName: &subregionName, + SubregionName: subregionName, } oscApiClient := s.scope.GetApi() oscAuthClient := s.scope.GetAuth() diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml index 82d33e05f..52efa3dfb 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml @@ -351,6 +351,9 @@ spec: resourceId: description: The Subnet Id response type: string + subregionName: + description: The subregion name of the Subnet + type: string type: object type: array subregionName: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml index 5d7b3497a..d091a0948 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml @@ -415,6 +415,9 @@ spec: resourceId: description: The Subnet Id response type: string + subregionName: + description: The subregion name of the Subnet + type: string type: object type: array subregionName: diff --git a/controllers/osccluster_bastion_controller_unit_test.go b/controllers/osccluster_bastion_controller_unit_test.go index 151498344..760584ce2 100644 --- a/controllers/osccluster_bastion_controller_unit_test.go +++ b/controllers/osccluster_bastion_controller_unit_test.go @@ -44,6 +44,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -116,6 +117,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -190,6 +192,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -347,6 +350,7 @@ func TestCheckBastionSecurityGroupOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -459,6 +463,7 @@ func TestCheckBastionSubnetAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -572,6 +577,7 @@ func TestCheckBastionPublicIpOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -673,6 +679,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -749,6 +756,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -824,6 +832,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -911,6 +920,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -986,6 +996,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1063,6 +1074,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1138,6 +1150,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1212,6 +1225,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1287,6 +1301,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1362,6 +1377,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1437,6 +1453,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1512,6 +1529,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -1587,6 +1605,7 @@ func TestCheckBastionFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ diff --git a/controllers/osccluster_loadbalancer_controller_unit_test.go b/controllers/osccluster_loadbalancer_controller_unit_test.go index d0d52dd3b..fd2134406 100644 --- a/controllers/osccluster_loadbalancer_controller_unit_test.go +++ b/controllers/osccluster_loadbalancer_controller_unit_test.go @@ -45,6 +45,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -83,6 +84,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -147,6 +149,7 @@ func TestCheckLoadBalancerSubnetOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -449,6 +452,7 @@ func TestCheckLoadBalancerSecurityGroupOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ diff --git a/controllers/osccluster_natservice_controller_unit_test.go b/controllers/osccluster_natservice_controller_unit_test.go index e1682266b..ce3165c8d 100644 --- a/controllers/osccluster_natservice_controller_unit_test.go +++ b/controllers/osccluster_natservice_controller_unit_test.go @@ -19,9 +19,10 @@ package controllers import ( "context" "fmt" - "github.com/stretchr/testify/assert" "testing" + "github.com/stretchr/testify/assert" + "github.com/golang/mock/gomock" infrastructurev1beta1 "github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1" "github.com/outscale-dev/cluster-api-provider-outscale.git/cloud/scope" @@ -47,6 +48,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, PublicIps: []*infrastructurev1beta1.OscPublicIp{ @@ -73,6 +75,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -177,6 +180,7 @@ func TestCheckNatFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, PublicIps: []*infrastructurev1beta1.OscPublicIp{ @@ -205,6 +209,7 @@ func TestCheckNatFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, PublicIps: []*infrastructurev1beta1.OscPublicIp{ @@ -233,6 +238,7 @@ func TestCheckNatFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -295,6 +301,7 @@ func TestCheckNatSubnetOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, PublicIps: []*infrastructurev1beta1.OscPublicIp{ diff --git a/controllers/osccluster_routetable_controller_unit_test.go b/controllers/osccluster_routetable_controller_unit_test.go index 42ba7b6ee..18013c1a9 100644 --- a/controllers/osccluster_routetable_controller_unit_test.go +++ b/controllers/osccluster_routetable_controller_unit_test.go @@ -44,6 +44,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -79,6 +80,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -123,6 +125,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -164,6 +167,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -208,6 +212,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -255,6 +260,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -431,6 +437,7 @@ func TestCheckRouteTableSubnetOscAssociateResourceName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -501,6 +508,7 @@ func TestCheckRouteTableFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -572,6 +580,7 @@ func TestCheckRouteFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -609,6 +618,7 @@ func TestCheckRouteFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -646,6 +656,7 @@ func TestCheckRouteFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -711,6 +722,7 @@ func TestCheckRouteTableOscDuplicateName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -800,6 +812,7 @@ func TestCheckRouteOscDuplicateName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -843,6 +856,7 @@ func TestCheckRouteOscDuplicateName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -886,6 +900,7 @@ func TestCheckRouteOscDuplicateName(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -1792,6 +1807,7 @@ func TestReconcileCreateRouteTable(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, InternetService: infrastructurev1beta1.OscInternetService{ diff --git a/controllers/osccluster_subnet_controller.go b/controllers/osccluster_subnet_controller.go index f2b094524..41fd565d7 100644 --- a/controllers/osccluster_subnet_controller.go +++ b/controllers/osccluster_subnet_controller.go @@ -48,6 +48,7 @@ func checkSubnetFormatParameters(clusterScope *scope.ClusterScope) (string, erro } else { subnetsSpec = clusterScope.GetSubnet() } + networkSpec.SetSubnetSubregionNameDefaultValue() for _, subnetSpec := range subnetsSpec { subnetName := subnetSpec.Name + "-" + clusterScope.GetUID() clusterScope.V(2).Info("Check subnet name parameters") @@ -61,9 +62,14 @@ func checkSubnetFormatParameters(clusterScope *scope.ClusterScope) (string, erro if err != nil { return subnetTagName, err } + subnetSubregionName := subnetSpec.SubregionName + clusterScope.V(2).Info("Check subnet subregion parameters") + _, err = infrastructurev1beta1.ValidateSubregionName(subnetSubregionName) + if err != nil { + return subnetTagName, err + } } return "", nil - } // checkSubnetOscDuplicateName check that there are not the same name for subnet @@ -104,7 +110,6 @@ func reconcileSubnet(ctx context.Context, clusterScope *scope.ClusterScope, subn if err != nil { return reconcile.Result{}, err } - subregionName := networkSpec.SubregionName clusterScope.V(4).Info("Number of subnet", "subnet_length", len(subnetsSpec)) for _, subnetSpec := range subnetsSpec { subnetName := subnetSpec.Name + "-" + clusterScope.GetUID() @@ -128,7 +133,7 @@ func reconcileSubnet(ctx context.Context, clusterScope *scope.ClusterScope, subn } if !Contains(subnetIds, subnetId) && tag == nil { clusterScope.V(2).Info("Create the desired subnet", "subnetName", subnetName) - subnet, err := subnetSvc.CreateSubnet(subnetSpec, netId, clusterName, subnetName, subregionName) + subnet, err := subnetSvc.CreateSubnet(subnetSpec, netId, clusterName, subnetName) if err != nil { return reconcile.Result{}, fmt.Errorf("%w Can not create subnet for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) } diff --git a/controllers/osccluster_subnet_controller_unit_test.go b/controllers/osccluster_subnet_controller_unit_test.go index 7ee472dfd..874f81ace 100644 --- a/controllers/osccluster_subnet_controller_unit_test.go +++ b/controllers/osccluster_subnet_controller_unit_test.go @@ -35,8 +35,7 @@ import ( var ( defaultSubnetInitialize = infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - ClusterName: "test-cluster", - SubregionName: "eu-west-2a", + ClusterName: "test-cluster", Net: infrastructurev1beta1.OscNet{ Name: "test-net", IpRange: "10.0.0.0/16", @@ -45,14 +44,14 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, }, } defaultSubnetReconcile = infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - ClusterName: "test-cluster", - SubregionName: "eu-west-2a", + ClusterName: "test-cluster", Net: infrastructurev1beta1.OscNet{ Name: "test-net", IpRange: "10.0.0.0/16", @@ -62,6 +61,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, @@ -70,8 +70,7 @@ var ( defaultMultiSubnetInitialize = infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - ClusterName: "test-cluster", - SubregionName: "eu-west-2a", + ClusterName: "test-cluster", Net: infrastructurev1beta1.OscNet{ Name: "test-net", IpRange: "10.0.0.0/16", @@ -80,18 +79,19 @@ var ( { Name: "test-subnet-first", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, { Name: "test-subnet-second", IpSubnetRange: "10.0.1.0/24", + SubregionName: "eu-west-2b", }, }, }, } defaultMultiSubnetReconcile = infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - ClusterName: "test-cluster", - SubregionName: "eu-west-2a", + ClusterName: "test-cluster", Net: infrastructurev1beta1.OscNet{ Name: "test-net", IpRange: "10.0.0.0/16", @@ -101,11 +101,13 @@ var ( { Name: "test-subnet-first", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-first-uid", }, { Name: "test-subnet-second", IpSubnetRange: "10.0.1.0/24", + SubregionName: "eu-west-2b", ResourceId: "subnet-test-subnet-second-uid", }, }, @@ -194,10 +196,12 @@ func TestCheckSubnetOscDuplicateName(t *testing.T) { { Name: "test-subnet-first", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, { Name: "test-subnet-first", IpSubnetRange: "10.0.1.0/24", + SubregionName: "eu-west-2b", }, }, }, @@ -250,6 +254,7 @@ func TestCheckSubnetFormatParameters(t *testing.T) { { Name: "test-subnet@test", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, }, @@ -268,6 +273,7 @@ func TestCheckSubnetFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.0/36", + SubregionName: "eu-west-2a", }, }, }, @@ -286,6 +292,7 @@ func TestCheckSubnetFormatParameters(t *testing.T) { { Name: "test-subnet", IpSubnetRange: "10.0.0.256/16", + SubregionName: "eu-west-2a", }, }, }, diff --git a/controllers/oscmachine_vm_controller.go b/controllers/oscmachine_vm_controller.go index cd4f9b274..39a65bc2b 100644 --- a/controllers/oscmachine_vm_controller.go +++ b/controllers/oscmachine_vm_controller.go @@ -129,7 +129,7 @@ func checkVmSecurityGroupOscAssociateResourceName(machineScope *scope.MachineSco return nil } -// checkVmSubnetOscAssociateResourceName check that Subnet dependancies tag name in both resource configuration are the same. +// checkVmSubnetOscAssociateResourceName check that Subnet dependencies tag name in both resource configuration are the same. func checkVmSubnetOscAssociateResourceName(machineScope *scope.MachineScope, clusterScope *scope.ClusterScope) error { var resourceNameList []string vmSpec := machineScope.GetVm() diff --git a/controllers/oscmachine_vm_controller_unit_test.go b/controllers/oscmachine_vm_controller_unit_test.go index 84bb9c036..a1c78e79a 100644 --- a/controllers/oscmachine_vm_controller_unit_test.go +++ b/controllers/oscmachine_vm_controller_unit_test.go @@ -48,6 +48,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", }, }, SecurityGroups: []*infrastructurev1beta1.OscSecurityGroup{ @@ -92,6 +93,7 @@ var ( { Name: "test-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: "eu-west-2a", ResourceId: "subnet-test-subnet-uid", }, }, diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml new file mode 100644 index 000000000..5cdd6abf3 --- /dev/null +++ b/example/cluster-machine-template-multi-az.yaml @@ -0,0 +1,242 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: cluster-api-multi-az + namespace: default + labels: + cni: "cluster-api-multi-az-crs-cni" + ccm: "cluster-api-multi-az-crs-ccm" +spec: + clusterNetwork: + pods: + cidrBlocks: ["10.42.0.0/16"] + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscCluster + name: cluster-api-multi-az + namespace: default + controlPlaneRef: + kind: KubeadmControlPlane + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + name: "cluster-api-multi-az-control-plane" + namespace: default +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscCluster +metadata: + name: cluster-api-multi-az + namespace: default +spec: + network: + clusterName: cluster-api-multi-az + loadBalancer: + loadbalancername: capo-k8s + clusterName: cluster-api-multi-az + net: + clusterName: cluster-api-multi-az + internetService: + clusterName: cluster-api-multi-az + natService: + clusterName: cluster-api-multi-az + bastion: + clusterName: cluster-api-multi-az + enable: false + subnets: + - name: cluster-api-multi-az-eu-west-2a + ipSubnetRange: ["10.42.0.0/24"] + subregionName: eu-west-2a + - name: cluster-api-multi-az-eu-west-2b + ipSubnetRange: ["10.42.1.0/24"] + subregionName: eu-west-2b +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "cluster-api-multi-az-md-0-eu-west-2a" + namespace: default +spec: + clusterName: "cluster-api-multi-az" + replicas: 1 + selector: + matchLabels: + template: + spec: + clusterName: "cluster-api-multi-az" + version: "1.22.11" + bootstrap: + configRef: + name: "cluster-api-multi-az-md-0" + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: default + infrastructureRef: + name: "cluster-api-multi-az-md-0-eu-west-2a" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: default +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "cluster-api-multi-az-md-0-eu-west-2b" + namespace: default +spec: + clusterName: "cluster-api-multi-az" + replicas: 1 + selector: + matchLabels: + template: + spec: + clusterName: "cluster-api-multi-az" + version: "1.22.11" + bootstrap: + configRef: + name: "cluster-api-multi-az-md-0" + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: default + infrastructureRef: + name: "cluster-api-multi-az-md-0-eu-west-2b" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: default +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-multi-az-md-0-eu-west-2a" + namespace: default +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: true + vm: + clusterName: cluster-api-multi-az + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: "gp2" + keypairName: cluster-api-test + subnetName: cluster-api-multi-az-eu-west-2a + vmType: "tinav6.c2r4p2" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-multi-az-md-0-eu-west-2b" + namespace: default +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: true + vm: + clusterName: cluster-api-multi-az + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: "gp2" + keypairName: cluster-api-test + subnetName: cluster-api-multi-az-eu-west-2b + vmType: "tinav6.c2r4p2" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-multi-az-control-plane" + namespace: default +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: true + vm: + clusterName: cluster-api-multi-az + keypairName: cluster-api-test + subnetName: cluster-api-multi-az-eu-west-2a + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: "gp2" + role: controlplane + loadBalancerName: capo-k8s + vmType: "tinav6.c4r8p1" +--- +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: KubeadmConfigTemplate +metadata: + name: "cluster-api-multi-az-md-0" + namespace: default +spec: + template: + spec: + files: + - content: | + #!/bin/bash + + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + \cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + name: "{{ ds.meta_data.local_hostname }}" + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + preKubeadmCommands: + - sh /tmp/set_runc.sh +--- +kind: KubeadmControlPlane +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +metadata: + name: "cluster-api-multi-az-control-plane" +spec: + replicas: 1 + machineTemplate: + infrastructureRef: + kind: OscMachineTemplate + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + name: "cluster-api-multi-az-control-plane" + namespace: default + kubeadmConfigSpec: + initConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + name: '{{ ds.meta_data.local_hostname }}' + files: + - content: | + #!/bin/bash + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + \cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + preKubeadmCommands: + - sh /tmp/set_runc.sh + version: "1.22.11" diff --git a/helm/clusterapioutscale/templates/crd.yaml b/helm/clusterapioutscale/templates/crd.yaml index b8d7838cf..a03ffc6df 100644 --- a/helm/clusterapioutscale/templates/crd.yaml +++ b/helm/clusterapioutscale/templates/crd.yaml @@ -291,6 +291,9 @@ spec: resourceId: description: The Subnet Id response type: string + subregionName: + description: The subregion name of the Subnet + type: string type: object type: array type: object diff --git a/test/e2e/data/infrastructure-outscale/infrastructure-components.yaml b/test/e2e/data/infrastructure-outscale/infrastructure-components.yaml index 4abdf21cd..5b33d0cb6 100644 --- a/test/e2e/data/infrastructure-outscale/infrastructure-components.yaml +++ b/test/e2e/data/infrastructure-outscale/infrastructure-components.yaml @@ -260,6 +260,9 @@ spec: resourceId: description: The Subnet Id response type: string + subregionName: + description: The subregion name of the Subnet + type: string type: object type: array type: object diff --git a/testenv/osccluster_controller_test.go b/testenv/osccluster_controller_test.go index fe70f6b94..bb241095c 100644 --- a/testenv/osccluster_controller_test.go +++ b/testenv/osccluster_controller_test.go @@ -714,7 +714,6 @@ var _ = Describe("Outscale Cluster Reconciler", func() { infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - SubregionName: osc_subregion, Net: infrastructurev1beta1.OscNet{ Name: "cluster-api-net", IpRange: "10.0.0.0/16", @@ -723,6 +722,7 @@ var _ = Describe("Outscale Cluster Reconciler", func() { { Name: "cluster-api-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: osc_subregion, }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -795,7 +795,6 @@ var _ = Describe("Outscale Cluster Reconciler", func() { } infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - SubregionName: osc_subregion, Net: infrastructurev1beta1.OscNet{ Name: "cluster-api-net", IpRange: "10.0.0.0/16", @@ -804,10 +803,12 @@ var _ = Describe("Outscale Cluster Reconciler", func() { { Name: "cluster-api-subnet", IpSubnetRange: "10.0.0.0/24", + SubregionName: osc_subregion, }, { Name: "cluster-api-sub", IpSubnetRange: "10.0.1.0/24", + SubregionName: osc_subregion, }, }, InternetService: infrastructurev1beta1.OscInternetService{ @@ -900,7 +901,6 @@ var _ = Describe("Outscale Cluster Reconciler", func() { } infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - SubregionName: osc_subregion, Net: infrastructurev1beta1.OscNet{ Name: "cluster-api-net", }, @@ -928,7 +928,6 @@ var _ = Describe("Outscale Cluster Reconciler", func() { } infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ - SubregionName: osc_subregion, Net: infrastructurev1beta1.OscNet{ Name: "cluster-api-net", IpRange: "10.0.0.0/16", @@ -937,14 +936,17 @@ var _ = Describe("Outscale Cluster Reconciler", func() { { Name: "cluster-api-subnet-kcp", IpSubnetRange: "10.0.4.0/24", + SubregionName: osc_subregion, }, { Name: "cluster-api-subnet-kw", IpSubnetRange: "10.0.3.0/24", + SubregionName: osc_subregion, }, { Name: "cluster-api-subnet-public", IpSubnetRange: "10.0.2.0/24", + SubregionName: osc_subregion, }, }, InternetService: infrastructurev1beta1.OscInternetService{ From 42520ec4543a56ff2dd79cf8454a75c80022a9a7 Mon Sep 17 00:00:00 2001 From: Guido van der Hart Date: Mon, 30 Oct 2023 15:27:04 +0100 Subject: [PATCH 02/11] Apply fixes and update example --- api/v1beta1/osccluster_validation.go | 10 - api/v1beta1/types.go | 2 +- apicovers.html | 3543 ++++++++++++ apicovers.txt | 163 + cloud/services/net/mock_net/subnet_mock.go | 2 +- cloud/services/net/subnet.go | 2 +- .../osccluster_subnet_controller_unit_test.go | 5 +- covers.html | 4784 +++++++++++++++++ covers.txt | 119 + .../cluster-machine-template-multi-az.yaml | 4 +- testenv/osccluster_controller_test.go | 8 - 11 files changed, 8616 insertions(+), 26 deletions(-) create mode 100644 apicovers.html create mode 100644 apicovers.txt create mode 100644 covers.html create mode 100644 covers.txt diff --git a/api/v1beta1/osccluster_validation.go b/api/v1beta1/osccluster_validation.go index 2406671a2..8ec719f1f 100644 --- a/api/v1beta1/osccluster_validation.go +++ b/api/v1beta1/osccluster_validation.go @@ -61,16 +61,6 @@ func ValidateCidr(cidr string) (string, error) { return cidr, nil } -// ValidateSubregionName check that subregionName is a valid az format -func ValidateSubregionName(subregionName string) (string, error) { - switch { - case strings.HasSuffix(subregionName, "1a") || strings.HasSuffix(subregionName, "1b") || strings.HasSuffix(subregionName, "2a") || strings.HasSuffix(subregionName, "2b"): - return subregionName, nil - default: - return subregionName, errors.New("Invalid subregionName") - } -} - // ValidateIpProtocol check that ipProtocol is valid func ValidateIpProtocol(protocol string) (string, error) { switch { diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index c2080a43b..306ae9780 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -166,7 +166,7 @@ type OscSubnet struct { IpSubnetRange string `json:"ipSubnetRange,omitempty"` // The subregion name of the Subnet // +optional - SubregionName string `json:"SubregionName,omitempty"` + SubregionName string `json:"subregionName,omitempty"` // The Subnet Id response // +optional ResourceId string `json:"resourceId,omitempty"` diff --git a/apicovers.html b/apicovers.html new file mode 100644 index 000000000..8717deee8 --- /dev/null +++ b/apicovers.html @@ -0,0 +1,3543 @@ + + + + + + v1beta1: Go Coverage Report + + + +
+ +
+ not tracked + + not covered + covered + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/apicovers.txt b/apicovers.txt new file mode 100644 index 000000000..125dbba6a --- /dev/null +++ b/apicovers.txt @@ -0,0 +1,163 @@ +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:26: OscReplaceName 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:67: GetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:72: SetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:76: init 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:40: ValidateOscClusterSpec 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:53: ValidateCidr 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:65: ValidateIpProtocol 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:75: ValidateFlow 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:85: ValidateDescription 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:95: ValidatePort 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:104: ValidateLoadBalancerType 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:113: ValidateInterval 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:122: ValidateThreshold 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:131: ValidateProtocol 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:143: ValidateTimeout 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:152: ValidateLoadBalancerName 75.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:161: ValidateAndReturnErrorList 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:33: SetupWebhookWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:43: Default 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:53: ValidateCreate 80.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:63: ValidateUpdate 80.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:84: ValidateDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_types.go:53: init 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:38: SetupWebhookWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:46: Default 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:57: ValidateCreate 80.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:67: ValidateUpdate 75.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:83: ValidateDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:65: GetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:70: SetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:74: init 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:35: ValidateOscMachineSpec 87.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:115: ValidateKeypairName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:125: ValidateImageId 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:135: ValidateRatioSizeIops 66.7% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:145: ValidateImageName 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:155: ValidateIops 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:164: ValidateSize 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:173: ValidateVolumeType 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:183: ValidateSubregionName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:193: ValidateDeviceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:204: ValidateVmType 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:33: SetupWebhookWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:42: Default 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:52: ValidateCreate 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:62: ValidateUpdate 85.3% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:141: ValidateDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:63: GetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:67: SetConditions 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:71: init 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:36: SetupWebhookWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:45: Default 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:55: ValidateCreate 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:65: ValidateUpdate 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:81: ValidateDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/tags.go:31: ClusterTagKey 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:614: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:628: SetVolumeDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:664: SetKeyPairDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:684: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:695: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:796: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:843: SetImageDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:850: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:871: SetRouteTableDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:951: SetSecurityGroupDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1200: SetPublicIpDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1214: SetSubnetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1246: SetSubnetSubregionNameDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1259: SetDefaultValue 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:32: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:48: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:58: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:67: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:77: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:85: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:99: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:109: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:117: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:124: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:134: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:152: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:162: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:170: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:180: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:188: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:202: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:212: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:220: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:227: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:237: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:243: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:253: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:258: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:268: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:273: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:283: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:288: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:298: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:305: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:315: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:320: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:330: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:335: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:345: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:354: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:364: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:372: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:386: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:396: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:404: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:415: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:425: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:458: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:468: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:477: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:487: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:495: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:509: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:519: DeepCopyObject 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:527: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:534: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:544: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:550: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:560: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:579: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:589: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:594: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:604: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:609: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:619: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:674: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:684: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:716: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:726: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:745: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:755: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:765: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:775: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:780: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:790: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:795: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:805: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:817: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:827: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:832: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:842: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:847: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:857: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:872: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:882: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:892: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:902: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:907: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:917: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:922: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:932: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:937: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:947: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:963: DeepCopy 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:973: DeepCopyInto 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:978: DeepCopy 0.0% +total: (statements) 14.9% diff --git a/cloud/services/net/mock_net/subnet_mock.go b/cloud/services/net/mock_net/subnet_mock.go index 50bee1f2c..e945c03f4 100644 --- a/cloud/services/net/mock_net/subnet_mock.go +++ b/cloud/services/net/mock_net/subnet_mock.go @@ -36,7 +36,7 @@ func (m *MockOscSubnetInterface) EXPECT() *MockOscSubnetInterfaceMockRecorder { } // CreateSubnet mocks base method. -func (m *MockOscSubnetInterface) CreateSubnet(spec *v1beta1.OscSubnet, netId, clusterName, subnetName) (*osc.Subnet, error) { +func (m *MockOscSubnetInterface) CreateSubnet(spec *v1beta1.OscSubnet, netId, clusterName, subnetName string) (*osc.Subnet, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateSubnet", spec, netId, clusterName, subnetName) ret0, _ := ret[0].(*osc.Subnet) diff --git a/cloud/services/net/subnet.go b/cloud/services/net/subnet.go index 3db590d64..d7eb58c42 100644 --- a/cloud/services/net/subnet.go +++ b/cloud/services/net/subnet.go @@ -51,7 +51,7 @@ func (s *Service) CreateSubnet(spec *infrastructurev1beta1.OscSubnet, netId stri subnetRequest := osc.CreateSubnetRequest{ IpRange: ipSubnetRange, NetId: netId, - SubregionName: subregionName, + SubregionName: &subregionName, } oscApiClient := s.scope.GetApi() oscAuthClient := s.scope.GetAuth() diff --git a/controllers/osccluster_subnet_controller_unit_test.go b/controllers/osccluster_subnet_controller_unit_test.go index 874f81ace..90f564d84 100644 --- a/controllers/osccluster_subnet_controller_unit_test.go +++ b/controllers/osccluster_subnet_controller_unit_test.go @@ -392,7 +392,6 @@ func TestReconcileSubnetCreate(t *testing.T) { } subnetsSpec := stc.spec.Network.Subnets var subnetIds []string - subregionName := stc.spec.Network.SubregionName for _, subnetSpec := range subnetsSpec { subnetName := subnetSpec.Name + "-uid" subnetId := "subnet-" + subnetName @@ -423,12 +422,12 @@ func TestReconcileSubnetCreate(t *testing.T) { subnetRef.ResourceMap[subnetName] = subnetId mockOscSubnetInterface. EXPECT(). - CreateSubnet(gomock.Eq(subnetSpec), gomock.Eq(netId), gomock.Eq(clusterName), gomock.Eq(subnetName), gomock.Eq(subregionName)). + CreateSubnet(gomock.Eq(subnetSpec), gomock.Eq(netId), gomock.Eq(clusterName), gomock.Eq(subnetName)). Return(subnet.Subnet, stc.expCreateSubnetErr) } else { mockOscSubnetInterface. EXPECT(). - CreateSubnet(gomock.Eq(subnetSpec), gomock.Eq(netId), gomock.Eq(clusterName), gomock.Eq(subnetName), gomock.Eq(subregionName)). + CreateSubnet(gomock.Eq(subnetSpec), gomock.Eq(netId), gomock.Eq(clusterName), gomock.Eq(subnetName)). Return(nil, stc.expCreateSubnetErr) } } diff --git a/covers.html b/covers.html new file mode 100644 index 000000000..17d5b2cf3 --- /dev/null +++ b/covers.html @@ -0,0 +1,4784 @@ + + + + + + controllers: Go Coverage Report + + + +
+ +
+ not tracked + + not covered + covered + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/covers.txt b/covers.txt new file mode 100644 index 000000000..bea797bd1 --- /dev/null +++ b/covers.txt @@ -0,0 +1,119 @@ +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:34: getBastionResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:44: checkBastionSecurityGroupOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:71: checkBastionSubnetOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:91: checkBastionPublicIpOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:111: checkBastionFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:202: reconcileBastion 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:322: reconcileDeleteBastion 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:62: getNetSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:67: getSubnetSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:72: getInternetServiceSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:77: getRouteTableSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:82: getSecurityGroupSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:87: getNatServiceSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:92: getPublicIpSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:97: getLoadBalancerSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:102: getVmSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:107: getImageSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:112: getTagSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:116: Reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:171: alertDuplicate 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:184: Contains 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:194: reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:415: reconcileDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:495: SetupWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:31: getInternetServiceResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:41: checkInternetServiceFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:54: reconcileInternetService 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:104: reconcileDeleteInternetService 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:35: checkLoadBalancerSubnetOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:54: checkLoadBalancerFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:134: checkLoadBalancerSecurityGroupOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:153: reconcileLoadBalancer 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:233: reconcileDeleteLoadBalancer 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:32: getNatResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:41: checkNatFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:63: checkNatSubnetOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:83: reconcileNatService 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:137: reconcileDeleteNatService 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:33: getNetResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:43: checkNetFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:61: reconcileNet 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:105: reconcileDeleteNet 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:32: getPublicIpResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:41: getLinkPublicIpResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:51: checkPublicIpFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:72: checkPublicIpOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:95: checkPublicIpOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:111: reconcilePublicIp 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:165: reconcileDeletePublicIp 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:32: getRouteTableResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:42: getRouteResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:52: checkRouteTableFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:73: checkRouteFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:96: checkRouteTableSubnetOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:122: checkRouteTableOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:138: checkRouteOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:158: reconcileRoute 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:202: reconcileDeleteRoute 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:251: reconcileRouteTable 93.6% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:361: reconcileDeleteRouteTable 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:38: getSecurityGroupResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:48: getSecurityGroupRulesResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:58: checkSecurityGroupOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:74: checkSecurityGroupRuleOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:94: checkSecurityGroupFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:120: checkSecurityGroupRuleFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:170: reconcileSecurityGroupRule 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:205: deleteSecurityGroup 96.6% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:251: reconcileSecurityGroup 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:328: reconcileDeleteSecurityGroupRule 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:360: reconcileDeleteSecurityGroup 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:32: getSubnetResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:42: checkSubnetFormatParameters 95.8% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:76: checkSubnetOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:92: reconcileSubnet 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:148: reconcileDeleteSubnet 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:77: getVolumeSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:82: getVmSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:87: getImageSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:92: getPublicIpSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:97: getSecurityGroupSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:102: getLoadBalancerSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:107: getKeyPairSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:112: getTagSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:115: Reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:193: reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:354: reconcileDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:383: SetupWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:413: OscClusterToOscMachines 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:31: checkImageFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:50: getImageResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:60: reconcileImage 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:34: checkKeypairFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:55: getKeyPairResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:65: reconcileKeypair 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:98: reconcileDeleteKeypair 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:40: getVmResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:50: checkVmVolumeOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:70: checkVmLoadBalancerOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:90: checkVmVolumeSubregionName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:106: checkVmSecurityGroupOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:133: checkVmSubnetOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:153: checkVmPublicIpOscAssociateResourceName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:173: checkVmFormatParameters 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:284: checkVmPrivateIpOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:301: reconcileVm 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:523: reconcileDeleteVm 77.9% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:33: getVolumeResourceId 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:43: checkVolumeOscDuplicateName 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:59: checkVolumeFormatParameters 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:109: reconcileVolume 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:164: reconcileDeleteVolume 100.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:38: getVmSvc 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:52: Reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:120: reconcile 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:138: reconcileDelete 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:146: SetupWithManager 0.0% +github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_controller.go:31: reconcileCapacity 48.1% +total: (statements) 76.7% diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index 5cdd6abf3..0727c906a 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -43,10 +43,10 @@ spec: enable: false subnets: - name: cluster-api-multi-az-eu-west-2a - ipSubnetRange: ["10.42.0.0/24"] + ipSubnetRange: "10.42.0.0/24" subregionName: eu-west-2a - name: cluster-api-multi-az-eu-west-2b - ipSubnetRange: ["10.42.1.0/24"] + ipSubnetRange: "10.42.1.0/24" subregionName: eu-west-2b --- apiVersion: cluster.x-k8s.io/v1beta1 diff --git a/testenv/osccluster_controller_test.go b/testenv/osccluster_controller_test.go index bb241095c..20b360a1c 100644 --- a/testenv/osccluster_controller_test.go +++ b/testenv/osccluster_controller_test.go @@ -891,14 +891,6 @@ var _ = Describe("Outscale Cluster Reconciler", func() { }) It("should create a simple cluster with default values", func() { ctx := context.Background() - osc_region, ok := os.LookupEnv("OSC_REGION") - if !ok { - osc_region = "eu-west-2" - } - osc_subregion, ok := os.LookupEnv("OSC_SUBREGION_NAME") - if !ok { - osc_subregion = osc_region + "a" - } infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ Net: infrastructurev1beta1.OscNet{ From 7e1c912caee8781fa8c25cfb0b264ea702b26ae1 Mon Sep 17 00:00:00 2001 From: Guido van der Hart Date: Tue, 7 Nov 2023 09:28:23 +0100 Subject: [PATCH 03/11] update gitignore and remove files that should not be commited --- .gitignore | 4 + apicovers.html | 3543 ----------------------------------- apicovers.txt | 163 -- covers.html | 4784 ------------------------------------------------ covers.txt | 119 -- 5 files changed, 4 insertions(+), 8609 deletions(-) delete mode 100644 apicovers.html delete mode 100644 apicovers.txt delete mode 100644 covers.html delete mode 100644 covers.txt diff --git a/.gitignore b/.gitignore index d77cda7b7..059fc3988 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,10 @@ test/e2e/config/*.-envsubst.yaml *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out +apicovers.txt +covers.txt +apicovers.html +covers.html secret.* *.kubeconfig diff --git a/apicovers.html b/apicovers.html deleted file mode 100644 index 8717deee8..000000000 --- a/apicovers.html +++ /dev/null @@ -1,3543 +0,0 @@ - - - - - - v1beta1: Go Coverage Report - - - -
- -
- not tracked - - not covered - covered - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/apicovers.txt b/apicovers.txt deleted file mode 100644 index 125dbba6a..000000000 --- a/apicovers.txt +++ /dev/null @@ -1,163 +0,0 @@ -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:26: OscReplaceName 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:67: GetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:72: SetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_types.go:76: init 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:40: ValidateOscClusterSpec 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:53: ValidateCidr 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:65: ValidateIpProtocol 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:75: ValidateFlow 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:85: ValidateDescription 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:95: ValidatePort 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:104: ValidateLoadBalancerType 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:113: ValidateInterval 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:122: ValidateThreshold 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:131: ValidateProtocol 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:143: ValidateTimeout 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:152: ValidateLoadBalancerName 75.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_validation.go:161: ValidateAndReturnErrorList 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:33: SetupWebhookWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:43: Default 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:53: ValidateCreate 80.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:63: ValidateUpdate 80.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/osccluster_webhook.go:84: ValidateDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_types.go:53: init 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:38: SetupWebhookWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:46: Default 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:57: ValidateCreate 80.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:67: ValidateUpdate 75.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscclustertemplate_webhook.go:83: ValidateDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:65: GetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:70: SetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_types.go:74: init 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:35: ValidateOscMachineSpec 87.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:115: ValidateKeypairName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:125: ValidateImageId 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:135: ValidateRatioSizeIops 66.7% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:145: ValidateImageName 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:155: ValidateIops 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:164: ValidateSize 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:173: ValidateVolumeType 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:183: ValidateSubregionName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:193: ValidateDeviceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_validation.go:204: ValidateVmType 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:33: SetupWebhookWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:42: Default 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:52: ValidateCreate 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:62: ValidateUpdate 85.3% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachine_webhook.go:141: ValidateDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:63: GetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:67: SetConditions 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_type.go:71: init 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:36: SetupWebhookWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:45: Default 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:55: ValidateCreate 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:65: ValidateUpdate 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/oscmachinetemplate_webhook.go:81: ValidateDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/tags.go:31: ClusterTagKey 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:614: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:628: SetVolumeDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:664: SetKeyPairDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:684: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:695: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:796: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:843: SetImageDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:850: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:871: SetRouteTableDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:951: SetSecurityGroupDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1200: SetPublicIpDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1214: SetSubnetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1246: SetSubnetSubregionNameDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/types.go:1259: SetDefaultValue 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:32: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:48: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:58: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:67: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:77: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:85: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:99: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:109: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:117: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:124: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:134: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:152: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:162: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:170: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:180: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:188: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:202: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:212: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:220: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:227: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:237: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:243: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:253: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:258: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:268: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:273: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:283: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:288: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:298: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:305: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:315: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:320: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:330: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:335: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:345: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:354: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:364: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:372: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:386: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:396: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:404: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:415: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:425: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:458: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:468: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:477: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:487: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:495: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:509: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:519: DeepCopyObject 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:527: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:534: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:544: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:550: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:560: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:579: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:589: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:594: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:604: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:609: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:619: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:674: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:684: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:716: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:726: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:745: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:755: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:765: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:775: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:780: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:790: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:795: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:805: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:817: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:827: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:832: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:842: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:847: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:857: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:872: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:882: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:892: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:902: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:907: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:917: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:922: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:932: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:937: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:947: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:963: DeepCopy 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:973: DeepCopyInto 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1/zz_generated.deepcopy.go:978: DeepCopy 0.0% -total: (statements) 14.9% diff --git a/covers.html b/covers.html deleted file mode 100644 index 17d5b2cf3..000000000 --- a/covers.html +++ /dev/null @@ -1,4784 +0,0 @@ - - - - - - controllers: Go Coverage Report - - - -
- -
- not tracked - - not covered - covered - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/covers.txt b/covers.txt deleted file mode 100644 index bea797bd1..000000000 --- a/covers.txt +++ /dev/null @@ -1,119 +0,0 @@ -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:34: getBastionResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:44: checkBastionSecurityGroupOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:71: checkBastionSubnetOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:91: checkBastionPublicIpOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:111: checkBastionFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:202: reconcileBastion 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_bastion_controller.go:322: reconcileDeleteBastion 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:62: getNetSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:67: getSubnetSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:72: getInternetServiceSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:77: getRouteTableSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:82: getSecurityGroupSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:87: getNatServiceSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:92: getPublicIpSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:97: getLoadBalancerSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:102: getVmSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:107: getImageSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:112: getTagSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:116: Reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:171: alertDuplicate 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:184: Contains 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:194: reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:415: reconcileDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_controller.go:495: SetupWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:31: getInternetServiceResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:41: checkInternetServiceFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:54: reconcileInternetService 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_internetservice_controller.go:104: reconcileDeleteInternetService 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:35: checkLoadBalancerSubnetOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:54: checkLoadBalancerFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:134: checkLoadBalancerSecurityGroupOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:153: reconcileLoadBalancer 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_loadbalancer_controller.go:233: reconcileDeleteLoadBalancer 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:32: getNatResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:41: checkNatFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:63: checkNatSubnetOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:83: reconcileNatService 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_natservice_controller.go:137: reconcileDeleteNatService 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:33: getNetResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:43: checkNetFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:61: reconcileNet 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_net_controller.go:105: reconcileDeleteNet 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:32: getPublicIpResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:41: getLinkPublicIpResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:51: checkPublicIpFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:72: checkPublicIpOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:95: checkPublicIpOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:111: reconcilePublicIp 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_publicip_controller.go:165: reconcileDeletePublicIp 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:32: getRouteTableResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:42: getRouteResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:52: checkRouteTableFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:73: checkRouteFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:96: checkRouteTableSubnetOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:122: checkRouteTableOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:138: checkRouteOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:158: reconcileRoute 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:202: reconcileDeleteRoute 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:251: reconcileRouteTable 93.6% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_routetable_controller.go:361: reconcileDeleteRouteTable 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:38: getSecurityGroupResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:48: getSecurityGroupRulesResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:58: checkSecurityGroupOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:74: checkSecurityGroupRuleOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:94: checkSecurityGroupFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:120: checkSecurityGroupRuleFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:170: reconcileSecurityGroupRule 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:205: deleteSecurityGroup 96.6% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:251: reconcileSecurityGroup 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:328: reconcileDeleteSecurityGroupRule 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_securitygroup_controller.go:360: reconcileDeleteSecurityGroup 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:32: getSubnetResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:42: checkSubnetFormatParameters 95.8% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:76: checkSubnetOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:92: reconcileSubnet 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/osccluster_subnet_controller.go:148: reconcileDeleteSubnet 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:77: getVolumeSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:82: getVmSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:87: getImageSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:92: getPublicIpSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:97: getSecurityGroupSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:102: getLoadBalancerSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:107: getKeyPairSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:112: getTagSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:115: Reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:193: reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:354: reconcileDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:383: SetupWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_controller.go:413: OscClusterToOscMachines 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:31: checkImageFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:50: getImageResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_image_controller.go:60: reconcileImage 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:34: checkKeypairFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:55: getKeyPairResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:65: reconcileKeypair 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_keypair_controller.go:98: reconcileDeleteKeypair 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:40: getVmResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:50: checkVmVolumeOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:70: checkVmLoadBalancerOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:90: checkVmVolumeSubregionName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:106: checkVmSecurityGroupOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:133: checkVmSubnetOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:153: checkVmPublicIpOscAssociateResourceName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:173: checkVmFormatParameters 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:284: checkVmPrivateIpOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:301: reconcileVm 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_vm_controller.go:523: reconcileDeleteVm 77.9% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:33: getVolumeResourceId 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:43: checkVolumeOscDuplicateName 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:59: checkVolumeFormatParameters 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:109: reconcileVolume 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachine_volume_controller.go:164: reconcileDeleteVolume 100.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:38: getVmSvc 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:52: Reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:120: reconcile 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:138: reconcileDelete 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_capacity_controller.go:146: SetupWithManager 0.0% -github.com/outscale-dev/cluster-api-provider-outscale.git/controllers/oscmachinetemplate_controller.go:31: reconcileCapacity 48.1% -total: (statements) 76.7% From 1a8890847ba6c953e633aef8360678e690b7bf45 Mon Sep 17 00:00:00 2001 From: Guido van der Hart Date: Mon, 13 Nov 2023 18:43:56 +0100 Subject: [PATCH 04/11] feat(net): App mulit NAT feature --- api/v1beta1/types.go | 3 + cloud/scope/cluster.go | 5 + .../osccluster_natservice_controller.go | 226 +++++++++++------- .../cluster-machine-template-multi-az.yaml | 12 + 4 files changed, 163 insertions(+), 83 deletions(-) diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 306ae9780..36b759b53 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -51,6 +51,9 @@ type OscNetwork struct { // The Nat Service configuration // +optional NatService OscNatService `json:"natService,omitempty"` + // The Nat Services configuration + // +optional + NatServices []*OscNatService `json:"natServices,omitempty"` // The Route Table configuration // +optional RouteTables []*OscRouteTable `json:"routeTables,omitempty"` diff --git a/cloud/scope/cluster.go b/cloud/scope/cluster.go index 4fe9d87bb..3b0e9ce45 100644 --- a/cloud/scope/cluster.go +++ b/cloud/scope/cluster.go @@ -160,6 +160,11 @@ func (s *ClusterScope) GetNatService() *infrastructurev1beta1.OscNatService { return &s.OscCluster.Spec.Network.NatService } +// GetNatServices return the natServices of the cluster +func (s *ClusterScope) GetNatServices() []*infrastructurev1beta1.OscNatService { + return s.OscCluster.Spec.Network.NatServices +} + // GetNatServiceRef get the status of natService (a Map with tag name with cluster uid associate with resource response id) func (s *ClusterScope) GetNatServiceRef() *infrastructurev1beta1.OscResourceReference { return &s.OscCluster.Status.Network.NatServiceRef diff --git a/controllers/osccluster_natservice_controller.go b/controllers/osccluster_natservice_controller.go index 0ee5d56d6..2c178f854 100644 --- a/controllers/osccluster_natservice_controller.go +++ b/controllers/osccluster_natservice_controller.go @@ -20,6 +20,7 @@ import ( "context" "fmt" + infrastructurev1beta1 "github.com/outscale-dev/cluster-api-provider-outscale.git/api/v1beta1" "github.com/outscale-dev/cluster-api-provider-outscale.git/cloud/scope" "github.com/outscale-dev/cluster-api-provider-outscale.git/cloud/services/net" tag "github.com/outscale-dev/cluster-api-provider-outscale.git/cloud/tag" @@ -38,97 +39,146 @@ func getNatResourceId(resourceName string, clusterScope *scope.ClusterScope) (st } } -func checkNatFormatParameters(clusterScope *scope.ClusterScope) (string, error) { - natServiceSpec := clusterScope.GetNatService() - natServiceSpec.SetDefaultValue() - natName := natServiceSpec.Name + "-" + clusterScope.GetUID() - natSubnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() - natPublicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() - natTagName, err := tag.ValidateTagNameValue(natName) - if err != nil { - return natTagName, err +// checkNatServiceOscDuplicateName check that there are no identical names already existing for natServices +func checkNatServiceOscDuplicateName(clusterScope *scope.ClusterScope) error { + var resourceNameList []string + natServicesSpec := clusterScope.GetNatServices() + for _, natServiceSpec := range natServicesSpec { + resourceNameList = append(resourceNameList, natServiceSpec.Name) } - natSubnetTagName, err := tag.ValidateTagNameValue(natSubnetName) - if err != nil { - return natSubnetTagName, err + clusterScope.V(2).Info("Check unique nat service") + duplicateResourceErr := alertDuplicate(resourceNameList) + if duplicateResourceErr != nil { + return duplicateResourceErr + } else { + return nil } - natPublicIpTagName, err := tag.ValidateTagNameValue(natPublicIpName) - if err != nil { - return natPublicIpTagName, err +} + +func checkNatFormatParameters(clusterScope *scope.ClusterScope) (string, error) { + var natServicesSpec []*infrastructurev1beta1.OscNatService + networkSpec := clusterScope.GetNetwork() + if networkSpec.NatServices == nil { + // Add backwards compatibility with NatService parameter that used single NatService + natServiceSpec := clusterScope.GetNatService() + natServiceSpec.SetDefaultValue() + natServicesSpec = append(natServicesSpec, natServiceSpec) + } else { + natServicesSpec = clusterScope.GetNatServices() + } + for _, natServiceSpec := range natServicesSpec { + natName := natServiceSpec.Name + "-" + clusterScope.GetUID() + natSubnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() + natPublicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() + natTagName, err := tag.ValidateTagNameValue(natName) + if err != nil { + return natTagName, err + } + natSubnetTagName, err := tag.ValidateTagNameValue(natSubnetName) + if err != nil { + return natSubnetTagName, err + } + natPublicIpTagName, err := tag.ValidateTagNameValue(natPublicIpName) + if err != nil { + return natPublicIpTagName, err + } } return "", nil } -// checkNatSubnetOscAssociateResourceName check that Nat Subnet dependancies tag name in both resource configuration are the same. +// checkNatSubnetOscAssociateResourceName check that Nat Subnet dependencies tag name in both resource configuration are the same. func checkNatSubnetOscAssociateResourceName(clusterScope *scope.ClusterScope) error { var resourceNameList []string - natServiceSpec := clusterScope.GetNatService() - natServiceSpec.SetDefaultValue() - natSubnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() + var natServicesSpec []*infrastructurev1beta1.OscNatService + networkSpec := clusterScope.GetNetwork() + if networkSpec.NatServices == nil { + // Add backwards compatibility with NatService parameter that used single NatService + natServiceSpec := clusterScope.GetNatService() + natServiceSpec.SetDefaultValue() + natServicesSpec = append(natServicesSpec, natServiceSpec) + } else { + natServicesSpec = clusterScope.GetNatServices() + } + subnetsSpec := clusterScope.GetSubnet() for _, subnetSpec := range subnetsSpec { subnetName := subnetSpec.Name + "-" + clusterScope.GetUID() resourceNameList = append(resourceNameList, subnetName) } - clusterScope.V(2).Info("Check match subnet with nat service") - checkOscAssociate := Contains(resourceNameList, natSubnetName) - if checkOscAssociate { - return nil - } else { - return fmt.Errorf("%s subnet does not exist in natService", natSubnetName) + + clusterScope.V(2).Info("Check match subnet with nat services") + for _, natServiceSpec := range natServicesSpec { + natSubnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() + checkOscAssociate := Contains(resourceNameList, natSubnetName) + if checkOscAssociate { + return nil + } else { + return fmt.Errorf("%s subnet does not exist in natService", natSubnetName) + } } + return nil } // reconcileNatService reconcile the NatService of the cluster. func reconcileNatService(ctx context.Context, clusterScope *scope.ClusterScope, natServiceSvc net.OscNatServiceInterface, tagSvc tag.OscTagInterface) (reconcile.Result, error) { - - natServiceSpec := clusterScope.GetNatService() - - natServiceRef := clusterScope.GetNatServiceRef() - natServiceName := natServiceSpec.Name + "-" + clusterScope.GetUID() - var natService *osc.NatService - publicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() - publicIpId, err := getPublicIpResourceId(publicIpName, clusterScope) - if err != nil { - return reconcile.Result{}, err + var natServicesSpec []*infrastructurev1beta1.OscNatService + networkSpec := clusterScope.GetNetwork() + if networkSpec.NatServices == nil { + // Add backwards compatibility with NatService parameter that used single NatService + natServiceSpec := clusterScope.GetNatService() + natServiceSpec.SetDefaultValue() + natServicesSpec = append(natServicesSpec, natServiceSpec) + } else { + natServicesSpec = clusterScope.GetNatServices() } - subnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() + for _, natServiceSpec := range natServicesSpec { + natServiceRef := clusterScope.GetNatServiceRef() + natServiceName := natServiceSpec.Name + "-" + clusterScope.GetUID() + var natService *osc.NatService + publicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() + publicIpId, err := getPublicIpResourceId(publicIpName, clusterScope) + if err != nil { + return reconcile.Result{}, err + } - subnetId, err := getSubnetResourceId(subnetName, clusterScope) - if err != nil { - return reconcile.Result{}, err - } - if len(natServiceRef.ResourceMap) == 0 { - natServiceRef.ResourceMap = make(map[string]string) - } - tagKey := "Name" - tagValue := natServiceName - tag, err := tagSvc.ReadTag(tagKey, tagValue) - if err != nil { - return reconcile.Result{}, fmt.Errorf("%w Can not get tag for OscCluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) - } - if natServiceSpec.ResourceId != "" { - natServiceRef.ResourceMap[natServiceName] = natServiceSpec.ResourceId - natServiceId := natServiceSpec.ResourceId - clusterScope.V(4).Info("Get natService Id", "natService", natServiceId) - clusterScope.V(2).Info("Check if the desired natService exist") - natService, err = natServiceSvc.GetNatService(natServiceId) + subnetName := natServiceSpec.SubnetName + "-" + clusterScope.GetUID() + + subnetId, err := getSubnetResourceId(subnetName, clusterScope) if err != nil { return reconcile.Result{}, err } - } - if (natService == nil && tag == nil) || (natServiceSpec.ResourceId == "" && tag == nil) { - clusterScope.V(4).Info("Create the desired natService", "natServiceName", natServiceName) - networkSpec := clusterScope.GetNetwork() - clusterName := networkSpec.ClusterName + "-" + clusterScope.GetUID() - clusterScope.V(2).Info("Create the desired natService", "natServiceName", natServiceName) - natService, err := natServiceSvc.CreateNatService(publicIpId, subnetId, natServiceName, clusterName) + if len(natServiceRef.ResourceMap) == 0 { + natServiceRef.ResourceMap = make(map[string]string) + } + tagKey := "Name" + tagValue := natServiceName + tag, err := tagSvc.ReadTag(tagKey, tagValue) if err != nil { - return reconcile.Result{}, fmt.Errorf("%w Can not create natService for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) + return reconcile.Result{}, fmt.Errorf("%w Can not get tag for OscCluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) + } + if natServiceSpec.ResourceId != "" { + natServiceRef.ResourceMap[natServiceName] = natServiceSpec.ResourceId + natServiceId := natServiceSpec.ResourceId + clusterScope.V(4).Info("Get natService Id", "natService", natServiceId) + clusterScope.V(2).Info("Check if the desired natService exist") + natService, err = natServiceSvc.GetNatService(natServiceId) + if err != nil { + return reconcile.Result{}, err + } + } + if (natService == nil && tag == nil) || (natServiceSpec.ResourceId == "" && tag == nil) { + clusterScope.V(4).Info("Create the desired natService", "natServiceName", natServiceName) + networkSpec := clusterScope.GetNetwork() + clusterName := networkSpec.ClusterName + "-" + clusterScope.GetUID() + clusterScope.V(2).Info("Create the desired natService", "natServiceName", natServiceName) + natService, err := natServiceSvc.CreateNatService(publicIpId, subnetId, natServiceName, clusterName) + if err != nil { + return reconcile.Result{}, fmt.Errorf("%w Can not create natService for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) + } + natServiceRef.ResourceMap[natServiceName] = natService.GetNatServiceId() + natServiceSpec.ResourceId = natService.GetNatServiceId() } - natServiceRef.ResourceMap[natServiceName] = natService.GetNatServiceId() - natServiceSpec.ResourceId = natService.GetNatServiceId() } return reconcile.Result{}, nil } @@ -136,24 +186,34 @@ func reconcileNatService(ctx context.Context, clusterScope *scope.ClusterScope, // reconcileDeleteNatService reconcile the destruction of the NatService of the cluster. func reconcileDeleteNatService(ctx context.Context, clusterScope *scope.ClusterScope, natServiceSvc net.OscNatServiceInterface) (reconcile.Result, error) { osccluster := clusterScope.OscCluster - natServiceSpec := clusterScope.GetNatService() - natServiceSpec.SetDefaultValue() - natServiceName := natServiceSpec.Name + "-" + clusterScope.GetUID() - - natServiceId := natServiceSpec.ResourceId - natService, err := natServiceSvc.GetNatService(natServiceId) - if err != nil { - return reconcile.Result{}, err - } - if natService == nil { - clusterScope.V(2).Info("The desired natService does not exist anymore", "natServiceName", natServiceName) - controllerutil.RemoveFinalizer(osccluster, "oscclusters.infrastructure.cluster.x-k8s.io") - return reconcile.Result{}, nil + var natServicesSpec []*infrastructurev1beta1.OscNatService + networkSpec := clusterScope.GetNetwork() + if networkSpec.NatServices == nil { + // Add backwards compatibility with NatService parameter that used single NatService + natServiceSpec := clusterScope.GetNatService() + natServiceSpec.SetDefaultValue() + natServicesSpec = append(natServicesSpec, natServiceSpec) + } else { + natServicesSpec = clusterScope.GetNatServices() } - clusterScope.V(2).Info("Delete the desired natService", "natServiceName", natServiceName) - err = natServiceSvc.DeleteNatService(natServiceId) - if err != nil { - return reconcile.Result{}, fmt.Errorf("%w Can not delete natService for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) + + for _, natServiceSpec := range natServicesSpec { + natServiceName := natServiceSpec.Name + "-" + clusterScope.GetUID() + natServiceId := natServiceSpec.ResourceId + natService, err := natServiceSvc.GetNatService(natServiceId) + if err != nil { + return reconcile.Result{}, err + } + if natService == nil { + clusterScope.V(2).Info("The desired natService does not exist anymore", "natServiceName", natServiceName) + controllerutil.RemoveFinalizer(osccluster, "oscclusters.infrastructure.cluster.x-k8s.io") + return reconcile.Result{}, nil + } + clusterScope.V(2).Info("Delete the desired natService", "natServiceName", natServiceName) + err = natServiceSvc.DeleteNatService(natServiceId) + if err != nil { + return reconcile.Result{}, fmt.Errorf("%w Can not delete natService for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) + } } - return reconcile.Result{}, err + return reconcile.Result{}, nil } diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index 0727c906a..9e0798ef3 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -36,6 +36,7 @@ spec: clusterName: cluster-api-multi-az internetService: clusterName: cluster-api-multi-az + # TODO: use multiple nat services and set correct sg's natService: clusterName: cluster-api-multi-az bastion: @@ -48,6 +49,17 @@ spec: - name: cluster-api-multi-az-eu-west-2b ipSubnetRange: "10.42.1.0/24" subregionName: eu-west-2b + routetables: + - name: cluster-api-multi-az-eu-west-2a + subnets: + - cluster-api-multi-az-eu-west-2a + routes: + - name: local + + securityGroups: + - name: cluster-api-multi-az-eu-west-2a + securityGroupRules: + - --- apiVersion: cluster.x-k8s.io/v1beta1 kind: MachineDeployment From 3acc384be42cf63f6227a2d4977f67e6c9397da8 Mon Sep 17 00:00:00 2001 From: David Cherriere Date: Wed, 15 Nov 2023 17:24:51 +0100 Subject: [PATCH 05/11] feat(net): update examples and crds for multinat gateway --- ...tructure.cluster.x-k8s.io_oscclusters.yaml | 24 +++++- ....cluster.x-k8s.io_oscclustertemplates.yaml | 26 ++++++- ...tructure.cluster.x-k8s.io_oscmachines.yaml | 2 +- ....cluster.x-k8s.io_oscmachinetemplates.yaml | 2 +- .../cluster-machine-template-multi-az.yaml | 77 +++++++++++++++++-- 5 files changed, 121 insertions(+), 10 deletions(-) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml index 52efa3dfb..f51d806d6 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.1-0.20230203165829-9084e41bb752 + controller-gen.kubebuilder.io/version: v0.9.1-0.20220825130208-40db49591af1 creationTimestamp: null name: oscclusters.infrastructure.cluster.x-k8s.io spec: @@ -219,6 +219,28 @@ spec: description: The subnet tag name associate with a Subnet type: string type: object + natServices: + description: The Nat Services configuration + items: + properties: + clusterName: + description: The name of the cluster + type: string + name: + description: The tag name associate with the Nat Service + type: string + publicipname: + description: The Public Ip tag name associated wtih a Public + Ip + type: string + resourceId: + description: The Nat Service Id response + type: string + subnetname: + description: The subnet tag name associate with a Subnet + type: string + type: object + type: array net: description: The Net configuration properties: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml index d091a0948..5db703f53 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscclustertemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.1-0.20230203165829-9084e41bb752 + controller-gen.kubebuilder.io/version: v0.9.1-0.20220825130208-40db49591af1 creationTimestamp: null name: oscclustertemplates.infrastructure.cluster.x-k8s.io spec: @@ -276,6 +276,30 @@ spec: Subnet type: string type: object + natServices: + description: The Nat Services configuration + items: + properties: + clusterName: + description: The name of the cluster + type: string + name: + description: The tag name associate with the Nat + Service + type: string + publicipname: + description: The Public Ip tag name associated wtih + a Public Ip + type: string + resourceId: + description: The Nat Service Id response + type: string + subnetname: + description: The subnet tag name associate with + a Subnet + type: string + type: object + type: array net: description: The Net configuration properties: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachines.yaml index 073508e3e..03253a547 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachines.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.1-0.20230203165829-9084e41bb752 + controller-gen.kubebuilder.io/version: v0.9.1-0.20220825130208-40db49591af1 creationTimestamp: null name: oscmachines.infrastructure.cluster.x-k8s.io spec: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachinetemplates.yaml index 0625d88f2..93bf36a80 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_oscmachinetemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.1-0.20230203165829-9084e41bb752 + controller-gen.kubebuilder.io/version: v0.9.1-0.20220825130208-40db49591af1 creationTimestamp: null name: oscmachinetemplates.infrastructure.cluster.x-k8s.io spec: diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index 9e0798ef3..9b6b2ad3d 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -37,8 +37,11 @@ spec: internetService: clusterName: cluster-api-multi-az # TODO: use multiple nat services and set correct sg's - natService: - clusterName: cluster-api-multi-az + natservices: + - name: cluster-api-multi-az-eu-west-2a + clusterName: cluster-api-multi-az + - name: cluster-api-multi-az-eu-west-2b + clusterName: cluster-api-multi-az bastion: clusterName: cluster-api-multi-az enable: false @@ -55,7 +58,6 @@ spec: - cluster-api-multi-az-eu-west-2a routes: - name: local - securityGroups: - name: cluster-api-multi-az-eu-west-2a securityGroupRules: @@ -166,7 +168,7 @@ spec: apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OscMachineTemplate metadata: - name: "cluster-api-multi-az-control-plane" + name: "cluster-api-multi-az-control-plane-eu-west-2a" namespace: default spec: template: @@ -190,6 +192,33 @@ spec: loadBalancerName: capo-k8s vmType: "tinav6.c4r8p1" --- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-multi-az-control-plane-eu-west-2b" + namespace: default +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: true + vm: + clusterName: cluster-api-multi-az + keypairName: cluster-api-test + subnetName: cluster-api-multi-az-eu-west-2b + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: "gp2" + role: controlplane + loadBalancerName: capo-k8s + vmType: "tinav6.c4r8p1" +--- apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 kind: KubeadmConfigTemplate metadata: @@ -220,14 +249,14 @@ spec: kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 metadata: - name: "cluster-api-multi-az-control-plane" + name: "cluster-api-multi-az-control-plane-eu-west-2a" spec: replicas: 1 machineTemplate: infrastructureRef: kind: OscMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - name: "cluster-api-multi-az-control-plane" + name: "cluster-api-multi-az-control-plane-eu-west-2a" namespace: default kubeadmConfigSpec: initConfiguration: @@ -252,3 +281,39 @@ spec: preKubeadmCommands: - sh /tmp/set_runc.sh version: "1.22.11" +--- +kind: KubeadmControlPlane +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +metadata: + name: "cluster-api-multi-az-control-plane-eu-west-2b" +spec: + replicas: 1 + machineTemplate: + infrastructureRef: + kind: OscMachineTemplate + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + name: "cluster-api-multi-az-control-plane-eu-west-2b" + namespace: default + kubeadmConfigSpec: + initConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + name: '{{ ds.meta_data.local_hostname }}' + files: + - content: | + #!/bin/bash + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + \cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + preKubeadmCommands: + - sh /tmp/set_runc.sh + version: "1.22.11" \ No newline at end of file From d84bfabde4496e96d067df839116239435b3c2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20GLON?= Date: Fri, 17 Nov 2023 10:48:03 +0100 Subject: [PATCH 06/11] Fix publicIP --- controllers/osccluster_publicip_controller.go | 41 +- .../cluster-machine-template-multi-az.yaml | 452 +++++++++--------- 2 files changed, 252 insertions(+), 241 deletions(-) diff --git a/controllers/osccluster_publicip_controller.go b/controllers/osccluster_publicip_controller.go index d304dbaa2..247eeeac2 100644 --- a/controllers/osccluster_publicip_controller.go +++ b/controllers/osccluster_publicip_controller.go @@ -71,24 +71,37 @@ func checkPublicIpFormatParameters(clusterScope *scope.ClusterScope) (string, er // checkPublicIpOscAssociateResourceName check that PublicIp dependancies tag name in both resource configuration are the same. func checkPublicIpOscAssociateResourceName(clusterScope *scope.ClusterScope) error { var resourceNameList []string - natServiceSpec := clusterScope.GetNatService() - natServiceSpec.SetDefaultValue() - natPublicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() - var publicIpsSpec []*infrastructurev1beta1.OscPublicIp + var natServicesSpec []*infrastructurev1beta1.OscNatService networkSpec := clusterScope.GetNetwork() - publicIpsSpec = networkSpec.PublicIps - for _, publicIpSpec := range publicIpsSpec { - publicIpName := publicIpSpec.Name + "-" + clusterScope.GetUID() - resourceNameList = append(resourceNameList, publicIpName) + if networkSpec.NatServices == nil { + // Add backwards compatibility with NatService parameter that used single NatService + natServiceSpec := clusterScope.GetNatService() + natServiceSpec.SetDefaultValue() + natServicesSpec = append(natServicesSpec, natServiceSpec) + } else { + natServicesSpec = clusterScope.GetNatServices() } - clusterScope.V(2).Info("Check match public ip with nat service") - checkOscAssociate := Contains(resourceNameList, natPublicIpName) - if checkOscAssociate { - return nil - } else { - return fmt.Errorf("publicIp %s does not exist in natService ", natPublicIpName) + for _, natServiceSpec := range natServicesSpec { + natPublicIpName := natServiceSpec.PublicIpName + "-" + clusterScope.GetUID() + + var publicIpsSpec []*infrastructurev1beta1.OscPublicIp + networkSpec := clusterScope.GetNetwork() + publicIpsSpec = networkSpec.PublicIps + for _, publicIpSpec := range publicIpsSpec { + publicIpName := publicIpSpec.Name + "-" + clusterScope.GetUID() + resourceNameList = append(resourceNameList, publicIpName) + } + clusterScope.V(2).Info("Check match public ip with nat service") + + checkOscAssociate := Contains(resourceNameList, natPublicIpName) + if checkOscAssociate { + return nil + } else { + return fmt.Errorf("publicIp %s does not exist in natService ", natPublicIpName) + } } + return nil } // checkPublicIpOscDuplicateName check that there are not the same name for PublicIp resource. diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index 9b6b2ad3d..f05b913ac 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -2,7 +2,7 @@ apiVersion: cluster.x-k8s.io/v1beta1 kind: Cluster metadata: name: cluster-api-multi-az - namespace: default + namespace: capo-test labels: cni: "cluster-api-multi-az-crs-cni" ccm: "cluster-api-multi-az-crs-ccm" @@ -14,18 +14,18 @@ spec: apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OscCluster name: cluster-api-multi-az - namespace: default + namespace: capo-test controlPlaneRef: kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 name: "cluster-api-multi-az-control-plane" - namespace: default + namespace: capo-test --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OscCluster metadata: name: cluster-api-multi-az - namespace: default + namespace: capo-test spec: network: clusterName: cluster-api-multi-az @@ -37,7 +37,7 @@ spec: internetService: clusterName: cluster-api-multi-az # TODO: use multiple nat services and set correct sg's - natservices: + natServices: - name: cluster-api-multi-az-eu-west-2a clusterName: cluster-api-multi-az - name: cluster-api-multi-az-eu-west-2b @@ -52,7 +52,7 @@ spec: - name: cluster-api-multi-az-eu-west-2b ipSubnetRange: "10.42.1.0/24" subregionName: eu-west-2b - routetables: + routeTables: - name: cluster-api-multi-az-eu-west-2a subnets: - cluster-api-multi-az-eu-west-2a @@ -60,191 +60,189 @@ spec: - name: local securityGroups: - name: cluster-api-multi-az-eu-west-2a - securityGroupRules: - - ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: "cluster-api-multi-az-md-0-eu-west-2a" - namespace: default -spec: - clusterName: "cluster-api-multi-az" - replicas: 1 - selector: - matchLabels: - template: - spec: - clusterName: "cluster-api-multi-az" - version: "1.22.11" - bootstrap: - configRef: - name: "cluster-api-multi-az-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - namespace: default - infrastructureRef: - name: "cluster-api-multi-az-md-0-eu-west-2a" - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: OscMachineTemplate - namespace: default ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: "cluster-api-multi-az-md-0-eu-west-2b" - namespace: default -spec: - clusterName: "cluster-api-multi-az" - replicas: 1 - selector: - matchLabels: - template: - spec: - clusterName: "cluster-api-multi-az" - version: "1.22.11" - bootstrap: - configRef: - name: "cluster-api-multi-az-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - namespace: default - infrastructureRef: - name: "cluster-api-multi-az-md-0-eu-west-2b" - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: OscMachineTemplate - namespace: default ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-multi-az-md-0-eu-west-2a" - namespace: default -spec: - template: - spec: - node: - clusterName: cluster-api-multi-az - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: true - vm: - clusterName: cluster-api-multi-az - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: "gp2" - keypairName: cluster-api-test - subnetName: cluster-api-multi-az-eu-west-2a - vmType: "tinav6.c2r4p2" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-multi-az-md-0-eu-west-2b" - namespace: default -spec: - template: - spec: - node: - clusterName: cluster-api-multi-az - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: true - vm: - clusterName: cluster-api-multi-az - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: "gp2" - keypairName: cluster-api-test - subnetName: cluster-api-multi-az-eu-west-2b - vmType: "tinav6.c2r4p2" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-multi-az-control-plane-eu-west-2a" - namespace: default -spec: - template: - spec: - node: - clusterName: cluster-api-multi-az - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: true - vm: - clusterName: cluster-api-multi-az - keypairName: cluster-api-test - subnetName: cluster-api-multi-az-eu-west-2a - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: "gp2" - role: controlplane - loadBalancerName: capo-k8s - vmType: "tinav6.c4r8p1" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-multi-az-control-plane-eu-west-2b" - namespace: default -spec: - template: - spec: - node: - clusterName: cluster-api-multi-az - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: true - vm: - clusterName: cluster-api-multi-az - keypairName: cluster-api-test - subnetName: cluster-api-multi-az-eu-west-2b - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: "gp2" - role: controlplane - loadBalancerName: capo-k8s - vmType: "tinav6.c4r8p1" ---- -apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -kind: KubeadmConfigTemplate -metadata: - name: "cluster-api-multi-az-md-0" - namespace: default -spec: - template: - spec: - files: - - content: | - #!/bin/bash +# --- +# apiVersion: cluster.x-k8s.io/v1beta1 +# kind: MachineDeployment +# metadata: +# name: "cluster-api-multi-az-md-0-eu-west-2a" +# namespace: capo-test +# spec: +# clusterName: "cluster-api-multi-az" +# replicas: 1 +# selector: +# matchLabels: +# template: +# spec: +# clusterName: "cluster-api-multi-az" +# version: "1.22.11" +# bootstrap: +# configRef: +# name: "cluster-api-multi-az-md-0" +# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +# kind: KubeadmConfigTemplate +# namespace: capo-test +# infrastructureRef: +# name: "cluster-api-multi-az-md-0-eu-west-2a" +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# namespace: capo-test +# --- +# apiVersion: cluster.x-k8s.io/v1beta1 +# kind: MachineDeployment +# metadata: +# name: "cluster-api-multi-az-md-0-eu-west-2b" +# namespace: capo-test +# spec: +# clusterName: "cluster-api-multi-az" +# replicas: 1 +# selector: +# matchLabels: +# template: +# spec: +# clusterName: "cluster-api-multi-az" +# version: "1.22.11" +# bootstrap: +# configRef: +# name: "cluster-api-multi-az-md-0" +# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +# kind: KubeadmConfigTemplate +# namespace: capo-test +# infrastructureRef: +# name: "cluster-api-multi-az-md-0-eu-west-2b" +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# namespace: capo-test +# --- +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# metadata: +# name: "cluster-api-multi-az-md-0-eu-west-2a" +# namespace: capo-test +# spec: +# template: +# spec: +# node: +# clusterName: cluster-api-multi-az +# image: +# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 +# keypair: +# name: cluster-api-test +# deleteKeypair: true +# vm: +# clusterName: cluster-api-multi-az +# rootDisk: +# rootDiskSize: 30 +# rootDiskIops: 1500 +# rootDiskType: "gp2" +# keypairName: cluster-api-test +# subnetName: cluster-api-multi-az-eu-west-2a +# vmType: "tinav6.c2r4p2" +# --- +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# metadata: +# name: "cluster-api-multi-az-md-0-eu-west-2b" +# namespace: capo-test +# spec: +# template: +# spec: +# node: +# clusterName: cluster-api-multi-az +# image: +# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 +# keypair: +# name: cluster-api-test +# deleteKeypair: true +# vm: +# clusterName: cluster-api-multi-az +# rootDisk: +# rootDiskSize: 30 +# rootDiskIops: 1500 +# rootDiskType: "gp2" +# keypairName: cluster-api-test +# subnetName: cluster-api-multi-az-eu-west-2b +# vmType: "tinav6.c2r4p2" +# --- +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# metadata: +# name: "cluster-api-multi-az-control-plane-eu-west-2a" +# namespace: capo-test +# spec: +# template: +# spec: +# node: +# clusterName: cluster-api-multi-az +# image: +# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 +# keypair: +# name: cluster-api-test +# deleteKeypair: true +# vm: +# clusterName: cluster-api-multi-az +# keypairName: cluster-api-test +# subnetName: cluster-api-multi-az-eu-west-2a +# rootDisk: +# rootDiskSize: 30 +# rootDiskIops: 1500 +# rootDiskType: "gp2" +# role: controlplane +# loadBalancerName: capo-k8s +# vmType: "tinav6.c4r8p1" +# --- +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# kind: OscMachineTemplate +# metadata: +# name: "cluster-api-multi-az-control-plane-eu-west-2b" +# namespace: capo-test +# spec: +# template: +# spec: +# node: +# clusterName: cluster-api-multi-az +# image: +# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 +# keypair: +# name: cluster-api-test +# deleteKeypair: true +# vm: +# clusterName: cluster-api-multi-az +# keypairName: cluster-api-test +# subnetName: cluster-api-multi-az-eu-west-2b +# rootDisk: +# rootDiskSize: 30 +# rootDiskIops: 1500 +# rootDiskType: "gp2" +# role: controlplane +# loadBalancerName: capo-k8s +# vmType: "tinav6.c4r8p1" +# --- +# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +# kind: KubeadmConfigTemplate +# metadata: +# name: "cluster-api-multi-az-md-0" +# namespace: capo-test +# spec: +# template: +# spec: +# files: +# - content: | +# #!/bin/bash - curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 - chmod +x /tmp/runc.amd64 - \cp -f /tmp/runc.amd64 /usr/local/sbin/runc - owner: root:root - path: /tmp/set_runc.sh - permissions: "0744" - joinConfiguration: - nodeRegistration: - name: "{{ ds.meta_data.local_hostname }}" - kubeletExtraArgs: - cloud-provider: external - provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' - preKubeadmCommands: - - sh /tmp/set_runc.sh +# curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 +# chmod +x /tmp/runc.amd64 +# \cp -f /tmp/runc.amd64 /usr/local/sbin/runc +# owner: root:root +# path: /tmp/set_runc.sh +# permissions: "0744" +# joinConfiguration: +# nodeRegistration: +# name: "{{ ds.meta_data.local_hostname }}" +# kubeletExtraArgs: +# cloud-provider: external +# provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' +# preKubeadmCommands: +# - sh /tmp/set_runc.sh --- kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 @@ -257,7 +255,7 @@ spec: kind: OscMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 name: "cluster-api-multi-az-control-plane-eu-west-2a" - namespace: default + namespace: capo-test kubeadmConfigSpec: initConfiguration: nodeRegistration: @@ -281,39 +279,39 @@ spec: preKubeadmCommands: - sh /tmp/set_runc.sh version: "1.22.11" ---- -kind: KubeadmControlPlane -apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -metadata: - name: "cluster-api-multi-az-control-plane-eu-west-2b" -spec: - replicas: 1 - machineTemplate: - infrastructureRef: - kind: OscMachineTemplate - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - name: "cluster-api-multi-az-control-plane-eu-west-2b" - namespace: default - kubeadmConfigSpec: - initConfiguration: - nodeRegistration: - kubeletExtraArgs: - cloud-provider: external - provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' - name: '{{ ds.meta_data.local_hostname }}' - files: - - content: | - #!/bin/bash - curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 - chmod +x /tmp/runc.amd64 - \cp -f /tmp/runc.amd64 /usr/local/sbin/runc - owner: root:root - path: /tmp/set_runc.sh - permissions: "0744" - joinConfiguration: - nodeRegistration: - kubeletExtraArgs: - cloud-provider: external - preKubeadmCommands: - - sh /tmp/set_runc.sh - version: "1.22.11" \ No newline at end of file +# --- +# kind: KubeadmControlPlane +# apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +# metadata: +# name: "cluster-api-multi-az-control-plane-eu-west-2b" +# spec: +# replicas: 1 +# machineTemplate: +# infrastructureRef: +# kind: OscMachineTemplate +# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +# name: "cluster-api-multi-az-control-plane-eu-west-2b" +# namespace: capo-test +# kubeadmConfigSpec: +# initConfiguration: +# nodeRegistration: +# kubeletExtraArgs: +# cloud-provider: external +# provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' +# name: '{{ ds.meta_data.local_hostname }}' +# files: +# - content: | +# #!/bin/bash +# curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 +# chmod +x /tmp/runc.amd64 +# \cp -f /tmp/runc.amd64 /usr/local/sbin/runc +# owner: root:root +# path: /tmp/set_runc.sh +# permissions: "0744" +# joinConfiguration: +# nodeRegistration: +# kubeletExtraArgs: +# cloud-provider: external +# preKubeadmCommands: +# - sh /tmp/set_runc.sh +# version: "1.22.11" From bbe8b54e8eeae399868361e60799871d50339b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20GLON?= Date: Mon, 20 Nov 2023 15:09:10 +0100 Subject: [PATCH 07/11] Add test2 --- example/cluster-machine-template-simple2.yaml | 463 ++++++++++++++++++ 1 file changed, 463 insertions(+) create mode 100644 example/cluster-machine-template-simple2.yaml diff --git a/example/cluster-machine-template-simple2.yaml b/example/cluster-machine-template-simple2.yaml new file mode 100644 index 000000000..c684eabef --- /dev/null +++ b/example/cluster-machine-template-simple2.yaml @@ -0,0 +1,463 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: cluster-api + namespace: capo-test + labels: + cni: "calico-v3-19" + ccm: "cluster-api-crs-ccm" +spec: + clusterNetwork: + pods: + cidrBlocks: ["10.42.0.0/16"] + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscCluster + name: cluster-api + namespace: capo-test + controlPlaneRef: + kind: KubeadmControlPlane + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + name: "cluster-api-control-plane" + namespace: capo-test +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscCluster +metadata: + name: cluster-api + namespace: capo-test +spec: + network: + clusterName: cluster-api + subregionName: eu-west-2a + loadBalancer: + loadbalancername: osc-k8s + loadbalancertype: internet-facing + subnetname: cluster-api-subnet-public + securitygroupname: cluster-api-securitygroup-lb + clusterName: cluster-api + net: + name: cluster-api-net + clusterName: cluster-api + ipRange: "10.0.0.0/16" + subnets: + - name: cluster-api-subnet-kcp-a + ipSubnetRange: "10.0.4.0/24" + subregionName: eu-west-2a + # - name: cluster-api-subnet-kcp-b + # ipSubnetRange: "10.0.5.0/24" + # subregionName: eu-west-2b + - name: cluster-api-subnet-kw-a + ipSubnetRange: "10.0.3.0/24" + subregionName: eu-west-2a + - name: cluster-api-subnet-kw-b + ipSubnetRange: "10.0.6.0/24" + subregionName: eu-west-2b + - name: cluster-api-subnet-public + ipSubnetRange: "10.0.2.0/24" + publicIps: + - name: cluster-api-publicip-nat + internetService: + clusterName: cluster-api + name: cluster-api-internetservice + natServices: + - clusterName: cluster-api + name: cluster-api-natservice + publicipname: cluster-api-publicip-nat + subnetname: cluster-api-subnet-public + bastion: + clusterName: cluster-api + enable: false + routeTables: + - name: cluster-api-routetable-kw + subnets: + - cluster-api-subnet-kw-a + - cluster-api-subnet-kw-b + routes: + - name: cluster-api-routes-kw + targetName: cluster-api-natservice + targetType: nat + destination: "0.0.0.0/0" + - name: cluster-api-routetable-kcp + subnets: + - cluster-api-subnet-kcp-a + # - cluster-api-subnet-kcp-b + routes: + - name: cluster-api-routes-kcp + targetName: cluster-api-natservice + targetType: nat + destination: "0.0.0.0/0" + - name: cluster-api-routetable-public + subnets: + - cluster-api-subnet-public + routes: + - name: cluster-api-routes-public + targetName: cluster-api-internetservice + targetType: gateway + destination: "0.0.0.0/0" + securityGroups: + # - name: cluster-api-securitygroups + # description: Security Group with cluster-api + # securityGroupRules: + # - name: + # flow: Inboud + # ipProtocol: tcp + # fromPortRange: 22 + # toPortRange: 22 + - name: cluster-api-securitygroups-kw + description: Security Group with cluster-api + securityGroupRules: + - name: cluster-api-securitygrouprule-api-kubelet-kw + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.3.0/24" + fromPortRange: 10250 + toPortRange: 10250 + - name: cluster-api-securitygrouprule-api-kubelet-kcp + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 10250 + toPortRange: 10250 + - name: cluster-api-securitygrouprule-kcp-nodeip-kw + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.3.0/24" + fromPortRange: 30000 + toPortRange: 32767 + - name: cluster-api-securitygrouprule-kcp-nodeip-kcp + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 30000 + toPortRange: 32767 + - name: cluster-api-securitygrouprule-kw-bgp + flow: Inbound + ipProtocol: tcp + ipRange: "10.0.0.0/16" + fromPortRange: 179 + toPortRange: 179 + - name: cluster-api-securitygroups-kcp + description: Security Group with cluster-api + securityGroupRules: + - name: cluster-api-securitygrouprule-api-kw + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.3.0/24" + fromPortRange: 6443 + toPortRange: 6443 + - name: cluster-api-securitygrouprule-api-kcp + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 6443 + toPortRange: 6443 + - name: cluster-api-securitygrouprule-etcd + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 2378 + toPortRange: 2379 + - name: cluster-api-securitygrouprule-kubelet-kcp + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 10250 + toPortRange: 10252 + - name: cluster-api-securitygrouprule-kcp-bgp + flow: Inbound + ipProtocol: tcp + ipRange: "10.0.0.0/16" + fromPortRange: 179 + toPortRange: 179 + - name: cluster-api-securitygrouprule-kw-nodeip-kw + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.3.0/24" + fromPortRange: 30000 + toPortRange: 32767 + - name: cluster-api-securitygrouprule-kw-nodeip-kcp + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "10.0.4.0/24" + fromPortRange: 30000 + toPortRange: 32767 + - name: cluster-api-securitygroup-lb + description: Security Group lb with cluster-api + securityGroupRules: + - name: cluste-api-securitygrouprule-lb + flow: Inbound + ipProtocol: tcp +# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. + ipRange: "0.0.0.0/0" + fromPortRange: 6443 + toPortRange: 6443 + - name: cluster-api-securitygroups-node + description: Security Group node with cluster-api + tag: OscK8sMainSG + securityGroupRules: + - name: cluster-api-securitygrouprule-calico-vxlan + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 4789 + toPortRange: 4789 + - name: cluster-api-securitygrouprule-calico-typha + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 5473 + toPortRange: 5473 + - name: cluster-api-securitygrouprule-calico-wireguard + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 51820 + toPortRange: 51820 + - name: cluster-api-securitygrouprule-calico-wireguard-ipv6 + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 51821 + toPortRange: 51821 + - name: cluster-api-securitygrouprule-flannel + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 4789 + toPortRange: 4789 + - name: cluster-api-securitygrouperule-flannel-udp + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 8285 + toPortRange: 8285 + - name: cluster-api-securitygroup-flannel-vxlan + flow: Inbound + ipProtocol: udp + ipRange: "10.0.0.0/16" + fromPortRange: 8472 + toPortRange: 8472 +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "cluster-api-md-0" + namespace: capo-test +spec: + clusterName: "cluster-api" + replicas: 1 + selector: + matchLabels: + template: + spec: + clusterName: "cluster-api" + version: "1.22.11" + bootstrap: + configRef: + name: "cluster-api-md-0" + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: capo-test + infrastructureRef: + name: "cluster-api-md-0" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: capo-test +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "cluster-api-md-1" + namespace: capo-test +spec: + clusterName: "cluster-api" + replicas: 1 + selector: + matchLabels: + template: + spec: + clusterName: "cluster-api" + version: "1.22.11" + bootstrap: + configRef: + name: "cluster-api-md-0" + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: capo-test + infrastructureRef: + name: "cluster-api-md-1" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: capo-test +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-md-0" + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api + name: cluster-api-vm-kw + keypairName: cluster-api-test + deviceName: /dev/sda1 + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: gp2 + subnetName: cluster-api-subnet-kw-a + subregionName: eu-west-2a + securityGroupNames: + - name: cluster-api-securitygroups-kw + - name: cluster-api-securitygroups-node + vmType: "tinav5.c2r8p2" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-md-1" + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api + name: cluster-api-vm-kw + keypairName: cluster-api-test + deviceName: /dev/sda1 + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: gp2 + subnetName: cluster-api-subnet-kw-b + subregionName: eu-west-2b + securityGroupNames: + - name: cluster-api-securitygroups-kw + - name: cluster-api-securitygroups-node + vmType: "tinav5.c2r8p2" + +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: "cluster-api-control-plane" + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api + name: cluster-api-vm-kcp + keypairName: cluster-api-test + rootDisk: + rootDiskSize: 30 + rootDiskIops: 1500 + rootDiskType: gp2 + deviceName: /dev/sda1 + subregionName: eu-west-2a + subnetName: cluster-api-subnet-kcp-a + role: controlplane + loadBalancerName: osc-k8s + securityGroupNames: + - name: cluster-api-securitygroups-kcp + - name: cluster-api-securitygroups-node + vmType: "tinav5.c2r8p2" +--- +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: KubeadmConfigTemplate +metadata: + name: "cluster-api-md-0" + namespace: capo-test +spec: + template: + spec: + files: + - content: | + #!/bin/sh + + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + name: "{{ ds.meta_data.local_hostname }}" + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + preKubeadmCommands: + - sh /tmp/set_runc.sh +--- +kind: KubeadmControlPlane +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +metadata: + name: "cluster-api-control-plane" + namespace: capo-test +spec: + replicas: 1 + machineTemplate: + infrastructureRef: + kind: OscMachineTemplate + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + name: "cluster-api-control-plane" + namespace: capo-test + kubeadmConfigSpec: + initConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + name: '{{ ds.meta_data.local_hostname }}' + files: + - content: | + #!/bin/sh + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + preKubeadmCommands: + - sh /tmp/set_runc.sh + version: "1.22.11" From f029fe44eb0e051aec67ddcc8264f5ac8e1763fa Mon Sep 17 00:00:00 2001 From: Guido van der Hart Date: Mon, 20 Nov 2023 15:54:38 +0100 Subject: [PATCH 08/11] Update multi az example --- .../osccluster_natservice_controller.go | 1 - .../cluster-machine-template-multi-az.yaml | 518 ++++++++++-------- example/cluster-machine-template-simple2.yaml | 463 ---------------- 3 files changed, 277 insertions(+), 705 deletions(-) delete mode 100644 example/cluster-machine-template-simple2.yaml diff --git a/controllers/osccluster_natservice_controller.go b/controllers/osccluster_natservice_controller.go index 2c178f854..083aeea26 100644 --- a/controllers/osccluster_natservice_controller.go +++ b/controllers/osccluster_natservice_controller.go @@ -171,7 +171,6 @@ func reconcileNatService(ctx context.Context, clusterScope *scope.ClusterScope, clusterScope.V(4).Info("Create the desired natService", "natServiceName", natServiceName) networkSpec := clusterScope.GetNetwork() clusterName := networkSpec.ClusterName + "-" + clusterScope.GetUID() - clusterScope.V(2).Info("Create the desired natService", "natServiceName", natServiceName) natService, err := natServiceSvc.CreateNatService(publicIpId, subnetId, natServiceName, clusterName) if err != nil { return reconcile.Result{}, fmt.Errorf("%w Can not create natService for Osccluster %s/%s", err, clusterScope.GetNamespace(), clusterScope.GetName()) diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index f05b913ac..e06ea8f40 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -9,7 +9,9 @@ metadata: spec: clusterNetwork: pods: - cidrBlocks: ["10.42.0.0/16"] + cidrBlocks: ["10.233.64.0/18"] + services: + cidrBlocks: ["10.233.0.0/18"] infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: OscCluster @@ -18,7 +20,7 @@ spec: controlPlaneRef: kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - name: "cluster-api-multi-az-control-plane" + name: "cluster-api-multi-az-control-plane-2a" namespace: capo-test --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -30,231 +32,154 @@ spec: network: clusterName: cluster-api-multi-az loadBalancer: - loadbalancername: capo-k8s + loadbalancername: cluster-api-multi-az-lb clusterName: cluster-api-multi-az + loadbalancertype: internet-facing + subnetname: cluster-api-multi-az-subnet-2a-private + securitygroupname: cluster-api-multi-az-securitygroup-lb net: + name: cluster-api-multi-az-net clusterName: cluster-api-multi-az + ipRange: "10.0.0.0/16" internetService: + name: cluster-api-multi-az-igw clusterName: cluster-api-multi-az - # TODO: use multiple nat services and set correct sg's - natServices: - - name: cluster-api-multi-az-eu-west-2a - clusterName: cluster-api-multi-az - - name: cluster-api-multi-az-eu-west-2b - clusterName: cluster-api-multi-az - bastion: - clusterName: cluster-api-multi-az - enable: false subnets: - - name: cluster-api-multi-az-eu-west-2a - ipSubnetRange: "10.42.0.0/24" + - name: cluster-api-multi-az-subnet-2a-private + ipSubnetRange: "10.0.0.0/24" + subregionName: eu-west-2a + - name: cluster-api-multi-az-subnet-2b-private + ipSubnetRange: "10.0.1.0/24" + subregionName: eu-west-2b + - name: cluster-api-multi-az-subnet-2a-public + ipSubnetRange: "10.0.2.0/24" subregionName: eu-west-2a - - name: cluster-api-multi-az-eu-west-2b - ipSubnetRange: "10.42.1.0/24" + - name: cluster-api-multi-az-subnet-2b-public + ipSubnetRange: "10.0.3.0/24" subregionName: eu-west-2b + natServices: + - name: cluster-api-multi-az-2a-nat + clusterName: cluster-api-multi-az + publicipname: cluster-api-multi-az-publicip-2a-nat + subnetname: cluster-api-multi-az-subnet-2a-public + - name: cluster-api-multi-az-2b-nat + clusterName: cluster-api-multi-az + publicipname: cluster-api-multi-az-publicip-2b-nat + subnetname: cluster-api-multi-az-subnet-2b-public + publicIps: + - name: cluster-api-multi-az-publicip-2a-nat + clusterName: cluster-api-multi-az + - name: cluster-api-multi-az-publicip-2b-nat + clusterName: cluster-api-multi-az routeTables: - - name: cluster-api-multi-az-eu-west-2a + - name: cluster-api-multi-az-rtb-2a-private + subnets: + - cluster-api-multi-az-subnet-2a-private + routes: + - name: cluster-api-multi-az-route-2a-nat + targetName: cluster-api-multi-az-2a-nat + targetType: nat + destination: "0.0.0.0/0" + - name: cluster-api-multi-az-rtb-2b-private subnets: - - cluster-api-multi-az-eu-west-2a + - cluster-api-multi-az-subnet-2b-private routes: - - name: local + - name: cluster-api-multi-az-route-2b-nat + targetName: cluster-api-multi-az-2b-nat + targetType: nat + destination: "0.0.0.0/0" + - name: cluster-api-multi-az-rtb-2a-public + subnets: + - cluster-api-multi-az-subnet-2a-public + routes: + - name: cluster-api-multi-az-route-2a-igw + targetName: cluster-api-multi-az-igw + targetType: gateway + destination: "0.0.0.0/0" + - name: cluster-api-multi-az-rtb-2b-public + subnets: + - cluster-api-multi-az-subnet-2b-public + routes: + - name: cluster-api-multi-az-route-2b-igw + targetName: cluster-api-multi-az-igw + targetType: gateway + destination: "0.0.0.0/0" securityGroups: - - name: cluster-api-multi-az-eu-west-2a -# --- -# apiVersion: cluster.x-k8s.io/v1beta1 -# kind: MachineDeployment -# metadata: -# name: "cluster-api-multi-az-md-0-eu-west-2a" -# namespace: capo-test -# spec: -# clusterName: "cluster-api-multi-az" -# replicas: 1 -# selector: -# matchLabels: -# template: -# spec: -# clusterName: "cluster-api-multi-az" -# version: "1.22.11" -# bootstrap: -# configRef: -# name: "cluster-api-multi-az-md-0" -# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -# kind: KubeadmConfigTemplate -# namespace: capo-test -# infrastructureRef: -# name: "cluster-api-multi-az-md-0-eu-west-2a" -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# namespace: capo-test -# --- -# apiVersion: cluster.x-k8s.io/v1beta1 -# kind: MachineDeployment -# metadata: -# name: "cluster-api-multi-az-md-0-eu-west-2b" -# namespace: capo-test -# spec: -# clusterName: "cluster-api-multi-az" -# replicas: 1 -# selector: -# matchLabels: -# template: -# spec: -# clusterName: "cluster-api-multi-az" -# version: "1.22.11" -# bootstrap: -# configRef: -# name: "cluster-api-multi-az-md-0" -# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -# kind: KubeadmConfigTemplate -# namespace: capo-test -# infrastructureRef: -# name: "cluster-api-multi-az-md-0-eu-west-2b" -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# namespace: capo-test -# --- -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# metadata: -# name: "cluster-api-multi-az-md-0-eu-west-2a" -# namespace: capo-test -# spec: -# template: -# spec: -# node: -# clusterName: cluster-api-multi-az -# image: -# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 -# keypair: -# name: cluster-api-test -# deleteKeypair: true -# vm: -# clusterName: cluster-api-multi-az -# rootDisk: -# rootDiskSize: 30 -# rootDiskIops: 1500 -# rootDiskType: "gp2" -# keypairName: cluster-api-test -# subnetName: cluster-api-multi-az-eu-west-2a -# vmType: "tinav6.c2r4p2" -# --- -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# metadata: -# name: "cluster-api-multi-az-md-0-eu-west-2b" -# namespace: capo-test -# spec: -# template: -# spec: -# node: -# clusterName: cluster-api-multi-az -# image: -# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 -# keypair: -# name: cluster-api-test -# deleteKeypair: true -# vm: -# clusterName: cluster-api-multi-az -# rootDisk: -# rootDiskSize: 30 -# rootDiskIops: 1500 -# rootDiskType: "gp2" -# keypairName: cluster-api-test -# subnetName: cluster-api-multi-az-eu-west-2b -# vmType: "tinav6.c2r4p2" -# --- -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# metadata: -# name: "cluster-api-multi-az-control-plane-eu-west-2a" -# namespace: capo-test -# spec: -# template: -# spec: -# node: -# clusterName: cluster-api-multi-az -# image: -# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 -# keypair: -# name: cluster-api-test -# deleteKeypair: true -# vm: -# clusterName: cluster-api-multi-az -# keypairName: cluster-api-test -# subnetName: cluster-api-multi-az-eu-west-2a -# rootDisk: -# rootDiskSize: 30 -# rootDiskIops: 1500 -# rootDiskType: "gp2" -# role: controlplane -# loadBalancerName: capo-k8s -# vmType: "tinav6.c4r8p1" -# --- -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# kind: OscMachineTemplate -# metadata: -# name: "cluster-api-multi-az-control-plane-eu-west-2b" -# namespace: capo-test -# spec: -# template: -# spec: -# node: -# clusterName: cluster-api-multi-az -# image: -# name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 -# keypair: -# name: cluster-api-test -# deleteKeypair: true -# vm: -# clusterName: cluster-api-multi-az -# keypairName: cluster-api-test -# subnetName: cluster-api-multi-az-eu-west-2b -# rootDisk: -# rootDiskSize: 30 -# rootDiskIops: 1500 -# rootDiskType: "gp2" -# role: controlplane -# loadBalancerName: capo-k8s -# vmType: "tinav6.c4r8p1" -# --- -# apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -# kind: KubeadmConfigTemplate -# metadata: -# name: "cluster-api-multi-az-md-0" -# namespace: capo-test -# spec: -# template: -# spec: -# files: -# - content: | -# #!/bin/bash - -# curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 -# chmod +x /tmp/runc.amd64 -# \cp -f /tmp/runc.amd64 /usr/local/sbin/runc -# owner: root:root -# path: /tmp/set_runc.sh -# permissions: "0744" -# joinConfiguration: -# nodeRegistration: -# name: "{{ ds.meta_data.local_hostname }}" -# kubeletExtraArgs: -# cloud-provider: external -# provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' -# preKubeadmCommands: -# - sh /tmp/set_runc.sh + - name: cluster-api-multi-az-securitygroup-lb + description: Cluster-api Load Balancer Security Group + securityGroupRules: + - name: cluster-api-securitygrouprule-calico-vxlan + flow: Inbound + ipProtocol: tcp + ipRange: "0.0.0.0/0" + fromPortRange: 6443 + toPortRange: 6443 + - name: cluster-api-multi-az-securitygroup-control-plane + description: Cluster-api Control Plane Security Group + securityGroupRules: + - name: cluster-api-securitygrouprule-nodes + flow: Inbound + ipProtocol: "-1" + ipRange: "10.0.0.0/16" + fromPortRange: 1 + toPortRange: 65535 + - name: cluster-api-multi-az-securitygroup-worker + description: Cluster-api Worker Security Group + securityGroupRules: + - name: cluster-api-securitygrouprule-nodes + flow: Inbound + ipProtocol: "-1" + ipRange: "10.0.0.0/16" + fromPortRange: 1 + toPortRange: 65535 + bastion: + clusterName: cluster-api-multi-az + enable: false +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: cluster-api-multi-az-control-plane-2a + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api-multi-az + name: cluster-api-multi-az-vm-control-plane-2a + keypairName: cluster-api-test + rootDisk: + rootDiskSize: 50 + rootDiskIops: 1500 + rootDiskType: gp2 + deviceName: /dev/sda1 + subregionName: eu-west-2a + subnetName: cluster-api-multi-az-subnet-2a-private + role: controlplane + loadBalancerName: cluster-api-multi-az-lb + securityGroupNames: + - name: cluster-api-multi-az-securitygroup-control-plane + vmType: "tinav6.c4r8p1" --- kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 metadata: - name: "cluster-api-multi-az-control-plane-eu-west-2a" + name: cluster-api-multi-az-control-plane-2a + namespace: capo-test spec: replicas: 1 machineTemplate: infrastructureRef: kind: OscMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - name: "cluster-api-multi-az-control-plane-eu-west-2a" + name: cluster-api-multi-az-control-plane-2a namespace: capo-test kubeadmConfigSpec: initConfiguration: @@ -279,39 +204,150 @@ spec: preKubeadmCommands: - sh /tmp/set_runc.sh version: "1.22.11" -# --- -# kind: KubeadmControlPlane -# apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -# metadata: -# name: "cluster-api-multi-az-control-plane-eu-west-2b" -# spec: -# replicas: 1 -# machineTemplate: -# infrastructureRef: -# kind: OscMachineTemplate -# apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -# name: "cluster-api-multi-az-control-plane-eu-west-2b" -# namespace: capo-test -# kubeadmConfigSpec: -# initConfiguration: -# nodeRegistration: -# kubeletExtraArgs: -# cloud-provider: external -# provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' -# name: '{{ ds.meta_data.local_hostname }}' -# files: -# - content: | -# #!/bin/bash -# curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 -# chmod +x /tmp/runc.amd64 -# \cp -f /tmp/runc.amd64 /usr/local/sbin/runc -# owner: root:root -# path: /tmp/set_runc.sh -# permissions: "0744" -# joinConfiguration: -# nodeRegistration: -# kubeletExtraArgs: -# cloud-provider: external -# preKubeadmCommands: -# - sh /tmp/set_runc.sh -# version: "1.22.11" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: cluster-api-multi-az-worker-2a + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api-multi-az + name: cluster-api-multi-az-vm-worker-2a + keypairName: cluster-api-test + rootDisk: + rootDiskSize: 50 + rootDiskIops: 1500 + rootDiskType: gp2 + deviceName: /dev/sda1 + subregionName: eu-west-2a + subnetName: cluster-api-multi-az-subnet-2a-private + securityGroupNames: + - name: cluster-api-multi-az-securitygroup-worker + vmType: "tinav6.c4r8p2" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: OscMachineTemplate +metadata: + name: cluster-api-multi-az-worker-2b + namespace: capo-test +spec: + template: + spec: + node: + clusterName: cluster-api-multi-az + image: + name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 + keypair: + name: cluster-api-test + deleteKeypair: false + vm: + clusterName: cluster-api-multi-az + name: cluster-api-multi-az-vm-worker-2b + keypairName: cluster-api-test + rootDisk: + rootDiskSize: 50 + rootDiskIops: 1500 + rootDiskType: gp2 + deviceName: /dev/sda1 + subregionName: eu-west-2b + subnetName: cluster-api-multi-az-subnet-2b-private + securityGroupNames: + - name: cluster-api-multi-az-securitygroup-worker + vmType: "tinav6.c4r8p2" +--- +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: KubeadmConfigTemplate +metadata: + name: "cluster-api-multi-az-worker-config" + namespace: capo-test +spec: + template: + spec: + files: + - content: | + #!/bin/sh + + curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 + chmod +x /tmp/runc.amd64 + cp -f /tmp/runc.amd64 /usr/local/sbin/runc + owner: root:root + path: /tmp/set_runc.sh + permissions: "0744" + joinConfiguration: + nodeRegistration: + name: "{{ ds.meta_data.local_hostname }}" + kubeletExtraArgs: + cloud-provider: external + provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' + preKubeadmCommands: + - sh /tmp/set_runc.sh +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: cluster-api-multi-az-worker-2a-md + namespace: capo-test +spec: + clusterName: cluster-api-multi-az + replicas: 1 + selector: + matchLabels: + node-role: worker + template: + metadata: + labels: + node-role: worker + spec: + clusterName: cluster-api-multi-az + version: "1.22.11" + bootstrap: + configRef: + name: cluster-api-multi-az-worker-config + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: capo-test + infrastructureRef: + name: cluster-api-multi-az-worker-2a + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: capo-test +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: cluster-api-multi-az-worker-2b-md + namespace: capo-test +spec: + clusterName: cluster-api-multi-az + replicas: 1 + selector: + matchLabels: + node-role: worker + template: + metadata: + labels: + node-role: worker + spec: + clusterName: cluster-api-multi-az + version: "1.22.11" + bootstrap: + configRef: + name: cluster-api-multi-az-worker-config + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + namespace: capo-test + infrastructureRef: + name: cluster-api-multi-az-worker-2b + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OscMachineTemplate + namespace: capo-test diff --git a/example/cluster-machine-template-simple2.yaml b/example/cluster-machine-template-simple2.yaml deleted file mode 100644 index c684eabef..000000000 --- a/example/cluster-machine-template-simple2.yaml +++ /dev/null @@ -1,463 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - name: cluster-api - namespace: capo-test - labels: - cni: "calico-v3-19" - ccm: "cluster-api-crs-ccm" -spec: - clusterNetwork: - pods: - cidrBlocks: ["10.42.0.0/16"] - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: OscCluster - name: cluster-api - namespace: capo-test - controlPlaneRef: - kind: KubeadmControlPlane - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - name: "cluster-api-control-plane" - namespace: capo-test ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscCluster -metadata: - name: cluster-api - namespace: capo-test -spec: - network: - clusterName: cluster-api - subregionName: eu-west-2a - loadBalancer: - loadbalancername: osc-k8s - loadbalancertype: internet-facing - subnetname: cluster-api-subnet-public - securitygroupname: cluster-api-securitygroup-lb - clusterName: cluster-api - net: - name: cluster-api-net - clusterName: cluster-api - ipRange: "10.0.0.0/16" - subnets: - - name: cluster-api-subnet-kcp-a - ipSubnetRange: "10.0.4.0/24" - subregionName: eu-west-2a - # - name: cluster-api-subnet-kcp-b - # ipSubnetRange: "10.0.5.0/24" - # subregionName: eu-west-2b - - name: cluster-api-subnet-kw-a - ipSubnetRange: "10.0.3.0/24" - subregionName: eu-west-2a - - name: cluster-api-subnet-kw-b - ipSubnetRange: "10.0.6.0/24" - subregionName: eu-west-2b - - name: cluster-api-subnet-public - ipSubnetRange: "10.0.2.0/24" - publicIps: - - name: cluster-api-publicip-nat - internetService: - clusterName: cluster-api - name: cluster-api-internetservice - natServices: - - clusterName: cluster-api - name: cluster-api-natservice - publicipname: cluster-api-publicip-nat - subnetname: cluster-api-subnet-public - bastion: - clusterName: cluster-api - enable: false - routeTables: - - name: cluster-api-routetable-kw - subnets: - - cluster-api-subnet-kw-a - - cluster-api-subnet-kw-b - routes: - - name: cluster-api-routes-kw - targetName: cluster-api-natservice - targetType: nat - destination: "0.0.0.0/0" - - name: cluster-api-routetable-kcp - subnets: - - cluster-api-subnet-kcp-a - # - cluster-api-subnet-kcp-b - routes: - - name: cluster-api-routes-kcp - targetName: cluster-api-natservice - targetType: nat - destination: "0.0.0.0/0" - - name: cluster-api-routetable-public - subnets: - - cluster-api-subnet-public - routes: - - name: cluster-api-routes-public - targetName: cluster-api-internetservice - targetType: gateway - destination: "0.0.0.0/0" - securityGroups: - # - name: cluster-api-securitygroups - # description: Security Group with cluster-api - # securityGroupRules: - # - name: - # flow: Inboud - # ipProtocol: tcp - # fromPortRange: 22 - # toPortRange: 22 - - name: cluster-api-securitygroups-kw - description: Security Group with cluster-api - securityGroupRules: - - name: cluster-api-securitygrouprule-api-kubelet-kw - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.3.0/24" - fromPortRange: 10250 - toPortRange: 10250 - - name: cluster-api-securitygrouprule-api-kubelet-kcp - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 10250 - toPortRange: 10250 - - name: cluster-api-securitygrouprule-kcp-nodeip-kw - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.3.0/24" - fromPortRange: 30000 - toPortRange: 32767 - - name: cluster-api-securitygrouprule-kcp-nodeip-kcp - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 30000 - toPortRange: 32767 - - name: cluster-api-securitygrouprule-kw-bgp - flow: Inbound - ipProtocol: tcp - ipRange: "10.0.0.0/16" - fromPortRange: 179 - toPortRange: 179 - - name: cluster-api-securitygroups-kcp - description: Security Group with cluster-api - securityGroupRules: - - name: cluster-api-securitygrouprule-api-kw - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.3.0/24" - fromPortRange: 6443 - toPortRange: 6443 - - name: cluster-api-securitygrouprule-api-kcp - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 6443 - toPortRange: 6443 - - name: cluster-api-securitygrouprule-etcd - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 2378 - toPortRange: 2379 - - name: cluster-api-securitygrouprule-kubelet-kcp - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 10250 - toPortRange: 10252 - - name: cluster-api-securitygrouprule-kcp-bgp - flow: Inbound - ipProtocol: tcp - ipRange: "10.0.0.0/16" - fromPortRange: 179 - toPortRange: 179 - - name: cluster-api-securitygrouprule-kw-nodeip-kw - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.3.0/24" - fromPortRange: 30000 - toPortRange: 32767 - - name: cluster-api-securitygrouprule-kw-nodeip-kcp - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "10.0.4.0/24" - fromPortRange: 30000 - toPortRange: 32767 - - name: cluster-api-securitygroup-lb - description: Security Group lb with cluster-api - securityGroupRules: - - name: cluste-api-securitygrouprule-lb - flow: Inbound - ipProtocol: tcp -# IpRange to authorize access to kubernetes endpoints (kube-apiserver), you must keep it and change it with a CIDR that best suits with your environment. - ipRange: "0.0.0.0/0" - fromPortRange: 6443 - toPortRange: 6443 - - name: cluster-api-securitygroups-node - description: Security Group node with cluster-api - tag: OscK8sMainSG - securityGroupRules: - - name: cluster-api-securitygrouprule-calico-vxlan - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 4789 - toPortRange: 4789 - - name: cluster-api-securitygrouprule-calico-typha - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 5473 - toPortRange: 5473 - - name: cluster-api-securitygrouprule-calico-wireguard - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 51820 - toPortRange: 51820 - - name: cluster-api-securitygrouprule-calico-wireguard-ipv6 - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 51821 - toPortRange: 51821 - - name: cluster-api-securitygrouprule-flannel - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 4789 - toPortRange: 4789 - - name: cluster-api-securitygrouperule-flannel-udp - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 8285 - toPortRange: 8285 - - name: cluster-api-securitygroup-flannel-vxlan - flow: Inbound - ipProtocol: udp - ipRange: "10.0.0.0/16" - fromPortRange: 8472 - toPortRange: 8472 ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: "cluster-api-md-0" - namespace: capo-test -spec: - clusterName: "cluster-api" - replicas: 1 - selector: - matchLabels: - template: - spec: - clusterName: "cluster-api" - version: "1.22.11" - bootstrap: - configRef: - name: "cluster-api-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - namespace: capo-test - infrastructureRef: - name: "cluster-api-md-0" - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: OscMachineTemplate - namespace: capo-test ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: "cluster-api-md-1" - namespace: capo-test -spec: - clusterName: "cluster-api" - replicas: 1 - selector: - matchLabels: - template: - spec: - clusterName: "cluster-api" - version: "1.22.11" - bootstrap: - configRef: - name: "cluster-api-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - namespace: capo-test - infrastructureRef: - name: "cluster-api-md-1" - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: OscMachineTemplate - namespace: capo-test ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-md-0" - namespace: capo-test -spec: - template: - spec: - node: - clusterName: cluster-api - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: false - vm: - clusterName: cluster-api - name: cluster-api-vm-kw - keypairName: cluster-api-test - deviceName: /dev/sda1 - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: gp2 - subnetName: cluster-api-subnet-kw-a - subregionName: eu-west-2a - securityGroupNames: - - name: cluster-api-securitygroups-kw - - name: cluster-api-securitygroups-node - vmType: "tinav5.c2r8p2" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-md-1" - namespace: capo-test -spec: - template: - spec: - node: - clusterName: cluster-api - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: false - vm: - clusterName: cluster-api - name: cluster-api-vm-kw - keypairName: cluster-api-test - deviceName: /dev/sda1 - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: gp2 - subnetName: cluster-api-subnet-kw-b - subregionName: eu-west-2b - securityGroupNames: - - name: cluster-api-securitygroups-kw - - name: cluster-api-securitygroups-node - vmType: "tinav5.c2r8p2" - ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: OscMachineTemplate -metadata: - name: "cluster-api-control-plane" - namespace: capo-test -spec: - template: - spec: - node: - clusterName: cluster-api - image: - name: ubuntu-2004-2004-kubernetes-v1.22.11-2022-08-22 - keypair: - name: cluster-api-test - deleteKeypair: false - vm: - clusterName: cluster-api - name: cluster-api-vm-kcp - keypairName: cluster-api-test - rootDisk: - rootDiskSize: 30 - rootDiskIops: 1500 - rootDiskType: gp2 - deviceName: /dev/sda1 - subregionName: eu-west-2a - subnetName: cluster-api-subnet-kcp-a - role: controlplane - loadBalancerName: osc-k8s - securityGroupNames: - - name: cluster-api-securitygroups-kcp - - name: cluster-api-securitygroups-node - vmType: "tinav5.c2r8p2" ---- -apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -kind: KubeadmConfigTemplate -metadata: - name: "cluster-api-md-0" - namespace: capo-test -spec: - template: - spec: - files: - - content: | - #!/bin/sh - - curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 - chmod +x /tmp/runc.amd64 - cp -f /tmp/runc.amd64 /usr/local/sbin/runc - owner: root:root - path: /tmp/set_runc.sh - permissions: "0744" - joinConfiguration: - nodeRegistration: - name: "{{ ds.meta_data.local_hostname }}" - kubeletExtraArgs: - cloud-provider: external - provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' - preKubeadmCommands: - - sh /tmp/set_runc.sh ---- -kind: KubeadmControlPlane -apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -metadata: - name: "cluster-api-control-plane" - namespace: capo-test -spec: - replicas: 1 - machineTemplate: - infrastructureRef: - kind: OscMachineTemplate - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - name: "cluster-api-control-plane" - namespace: capo-test - kubeadmConfigSpec: - initConfiguration: - nodeRegistration: - kubeletExtraArgs: - cloud-provider: external - provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' - name: '{{ ds.meta_data.local_hostname }}' - files: - - content: | - #!/bin/sh - curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 - chmod +x /tmp/runc.amd64 - cp -f /tmp/runc.amd64 /usr/local/sbin/runc - owner: root:root - path: /tmp/set_runc.sh - permissions: "0744" - joinConfiguration: - nodeRegistration: - kubeletExtraArgs: - cloud-provider: external - provider-id: aws:///'{{ ds.meta_data.placement.availability_zone }}'/'{{ ds.meta_data.instance_id }}' - preKubeadmCommands: - - sh /tmp/set_runc.sh - version: "1.22.11" From 151122c4c84b6b0ea1f52b7c4e7150857e151744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20GLON?= Date: Tue, 21 Nov 2023 09:27:56 +0100 Subject: [PATCH 09/11] fix yaml parsing --- example/cluster-machine-template-multi-az.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/cluster-machine-template-multi-az.yaml b/example/cluster-machine-template-multi-az.yaml index e06ea8f40..e6f38803f 100644 --- a/example/cluster-machine-template-multi-az.yaml +++ b/example/cluster-machine-template-multi-az.yaml @@ -1,3 +1,4 @@ +--- apiVersion: cluster.x-k8s.io/v1beta1 kind: Cluster metadata: @@ -276,7 +277,6 @@ spec: files: - content: | #!/bin/sh - curl https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 -Lo /tmp/runc.amd64 chmod +x /tmp/runc.amd64 cp -f /tmp/runc.amd64 /usr/local/sbin/runc From 9e15deda64d819d2680fc64a93b0a5e1ce1e5175 Mon Sep 17 00:00:00 2001 From: David Cherriere Date: Fri, 1 Dec 2023 11:58:49 +0100 Subject: [PATCH 10/11] fix: Bring back osc_region vars and update boiler_plate. --- hack/boilerplate/boilerplate.py | 2 +- hack/verify-boilerplate.sh | 2 +- testenv/osccluster_controller_test.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index cb0093fe2..3f31b0ef3 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -151,7 +151,7 @@ def file_extension(filename): "pkg/kubectl/generated/bindata.go", "tilt_modules", "cloud/services/net/mock_net", "cloud/services/security/mock_security", "cloud/services/service/mock_service", "cloud/services/storage/mock_storage", "cloud/services/compute/mock_compute", - "cloud/tag/mock_tag", "api/v1beta1/zz_generated.deepcopy.go"] + "cloud/tag/mock_tag", "cloud/scope/mock_scope", "api/v1beta1/zz_generated.deepcopy.go"] # list all the files contain 'DO NOT EDIT', but are not generated skipped_ungenerated_files = ['hack/lib/swagger.sh', 'hack/boilerplate/boilerplate.py'] diff --git a/hack/verify-boilerplate.sh b/hack/verify-boilerplate.sh index 09b5ffa3a..ef1f51eab 100755 --- a/hack/verify-boilerplate.sh +++ b/hack/verify-boilerplate.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/bin/bash # Copyright 2022 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/testenv/osccluster_controller_test.go b/testenv/osccluster_controller_test.go index 20b360a1c..b6fc1ae56 100644 --- a/testenv/osccluster_controller_test.go +++ b/testenv/osccluster_controller_test.go @@ -891,6 +891,7 @@ var _ = Describe("Outscale Cluster Reconciler", func() { }) It("should create a simple cluster with default values", func() { ctx := context.Background() + osc_region, ok := os.LookupEnv("OSC_REGION") infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ Net: infrastructurev1beta1.OscNet{ From c633a396dca4808f38322a8549507e263d8c806d Mon Sep 17 00:00:00 2001 From: David Cherriere Date: Fri, 1 Dec 2023 16:21:43 +0100 Subject: [PATCH 11/11] Put back deleted line as requested in PR review --- testenv/osccluster_controller_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/testenv/osccluster_controller_test.go b/testenv/osccluster_controller_test.go index b6fc1ae56..e0ea0d070 100644 --- a/testenv/osccluster_controller_test.go +++ b/testenv/osccluster_controller_test.go @@ -894,6 +894,7 @@ var _ = Describe("Outscale Cluster Reconciler", func() { osc_region, ok := os.LookupEnv("OSC_REGION") infraClusterSpec := infrastructurev1beta1.OscClusterSpec{ Network: infrastructurev1beta1.OscNetwork{ + SubregionName: osc_subregion, Net: infrastructurev1beta1.OscNet{ Name: "cluster-api-net", },