Skip to content
Merged
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 .golangci-kal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ linters:
text: "Conditions field must be a slice of metav1.Condition"
linters:
- kubeapilinter
- path: "api/v1beta2/*|api/v1beta1/*"
- path: "api/v1beta1/*"
text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
linters:
- kubeapilinter
Expand Down
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ linters:
- linters:
- staticcheck
text: 'SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|dockerMachine.Spec.Backend.Docker.Bootstrapped|dockerMachine.Spec.Bootstrapped|devMachine.Spec.Backend.Docker.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|clusterv1beta1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated'
# Deprecations forGetIPFamily
- linters:
- staticcheck
text: 'SA1019: cluster.GetIPFamily is deprecated: IPFamily is not a concept in Kubernetes. It was originally introduced in CAPI for CAPD. IPFamily will be dropped in a future release. More details at https://github.com/kubernetes-sigs/cluster-api/issues/7521'
# Deprecations for MD revision management
- linters:
- staticcheck
Expand Down
88 changes: 0 additions & 88 deletions api/v1beta2/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net"
"strings"

"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -1222,93 +1221,6 @@ func (c *Cluster) SetConditions(conditions []metav1.Condition) {
c.Status.Conditions = conditions
}

// GetIPFamily returns a ClusterIPFamily from the configuration provided.
//
// Deprecated: IPFamily is not a concept in Kubernetes. It was originally introduced in CAPI for CAPD.
// IPFamily will be dropped in a future release. More details at https://github.com/kubernetes-sigs/cluster-api/issues/7521
func (c *Cluster) GetIPFamily() (ClusterIPFamily, error) {
var podCIDRs, serviceCIDRs []string
if c.Spec.ClusterNetwork != nil {
if c.Spec.ClusterNetwork.Pods != nil {
podCIDRs = c.Spec.ClusterNetwork.Pods.CIDRBlocks
}
if c.Spec.ClusterNetwork.Services != nil {
serviceCIDRs = c.Spec.ClusterNetwork.Services.CIDRBlocks
}
}
if len(podCIDRs) == 0 && len(serviceCIDRs) == 0 {
return IPv4IPFamily, nil
}

podsIPFamily, err := ipFamilyForCIDRStrings(podCIDRs)
if err != nil {
return InvalidIPFamily, fmt.Errorf("pods: %s", err)
}
if len(serviceCIDRs) == 0 {
return podsIPFamily, nil
}

servicesIPFamily, err := ipFamilyForCIDRStrings(serviceCIDRs)
if err != nil {
return InvalidIPFamily, fmt.Errorf("services: %s", err)
}
if len(podCIDRs) == 0 {
return servicesIPFamily, nil
}

if podsIPFamily == DualStackIPFamily {
return DualStackIPFamily, nil
} else if podsIPFamily != servicesIPFamily {
return InvalidIPFamily, errors.New("pods and services IP family mismatch")
}

return podsIPFamily, nil
}

func ipFamilyForCIDRStrings(cidrs []string) (ClusterIPFamily, error) {
if len(cidrs) > 2 {
return InvalidIPFamily, errors.New("too many CIDRs specified")
}
var foundIPv4 bool
var foundIPv6 bool
for _, cidr := range cidrs {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
return InvalidIPFamily, fmt.Errorf("could not parse CIDR: %s", err)
}
if ip.To4() != nil {
foundIPv4 = true
} else {
foundIPv6 = true
}
}
switch {
case foundIPv4 && foundIPv6:
return DualStackIPFamily, nil
case foundIPv4:
return IPv4IPFamily, nil
case foundIPv6:
return IPv6IPFamily, nil
default:
return InvalidIPFamily, nil
}
}

// ClusterIPFamily defines the types of supported IP families.
type ClusterIPFamily int

// Define the ClusterIPFamily constants.
const (
InvalidIPFamily ClusterIPFamily = iota
IPv4IPFamily
IPv6IPFamily
DualStackIPFamily
)

func (f ClusterIPFamily) String() string {
return [...]string{"InvalidIPFamily", "IPv4IPFamily", "IPv6IPFamily", "DualStackIPFamily"}[f]
}

// +kubebuilder:object:root=true

// ClusterList contains a list of Cluster.
Expand Down
197 changes: 0 additions & 197 deletions api/v1beta2/cluster_types_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,7 @@ In addition to variables specified in the ClusterClass, the following builtin va
referenced in patches:
- `builtin.cluster.{name,namespace,uid,metadata.labels,metadata.annotations}`
- `builtin.cluster.topology.{version,class,classNamespace}`
- `builtin.cluster.network.{serviceDomain,services,pods,ipFamily}`
- Note: ipFamily is deprecated and will be removed in a future release. see https://github.com/kubernetes-sigs/cluster-api/issues/7521.
- `builtin.cluster.network.{serviceDomain,services,pods}`
- `builtin.controlPlane.{replicas,version,name,metadata.labels,metadata.annotations}`
- Please note, these variables are only available when patching control plane or control plane
machine templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ type ClusterNetworkBuiltins struct {
// pods is the network ranges from which Pod networks are allocated.
// +optional
Pods []string `json:"pods,omitempty"`
// ipFamily is the IPFamily the Cluster is operating in. One of Invalid, IPv4, IPv6, DualStack.
//
// Deprecated: IPFamily is not a concept in Kubernetes. It was originally introduced in CAPI for CAPD.
// IPFamily will be dropped in a future release. More details at https://github.com/kubernetes-sigs/cluster-api/issues/7521
// +optional
IPFamily string `json:"ipFamily,omitempty"`
}

// ControlPlaneBuiltins represents builtin ControlPlane variables.
Expand Down
7 changes: 0 additions & 7 deletions exp/runtime/hooks/api/v1alpha1/zz_generated.openapi.go

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

Loading
Loading