Skip to content

Commit 24b7961

Browse files
committed
Update FloatingIPPool to use v1beta1
Also make IdentityRef required, as it doesn't currently permit fallback to cluster credentials.
1 parent 27b3cef commit 24b7961

File tree

5 files changed

+76
-53
lines changed

5 files changed

+76
-53
lines changed

api/v1alpha1/openstackfloatingippool_types.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2424

25-
// We use v1alpha7 here rather than anything newer because as of writing
26-
// it is the newest API version we should no longer be making breaking
27-
// changes to. If we bump this we need to look carefully for resulting
28-
// CRD changes in v1alpha1 to ensure they are compatible.
29-
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
25+
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
3026
)
3127

3228
const (
@@ -62,16 +58,12 @@ type OpenStackFloatingIPPoolSpec struct {
6258
MaxIPs *int `json:"maxIPs,omitempty"`
6359

6460
// IdentityRef is a reference to a identity to be used when reconciling this pool.
65-
// +optional
66-
IdentityRef *infrav1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"`
61+
// +kubebuilder:validation:Required
62+
IdentityRef infrav1.OpenStackIdentityReference `json:"identityRef"`
6763

6864
// FloatingIPNetwork is the external network to use for floating ips, if there's only one external network it will be used by default
6965
// +optional
70-
FloatingIPNetwork infrav1alpha7.NetworkFilter `json:"floatingIPNetwork"`
71-
72-
// The name of the cloud to use from the clouds secret
73-
// +optional
74-
CloudName string `json:"cloudName"`
66+
FloatingIPNetwork infrav1.NetworkFilter `json:"floatingIPNetwork"`
7567

7668
// The stratergy to use for reclaiming floating ips when they are released from a machine
7769
// +kubebuilder:validation:Optional
@@ -95,7 +87,7 @@ type OpenStackFloatingIPPoolStatus struct {
9587

9688
// floatingIPNetwork contains information about the network used for floating ips
9789
// +optional
98-
FloatingIPNetwork *infrav1alpha7.NetworkStatus `json:"floatingIPNetwork,omitempty"`
90+
FloatingIPNetwork *infrav1.NetworkStatus `json:"floatingIPNetwork,omitempty"`
9991

10092
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
10193
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackfloatingippools.yaml

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ spec:
4141
description: OpenStackFloatingIPPoolSpec defines the desired state of
4242
OpenStackFloatingIPPool.
4343
properties:
44-
cloudName:
45-
description: The name of the cloud to use from the clouds secret
46-
type: string
4744
floatingIPNetwork:
4845
description: FloatingIPNetwork is the external network to use for
4946
floating ips, if there's only one external network it will be used
@@ -56,34 +53,77 @@ spec:
5653
name:
5754
type: string
5855
notTags:
59-
type: string
56+
description: |-
57+
NotTags is a list of tags to filter by. If specified, resources which
58+
contain all of the given tags will be excluded from the result.
59+
items:
60+
description: |-
61+
NeutronTag represents a tag on a Neutron resource.
62+
It may not be empty and may not contain commas.
63+
minLength: 1
64+
pattern: ^[^,]+$
65+
type: string
66+
type: array
67+
x-kubernetes-list-type: set
6068
notTagsAny:
61-
type: string
62-
projectId:
69+
description: |-
70+
NotTagsAny is a list of tags to filter by. If specified, resources
71+
which contain any of the given tags will be excluded from the result.
72+
items:
73+
description: |-
74+
NeutronTag represents a tag on a Neutron resource.
75+
It may not be empty and may not contain commas.
76+
minLength: 1
77+
pattern: ^[^,]+$
78+
type: string
79+
type: array
80+
x-kubernetes-list-type: set
81+
projectID:
6382
type: string
6483
tags:
65-
type: string
84+
description: |-
85+
Tags is a list of tags to filter by. If specified, the resource must
86+
have all of the tags specified to be included in the result.
87+
items:
88+
description: |-
89+
NeutronTag represents a tag on a Neutron resource.
90+
It may not be empty and may not contain commas.
91+
minLength: 1
92+
pattern: ^[^,]+$
93+
type: string
94+
type: array
95+
x-kubernetes-list-type: set
6696
tagsAny:
67-
type: string
97+
description: |-
98+
TagsAny is a list of tags to filter by. If specified, the resource
99+
must have at least one of the tags specified to be included in the
100+
result.
101+
items:
102+
description: |-
103+
NeutronTag represents a tag on a Neutron resource.
104+
It may not be empty and may not contain commas.
105+
minLength: 1
106+
pattern: ^[^,]+$
107+
type: string
108+
type: array
109+
x-kubernetes-list-type: set
68110
type: object
69111
identityRef:
70112
description: IdentityRef is a reference to a identity to be used when
71113
reconciling this pool.
72114
properties:
73-
kind:
74-
description: |-
75-
Kind of the identity. Must be supported by the infrastructure
76-
provider and may be either cluster or namespace-scoped.
77-
minLength: 1
115+
cloudName:
116+
description: CloudName specifies the name of the entry in the
117+
clouds.yaml file to use.
78118
type: string
79119
name:
80120
description: |-
81-
Name of the infrastructure identity to be used.
82-
Must be either a cluster-scoped resource, or namespaced-scoped
83-
resource the same namespace as the resource(s) being provisioned.
121+
Name is the name of a secret in the same namespace as the resource being provisioned.
122+
The secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
123+
The secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
84124
type: string
85125
required:
86-
- kind
126+
- cloudName
87127
- name
88128
type: object
89129
maxIPs:
@@ -105,6 +145,8 @@ spec:
105145
- Retain
106146
- Delete
107147
type: string
148+
required:
149+
- identityRef
108150
type: object
109151
status:
110152
description: OpenStackFloatingIPPoolStatus defines the observed state

controllers/openstackfloatingippool_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ import (
4141
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4242

4343
infrav1alpha1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha1"
44-
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
4544
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
4645
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/networking"
4746
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
48-
filterconvert "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/filterconvert/v1alpha7"
47+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/filterconvert"
4948
)
5049

5150
const (
@@ -402,7 +401,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc
402401
}
403402

404403
netListOpts := external.ListOptsExt{
405-
ListOptsBuilder: filterconvert.NetworkFilterToListOpt(&pool.Spec.FloatingIPNetwork),
404+
ListOptsBuilder: filterconvert.NetworkFilterToListOpts(&pool.Spec.FloatingIPNetwork),
406405
External: pointer.Bool(true),
407406
}
408407

@@ -414,7 +413,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc
414413
return fmt.Errorf("found multiple networks, expects filter to match one (result: %v)", networkList)
415414
}
416415

417-
pool.Status.FloatingIPNetwork = &infrav1alpha7.NetworkStatus{
416+
pool.Status.FloatingIPNetwork = &infrav1.NetworkStatus{
418417
ID: networkList[0].ID,
419418
Name: networkList[0].Name,
420419
Tags: networkList[0].Tags,

pkg/scope/provider.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,9 @@ func (f *providerScopeFactory) NewClientScopeFromCluster(ctx context.Context, ct
106106
}
107107

108108
func (f *providerScopeFactory) NewClientScopeFromFloatingIPPool(ctx context.Context, ctrlClient client.Client, openstackFloatingIPPool *v1alpha1.OpenStackFloatingIPPool, defaultCACert []byte, logger logr.Logger) (Scope, error) {
109-
var cloud clientconfig.Cloud
110-
var caCert []byte
111-
112-
if openstackFloatingIPPool.Spec.IdentityRef != nil {
113-
var err error
114-
cloud, caCert, err = getCloudFromSecret(ctx, ctrlClient, openstackFloatingIPPool.Namespace, openstackFloatingIPPool.Spec.IdentityRef.Name, openstackFloatingIPPool.Spec.CloudName)
115-
if err != nil {
116-
return nil, err
117-
}
109+
cloud, caCert, err := getCloudFromSecret(ctx, ctrlClient, openstackFloatingIPPool.Namespace, openstackFloatingIPPool.Spec.IdentityRef.Name, openstackFloatingIPPool.Spec.IdentityRef.CloudName)
110+
if err != nil {
111+
return nil, err
118112
}
119113

120114
if caCert == nil {

0 commit comments

Comments
 (0)