Skip to content

Commit

Permalink
Merge pull request #27 from tegridy-io/breaking/overhaul-component-co…
Browse files Browse the repository at this point in the history
…nfig

Simplify configuration parameters
  • Loading branch information
DebakelOrakel authored Feb 24, 2024
2 parents c343693 + 5dd6b59 commit 4bafa83
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 183 deletions.
9 changes: 1 addition & 8 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ parameters:
enabled: false
version: v1.2.0

config:
kubevirt: {}
data_importer: {}
network_addons: {}
hostpath_provisioner: {}
schedule_scale: {}
tenant_quota: {}

config: {}

vm:
types: {}
Expand Down
38 changes: 22 additions & 16 deletions component/helper.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,9 @@ local kap = import 'lib/kapitan.libjsonnet';
local inv = kap.inventory();
local params = inv.parameters.kubevirt_operator;

// OLM
local deployOlm = params.olm.enabled;

// Config
local config(component) = if deployOlm then
com.makeMergeable(params.config.schedule_scale)
+ com.makeMergeable(params.config.tenant_quota)
+ com.makeMergeable(params.config.hostpath_provisioner)
+ com.makeMergeable(params.config.network_addons)
+ com.makeMergeable(params.config.data_importer)
+ com.makeMergeable(params.config.kubevirt)
else
std.get(params.config, component, {});

// Component
local deployOlm = params.olm.enabled;
local isEnabled(component) = std.get(params.operators, component, { enabled: false }).enabled;
local hasConfig(component) = std.length(config(component)) > 0;

