Skip to content

Commit e1ee8db

Browse files
authored
Buildless adjust function api to old serverless (#1610)
1 parent 19d2f64 commit e1ee8db

File tree

4 files changed

+409
-11
lines changed

4 files changed

+409
-11
lines changed

components/buildless-serverless/api/v1alpha2/function_types.go

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,31 @@ type FunctionSpec struct {
5050
// Specifies an array of key-value pairs to be used as environment variables for the Function.
5151
// You can define values as static strings or reference values from ConfigMaps or Secrets.
5252
// For configuration details, see the [official Kubernetes documentation](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/).
53-
// +kubebuilder:validation:XValidation:message="Following envs are reserved and cannot be used: ['FUNC_RUNTIME','FUNC_HANDLER','FUNC_PORT','FUNC_HANDLER_SOURCE','FUNC_HANDLER_DEPENDENCIES','MOD_NAME','NODE_PATH','PYTHONPATH']",rule="(self.all(e, !(e.name in ['FUNC_RUNTIME','FUNC_HANDLER','FUNC_PORT','MOD_NAME','NODE_PATH','PYTHONPATH'])))"
53+
// +kubebuilder:validation:XValidation:message="Following envs are reserved and cannot be used: ['FUNC_RUNTIME','FUNC_HANDLER','FUNC_PORT','FUNC_HANDLER_SOURCE','FUNC_HANDLER_DEPENDENCIES','MOD_NAME','NODE_PATH','PYTHONPATH']",rule="(self.all(e, !(e.name in ['FUNC_RUNTIME','FUNC_HANDLER','FUNC_PORT','FUNC_HANDLER_SOURCE','FUNC_HANDLER_DEPENDENCIES','MOD_NAME','NODE_PATH','PYTHONPATH'])))"
5454
Env []corev1.EnvVar `json:"env,omitempty"`
5555

5656
// Specifies resources requested by the Function and the build Job.
5757
// +optional
5858
ResourceConfiguration *ResourceConfiguration `json:"resourceConfiguration,omitempty"`
5959

60+
// Deprecated:
61+
// This setting will be removed. Serverless no longer automatically creates HPA.
62+
// +optional
63+
ScaleConfig *ScaleConfig `json:"scaleConfig,omitempty"`
64+
6065
// Defines the exact number of Function's Pods to run at a time.
61-
// If the Function is targeted by an external scaler,
66+
// If the Function is targeted by an external scaler,
6267
// then the **Replicas** field is used by the relevant HorizontalPodAutoscaler to control the number of active replicas.
6368
// +kubebuilder:validation:Minimum=0
6469
// +kubebuilder:default:=1
6570
// +optional
6671
Replicas *int32 `json:"replicas,omitempty"`
6772

73+
// Deprecated: Use **Labels** and **Annotations** to label and/or annotate Function's Pods.
74+
// +optional
75+
// +kubebuilder:validation:XValidation:message="Not supported: Use spec.labels and spec.annotations to label and/or annotate Function's Pods.",rule="!has(self.labels) && !has(self.annotations)"
76+
Template *Template `json:"template,omitempty"`
77+
6878
// Specifies Secrets to mount into the Function's container filesystem.
6979
SecretMounts []SecretMount `json:"secretMounts,omitempty"`
7080

@@ -155,6 +165,13 @@ type Repository struct {
155165
}
156166

157167
type ResourceConfiguration struct {
168+
// Deprecated: Specifies resources requested by the build Job's Pod.
169+
// This setting will be removed. Functions don't require building images.
170+
// +optional
171+
// +kubebuilder:validation:XValidation:message="Use profile or resources",rule="has(self.profile) && !has(self.resources) || !has(self.profile) && has(self.resources)"
172+
// +kubebuilder:validation:XValidation:message="Invalid profile, please use one of: ['local-dev','slow','normal','fast']",rule="(!has(self.profile) || self.profile in ['local-dev','slow','normal','fast'])"
173+
Build *ResourceRequirements `json:"build,omitempty"`
174+
158175
// Specifies resources requested by the Function's Pod.
159176
// +optional
160177
// +kubebuilder:validation:XValidation:message="Use profile or resources",rule="has(self.profile) && !has(self.resources) || !has(self.profile) && has(self.resources)"
@@ -175,6 +192,16 @@ type ResourceRequirements struct {
175192
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
176193
}
177194

195+
type ScaleConfig struct {
196+
// Defines the minimum number of Function's Pods to run at a time.
197+
// +kubebuilder:validation:Minimum:=1
198+
MinReplicas *int32 `json:"minReplicas"`
199+
200+
// Defines the maximum number of Function's Pods to run at a time.
201+
// +kubebuilder:validation:Minimum:=1
202+
MaxReplicas *int32 `json:"maxReplicas"`
203+
}
204+
178205
type SecretMount struct {
179206
// Specifies the name of the Secret in the Function's Namespace.
180207
// +kubebuilder:validation:Required
@@ -188,7 +215,16 @@ type SecretMount struct {
188215
MountPath string `json:"mountPath"`
189216
}
190217

191-
// FunctionStatus defines the observed state of Function.
218+
type Template struct {
219+
// Deprecated: Use **FunctionSpec.Labels** to label Function's Pods.
220+
// +optional
221+
Labels map[string]string `json:"labels,omitempty"`
222+
// Deprecated: Use **FunctionSpec.Annotations** to annotate Function's Pods.
223+
// +optional
224+
Annotations map[string]string `json:"annotations,omitempty"`
225+
}
226+
227+
// FunctionStatus defines the observed state of the Function.
192228
type FunctionStatus struct {
193229
// Specifies the **Runtime** type of the Function.
194230
Runtime Runtime `json:"runtime,omitempty"`
@@ -246,6 +282,14 @@ const (
246282

247283
// +kubebuilder:object:root=true
248284
// +kubebuilder:subresource:status
285+
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.podSelector
286+
// +kubebuilder:resource:categories={all},shortName={fn,fns}
287+
// +kubebuilder:storageversion
288+
// +kubebuilder:printcolumn:name="Configured",type="string",JSONPath=".status.conditions[?(@.type=='ConfigurationReady')].status"
289+
// +kubebuilder:printcolumn:name="Running",type="string",JSONPath=".status.conditions[?(@.type=='Running')].status"
290+
// +kubebuilder:printcolumn:name="Runtime",type="string",JSONPath=".spec.runtime"
291+
// +kubebuilder:printcolumn:name="Version",type="integer",JSONPath=".metadata.generation"
292+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
249293

250294
// Function is the Schema for the functions API.
251295
type Function struct {

components/buildless-serverless/api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)