Skip to content

Commit b26ad25

Browse files
committed
Adding SandboxTemplate and SandboxClaim CRDs
SanboxTemplate: * Config object no controller expected for this * Created by administrator to specify common parameters for a sandbox * example names: py3, java8, conda-teamA, ... * We use claims to create a Sandbox instance from the template SandboxClaim: * Create an instance of sandbox from a given claim * ttl determines after how long the sandboxClaim is auto-deleted, thereby deleting the sandbox * Seperation of concerns. User can be given access to create only claims.
1 parent 770015f commit b26ad25

File tree

5 files changed

+4078
-0
lines changed

5 files changed

+4078
-0
lines changed

api/v1alpha1/sandboxclaim_types.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright 2025.
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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
24+
// Important: Run "make" to regenerate code after modifying this file
25+
26+
// SandboxClaimSpec defines the desired state of Sandbox
27+
type SandboxClaimSpec struct {
28+
// The following markers will use OpenAPI v3 schema to validate the value
29+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
30+
31+
TTLSeconds *int32 `json:"ttlSeconds,omitempty" protobuf:"varint,1,opt,name=ttlSeconds"`
32+
33+
// Template refers to the SandboxTemplate to be used for creating a Sandbox
34+
// +kubebuilder:validation:Required
35+
TemplateName string `json:"templateName,omitempty" protobuf:"bytes,3,name=templateName"`
36+
37+
// TemplateNamespace refers to the SandboxTemplate namespace
38+
// +kubebuilder:validation:Optional
39+
TemplateNamespace string `json:"templateNamespace,omitempty" protobuf:"bytes,4,opt,name=templateNamespace"`
40+
}
41+
42+
// SandboxClaimStatus defines the observed state of Sandbox.
43+
type SandboxClaimStatus struct {
44+
SandboxName string `json:"sandboxName,omitempty"`
45+
TemplateRevision string `json:"templateRevision,omitempty"`
46+
Hostname string `json:"hostname,omitempty"`
47+
}
48+
49+
// +kubebuilder:object:root=true
50+
// +kubebuilder:subresource:status
51+
// +kubebuilder:resource:scope=Namespaced,shortName=sandboxclaim
52+
// SandboxClaim is the Schema for the sandbox Claim API
53+
type SandboxClaim struct {
54+
metav1.TypeMeta `json:",inline"`
55+
56+
// metadata is a standard object metadata
57+
// +optional
58+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
59+
60+
// spec defines the desired state of Sandbox
61+
// +required
62+
Spec SandboxClaimSpec `json:"spec"`
63+
64+
// status defines the observed state of Sandbox
65+
// +optional
66+
Status SandboxClaimStatus `json:"status,omitempty,omitzero"`
67+
}
68+
69+
// +kubebuilder:object:root=true
70+
71+
// SandboxList contains a list of Sandbox
72+
type SandboxClaimList struct {
73+
metav1.TypeMeta `json:",inline"`
74+
metav1.ListMeta `json:"metadata,omitempty"`
75+
Items []SandboxClaim `json:"items"`
76+
}
77+
78+
func init() {
79+
SchemeBuilder.Register(&SandboxClaim{}, &SandboxClaimList{})
80+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Copyright 2025.
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 v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
// Important: Run "make" to regenerate code after modifying this file
26+
27+
// SandboxTemplateSpec defines the desired state of Sandbox
28+
type SandboxTemplateSpec struct {
29+
// The following markers will use OpenAPI v3 schema to validate the value
30+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
31+
32+
TTLSeconds *int32 `json:"ttlSeconds,omitempty" protobuf:"varint,1,opt,name=ttlSeconds"`
33+
// template is the object that describes the pod spec that will be used to create
34+
// an agent sandbox.
35+
// +kubebuilder:validation:Required
36+
Template corev1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"`
37+
}
38+
39+
// SandboxTemplateStatus defines the observed state of Sandbox.
40+
type SandboxTemplateStatus struct {
41+
}
42+
43+
// +kubebuilder:object:root=true
44+
// +kubebuilder:subresource:status
45+
// +kubebuilder:resource:scope=Namespaced,shortName=sandboxtemplate
46+
// SandboxTemplate is the Schema for the sandboxe template API
47+
type SandboxTemplate struct {
48+
metav1.TypeMeta `json:",inline"`
49+
50+
// metadata is a standard object metadata
51+
// +optional
52+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
53+
54+
// spec defines the desired state of Sandbox
55+
// +required
56+
Spec SandboxTemplateSpec `json:"spec"`
57+
58+
// status defines the observed state of Sandbox
59+
// +optional
60+
Status SandboxTemplateStatus `json:"status,omitempty,omitzero"`
61+
}
62+
63+
// +kubebuilder:object:root=true
64+
65+
// SandboxTemplateList contains a list of Sandbox
66+
type SandboxTemplateList struct {
67+
metav1.TypeMeta `json:",inline"`
68+
metav1.ListMeta `json:"metadata,omitempty"`
69+
Items []SandboxTemplate `json:"items"`
70+
}
71+
72+
func init() {
73+
SchemeBuilder.Register(&SandboxTemplate{}, &SandboxTemplateList{})
74+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 189 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)