Skip to content

Commit fe5230d

Browse files
author
Joshua Reed
committed
Creates FDs, but doesn't fully use them yet.
1 parent fdc96b3 commit fe5230d

25 files changed

+431
-280
lines changed

api/v1beta2/cloudstackcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,19 @@ type CloudStackClusterStatus struct {
118118
Ready bool `json:"ready"`
119119

120120
// Cloudstack Domain ID the cluster is built in.
121+
// +optional
121122
DomainID string `json:"domainID,omitempty"`
122123

123124
// The CS public IP ID to use for the k8s endpoint.
125+
// +optional
124126
PublicIPID string `json:"publicIPID,omitempty"`
125127

126128
// The ID of the network the PublicIP is in.
129+
// +optional
127130
PublicIPNetworkID string `json:"publicIPNetworkID,omitempty"`
128131

129132
// The ID of the lb rule used to assign VMs to the lb.
133+
// +optional
130134
LBRuleID string `json:"loadBalancerRuleID,omitempty"`
131135
}
132136

api/v1beta2/cloudstackcluster_webhook.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package v1beta2
1818

1919
import (
2020
"fmt"
21-
"reflect"
2221

2322
"k8s.io/apimachinery/pkg/api/errors"
2423
"k8s.io/apimachinery/pkg/runtime"
@@ -38,8 +37,6 @@ func (r *CloudStackCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
3837
Complete()
3938
}
4039

41-
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta2-cloudstackcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,verbs=create;update,versions=v1beta2,name=mcloudstackcluster.kb.io,admissionReviewVersions=v1beta1
42-
4340
var _ webhook.Defaulter = &CloudStackCluster{}
4441

4542
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -48,7 +45,14 @@ func (r *CloudStackCluster) Default() {
4845
// No defaulted values supported yet.
4946
}
5047

51-
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudstackcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,verbs=create;update,versions=v1beta2,name=vcloudstackcluster.kb.io,admissionReviewVersions=v1beta1
48+
// +kubebuilder:webhook:
49+
// name=vcloudstackcluster.kb.io
50+
// groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters
51+
// versions=v1beta2
52+
// verbs=create;update
53+
// path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudstackcluster
54+
// mutating=false,failurePolicy=fail,sideEffects=None
55+
// admissionReviewVersions=v1beta2
5256

5357
var _ webhook.Validator = &CloudStackCluster{}
5458

@@ -101,10 +105,10 @@ func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) error {
101105

102106
// No spec fields may be updated.
103107
errorList := field.ErrorList(nil)
104-
if !reflect.DeepEqual(oldSpec.FailureDomains, spec.FailureDomains) {
105-
errorList = append(errorList, field.Forbidden(
106-
field.NewPath("spec", "Zones"), "Zones and sub-attributes may not be modified after creation"))
107-
}
108+
// if !reflect.DeepEqual(oldSpec.FailureDomains, spec.FailureDomains) {
109+
// errorList = append(errorList, field.Forbidden(
110+
// field.NewPath("spec", "Zones"), "Zones and sub-attributes may not be modified after creation"))
111+
// }
108112
if oldSpec.ControlPlaneEndpoint.Host != "" { // Need to allow one time endpoint setting via CAPC cluster controller.
109113
errorList = webhookutil.EnsureStringFieldsAreEqual(
110114
spec.ControlPlaneEndpoint.Host, oldSpec.ControlPlaneEndpoint.Host, "controlplaneendpoint.host", errorList)

api/v1beta2/cloudstackcluster_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var _ = Describe("CloudStackCluster webhooks", func() {
5050
})
5151

5252
It("Should reject a CloudStackCluster with missing Zone attribute", func() {
53-
dummies.CSCluster.Spec.FailureDomains[0].Zone = infrav1.Zone{}
53+
dummies.CSCluster.Spec.FailureDomains[0].Zone = infrav1.CloudStackZoneSpec{}
5454
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(MatchError(MatchRegexp(requiredRegex,
5555
"each Zone requires a Network specification")))
5656
})

api/v1beta2/cloudstackfailuredomain_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const (
25-
FailuDomainFinalizer = "cloudstackzone.infrastructure.cluster.x-k8s.io"
25+
FailureDomainFinalizer = "cloudstackfailuredomain.infrastructure.cluster.x-k8s.io"
2626
)
2727

2828
// CloudStackFailureDomainSpec defines the desired state of CloudStackFailureDomain
@@ -31,7 +31,7 @@ type CloudStackFailureDomainSpec struct {
3131
Name string `json:"name"`
3232

3333
// The ACS Zone for this failure domain.
34-
Zone Zone `json:"zone"`
34+
Zone CloudStackZoneSpec `json:"zone"`
3535

3636
// CloudStack account.
3737
// +optional

api/v1beta2/cloudstackisolatednetwork_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type CloudStackIsolatedNetworkSpec struct {
3838

3939
// The kubernetes control plane endpoint.
4040
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
41+
42+
// FailureDomain -- the FailureDomain the network is placed in.
43+
FailureDomain CloudStackFailureDomainSpec `json:"failureDomain"`
4144
}
4245

4346
// CloudStackIsolatedNetworkStatus defines the observed state of CloudStackIsolatedNetwork

api/v1beta2/cloudstackmachine_types.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ type CloudStackMachineSpec struct {
7979
// +optional
8080
ProviderID *string `json:"providerID,omitempty"`
8181

82-
// Optionally settable Zone ID to land the machine in.
83-
ZoneID string `json:"zoneID,omitempty"`
84-
85-
// Optionally settable Zone Name to land the machine in.
86-
ZoneName string `json:"zoneName,omitempty"`
82+
// FailureDomain -- the FailureDomain the machine is placed in.
83+
FailureDomain CloudStackFailureDomainSpec `json:"failureDomain"`
8784

8885
// IdentityRef is a reference to a identity to be used when reconciling this cluster
8986
// +optional

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 2 additions & 0 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_cloudstackisolatednetworks.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,63 @@ spec:
118118
- host
119119
- port
120120
type: object
121+
failureDomain:
122+
description: FailureDomain -- the FailureDomain the network is placed
123+
in.
124+
properties:
125+
ACSEndpoint:
126+
description: Apache CloudStack Endpoint secret reference.
127+
properties:
128+
name:
129+
description: Name is unique within a namespace to reference
130+
a secret resource.
131+
type: string
132+
namespace:
133+
description: Namespace defines the space within which the
134+
secret name must be unique.
135+
type: string
136+
type: object
137+
account:
138+
description: CloudStack account.
139+
type: string
140+
domain:
141+
description: CloudStack domain.
142+
type: string
143+
name:
144+
description: The failure domain unique name.
145+
type: string
146+
zone:
147+
description: The ACS Zone for this failure domain.
148+
properties:
149+
id:
150+
description: ID.
151+
type: string
152+
name:
153+
description: Name.
154+
type: string
155+
network:
156+
description: The network within the Zone to use.
157+
properties:
158+
id:
159+
description: Cloudstack Network ID the cluster is built
160+
in.
161+
type: string
162+
name:
163+
description: Cloudstack Network Name the cluster is built
164+
in.
165+
type: string
166+
type:
167+
description: Cloudstack Network Type the cluster is built
168+
in.
169+
type: string
170+
type: object
171+
required:
172+
- network
173+
type: object
174+
required:
175+
- name
176+
- zone
177+
type: object
121178
id:
122179
description: ID.
123180
type: string
@@ -126,6 +183,7 @@ spec:
126183
type: string
127184
required:
128185
- controlPlaneEndpoint
186+
- failureDomain
129187
type: object
130188
status:
131189
description: CloudStackIsolatedNetworkStatus defines the observed state

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

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,63 @@ spec:
383383
- label
384384
- mountPath
385385
type: object
386+
failureDomain:
387+
description: FailureDomain -- the FailureDomain the machine is placed
388+
in.
389+
properties:
390+
ACSEndpoint:
391+
description: Apache CloudStack Endpoint secret reference.
392+
properties:
393+
name:
394+
description: Name is unique within a namespace to reference
395+
a secret resource.
396+
type: string
397+
namespace:
398+
description: Namespace defines the space within which the
399+
secret name must be unique.
400+
type: string
401+
type: object
402+
account:
403+
description: CloudStack account.
404+
type: string
405+
domain:
406+
description: CloudStack domain.
407+
type: string
408+
name:
409+
description: The failure domain unique name.
410+
type: string
411+
zone:
412+
description: The ACS Zone for this failure domain.
413+
properties:
414+
id:
415+
description: ID.
416+
type: string
417+
name:
418+
description: Name.
419+
type: string
420+
network:
421+
description: The network within the Zone to use.
422+
properties:
423+
id:
424+
description: Cloudstack Network ID the cluster is built
425+
in.
426+
type: string
427+
name:
428+
description: Cloudstack Network Name the cluster is built
429+
in.
430+
type: string
431+
type:
432+
description: Cloudstack Network Type the cluster is built
433+
in.
434+
type: string
435+
type: object
436+
required:
437+
- network
438+
type: object
439+
required:
440+
- name
441+
- zone
442+
type: object
386443
id:
387444
description: ID.
388445
type: string
@@ -436,13 +493,8 @@ spec:
436493
description: Cloudstack resource Name
437494
type: string
438495
type: object
439-
zoneID:
440-
description: Optionally settable Zone ID to land the machine in.
441-
type: string
442-
zoneName:
443-
description: Optionally settable Zone Name to land the machine in.
444-
type: string
445496
required:
497+
- failureDomain
446498
- offering
447499
- template
448500
type: object

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

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,63 @@ spec:
336336
- label
337337
- mountPath
338338
type: object
339+
failureDomain:
340+
description: FailureDomain -- the FailureDomain the machine
341+
is placed in.
342+
properties:
343+
ACSEndpoint:
344+
description: Apache CloudStack Endpoint secret reference.
345+
properties:
346+
name:
347+
description: Name is unique within a namespace to
348+
reference a secret resource.
349+
type: string
350+
namespace:
351+
description: Namespace defines the space within which
352+
the secret name must be unique.
353+
type: string
354+
type: object
355+
account:
356+
description: CloudStack account.
357+
type: string
358+
domain:
359+
description: CloudStack domain.
360+
type: string
361+
name:
362+
description: The failure domain unique name.
363+
type: string
364+
zone:
365+
description: The ACS Zone for this failure domain.
366+
properties:
367+
id:
368+
description: ID.
369+
type: string
370+
name:
371+
description: Name.
372+
type: string
373+
network:
374+
description: The network within the Zone to use.
375+
properties:
376+
id:
377+
description: Cloudstack Network ID the cluster
378+
is built in.
379+
type: string
380+
name:
381+
description: Cloudstack Network Name the cluster
382+
is built in.
383+
type: string
384+
type:
385+
description: Cloudstack Network Type the cluster
386+
is built in.
387+
type: string
388+
type: object
389+
required:
390+
- network
391+
type: object
392+
required:
393+
- name
394+
- zone
395+
type: object
339396
id:
340397
description: ID.
341398
type: string
@@ -391,15 +448,8 @@ spec:
391448
description: Cloudstack resource Name
392449
type: string
393450
type: object
394-
zoneID:
395-
description: Optionally settable Zone ID to land the machine
396-
in.
397-
type: string
398-
zoneName:
399-
description: Optionally settable Zone Name to land the machine
400-
in.
401-
type: string
402451
required:
452+
- failureDomain
403453
- offering
404454
- template
405455
type: object

0 commit comments

Comments
 (0)