Skip to content

Commit

Permalink
Merge pull request #11 from run-ai/support_daemonsetPool
Browse files Browse the repository at this point in the history
support daemonset
  • Loading branch information
lliranbabi authored Jul 18, 2024
2 parents d103579 + 610ddb7 commit 39da5ce
Show file tree
Hide file tree
Showing 18 changed files with 8,680 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.5
VERSION ?= 0.0.7

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ resources:
kind: JobPool
path: github.com/run-ai/kwok-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: run-ai.com
group: kwok.sigs
kind: DaemonsetPool
path: github.com/run-ai/kwok-operator/api/v1beta1
version: v1beta1
version: "3"
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ To install Kwok CRDs and the Kwok Operator, follow these steps:
```
or
```shell
kubectl apply --server-side -f https://github.com/run-ai/kwok-operator/releases/download/0.0.5/kwok-operator.yaml
kubectl apply --server-side -f https://github.com/run-ai/kwok-operator/releases/download/0.0.7/kwok-operator.yaml
```
## Usage

Expand Down Expand Up @@ -250,6 +250,53 @@ spec:
command: ["sh", "-c", "echo Hello, Kubernetes! && sleep 3600"]
restartPolicy: Never
```
To use the Kwok Operator to manage Daemonset on top the nodes you provisioned above, follow these steps:
1. ensure the namespace is exist
2. Define a DaemonsetPool custom resource (CR) with your desired configuration. Example:
```yaml
apiVersion: kwok.sigs.run-ai.com/v1beta1
kind: DaemonsetPool
metadata:
labels:
app.kubernetes.io/name: daemonsetpool
app.kubernetes.io/instance: daemonsetpool-sample
app.kubernetes.io/part-of: kwok-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: kwok-operator
name: daemonsetpool-sample
namespace: default
spec:
daemonsetTemplate:
metadata:
name: kwok-operator
labels:
app.kubernetes.io/name: daemonset
app.kubernetes.io/instance: daemonset-sample
app.kubernetes.io/part-of: kwok-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: kwok-operator
spec:
selector:
matchLabels:
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: deployment-sample
app.kubernetes.io/part-of: kwok-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: kwok-operator
template:
metadata:
labels:
app.kubernetes.io/name: daemonset
app.kubernetes.io/instance: daemonset-sample
app.kubernetes.io/part-of: kwok-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: kwok-operator
spec:
containers:
- image: nginx
name: nginx
restartPolicy: Always
```
## Troubleshooting
If you encounter any issues with the Kwok Operator, please check the following:
Expand Down
59 changes: 59 additions & 0 deletions api/v1beta1/daemonsetpool_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2024.
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 v1beta1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// DaemonsetPoolSpec defines the desired state of DaemonsetPool

type DaemonsetPoolSpec struct {
DaemonsetTemplate appsv1.DaemonSet `json:"daemonsetTemplate"`
}

// DaemonsetPoolStatus defines the observed state of DaemonsetPool
type DaemonsetPoolStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,2,opt,name=observedGeneration"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// DaemonsetPool is the Schema for the daemonsetpools API
type DaemonsetPool struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec DaemonsetPoolSpec `json:"spec,omitempty"`
Status DaemonsetPoolStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// DaemonsetPoolList contains a list of DaemonsetPool
type DaemonsetPoolList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DaemonsetPool `json:"items"`
}

func init() {
SchemeBuilder.Register(&DaemonsetPool{}, &DaemonsetPoolList{})
}
97 changes: 97 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "JobPool")
os.Exit(1)
}
if err = (&controller.DaemonsetPoolReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DaemonsetPool")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading

0 comments on commit 39da5ce

Please sign in to comment.