// Loading and patching manifests
local clusterScoped = [
Expand Down Expand Up @@ -60,6 +46,27 @@ local patchManifests(path, namespace) = std.map(
manifests('kubevirt-operator/manifests/' + path)
);

// Config
local config(component) = if deployOlm then {
[k]: params.config[k]
for k in std.filter(
function(it) !std.member(
[
'kubevirt',
'data_importer',
'network_addons',
'hostpath_provisioner',
'schedule_scale',
'tenant_quota',
],
it
),
std.objectFields(params.config)
)
}
else
std.get(params.config, component, {});

// Instances
local _instanceObj = {
olm: {
Expand Down Expand Up @@ -109,6 +116,5 @@ local instance(component, namespace) = _instanceObj[component] {
load: patchManifests,
instance: instance,
isEnabled: isEnabled,
hasConfig: hasConfig,
deployOlm: deployOlm,
}
12 changes: 6 additions & 6 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ local vm_preferences = {
[if helper.isEnabled('hostpath_provisioner') then '10_bundle_hostpath']: bundle_hostpath,
[if helper.isEnabled('schedule_scale') then '10_bundle_schedule']: bundle_schedule,
[if helper.isEnabled('tenant_quota') then '10_bundle_quota']: bundle_quota,
[if helper.hasConfig('kubevirt') then '20_instance_kubevirt']: instance_kubevirt,
[if helper.hasConfig('data_importer') then '20_instance_importer']: instance_importer,
[if helper.hasConfig('network_addons') then '20_instance_network']: instance_network,
[if helper.hasConfig('hostpath_provisioner') then '20_instance_hostpath']: instance_hostpath,
[if helper.hasConfig('schedule_scale') then '20_instance_schedule']: instance_schedule,
[if helper.hasConfig('tenant_quota') then '20_instance_quota']: instance_quota,
[if helper.isEnabled('kubevirt') then '20_instance_kubevirt']: instance_kubevirt,
[if helper.isEnabled('data_importer') then '20_instance_importer']: instance_importer,
[if helper.isEnabled('network_addons') then '20_instance_network']: instance_network,
[if helper.isEnabled('hostpath_provisioner') then '20_instance_hostpath']: instance_hostpath,
[if helper.isEnabled('schedule_scale') then '20_instance_schedule']: instance_schedule,
[if helper.isEnabled('tenant_quota') then '20_instance_quota']: instance_quota,
}
+ vm_types
+ vm_preferences
145 changes: 67 additions & 78 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ olm:

Hyperconverged cluster operator configuration.

Deploying hyperconverged cluster operator will use OLM to install the operator.

This operator will manage all other operator contained in this component.

See https://github.com/kubevirt/hyperconverged-cluster-operator[Hyperconverged Cluster Operator Github] for documentation.

[NOTE]
====
* Deploying hyperconverged cluster operator will use OLM to install the operator.
* This operator will manage all other operator contained in this component.
====


== `operators`

Expand Down Expand Up @@ -166,49 +168,50 @@ Managed Tenant Quota operator configuration.

== `config`

Configure instances.


=== `kubevirt`

[horizontal]
type:: dictionary
default:: See https://kubevirt.io/user-guide/operations/customize_components[KubeVirt Documentation].


=== `data_importer`

[horizontal]
type:: dictionary
default:: See https://github.com/kubevirt/containerized-data-importer/blob/main/doc/cdi-config.md[Containerized Data Importer Documentation].


=== `network_addons`

[horizontal]
type:: dictionary
default:: See https://github.com/kubevirt/cluster-network-addons-operator[Cluster Network Addons Documentation].


=== `hostpath_provisioner`

[horizontal]
type:: dictionary
default:: See https://github.com/kubevirt/hostpath-provisioner-operator[Hostpath Provisioner Documentation].

default:: {}

=== `schedule_scale`
[NOTE]
====
If using olm / Hyperconverged Cluster operator all configuration is done under this field:
[horizontal]
type:: dictionary
default:: See https://github.com/kubevirt/ssp-operator/blob/main/docs/configuration.md[Scheduling, Scale and Performance Documentation].
[source,yaml]
----
config:
featureGates:
persistentReservation: true
withHostPassthroughCPU: true
----
====

[NOTE]
====
If using indivudual operators configure under specified keys:
=== `teanant_quota`
* `kubevirt`: See https://kubevirt.io/user-guide/operations/customize_components[KubeVirt Documentation].
* `data_importer`: See https://github.com/kubevirt/containerized-data-importer/blob/main/doc/cdi-config.md[Containerized Data Importer Documentation].
* `network_addons`: See https://github.com/kubevirt/cluster-network-addons-operator[Cluster Network Addons Documentation].
* `hostpath_provisioner`: See https://github.com/kubevirt/hostpath-provisioner-operator[Hostpath Provisioner Documentation].
* `schedule_scale`: See https://github.com/kubevirt/ssp-operator/blob/main/docs/configuration.md[Scheduling, Scale and Performance Documentation].
* `teanant_quota`: See https://github.com/kubevirt/managed-tenant-quota[Managed Tenant Quota Documentation].
[horizontal]
type:: dictionary
default:: See https://github.com/kubevirt/managed-tenant-quota[Managed Tenant Quota Documentation].
[source,yaml]
----
config:
kubevirt:
imagePullPolicy: IfNotPresent
infra:
replicas: 1
data_importer:
config:
featureGates:
- HonorWaitForFirstConsumer
infra:
replicas: 1
----
====


== `vm`
Expand All @@ -224,6 +227,21 @@ default:: {}

ClusterInstanceTypes configuration, see https://kubevirt.io/user-guide/virtual_machines/instancetypes/[KubeVirt Documentation] for specs.

[NOTE]
====
Example `VirtualMachineClusterInstancetype`:
[source,yaml]
----
vm:
types:
small-4:
cpu:
guest: 2
memory:
quest: 4Gi
----
====

=== `preferences`

Expand All @@ -233,45 +251,16 @@ default:: {}

ClusterInstancePreferences configuration, see https://kubevirt.io/user-guide/virtual_machines/instancetypes/[KubeVirt Documentation] for specs.


== Example
[NOTE]
====
Example `VirtualMachineClusterPreference`:
[source,yaml]
----
kubevirt_operator:
config:
kubevirt:
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
workload:
nodeSelector:
kubernetes.io/os: linux
importer:
config:
featureGates:
- HonorWaitForFirstConsumer
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
workload:
nodeSelector:
kubernetes.io/os: linux
cluster:
types:
small-4:
cpu:
guest: 2
memory:
quest: 4Gi
vm:
preferences:
virtio:
devices:
preferredDiskBus: virtio
----
====
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: cdi.kubevirt.io/v1beta1
kind: CDI
metadata:
labels:
app.kubernetes.io/instance: data_importer
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: instance
name: instance
namespace: syn-kubevirt-operator
spec: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kubevirt.io/v1
kind: KubeVirt
metadata:
labels:
app.kubernetes.io/instance: kubevirt
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: instance
name: instance
namespace: syn-kubevirt-operator
spec: {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@ metadata:
name: kubevirt-hyperconverged
namespace: kubevirt-hyperconverged
spec:
additionalMigrationResources:
requests.cpu: 500m
requests.memory: 512Mi
config:
featureGates:
- HonorWaitForFirstConsumer
featureGates:
deployTektonTaskResources: true
deployVmConsoleProxy: true
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
linuxBridge: {}
multus: {}
multusDynamicNetworks: {}
storagePools:
- name: local
path: /var/hpvolumes
workload:
nodeSelector:
kubernetes.io/os: linux
persistentReservation: true
withHostPassthroughCPU: true
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ metadata:
spec:
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
replicas: 1
workload:
nodeSelector:
kubernetes.io/os: linux
46 changes: 5 additions & 41 deletions tests/witholm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,10 @@ parameters:
enabled: true

config:
kubevirt:
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
workload:
nodeSelector:
kubernetes.io/os: linux
featureGates:
persistentReservation: true
withHostPassthroughCPU: true

data_importer:
config:
featureGates:
- HonorWaitForFirstConsumer
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
workload:
nodeSelector:
kubernetes.io/os: linux

network_addons:
multus: {}
multusDynamicNetworks: {}
linuxBridge: {}

hostpath_provisioner:
storagePools:
- name: "local"
path: "/var/hpvolumes"

schedule_scale:
featureGates:
deployTektonTaskResources: true
deployVmConsoleProxy: true

tenant_quota:
additionalMigrationResources:
requests.cpu: 500m
requests.memory: 512Mi
forgottenArtifact: true
mergedArtifact: true
Loading

0 comments on commit 4bafa83

Please sign in to comment.