Skip to content

Commit 96011a4

Browse files
Maxusmustiopenshift-merge-robot
authored andcommitted
Installing InstaScale via Operator
1 parent 0912aa4 commit 96011a4

31 files changed

+997
-6
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ resources:
1616
kind: MCAD
1717
path: github.com/project-codeflare/codeflare-operator/api/v1alpha1
1818
version: v1alpha1
19+
- api:
20+
crdVersion: v1
21+
namespaced: true
22+
controller: true
23+
domain: codeflare.dev
24+
group: codeflare
25+
kind: InstaScale
26+
path: github.com/project-codeflare/codeflare-operator/api/v1alpha1
27+
version: v1alpha1
1928
version: "3"

api/v1alpha1/instascale_types.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2023.
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+
// InstaScaleSpec defines the desired state of InstaScale
24+
type InstaScaleSpec struct {
25+
26+
// enableMonitoring determines if monitoring artifacts are deployed for the InstaScale instance.
27+
// +kubebuilder:default=true
28+
EnableMonitoring bool `json:"enableMonitoring,omitempty"`
29+
30+
// maxScaleoutAllowed determines the max number of machines that can be scaled up by InstaScale
31+
// +kubebuilder:default=15
32+
MaxScaleoutAllowed int `json:"maxScaleoutAllowed,omitempty"`
33+
}
34+
35+
// InstaScaleStatus defines the observed state of InstaScale
36+
type InstaScaleStatus struct {
37+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38+
// Important: Run "make" to regenerate code after modifying this file
39+
}
40+
41+
//+kubebuilder:object:root=true
42+
//+kubebuilder:subresource:status
43+
44+
// InstaScale is the Schema for the instascales API
45+
type InstaScale struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec InstaScaleSpec `json:"spec,omitempty"`
50+
Status InstaScaleStatus `json:"status,omitempty"`
51+
}
52+
53+
//+kubebuilder:object:root=true
54+
55+
// InstaScaleList contains a list of InstaScale
56+
type InstaScaleList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []InstaScale `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&InstaScale{}, &InstaScaleList{})
64+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.2
7+
creationTimestamp: null
8+
name: instascales.codeflare.codeflare.dev
9+
spec:
10+
group: codeflare.codeflare.dev
11+
names:
12+
kind: InstaScale
13+
listKind: InstaScaleList
14+
plural: instascales
15+
singular: instascale
16+
scope: Namespaced
17+
versions:
18+
- name: v1alpha1
19+
schema:
20+
openAPIV3Schema:
21+
description: InstaScale is the Schema for the instascales API
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: InstaScaleSpec defines the desired state of InstaScale
37+
properties:
38+
enableMonitoring:
39+
default: true
40+
description: enableMonitoring determines if monitoring artifacts are
41+
deployed for the InstaScale instance.
42+
type: boolean
43+
maxScaleoutAllowed:
44+
default: 15
45+
description: maxScaleoutAllowed determines the max number of machines
46+
that can be scaled up by InstaScale
47+
type: integer
48+
type: object
49+
status:
50+
description: InstaScaleStatus defines the observed state of InstaScale
51+
type: object
52+
type: object
53+
served: true
54+
storage: true
55+
subresources:
56+
status: {}

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# It should be run by config/default
44
resources:
55
- bases/codeflare.codeflare.dev_mcads.yaml
6+
- bases/codeflare.codeflare.dev_instascales.yaml
67
- bases/mcad.ibm.com_appwrappers.yaml
78
- bases/mcad.ibm.com_queuejobs.yaml
89
- bases/mcad.ibm.com_schedulingspecs.yaml
@@ -12,11 +13,13 @@ patchesStrategicMerge:
1213
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1314
# patches here are for enabling the conversion webhook for each CRD
1415
#- patches/webhook_in_mcads.yaml
16+
#- patches/webhook_in_instascales.yaml
1517
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1618

1719
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1820
# patches here are for enabling the CA injection for each CRD
1921
#- patches/cainjection_in_mcads.yaml
22+
#- patches/cainjection_in_instascales.yaml
2023
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2124

2225
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: instascales.codeflare.codeflare.dev
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: instascales.codeflare.codeflare.dev
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: instascale-{{.Name}}-cr
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- nodes
10+
- configmaps
11+
verbs:
12+
- list
13+
- watch
14+
- get
15+
- create
16+
- update
17+
- delete
18+
- patch
19+
20+
- apiGroups:
21+
- apps
22+
resources:
23+
- deployments
24+
verbs:
25+
- list
26+
- watch
27+
- get
28+
- apiGroups:
29+
- machine.openshift.io
30+
resources:
31+
- "*"
32+
verbs:
33+
- list
34+
- watch
35+
- get
36+
- create
37+
- update
38+
- delete
39+
- patch
40+
41+
- apiGroups:
42+
- mcad.ibm.com
43+
resources:
44+
- appwrappers
45+
verbs:
46+
- list
47+
- watch
48+
- get
49+
- create
50+
- update
51+
- delete
52+
- patch
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: instascale-{{.Name}}-crb
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: instascale-{{.Name}}-cr
9+
subjects:
10+
- kind: ServiceAccount
11+
name: instascale-{{.Name}}-sa
12+
namespace: {{.Namespace}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: instascale-{{.Name}}-config
5+
namespace: {{.Namespace}}
6+
labels:
7+
app: instascale-{{.Name}}
8+
component: instascale
9+
data:
10+
maxScaleoutAllowed: "{{.MaxScaleoutAllowed}}"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: instascale-{{.Name}}
6+
name: instascale-{{.Name}}
7+
namespace: {{.Namespace}}
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: instascale-{{.Name}}
13+
template:
14+
metadata:
15+
labels:
16+
app: instascale-{{.Name}}
17+
spec:
18+
containers:
19+
- image: quay.io/project-codeflare/instascale-controller:latest
20+
name: instascale
21+
resources:
22+
limits:
23+
cpu: "2"
24+
memory: "2G"
25+
requests:
26+
cpu: "2"
27+
memory: "2G"
28+
serviceAccountName: instascale-{{.Name}}-sa
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: instascale-{{.Name}}-sa
5+
namespace: {{.Namespace}}

0 commit comments

Comments
 (0)