Skip to content

Commit c1c180c

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 * template is cluster scoped 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 7052216 commit c1c180c

File tree

7 files changed

+4252
-1
lines changed

7 files changed

+4252
-1
lines changed

codegen.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616

1717
package agentsandbox
1818

19-
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
19+
// Generate CRDs and RBAC rules
20+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./api/..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
21+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./extensions/..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package v1alpha1 contains API Schema definitions for the agents v1alpha1 API group.
16+
// +kubebuilder:object:generate=true
17+
// +groupName=extensions.agents.x-k8s.io
18+
package v1alpha1
19+
20+
import (
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
"sigs.k8s.io/controller-runtime/pkg/scheme"
23+
)
24+
25+
var (
26+
// GroupVersion is group version used to register these objects.
27+
GroupVersion = schema.GroupVersion{Group: "extensions.agents.x-k8s.io", Version: "v1alpha1"}
28+
29+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
30+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
31+
32+
// AddToScheme adds the types in this group-version to the given scheme.
33+
AddToScheme = SchemeBuilder.AddToScheme
34+
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*
16+
Copyright 2025.
17+
18+
Licensed under the Apache License, Version 2.0 (the "License");
19+
you may not use this file except in compliance with the License.
20+
You may obtain a copy of the License at
21+
22+
http://www.apache.org/licenses/LICENSE-2.0
23+
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an "AS IS" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
*/
30+
31+
package v1alpha1
32+
33+
import (
34+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35+
)
36+
37+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
38+
// Important: Run "make" to regenerate code after modifying this file
39+
40+
// SandboxClaimSpec defines the desired state of Sandbox
41+
type SandboxClaimSpec struct {
42+
// SandboxTemplateRefName - name of the SandboxTemplate to be used for creating a Sandbox
43+
// +kubebuilder:validation:Required
44+
SandboxTemplateRefName string `json:"sandboxTemplateRefName,omitempty" protobuf:"bytes,3,name=sandboxTemplateRefName"`
45+
}
46+
47+
// SandboxClaimStatus defines the observed state of Sandbox.
48+
type SandboxClaimStatus struct {
49+
}
50+
51+
// +kubebuilder:object:root=true
52+
// +kubebuilder:subresource:status
53+
// +kubebuilder:resource:scope=Namespaced,shortName=sandboxclaim
54+
// SandboxClaim is the Schema for the sandbox Claim API
55+
type SandboxClaim struct {
56+
metav1.TypeMeta `json:",inline"`
57+
58+
// metadata is a standard object metadata
59+
// +optional
60+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
61+
62+
// spec defines the desired state of Sandbox
63+
// +required
64+
Spec SandboxClaimSpec `json:"spec"`
65+
66+
// status defines the observed state of Sandbox
67+
// +optional
68+
Status SandboxClaimStatus `json:"status,omitempty,omitzero"`
69+
}
70+
71+
// +kubebuilder:object:root=true
72+
73+
// SandboxList contains a list of Sandbox
74+
type SandboxClaimList struct {
75+
metav1.TypeMeta `json:",inline"`
76+
metav1.ListMeta `json:"metadata,omitempty"`
77+
Items []SandboxClaim `json:"items"`
78+
}
79+
80+
func init() {
81+
SchemeBuilder.Register(&SandboxClaim{}, &SandboxClaimList{})
82+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2025 The Kubernetes Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*
16+
Copyright 2025.
17+
18+
Licensed under the Apache License, Version 2.0 (the "License");
19+
you may not use this file except in compliance with the License.
20+
You may obtain a copy of the License at
21+
22+
http://www.apache.org/licenses/LICENSE-2.0
23+
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an "AS IS" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
*/
30+
31+
package v1alpha1
32+
33+
import (
34+
corev1 "k8s.io/api/core/v1"
35+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
36+
)
37+
38+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
39+
// Important: Run "make" to regenerate code after modifying this file
40+
41+
// SandboxTemplateSpec defines the desired state of Sandbox
42+
type SandboxTemplateSpec struct {
43+
// template is the object that describes the pod spec that will be used to create
44+
// an agent sandbox.
45+
// +kubebuilder:validation:Required
46+
PodTemplate corev1.PodTemplateSpec `json:"podTemplate" protobuf:"bytes,3,opt,name=podTemplate"`
47+
}
48+
49+
// SandboxTemplateStatus defines the observed state of Sandbox.
50+
type SandboxTemplateStatus struct {
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:subresource:status
55+
// +kubebuilder:resource:scope=Cluster,shortName=sandboxtemplate
56+
// SandboxTemplate is the Schema for the sandboxe template API
57+
type SandboxTemplate struct {
58+
metav1.TypeMeta `json:",inline"`
59+
60+
// metadata is a standard object metadata
61+
// +optional
62+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
63+
64+
// spec defines the desired state of Sandbox
65+
// +required
66+
Spec SandboxTemplateSpec `json:"spec"`
67+
68+
// status defines the observed state of Sandbox
69+
// +optional
70+
Status SandboxTemplateStatus `json:"status,omitempty,omitzero"`
71+
}
72+
73+
// +kubebuilder:object:root=true
74+
75+
// SandboxTemplateList contains a list of Sandbox
76+
type SandboxTemplateList struct {
77+
metav1.TypeMeta `json:",inline"`
78+
metav1.ListMeta `json:"metadata,omitempty"`
79+
Items []SandboxTemplate `json:"items"`
80+
}
81+
82+
func init() {
83+
SchemeBuilder.Register(&SandboxTemplate{}, &SandboxTemplateList{})
84+
}

extensions/api/v1alpha1/zz_generated.deepcopy.go

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