Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add warmup controller #6

Merged
merged 9 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Lint
run: make lint

# - name: Test
# run: make test
- name: Test
run: make test

e2e:
runs-on: ubuntu-latest
Expand Down
25 changes: 20 additions & 5 deletions api/v1/warmup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type WarmUpSpec struct {
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
TtlSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
Tolerations corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector corev1.NodeSelector `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Targets []string `json:"targets,omitempty"`
Options []string `json:"options,omitempty"`
Policy Policy `json:"policy,omitempty"`
Expand Down Expand Up @@ -72,15 +72,24 @@ type Cron struct {

// WarmUpStatus defines the observed state of WarmUp
type WarmUpStatus struct {
Phase string `json:"phase"`
Duration string `json:"duration"`
Conditions []Condition `json:"conditions"`
Phase WarmUpPhase `json:"phase"`
Duration string `json:"duration,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`

LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`
LastCompleteTime *metav1.Time `json:"lastCompleteTime,omitempty"`
LastCompleteNode string `json:"LastCompleteNode,omitempty"`
}

type WarmUpPhase string

const (
WarmUpPhasePending WarmUpPhase = "Pending"
WarmUpPhaseRunning WarmUpPhase = "Running"
WarmUpPhaseFailed WarmUpPhase = "Failed"
WarmUpPhaseComplete WarmUpPhase = "Complete"
)

type Condition struct {
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
Expand All @@ -89,6 +98,12 @@ type Condition struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:resource:shortName=wu
// +kubebuilder:printcolumn:name="CacheGroup",type="string",JSONPath=`.spec.cacheGroupName`
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=`.status.phase`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:printcolumn:name="Duration",type="string",JSONPath=`.status.duration`

// WarmUp is the Schema for the warmups API
type WarmUp struct {
Expand Down
16 changes: 14 additions & 2 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion cmd/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func run() {
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create warmup controller", "controller", "Warmup")
setupLog.Error(err, "unable to create warmup controller", "controller", "WarmUp")
os.Exit(1)
}

Expand Down
96 changes: 33 additions & 63 deletions config/crd/bases/juicefs.io_warmups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,25 @@ spec:
kind: WarmUp
listKind: WarmUpList
plural: warmups
shortNames:
- wu
singular: warmup
scope: Namespaced
versions:
- name: v1
- additionalPrinterColumns:
- jsonPath: .spec.cacheGroupName
name: CacheGroup
type: string
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.duration
name: Duration
type: string
name: v1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -43,54 +58,9 @@ spec:
type: object
type: object
nodeSelector:
properties:
nodeSelectorTerms:
items:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchFields:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
type: object
x-kubernetes-map-type: atomic
type: array
x-kubernetes-list-type: atomic
required:
- nodeSelectorTerms
additionalProperties:
type: string
type: object
x-kubernetes-map-type: atomic
options:
items:
type: string
Expand Down Expand Up @@ -143,19 +113,21 @@ spec:
type: string
type: array
tolerations:
properties:
effect:
type: string
key:
type: string
operator:
type: string
tolerationSeconds:
format: int64
type: integer
value:
type: string
type: object
items:
properties:
effect:
type: string
key:
type: string
operator:
type: string
tolerationSeconds:
format: int64
type: integer
value:
type: string
type: object
type: array
ttlSecondsAfterFinished:
format: int32
type: integer
Expand Down Expand Up @@ -189,8 +161,6 @@ spec:
phase:
type: string
required:
- conditions
- duration
- phase
type: object
type: object
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: example.com/juicefs-cache-group-operator
newTag: v0.0.1
newName: controller
newTag: latest
29 changes: 29 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ rules:
- pods/exec
verbs:
- create
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- watch
- apiGroups:
- juicefs.io
resources:
Expand Down Expand Up @@ -58,3 +77,13 @@ rules:
- get
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
- roles
verbs:
- create
- get
- list
- watch
5 changes: 1 addition & 4 deletions config/samples/juicefs.io_v1_warmup.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: juicefs.io/v1
kind: WarmUp
metadata:
labels:
app.kubernetes.io/name: juicefs-cache-group-operator
app.kubernetes.io/managed-by: kustomize
name: warmup-sample
spec:
# TODO(user): Add fields here
cacheGroupName: cachegroup-sample
Loading
Loading