Skip to content

Commit

Permalink
Deploy common-instancetypes v0.0.1-rc
Browse files Browse the repository at this point in the history
This initial change starts to simply deploy the v0.0.1-rc bundle
of VirtualMachineCluster{Instancetypes,Preferences} resources. These
resources are deployed under both OpenShift and non-OpenShift
environments. At present this is the only functionality enabled within
the operator when deployed under non-OpenShift environments.

Future changes will introduce support for removing deprecated resources
and for deploying resources from a kustomize repo URI.

Signed-off-by: Lee Yarwood <[email protected]>
  • Loading branch information
lyarwood committed Dec 8, 2022
1 parent deb0639 commit b521a26
Show file tree
Hide file tree
Showing 15 changed files with 2,458 additions and 11 deletions.
24 changes: 24 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,30 @@ rules:
- patch
- update
- watch
- apiGroups:
- instancetype.kubevirt.io
resources:
- virtualmachineclusterinstancetypes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- instancetype.kubevirt.io
resources:
- virtualmachineclusterpreferences
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- kubevirt.io
resources:
Expand Down
30 changes: 19 additions & 11 deletions controllers/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"kubevirt.io/ssp-operator/internal/common"
crd_watch "kubevirt.io/ssp-operator/internal/crd-watch"
"kubevirt.io/ssp-operator/internal/operands"
common_instancetypes "kubevirt.io/ssp-operator/internal/operands/common-instancetypes"
common_templates "kubevirt.io/ssp-operator/internal/operands/common-templates"
data_sources "kubevirt.io/ssp-operator/internal/operands/data-sources"
"kubevirt.io/ssp-operator/internal/operands/metrics"
Expand Down Expand Up @@ -47,23 +48,30 @@ func setupManager(ctx context.Context, cancel context.CancelFunc, mgr controller
return fmt.Errorf("failed to read template bundle: %w", err)
}

runningOnOpenShift, err := common.RunningOnOpenshift(ctx, mgr.GetAPIReader())
instancetypePath := common_instancetypes.BundleDir + common_instancetypes.ClusterInstancetypesBundlePrefix + ".yaml"
preferencePath := common_instancetypes.BundleDir + common_instancetypes.ClusterPreferencesBundlePrefix + ".yaml"
common_instancetypes_operand, err := common_instancetypes.New(instancetypePath, preferencePath)
if err != nil {
return err
}

if !runningOnOpenShift {
// do nothing if not running on OpenShift
mgr.GetLogger().Info("SSP operator is running in inactive mode. The operator will not react to any event.")
return nil
sspOperands := []operands.Operand{
common_instancetypes_operand,
}

sspOperands := []operands.Operand{
metrics.New(),
template_validator.New(),
common_templates.New(templatesBundle.Templates),
data_sources.New(templatesBundle.DataSources),
node_labeller.New(),
runningOnOpenShift, err := common.RunningOnOpenshift(ctx, mgr.GetAPIReader())
if err != nil {
return err
}

if runningOnOpenShift {
sspOperands = append(sspOperands,
metrics.New(),
template_validator.New(),
common_templates.New(templatesBundle.Templates),
data_sources.New(templatesBundle.DataSources),
node_labeller.New(),
)
}

var requiredCrds []string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: large
name: highperformance.large
spec:
cpu:
dedicatedCPUPlacement: true
guest: 2
isolateEmulatorThread: true
ioThreadsPolicy: shared
memory:
guest: 8Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: medium
name: highperformance.medium
spec:
cpu:
dedicatedCPUPlacement: true
guest: 1
isolateEmulatorThread: true
ioThreadsPolicy: shared
memory:
guest: 4Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: small
name: highperformance.small
spec:
cpu:
dedicatedCPUPlacement: true
guest: 1
isolateEmulatorThread: true
ioThreadsPolicy: shared
memory:
guest: 2Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: large
name: server.large
spec:
cpu:
guest: 2
memory:
guest: 8Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: medium
name: server.medium
spec:
cpu:
guest: 1
memory:
guest: 4Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: small
name: server.small
spec:
cpu:
guest: 1
memory:
guest: 2Gi
---
apiVersion: instancetype.kubevirt.io/v1alpha2
kind: VirtualMachineClusterInstancetype
metadata:
labels:
kubevirt.io/size: tiny
name: server.tiny
spec:
cpu:
guest: 1
memory:
guest: 1.5Gi
Loading

0 comments on commit b521a26

Please sign in to comment.