Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added pagination for list calls #283

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY version/ version/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}

FROM ghcr.io/oracle/oraclelinux:8-slim
FROM ghcr.io/oracle/oraclelinux:9-slim
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ generate-e2e-templates: $(KUSTOMIZE)
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-externally-managed-vcn --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-externally-managed-vcn.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-machine-pool.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-node-recycling --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-node-recycling.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-self-managed-nodes --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-self-managed-nodes.yaml

.PHONY: test-e2e-run
test-e2e-run: generate-e2e-templates $(GINKGO) $(ENVSUBST) ## Run e2e tests
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ The Cluster API itself is shared across multiple cloud providers allowing for tr

### Features

- Manages the bootstrapping of VCNs, gateways, subnets, network security groups and instances
- Deploy either Oracle Linux or Ubuntu based instances using custom images built with the [Image Builder][image_builder_book] tool
- Deploys Kubernetes Control plane into private subnets front-ended by a public load balancer
- Self-managed and OCI Container Engine for Kubernetes(OKE) clusters
- Manages the bootstrapping of VCNs, gateways, subnets, network security groups
- Provide secure and sensible defaults

### Getting Started
Expand Down Expand Up @@ -81,5 +80,5 @@ Released under the Apache License License Version 2.0 as shown at http://www.apa
[image_builder_book]: https://image-builder.sigs.k8s.io/capi/providers/oci.html
[capoci_book]: https://oracle.github.io/cluster-api-provider-oci/
[#cluster-api-oci slack]: https://kubernetes.slack.com/archives/C039CDHABFF
[zoomMeeting]: https://oracle.zoom.us/j/99910180651
[zoomMeeting]: https://oracle.zoom.us/j/97952312891?pwd=NlFnMWQzbGpMRmNyaityVHNWQWxSdz09
[notes]: https://docs.google.com/document/d/1mgZxjDbnSv74Vut1aHtWplG6vsR9zu5sqXvQN8SPgCc
2 changes: 2 additions & 0 deletions api/v1beta1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ const (
ControlPlaneDefaultName = "control-plane"
WorkerDefaultName = "worker"
ServiceLBDefaultName = "service-lb"
PodDefaultName = "pod"
PodDefaultCIDR = "10.0.128.0/18"
)
26 changes: 18 additions & 8 deletions api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package v1beta1

import (
"errors"
"github.com/oracle/cluster-api-provider-oci/api/v1beta2"
"k8s.io/apimachinery/pkg/conversion"
)
Expand Down Expand Up @@ -115,20 +114,31 @@ func Convert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec(in *OCIMachineSpec
if err != nil {
return err
}
if in.NetworkDetails.SubnetId != nil {
return errors.New("deprecated field NetworkDetails.SubnetId is present in OCIMachineSpec")
}
if in.NetworkDetails.NSGId != nil {
return errors.New("deprecated field NetworkDetails.NSGId is present in OCIMachineSpec")
}
if in.NSGName != "" && len(in.NetworkDetails.NsgNames) == 0 {
out.NetworkDetails.NsgNames = []string{in.NSGName}
}
return nil
}

// Convert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer converts v1beta2 LoadBalancer to v1beta1 LoadBalancer

func Convert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer(in *v1beta2.LoadBalancer, out *LoadBalancer, s conversion.Scope) error {
return autoConvert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer(in, out, s)
}

func Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error {
return autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in, out, s)
}

func Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error {
return autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in, out, s)
}

// Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus converts v1beta1 OCIManagedClusterStatus to v1beta2 OCIManagedClusterStatus
func Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in *OCIManagedClusterStatus, out *v1beta2.OCIManagedClusterStatus, s conversion.Scope) error {
return autoConvert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in, out, s)
}

// Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec converts v1beta1 OCIManagedClusterSpec to v1beta2 OCIManagedClusterSpec
func Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in *v1beta2.OCIManagedClusterSpec, out *OCIManagedClusterSpec, s conversion.Scope) error {
return autoConvert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in, out, s)
}
41 changes: 37 additions & 4 deletions api/v1beta1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
OCIMachineTemplateFuzzer,
OCIClusterFuzzer,
OCIClusterTemplateFuzzer,
OCIManagedClusterFuzzer,
}
}

func OCIMachineFuzzer(obj *OCIMachine, c fuzz.Continue) {
c.FuzzNoCustom(obj)
// nil fields which have been removed so that tests dont fail
obj.Spec.NetworkDetails.NSGId = nil
obj.Spec.NetworkDetails.SubnetId = nil
obj.Spec.NSGName = ""
}

