Skip to content

Commit 2702e07

Browse files
committed
add openstackclusteridentity crd and supporting code
Signed-off-by: Bharath Nallapeta <[email protected]>
1 parent 77c09c2 commit 2702e07

38 files changed

+1722
-41
lines changed

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ resources:
2323
- group: infrastructure
2424
kind: OpenStackServer
2525
version: v1alpha1
26+
- group: infrastructure
27+
kind: OpenStackClusterIdentity
28+
version: v1alpha1
2629
- group: infrastructure
2730
version: "2"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// OpenStackCredentialSecretReference references a Secret containing OpenStack credentials.
24+
type OpenStackCredentialSecretReference struct {
25+
// Name of the Secret which contains a `clouds.yaml` key (and optionally `cacert`).
26+
// +kubebuilder:validation:Required
27+
Name string `json:"name"`
28+
29+
// Namespace where the Secret resides.
30+
// +kubebuilder:validation:Required
31+
Namespace string `json:"namespace"`
32+
}
33+
34+
// OpenStackClusterIdentitySpec defines the desired state for an OpenStackClusterIdentity.
35+
type OpenStackClusterIdentitySpec struct {
36+
// SecretRef references the credentials Secret containing a `clouds.yaml` file.
37+
// +kubebuilder:validation:Required
38+
SecretRef OpenStackCredentialSecretReference `json:"secretRef"`
39+
40+
// NamespaceSelector limits which namespaces may use this identity. If nil, all namespaces are allowed.
41+
// +optional
42+
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
43+
}
44+
45+
// +genclient
46+
// +kubebuilder:object:root=true
47+
// +kubebuilder:resource:path=openstackclusteridentities,scope=Cluster,categories=cluster-api,shortName=osci
48+
49+
// OpenStackClusterIdentity is a cluster-scoped identity that centralizes OpenStack credentials.
50+
type OpenStackClusterIdentity struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ObjectMeta `json:"metadata,omitempty"`
53+
54+
Spec OpenStackClusterIdentitySpec `json:"spec,omitempty"`
55+
}
56+
57+
// +kubebuilder:object:root=true
58+
59+
// OpenStackClusterIdentityList contains a list of OpenStackClusterIdentity.
60+
type OpenStackClusterIdentityList struct {
61+
metav1.TypeMeta `json:",inline"`
62+
metav1.ListMeta `json:"metadata,omitempty"`
63+
Items []OpenStackClusterIdentity `json:"items"`
64+
}
65+
66+
func init() {
67+
SchemeBuilder.Register(&OpenStackClusterIdentity{}, &OpenStackClusterIdentityList{})
68+
}

api/v1alpha1/zz_generated.deepcopy.go

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

api/v1beta1/identity_types.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@ package v1beta1
1919
// OpenStackIdentityReference is a reference to an infrastructure
2020
// provider identity to be used to provision cluster resources.
2121
// +kubebuilder:validation:XValidation:rule="(!has(self.region) && !has(oldSelf.region)) || self.region == oldSelf.region",message="region is immutable"
22+
// +kubebuilder:validation:XValidation:rule="has(self.name)",message="name is required"
23+
// +kubebuilder:validation:XValidation:rule="has(self.cloudName)",message="cloudName is required"
2224
type OpenStackIdentityReference struct {
23-
// Name is the name of a secret in the same namespace as the resource being provisioned.
24-
// The secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
25-
// The secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
25+
// Type specifies the identity reference type. Defaults to Secret for backward compatibility.
26+
// +kubebuilder:validation:Enum=Secret;ClusterIdentity
27+
// +kubebuilder:default=Secret
28+
// +kubebuilder:validation:Required
29+
Type string `json:"type,omitempty"`
30+
31+
// Name is the name of a Secret (type=Secret) in the same namespace as the resource being provisioned,
32+
// or the name of an OpenStackClusterIdentity (type=ClusterIdentity).
33+
// The Secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
34+
// The Secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
2635
// +kubebuilder:validation:Required
2736
Name string `json:"name"`
2837

0 commit comments

Comments
 (0)