|
| 1 | +/* |
| 2 | +Copyright 2022 The Tinkerbell 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 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 22 | +) |
| 23 | + |
| 24 | +const ( |
| 25 | + // ClusterFinalizer allows ReconcileTinkerbellCluster to clean up Tinkerbell resources before |
| 26 | + // removing it from the apiserver. |
| 27 | + ClusterFinalizer = "tinkerbellcluster.infrastructure.cluster.x-k8s.io" |
| 28 | +) |
| 29 | + |
| 30 | +// TinkerbellClusterSpec defines the desired state of TinkerbellCluster. |
| 31 | +type TinkerbellClusterSpec struct { |
| 32 | + // ControlPlaneEndpoint is a required field by ClusterAPI v1beta1. |
| 33 | + // |
| 34 | + // See https://cluster-api.sigs.k8s.io/developer/architecture/controllers/cluster.html |
| 35 | + // for more details. |
| 36 | + // |
| 37 | + // +optional |
| 38 | + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"` |
| 39 | + |
| 40 | + // ImageLookupFormat is the URL naming format to use for machine images when |
| 41 | + // a machine does not specify. When set, this will be used for all cluster machines |
| 42 | + // unless a machine specifies a different ImageLookupFormat. Supports substitutions |
| 43 | + // for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with |
| 44 | + // the basse URL, OS distribution, OS version, and kubernetes version, respectively. |
| 45 | + // BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell |
| 46 | + // (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), |
| 47 | + // OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro |
| 48 | + // (if known), and the kubernetes version as defined by the packages produced by |
| 49 | + // kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default |
| 50 | + // image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will |
| 51 | + // attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ |
| 52 | + // +optional |
| 53 | + ImageLookupFormat string `json:"imageLookupFormat,omitempty"` |
| 54 | + |
| 55 | + // ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, |
| 56 | + // if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. |
| 57 | + // +optional |
| 58 | + // +kubebuilder:default=ghcr.io/tinkerbell/cluster-api-provider-tinkerbell |
| 59 | + ImageLookupBaseRegistry string `json:"imageLookupBaseRegistry,omitempty"` |
| 60 | + |
| 61 | + // ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, |
| 62 | + // if not set it will default to ubuntu. |
| 63 | + // +optional |
| 64 | + // +kubebuilder:default=ubuntu |
| 65 | + ImageLookupOSDistro string `json:"imageLookupOSDistro,omitempty"` |
| 66 | + |
| 67 | + // ImageLookupOSVersion is the version of the OS distribution to use when fetching machine |
| 68 | + // images. If not set it will default based on ImageLookupOSDistro. |
| 69 | + // +optional |
| 70 | + ImageLookupOSVersion string `json:"imageLookupOSVersion,omitempty"` |
| 71 | +} |
| 72 | + |
| 73 | +// TinkerbellClusterStatus defines the observed state of TinkerbellCluster. |
| 74 | +type TinkerbellClusterStatus struct { |
| 75 | + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster |
| 76 | + // Important: Run "make" to regenerate code after modifying this file. |
| 77 | + |
| 78 | + // Ready denotes that the cluster (infrastructure) is ready. |
| 79 | + // +optional |
| 80 | + Ready bool `json:"ready"` |
| 81 | +} |
| 82 | + |
| 83 | +// +kubebuilder:subresource:status |
| 84 | +// +kubebuilder:resource:path=tinkerbellclusters,scope=Namespaced,categories=cluster-api |
| 85 | +// +kubebuilder:object:root=true |
| 86 | +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this TinkerbellCluster belongs" |
| 87 | +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="TinkerbellCluster ready status" |
| 88 | + |
| 89 | +// TinkerbellCluster is the Schema for the tinkerbellclusters API. |
| 90 | +type TinkerbellCluster struct { |
| 91 | + metav1.TypeMeta `json:",inline"` |
| 92 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 93 | + |
| 94 | + Spec TinkerbellClusterSpec `json:"spec,omitempty"` |
| 95 | + Status TinkerbellClusterStatus `json:"status,omitempty"` |
| 96 | +} |
| 97 | + |
| 98 | +// +kubebuilder:object:root=true |
| 99 | + |
| 100 | +// TinkerbellClusterList contains a list of TinkerbellCluster. |
| 101 | +type TinkerbellClusterList struct { |
| 102 | + metav1.TypeMeta `json:",inline"` |
| 103 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 104 | + Items []TinkerbellCluster `json:"items"` |
| 105 | +} |
| 106 | + |
| 107 | +//nolint:gochecknoinits |
| 108 | +func init() { |
| 109 | + SchemeBuilder.Register(&TinkerbellCluster{}, &TinkerbellClusterList{}) |
| 110 | +} |
0 commit comments