Skip to content

Commit

Permalink
Support deploying hostpath provisioner operator (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Debakel Orakel <debakel.orakel@tegridy.io>
  • Loading branch information
DebakelOrakel and Debakel Orakel authored Feb 23, 2024
1 parent 9d32dec commit e7997aa
Show file tree
Hide file tree
Showing 11 changed files with 4,163 additions and 1 deletion.
10 changes: 9 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ parameters:
labels: {}
name: syn-kubevirt-cna

hostpath_provisioner:
enabled: true
version: v0.18.0
namespace:
annotations: {}
labels: {}
name: syn-kubevirt-hostpath

hostpath: {}
quota: {}
scale: {}
Expand All @@ -46,7 +54,7 @@ parameters:
kubevirt: {}
importer: {}
network_addons: {}
hostpath: {}
hostpath_provisioner: {}
quota: {}
scale: {}

Expand Down
11 changes: 11 additions & 0 deletions class/kubevirt-operator.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
parameters:
kapitan:
dependencies:
# --- kubevirt
- type: https
source: https://github.com/kubevirt/kubevirt/releases/download/${kubevirt_operator:operators:kubevirt:version}/kubevirt-operator.yaml
output_path: ${_base_directory}/manifests/kubevirt-${kubevirt_operator:operators:kubevirt:version}/kubevirt-operator.yaml
# --- containerized data importer
- type: https
source: https://github.com/kubevirt/containerized-data-importer/releases/download/${kubevirt_operator:operators:importer:version}/cdi-operator.yaml
output_path: ${_base_directory}/manifests/cdi-${kubevirt_operator:operators:importer:version}/cdi-operator.yaml
# --- cluster network addons
- type: https
source: https://github.com/kubevirt/cluster-network-addons-operator/releases/download/${kubevirt_operator:operators:network_addons:version}/operator.yaml
output_path: ${_base_directory}/manifests/cna-${kubevirt_operator:operators:network_addons:version}/operator.yaml
- type: https
source: https://github.com/kubevirt/cluster-network-addons-operator/releases/download/${kubevirt_operator:operators:network_addons:version}/network-addons-config.crd.yaml
output_path: ${_base_directory}/manifests/cna-${kubevirt_operator:operators:network_addons:version}/crd.yaml
# --- hostpath provisioner
- type: https
source: https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/${kubevirt_operator:operators:hostpath_provisioner:version}/operator.yaml
output_path: ${_base_directory}/manifests/hpp-${kubevirt_operator:operators:hostpath_provisioner:version}/operator.yaml
compile:
- input_paths:
- ${_base_directory}/component/app.jsonnet
input_type: jsonnet
output_path: apps/
- input_paths:
- ${_base_directory}/component/main.jsonnet
input_type: jsonnet
output_path: kubevirt-operator/
- input_paths:
- ${_base_directory}/component/importer.jsonnet
input_type: jsonnet
Expand Down
12 changes: 12 additions & 0 deletions component/app.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,16 @@ local app = argocd.App('kubevirt-operator', params.kubevirt.namespace.name);
},
},
},
[if helper.isEnabled('hostpath_provisioner') then 'kubevirt-hpp']: app {
spec+: {
source: {
path: 'manifests/kubevirt-operator/40_hostpath_provisioner',
},
syncPolicy+: {
syncOptions+: [
'ServerSideApply=true',
],
},
},
},
}
24 changes: 24 additions & 0 deletions component/helper.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ local patchManifests(path, namespace) = std.map(
manifests('kubevirt-operator/manifests/' + path)
);

// Instances
local _instanceObj = {
data_importer: {
apiVersion: 'cdi.kubevirt.io/v1beta1',
kind: 'CDI',
},
hostpath_provisioner: {
apiVersion: 'hostpathprovisioner.kubevirt.io/v1beta1',
kind: 'HostPathProvisioner',
},
};
local instance(component, namespace, config={}) = _instanceObj[component] {
metadata+: {
labels: {
'app.kubernetes.io/managed-by': 'commodore',
'app.kubernetes.io/name': 'instance',
'app.kubernetes.io/instance': component,
},
namespace: namespace,
},
spec: if std.length(config) > 0 then config else std.get(params.config, component, {}),
};

// Component
local componentEnabled(component) =
if component == 'hyperconverged' then
Expand All @@ -48,5 +71,6 @@ local componentEnabled(component) =

{
load: patchManifests,
instance: instance,
isEnabled: componentEnabled,
}
36 changes: 36 additions & 0 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// main template for kubevirt-operator
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';

local helper = import 'helper.libsonnet';

// The hiera parameters for the component
local inv = kap.inventory();
local params = inv.parameters.kubevirt_operator;
local isOpenshift = std.startsWith(inv.parameters.facts.distribution, 'openshift');

// Namespace
// local namespace = kube.Namespace(params.namespace.name) {
// metadata+: {
// annotations+: params.namespace.annotations,
// labels+: {
// // Configure the namespaces so that the OCP4 cluster-monitoring
// // Prometheus can find the servicemonitors and rules.
// [if isOpenshift then 'openshift.io/cluster-monitoring']: 'true',
// } + com.makeMergeable(params.namespace.labels),
// },
// };

// Instance

// Define outputs below
{
[if helper.isEnabled('hostpath_provisioner') then '40_hostpath_provisioner/10_bundle']: helper.load('hpp-%s/operator.yaml' % params.operators.hostpath_provisioner.version, params.operators.hostpath_provisioner.namespace.name),
[if std.length(params.config.hostpath_provisioner) > 0 then '40_hostpath_provisioner/20_instance']: helper.instance('hostpath_provisioner', params.operators.hostpath_provisioner.namespace.name),
}
// if helper.isEnabled('importer') then {
// '20_importer/00_namespace': namespace,
// '20_importer/10_bundle': helper.load('cdi-%s/cdi-operator.yaml' % operator.version, operator.namespace.name),
// [if std.length(config) > 0 then '20_importer/20_instance']: instance,
// } else {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec:
source:
path: manifests/kubevirt-operator/40_hostpath_provisioner
syncPolicy:
syncOptions:
- ServerSideApply=true
Loading

0 comments on commit e7997aa

Please sign in to comment.