k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/addon.go (about) 1 /* 2 Copyright 2023 The Kubermatic Kubernetes Platform contributors. 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 v1 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 "k8s.io/apimachinery/pkg/runtime" 23 ) 24 25 // +kubebuilder:validation:Enum=AddonResourcesCreatedSuccessfully 26 type AddonConditionType string 27 28 const ( 29 AddonConditionResourcesCreated AddonConditionType = "AddonResourcesCreatedSuccessfully" 30 ) 31 32 // +genclient 33 // +kubebuilder:resource:scope=Cluster 34 // +kubebuilder:object:generate=true 35 // +kubebuilder:object:root=true 36 // +kubebuilder:subresource:status 37 // +kubebuilder:printcolumn:JSONPath=".spec.cluster.name",name="Cluster",type="string" 38 // +kubebuilder:printcolumn:JSONPath=".spec.addon",name="Addon",type="string" 39 // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" 40 41 // Addon specifies a cluster addon. Addons can be installed into user clusters 42 // to provide additional manifests for CNIs, CSIs or other applications, which makes 43 // addons a necessary component to create functioning user clusters. 44 type Addon struct { 45 metav1.TypeMeta `json:",inline"` 46 metav1.ObjectMeta `json:"metadata,omitempty"` 47 48 // Spec describes the desired addon state. 49 Spec AddonSpec `json:"spec,omitempty"` 50 51 // Status contains information about the reconciliation status. 52 Status AddonStatus `json:"status,omitempty"` 53 } 54 55 // GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion 56 // to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling. 57 type GroupVersionKind struct { 58 Group string `json:"group,omitempty"` 59 Version string `json:"version,omitempty"` 60 Kind string `json:"kind,omitempty"` 61 } 62 63 // AddonSpec specifies details of an addon. 64 type AddonSpec struct { 65 // Name defines the name of the addon to install 66 Name string `json:"name"` 67 // Cluster is the reference to the cluster the addon should be installed in 68 Cluster ClusterReference `json:"cluster"` 69 // Variables is free form data to use for parsing the manifest templates 70 // +kubebuilder:pruning:PreserveUnknownFields 71 Variables *runtime.RawExtension `json:"variables,omitempty"` 72 // RequiredResourceTypes allows to indicate that this addon needs some resource type before it 73 // can be installed. This can be used to indicate that a specific CRD and/or extension 74 // apiserver must be installed before this addon can be installed. The addon will not 75 // be installed until that resource is served. 76 RequiredResourceTypes []GroupVersionKind `json:"requiredResourceTypes,omitempty"` 77 // IsDefault indicates whether the addon is installed because it was configured in 78 // the default addon section in the KubermaticConfiguration. User-installed addons 79 // must not set this field to true, as extra default Addon objects (that are not in 80 // the KubermaticConfiguration) will be garbage-collected. 81 IsDefault bool `json:"isDefault,omitempty"` 82 } 83 84 // AddonStatus contains information about the reconciliation status. 85 type AddonStatus struct { 86 Conditions map[AddonConditionType]AddonCondition `json:"conditions,omitempty"` 87 } 88 89 type AddonCondition struct { 90 // Status of the condition, one of True, False, Unknown. 91 Status corev1.ConditionStatus `json:"status"` 92 // Last time we got an update on a given condition. 93 LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"` 94 // Last time the condition transitioned from one status to another. 95 // +optional 96 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 97 } 98 99 // +kubebuilder:object:generate=true 100 // +kubebuilder:object:root=true 101 102 // AddonList is a list of addons. 103 type AddonList struct { 104 metav1.TypeMeta `json:",inline"` 105 metav1.ListMeta `json:"metadata,omitempty"` 106 107 Items []Addon `json:"items"` 108 }