Skip to content

Commit 37846fa

Browse files
Merge pull request GoogleCloudPlatform#2766 from hankfreund/scifi_attached_api
Define backward-compatible attached clusters API for the direct controller
2 parents eddc394 + 84dcbd8 commit 37846fa

File tree

11 files changed

+1227
-182
lines changed

11 files changed

+1227
-182
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1beta1
16+
17+
import (
18+
refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1"
19+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1"
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
var ContainerAttachedClusterGVK = GroupVersion.WithKind("ContainerAttachedCluster")
24+
25+
// ContainerAttachedClusterSpec defines the desired state of ContainerAttachedCluster
26+
// +kcc:proto=google.cloud.gkemulticloud.v1.AttachedCluster
27+
type ContainerAttachedClusterSpec struct {
28+
/* The ID of the project in which the resource belongs. If it is not provided, the provider project is used. */
29+
// +optional
30+
ProjectRef *refs.ProjectRef `json:"projectRef,omitempty"`
31+
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
33+
// Immutable, Optional.
34+
// The ContainerAttachedCluster name. If not given, the metadata.name will be used.
35+
ResourceID *string `json:"resourceID,omitempty"`
36+
37+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Location field is immutable"
38+
// Immutable. The location for the resource.
39+
Location string `json:"location"`
40+
41+
// Optional. A human readable description of this Attached cluster.
42+
// Cannot be longer than 255 UTF-8 encoded bytes.
43+
Description *string `json:"description,omitempty"`
44+
45+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="OidcConfig field is immutable"
46+
/* Required. OpenID Connect (OIDC) discovery information of the target cluster.
47+
48+
Kubernetes Service Account (KSA) tokens are JWT tokens signed by the cluster
49+
API server. This field indicates how GCP services validate KSA tokens in order
50+
to allow system workloads (such as GKE Connect and telemetry agents) to
51+
authenticate back to GCP.
52+
53+
Both clusters with public and private issuer URLs are supported.
54+
Clusters with public issuers only need to specify the 'issuerUrl' field
55+
while clusters with private issuers need to provide both 'issuerUrl' and 'jwks'.
56+
*/
57+
OidcConfig AttachedOidcConfig `json:"oidcConfig"`
58+
59+
// Required. The platform version for the cluster (e.g. `1.30.0-gke.1`).
60+
PlatformVersion string `json:"platformVersion"`
61+
62+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Distribution field is immutable"
63+
// Immutable. The Kubernetes distribution of the underlying attached cluster.
64+
//
65+
// Supported values: ["eks", "aks", "generic"].
66+
Distribution string `json:"distribution"`
67+
68+
// Required. Fleet configuration.
69+
Fleet Fleet `json:"fleet"`
70+
71+
/*NOTYET
72+
// Allows clients to perform consistent read-modify-writes
73+
// through optimistic concurrency control.
74+
//
75+
// Can be sent on update and delete requests to ensure the
76+
// client has an up-to-date value before proceeding.
77+
Etag *string `json:"etag,omitempty"`
78+
*/
79+
80+
// Optional. Annotations on the cluster.
81+
//
82+
// This field has the same restrictions as Kubernetes annotations.
83+
// The total size of all keys and values combined is limited to 256k.
84+
// Key can have 2 segments: prefix (optional) and name (required),
85+
// separated by a slash (/).
86+
// Prefix must be a DNS subdomain.
87+
// Name must be 63 characters or less, begin and end with alphanumerics,
88+
// with dashes (-), underscores (_), dots (.), and alphanumerics between.
89+
Annotations map[string]string `json:"annotations,omitempty"`
90+
91+
// Optional. Logging configuration for this cluster.
92+
LoggingConfig *LoggingConfig `json:"loggingConfig,omitempty"`
93+
94+
// Optional. Configuration related to the cluster RBAC settings.
95+
Authorization *AttachedClustersAuthorization `json:"authorization,omitempty"`
96+
97+
// Optional. Monitoring configuration for this cluster.
98+
MonitoringConfig *MonitoringConfig `json:"monitoringConfig,omitempty"`
99+
100+
/*NOTYET
101+
// Optional. Proxy configuration for outbound HTTP(S) traffic.
102+
ProxyConfig *AttachedProxyConfig `json:"proxyConfig,omitempty"`
103+
*/
104+
105+
// Optional. Binary Authorization configuration for this cluster.
106+
BinaryAuthorization *BinaryAuthorization `json:"binaryAuthorization,omitempty"`
107+
108+
// Optional. Policy to determine what flags to send on delete.
109+
DeletionPolicy *string `json:"deletionPolicy,omitempty"`
110+
}
111+
112+
// ContainerAttachedClusterStatus defines the config connector machine state of ContainerAttachedCluster
113+
type ContainerAttachedClusterStatus struct {
114+
/* Conditions represent the latest available observations of the
115+
object's current state. */
116+
Conditions []v1alpha1.Condition `json:"conditions,omitempty"`
117+
118+
// ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource.
119+
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
120+
121+
// A globally unique identifier for the cluster.
122+
Uid *string `json:"uid,omitempty"`
123+
124+
// The region where this cluster runs.
125+
//
126+
// For EKS clusters, this is an AWS region. For AKS clusters,
127+
// this is an Azure region.
128+
ClusterRegion *string `json:"clusterRegion,omitempty"`
129+
130+
// The Kubernetes version of the cluster.
131+
KubernetesVersion *string `json:"kubernetesVersion,omitempty"`
132+
133+
// Workload Identity settings.
134+
WorkloadIdentityConfig []WorkloadIdentityConfig `json:"workloadIdentityConfig,omitempty"`
135+
136+
// The time at which this cluster was registered.
137+
CreateTime *string `json:"createTime,omitempty"`
138+
139+
// The time at which this cluster was last updated.
140+
UpdateTime *string `json:"updateTime,omitempty"`
141+
142+
// If set, there are currently changes in flight to the cluster.
143+
Reconciling *bool `json:"reconciling,omitempty"`
144+
145+
/* The current state of the cluster.
146+
Possible values: STATE_UNSPECIFIED, PROVISIONING, RUNNING, RECONCILING, STOPPING, ERROR, DEGRADED. */
147+
State *string `json:"state,omitempty"`
148+
149+
// A set of errors found in the cluster.
150+
Errors []AttachedClusterError `json:"errors,omitempty"`
151+
152+
// ObservedState is the state of the resource as most recently observed in GCP.
153+
ObservedState *ContainerAttachedClusterObservedState `json:"observedState,omitempty"`
154+
}
155+
156+
// ContainerAttachedClusterObservedState is the state of the ContainerAttachedCluster resource as most recently observed in GCP.
157+
type ContainerAttachedClusterObservedState struct {
158+
// Output only. The name of the managed Hub Membership resource associated to
159+
// this cluster.
160+
//
161+
// Membership names are formatted as
162+
// `projects/<project-number>/locations/global/membership/<cluster-id>`.
163+
// This field mirrors the Spec.Fleet.Membership field.
164+
FleetMembership *string `json:"fleetMembership,omitempty"`
165+
}
166+
167+
// +genclient
168+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
169+
// +kubebuilder:resource:categories=gcp,shortName=gcpcontainerattachedcluster;gcpcontainerattachedclusters
170+
// +kubebuilder:subresource:status
171+
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/tf2crd=true";"cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true"
172+
// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date"
173+
// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded"
174+
// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'"
175+
// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'"
176+
177+
// ContainerAttachedCluster is the Schema for the ContainerAttachedCluster API
178+
// +k8s:openapi-gen=true
179+
type ContainerAttachedCluster struct {
180+
metav1.TypeMeta `json:",inline"`
181+
metav1.ObjectMeta `json:"metadata,omitempty"`
182+
183+
Spec ContainerAttachedClusterSpec `json:"spec"`
184+
Status ContainerAttachedClusterStatus `json:"status,omitempty"`
185+
}
186+
187+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
188+
// ContainerAttachedClusterList contains a list of ContainerAttachedCluster
189+
type ContainerAttachedClusterList struct {
190+
metav1.TypeMeta `json:",inline"`
191+
metav1.ListMeta `json:"metadata,omitempty"`
192+
Items []ContainerAttachedCluster `json:"items"`
193+
}
194+
195+
func init() {
196+
SchemeBuilder.Register(&ContainerAttachedCluster{}, &ContainerAttachedClusterList{})
197+
}

apis/containerattached/v1beta1/doc.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// +kcc:proto=google.cloud.gkemulticloud.v1
16+
package v1beta1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// +kubebuilder:object:generate=true
16+
// +groupName=containerattached.cnrm.cloud.google.com
17+
package v1beta1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime/schema"
21+
"sigs.k8s.io/controller-runtime/pkg/scheme"
22+
)
23+
24+
var (
25+
// GroupVersion is group version used to register these objects
26+
GroupVersion = schema.GroupVersion{Group: "containerattached.cnrm.cloud.google.com", Version: "v1beta1"}
27+
28+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
29+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
30+
31+
// AddToScheme adds the types in this group-version to the given scheme.
32+
AddToScheme = SchemeBuilder.AddToScheme
33+
)
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1beta1
16+
17+
type FleetProjectRef struct {
18+
/* The project of the fleet. Allowed value: The Google Cloud resource name of a `Project` resource (format: `projects/{{name}}`).*/
19+
External string `json:"external,omitempty"`
20+
/* Name of the project resource. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names */
21+
Name string `json:"name,omitempty"`
22+
/* Namespace of the project resource. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ */
23+
Namespace string `json:"namespace,omitempty"`
24+
}

0 commit comments

Comments
 (0)