sigs.k8s.io/cluster-api-provider-azure@v1.14.3/api/v1beta1/azureclusteridentity_types.go (about) 1 /* 2 Copyright 2021 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 v1beta1 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" 23 ) 24 25 // AllowedNamespaces defines the namespaces the clusters are allowed to use the identity from 26 // NamespaceList takes precedence over the Selector. 27 type AllowedNamespaces struct { 28 // A nil or empty list indicates that AzureCluster cannot use the identity from any namespace. 29 // 30 // +optional 31 // +nullable 32 NamespaceList []string `json:"list"` 33 // Selector is a selector of namespaces that AzureCluster can 34 // use this Identity from. This is a standard Kubernetes LabelSelector, 35 // a label query over a set of resources. The result of matchLabels and 36 // matchExpressions are ANDed. 37 // 38 // A nil or empty selector indicates that AzureCluster cannot use this 39 // AzureClusterIdentity from any namespace. 40 // +optional 41 Selector *metav1.LabelSelector `json:"selector"` 42 } 43 44 // AzureClusterIdentitySpec defines the parameters that are used to create an AzureIdentity. 45 type AzureClusterIdentitySpec struct { 46 // Type is the type of Azure Identity used. 47 // ServicePrincipal, ServicePrincipalCertificate, UserAssignedMSI, ManualServicePrincipal or WorkloadIdentity. 48 Type IdentityType `json:"type"` 49 // ResourceID is the Azure resource ID for the User Assigned MSI resource. 50 // Only applicable when type is UserAssignedMSI. 51 // +optional 52 ResourceID string `json:"resourceID,omitempty"` 53 // ClientID is the service principal client ID. 54 // Both User Assigned MSI and SP can use this field. 55 ClientID string `json:"clientID"` 56 // ClientSecret is a secret reference which should contain either a Service Principal password or certificate secret. 57 // +optional 58 ClientSecret corev1.SecretReference `json:"clientSecret,omitempty"` 59 // TenantID is the service principal primary tenant id. 60 TenantID string `json:"tenantID"` 61 // AllowedNamespaces is used to identify the namespaces the clusters are allowed to use the identity from. 62 // Namespaces can be selected either using an array of namespaces or with label selector. 63 // An empty allowedNamespaces object indicates that AzureClusters can use this identity from any namespace. 64 // If this object is nil, no namespaces will be allowed (default behaviour, if this field is not provided) 65 // A namespace should be either in the NamespaceList or match with Selector to use the identity. 66 // 67 // +optional 68 // +nullable 69 AllowedNamespaces *AllowedNamespaces `json:"allowedNamespaces"` 70 } 71 72 // AzureClusterIdentityStatus defines the observed state of AzureClusterIdentity. 73 type AzureClusterIdentityStatus struct { 74 // Conditions defines current service state of the AzureClusterIdentity. 75 // +optional 76 Conditions clusterv1.Conditions `json:"conditions,omitempty"` 77 } 78 79 // +kubebuilder:object:root=true 80 // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type",description="Type of AzureClusterIdentity" 81 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of this AzureClusterIdentity" 82 // +kubebuilder:resource:path=azureclusteridentities,scope=Namespaced,categories=cluster-api 83 // +kubebuilder:storageversion 84 // +kubebuilder:subresource:status 85 86 // AzureClusterIdentity is the Schema for the azureclustersidentities API. 87 type AzureClusterIdentity struct { 88 metav1.TypeMeta `json:",inline"` 89 metav1.ObjectMeta `json:"metadata,omitempty"` 90 91 Spec AzureClusterIdentitySpec `json:"spec,omitempty"` 92 Status AzureClusterIdentityStatus `json:"status,omitempty"` 93 } 94 95 // +kubebuilder:object:root=true 96 97 // AzureClusterIdentityList contains a list of AzureClusterIdentity. 98 type AzureClusterIdentityList struct { 99 metav1.TypeMeta `json:",inline"` 100 metav1.ListMeta `json:"metadata,omitempty"` 101 Items []AzureClusterIdentity `json:"items"` 102 } 103 104 // GetConditions returns the list of conditions for an AzureClusterIdentity API object. 105 func (c *AzureClusterIdentity) GetConditions() clusterv1.Conditions { 106 return c.Status.Conditions 107 } 108 109 // SetConditions will set the given conditions on an AzureClusterIdentity object. 110 func (c *AzureClusterIdentity) SetConditions(conditions clusterv1.Conditions) { 111 c.Status.Conditions = conditions 112 } 113 114 func init() { 115 SchemeBuilder.Register(&AzureClusterIdentity{}, &AzureClusterIdentityList{}) 116 }