Expand Down Expand Up @@ -92,11 +91,31 @@ func OCIClusterTemplateFuzzer(obj *OCIClusterTemplate, c fuzz.Continue) {
func OCIMachineTemplateFuzzer(obj *OCIMachineTemplate, c fuzz.Continue) {
c.FuzzNoCustom(obj)
// nil fields which ave been removed so that tests dont fail
obj.Spec.Template.Spec.NetworkDetails.NSGId = nil
obj.Spec.Template.Spec.NetworkDetails.SubnetId = nil
obj.Spec.Template.Spec.NSGName = ""
}

func OCIManagedClusterFuzzer(obj *OCIManagedCluster, c fuzz.Continue) {
c.FuzzNoCustom(obj)
// nil fields which have been removed so that tests dont fail
for _, nsg := range obj.Spec.NetworkSpec.Vcn.NetworkSecurityGroups {
if nsg != nil {
ingressRules := make([]IngressSecurityRuleForNSG, len(nsg.IngressRules))
for _, rule := range nsg.IngressRules {
rule.ID = nil
ingressRules = append(ingressRules, rule)
}
nsg.IngressRules = ingressRules

egressRules := make([]EgressSecurityRuleForNSG, len(nsg.EgressRules))
for _, rule := range nsg.EgressRules {
(&rule).ID = nil
egressRules = append(egressRules, rule)
}
nsg.EgressRules = egressRules
}
}
}

func TestFuzzyConversion(t *testing.T) {
g := NewWithT(t)
scheme := runtime.NewScheme()
Expand Down Expand Up @@ -138,4 +157,18 @@ func TestFuzzyConversion(t *testing.T) {
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

t.Run("for OCIManagedControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1beta2.OCIManagedControlPlane{},
Spoke: &OCIManagedControlPlane{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

t.Run("for OCIManagedCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1beta2.OCIManagedCluster{},
Spoke: &OCIManagedCluster{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
package v1beta1

import (
infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1"
"github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2"
"github.com/oracle/cluster-api-provider-oci/api/v1beta2"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand All @@ -31,7 +30,7 @@ func (src *OCIManagedCluster) ConvertTo(dstRaw conversion.Hub) error {
return err
}

ad, err := infrastructurev1beta1.Convertv1beta1AdMapTov1beta2AdMap(src.Status.AvailabilityDomains)
ad, err := Convertv1beta1AdMapTov1beta2AdMap(src.Status.AvailabilityDomains)
if err != nil {
return err
}
Expand Down Expand Up @@ -61,7 +60,7 @@ func (r *OCIManagedCluster) ConvertFrom(srcRaw conversion.Hub) error {
return err
}

ad, err := infrastructurev1beta1.Convertv1beta2AdMapTov1beta1AdMap(src.Spec.AvailabilityDomains)
ad, err := Convertv1beta2AdMapTov1beta1AdMap(src.Spec.AvailabilityDomains)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1beta1

import (
infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand All @@ -43,7 +42,7 @@ type OCIManagedClusterSpec struct {

// NetworkSpec encapsulates all things related to OCI network.
// +optional
NetworkSpec infrastructurev1beta1.NetworkSpec `json:"networkSpec,omitempty"`
NetworkSpec NetworkSpec `json:"networkSpec,omitempty"`

// Free-form tags for this resource.
// +optional
Expand Down Expand Up @@ -76,7 +75,7 @@ type OCIManagedClusterStatus struct {
// AvailabilityDomains encapsulates the clusters Availability Domain (AD) information in a map
// where the map key is the AD name and the struct is details about the AD.
// +optional
AvailabilityDomains map[string]infrastructurev1beta1.OCIAvailabilityDomain `json:"availabilityDomains,omitempty"`
AvailabilityDomains map[string]OCIAvailabilityDomain `json:"availabilityDomains,omitempty"`

// +optional
Ready bool `json:"ready"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1beta1

import (
"github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2"
"github.com/oracle/cluster-api-provider-oci/api/v1beta2"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand All @@ -34,6 +34,8 @@ func (src *OCIManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error {
return err
}
dst.Spec.ClusterType = restored.Spec.ClusterType
dst.Spec.Addons = restored.Spec.Addons
dst.Status.AddonStatus = restored.Status.AddonStatus
return nil
}

Expand Down
12 changes: 9 additions & 3 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ var OCIManagedClusterSubnetRoles = []Role{PodRole, ControlPlaneEndpointRole, Wor

// NetworkDetails defines the configuration options for the network
type NetworkDetails struct {
// SubnetId defines the ID of the subnet to use.
// Deprecated, use SubnetName parameter
// SubnetId defines the ID of the subnet to use. This parameter takes priority over SubnetName.
SubnetId *string `json:"subnetId,omitempty"`

// AssignPublicIp defines whether the instance should have a public IP address
Expand All @@ -44,7 +43,7 @@ type NetworkDetails struct {
// SubnetName defines the subnet name to use for the VNIC
SubnetName string `json:"subnetName,omitempty"`

// Deprecated, use NsgNames parameter to define the NSGs
// NSGId defines the ID of the NSG to use. This parameter takes priority over NsgNames.
NSGId *string `json:"nsgId,omitempty"`

// SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC.
Expand Down Expand Up @@ -1026,3 +1025,10 @@ type RemotePeeringConnection struct {
// RPCConnectionId is the connection ID of the connection between peer and local RPC.
RPCConnectionId *string `json:"rpcConnectionId,omitempty"`
}

const (
VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE"
FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY"
)

type CNIOptionEnum string
Loading