Skip to content

Commit 3ba7736

Browse files
authored
Merge pull request #2682 from bnallapeta/os_clusteridentity
✨ Add OpenStackClusterIdentity for centralized credential management
2 parents 644fe9c + 174e2e8 commit 3ba7736

File tree

51 files changed

+2534
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2534
-44
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
193193
cluster-template-flatcar-sysext.yaml \
194194
cluster-template-no-bastion.yaml \
195195
cluster-template-health-monitor.yaml \
196-
cluster-template-capi-v1beta1.yaml)
196+
cluster-template-capi-v1beta1.yaml \
197+
cluster-template-cluster-identity.yaml)
197198
# Currently no templates that require CI artifacts
198199
# $(addprefix $(E2E_TEMPLATES_DIR)/, add-templates-here.yaml) \
199200

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
@@ -20,14 +20,23 @@ package v1beta1
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"
2222
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.
23+
// Type specifies the identity reference type. Defaults to Secret for backward compatibility.
24+
// +kubebuilder:validation:Enum=Secret;ClusterIdentity
25+
// +kubebuilder:default=Secret
2626
// +kubebuilder:validation:Required
27+
Type string `json:"type,omitempty"`
28+
29+
// Name is the name of a Secret (type=Secret) in the same namespace as the resource being provisioned,
30+
// or the name of an OpenStackClusterIdentity (type=ClusterIdentity).
31+
// The Secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
32+
// The Secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
33+
// +kubebuilder:validation:Required
34+
// +kubebuilder:validation:MinLength=1
2735
Name string `json:"name"`
2836

2937
// CloudName specifies the name of the entry in the clouds.yaml file to use.
3038
// +kubebuilder:validation:Required
39+
// +kubebuilder:validation:MinLength=1
3140
CloudName string `json:"cloudName"`
3241

3342
// Region specifies an OpenStack region to use. If specified, it overrides

0 commit comments

Comments
 (0)