Skip to content

Commit

Permalink
Merge pull request #70 from GDATASoftwareAG/ipaddressclaims
Browse files Browse the repository at this point in the history
Use IPAddressClaims
  • Loading branch information
Mattes83 authored Feb 1, 2024
2 parents 64ed187 + 5469b22 commit aa30625
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 2 deletions.
19 changes: 19 additions & 0 deletions api/v1alpha1/ionoscloudmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,32 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
// IPAddressCreatedCondition documents the claim of the IPAddress
IPAddressCreatedCondition clusterv1.ConditionType = "IPAddressCreated"

// IPAddressCreationFailedReason (Severity=Error) documents a controller detecting
// issues with the creation of the IP address.
IPAddressCreationFailedReason = "IPAddressCreationFailed"

// ServerCreatedCondition documents the creation of the Server
ServerCreatedCondition clusterv1.ConditionType = "ServerCreated"

// ServerCreationFailedReason (Severity=Error) documents a controller detecting
// issues with the creation of the Server.
ServerCreationFailedReason = "ServerCreationFailed"

// IPAddressClaimCreatedCondition documents the creation of the IP Address
IPAddressClaimCreatedCondition clusterv1.ConditionType = "IPAddressClaimCreated"

// IPAddressClaimCreationFailedReason (Severity=Error) documents a controller detecting
// issues with the creation of the IP address.
IPAddressClaimCreationFailedReason = "IPAddressClaimCreationFailed"
)

// IONOSCloudMachineSpec defines the desired state of IONOSCloudMachine
Expand Down Expand Up @@ -73,6 +88,10 @@ type IONOSVolumeSpec struct {
type IONOSNicSpec struct {
LanRef IONOSLanRefSpec `json:"lanRef"`
PrimaryIP *string `json:"primaryIP,omitempty"`
// PrimaryAddressFrom is an IPAddressPools that should be assigned
// to an IPAddressClaims.
// +optional
PrimaryAddressFrom *corev1.TypedLocalObjectReference `json:"primaryAddressFrom,omitempty"`
//NameTemplate string `json:"nameTemplate"`
}

Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"

infrastructurev1alpha1 "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/api/v1alpha1"
"github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/controller"
Expand All @@ -52,6 +53,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
utilruntime.Must(infrastructurev1alpha1.AddToScheme(scheme))
utilruntime.Must(ipamv1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ spec:
required:
- name
type: object
primaryAddressFrom:
description: PrimaryAddressFrom is an IPAddressPools that should
be assigned to an IPAddressClaims.
properties:
apiGroup:
description: APIGroup is the group for the resource being
referenced. If APIGroup is not specified, the specified
Kind must be in the core API group. For any other third-party
types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
x-kubernetes-map-type: atomic
primaryIP:
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ spec:
required:
- name
type: object
primaryAddressFrom:
description: PrimaryAddressFrom is an IPAddressPools
that should be assigned to an IPAddressClaims.
properties:
apiGroup:
description: APIGroup is the group for the resource
being referenced. If APIGroup is not specified,
the specified Kind must be in the core API group.
For any other third-party types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being
referenced
type: string
name:
description: Name is the name of resource being
referenced
type: string
required:
- kind
- name
type: object
x-kubernetes-map-type: atomic
primaryIP:
type: string
required:
Expand Down
24 changes: 24 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,27 @@ rules:
- get
- patch
- update
- apiGroups:
- ipam.cluster.x-k8s.io
resources:
- ipaddressclaims
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ipam.cluster.x-k8s.io
resources:
- ipaddresses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
Loading

0 comments on commit aa30625

Please sign in to comment.