Skip to content

Commit

Permalink
Support deploying container network addons (#15)
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 dbf6568 commit 9d32dec
Show file tree
Hide file tree
Showing 14 changed files with 7,812 additions and 8 deletions.
13 changes: 9 additions & 4 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parameters:
kubevirt.io: ''
pod-security.kubernetes.io/enforce: privileged
name: syn-kubevirt-operator
replicas: 1

importer:
enabled: true
Expand All @@ -30,17 +29,23 @@ parameters:
labels:
cdi.kubevirt.io: ''
name: syn-kubevirt-cdi
replicas: 1

network: {}
network_addons:
enabled: true
version: v0.91.0
namespace:
annotations: {}
labels: {}
name: syn-kubevirt-cna

hostpath: {}
quota: {}
scale: {}

config:
kubevirt: {}
importer: {}
network: {}
network_addons: {}
hostpath: {}
quota: {}
scale: {}
Expand Down
10 changes: 10 additions & 0 deletions class/kubevirt-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ parameters:
- 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
- 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
compile:
- input_paths:
- ${_base_directory}/component/app.jsonnet
Expand All @@ -28,3 +34,7 @@ parameters:
- ${_base_directory}/component/hyper.jsonnet
input_type: jsonnet
output_path: kubevirt-operator/
- input_paths:
- ${_base_directory}/component/network_addons.jsonnet
input_type: jsonnet
output_path: kubevirt-operator/
24 changes: 24 additions & 0 deletions component/app.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ local helper = import 'helper.libsonnet';
local app = argocd.App('kubevirt-operator', params.kubevirt.namespace.name);

{
[if helper.isEnabled('hyperconverged') then 'kubevirt-hyperconverged']: app {
spec+: {
source: {
path: 'manifests/kubevirt-operator/',
},
syncPolicy+: {
syncOptions+: [
'ServerSideApply=true',
],
},
},
},
[if helper.isEnabled('kubevirt') then 'kubevirt-operator']: app {
spec+: {
source: {
Expand All @@ -31,4 +43,16 @@ local app = argocd.App('kubevirt-operator', params.kubevirt.namespace.name);
},
},
},
[if helper.isEnabled('network_addons') then 'kubevirt-cna']: app {
spec+: {
source: {
path: 'manifests/kubevirt-operator/30_network_addons',
},
syncPolicy+: {
syncOptions+: [
'ServerSideApply=true',
],
},
},
},
}
48 changes: 48 additions & 0 deletions component/network_addons.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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 operator = inv.parameters.kubevirt_operator.operators.network_addons;
local config = inv.parameters.kubevirt_operator.config.network_addons;
local isOpenshift = std.startsWith(inv.parameters.facts.distribution, 'openshift');

// Namespace
local namespace = kube.Namespace(operator.namespace.name) {
metadata+: {
annotations+: operator.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(operator.namespace.labels),
},
};

// Bundle
local bundle = helper.load('cna-%s/crd.yaml' % operator.version, operator.namespace.name)
+ helper.load('cna-%s/operator.yaml' % operator.version, operator.namespace.name);

// Instance
local instance = kube._Object('networkaddonsoperator.network.kubevirt.io/v1', 'NetworkAddonsConfig', 'instance') {
metadata+: {
labels: {
'app.kubernetes.io/managed-by': 'commodore',
'app.kubernetes.io/name': 'instance',
'app.kubernetes.io/instance': 'instance',
},
namespace: operator.namespace.name,
},
spec: config,
};

// Define outputs below
if helper.isEnabled('importer') then {
'30_network_addons/00_namespace': namespace,
'30_network_addons/10_bundle': bundle,
[if std.length(config) > 0 then '30_network_addons/20_instance']: instance,
} else {}
34 changes: 30 additions & 4 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ kubevirt:
kubevirt.io: ''
pod-security.kubernetes.io/enforce: privileged
name: syn-kubevirt-operator
replicas: 1 <4>
----
<1> Enable KubeVirt operator.
<2> KubeVirt version.
<3> Configure KubeVirt namespace.
<4> Configure KubeVirt operator replicas.

KubeVirt operator configuration.

Expand All @@ -81,16 +79,37 @@ importer:
labels:
cdi.kubevirt.io: ''
name: syn-kubevirt-cdi
replicas: 1 <4>
----
<1> Enable CDI operator.
<2> Containerized Data Importer version.
<3> Configure CDI namespace.
<4> Configure CDI operator replicas.

Containerized Data Importer operator configuration.


=== `network_addons`

[horizontal]
type:: dictionary
default::
+
[source,yaml]
----
network_addons:
enabled: true <1>
version: v0.91.0 <2>
namespace: <3>
annotations: {}
labels: {}
name: syn-kubevirt-cna
----
<1> Enable CNA operator.
<2> Cluster Network Addons version.
<3> Configure CNA namespace.

Cluster Network Addons operator configuration.


== `config`

Configure instances.
Expand All @@ -110,6 +129,13 @@ type:: dictionary
default:: See https://github.com/kubevirt/containerized-data-importer/blob/main/doc/cdi-config.md[CDI Documentation].


=== `network_addons`

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


== `cluster`

Cluster scoped VM types and preferences.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec:
source:
path: manifests/kubevirt-operator/30_network_addons
syncPolicy:
syncOptions:
- ServerSideApply=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
annotations: {}
labels:
name: syn-kubevirt-cna
name: syn-kubevirt-cna
Loading

0 comments on commit 9d32dec

Please sign in to comment.