-
Notifications
You must be signed in to change notification settings - Fork 33
/
kataconfig_types.go
143 lines (117 loc) · 5.43 KB
/
kataconfig_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// KataConfigSpec defines the desired state of KataConfig
type KataConfigSpec struct {
// KataConfigPoolSelector is used to filter the worker nodes
// if not specified, all worker nodes are selected
// +optional
// +nullable
KataConfigPoolSelector *metav1.LabelSelector `json:"kataConfigPoolSelector"`
// CheckNodeEligibility is used to detect the node(s) eligibility to run Kata containers.
// This is currently done through the use of the Node Feature Discovery Operator (NFD).
// For more information on how the check works, please refer to the sandboxed containers documentation - https://docs.openshift.com/container-platform/latest/sandboxed_containers/deploying-sandboxed-container-workloads.html
// +kubebuilder:default:=false
CheckNodeEligibility bool `json:"checkNodeEligibility"`
// Sets log level on kata-equipped nodes. Valid values are the same as for `crio --log-level`.
// +kubebuilder:default:="info"
LogLevel string `json:"logLevel,omitempty"`
// EnablePeerPods is used to transparently create pods on a remote system.
// For more information on how this works, please refer to the sandboxed containers documentation - https://docs.openshift.com/container-platform/latest/sandboxed_containers/deploying-sandboxed-container-workloads.html
// +optional
// +kubebuilder:default:=false
EnablePeerPods bool `json:"enablePeerPods"`
}
// KataConfigStatus defines the observed state of KataConfig
type KataConfigStatus struct {
// RuntimeClasses is the names of the RuntimeClasses created by this controller
// +optional
RuntimeClasses []string `json:"runtimeClasses"`
// +optional
KataNodes KataNodesStatus `json:"kataNodes,omitempty"`
// +optional
Conditions []KataConfigCondition `json:"conditions,omitempty"`
// Used internally to persist state between reconciliations
// +optional
// +kubebuilder:default:=false
WaitingForMcoToStart bool `json:"waitingForMcoToStart,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KataConfig is the Schema for the kataconfigs API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=kataconfigs,scope=Cluster
// +kubebuilder:printcolumn:name="InProgress",type=string,JSONPath=".status.conditions[?(@.type=='InProgress')].status",description="Status of Kata runtime installation"
// +kubebuilder:printcolumn:name="Completed",type=integer,JSONPath=".status.kataNodes.readyNodeCount",description="Number of nodes with Kata runtime installed"
// +kubebuilder:printcolumn:name="Total",type=integer,JSONPath=".status.kataNodes.nodeCount",description="Total number of nodes"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp",description="Age of the KataConfig Custom Resource"
type KataConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
// +nullable
Spec KataConfigSpec `json:"spec,omitempty"`
Status KataConfigStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// KataConfigList contains a list of KataConfig
type KataConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KataConfig `json:"items"`
}
func init() {
SchemeBuilder.Register(&KataConfig{}, &KataConfigList{})
}
type KataNodesStatus struct {
// Number of cluster nodes that have kata installed on them including
// those queued for installation and currently installing, though
// excluding nodes that have a kata installation but are queued for
// uninstallation or currently uninstalling.
// +optional
NodeCount int `json:"nodeCount"`
// Number of cluster nodes that have kata installed on them and are
// currently ready to run kata workloads.
// +optional
ReadyNodeCount int `json:"readyNodeCount"`
// +optional
Installed []string `json:"installed,omitempty"`
// +optional
Installing []string `json:"installing,omitempty"`
// +optional
WaitingToInstall []string `json:"waitingToInstall,omitempty"`
// +optional
FailedToInstall []string `json:"failedToInstall,omitempty"`
// +optional
Uninstalling []string `json:"uninstalling,omitempty"`
// +optional
WaitingToUninstall []string `json:"waitingToUninstall,omitempty"`
// +optional
FailedToUninstall []string `json:"failedToUninstall,omitempty"`
}
type KataConfigConditionType string
const (
KataConfigInProgress KataConfigConditionType = "InProgress"
)
type KataConfigCondition struct {
Type KataConfigConditionType `json:"type"`
Status corev1.ConditionStatus `json:"status"`
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
Reason string `json:"reason"`
Message string `json:"message"`
}