diff --git a/hack/update-crd.sh b/hack/update-crd.sh index 81172406f..720a4fb6c 100755 --- a/hack/update-crd.sh +++ b/hack/update-crd.sh @@ -67,11 +67,16 @@ esac # Determine variant from PackageSource file # Look for packages/core/platform/sources/${NAME}-application.yaml +# VARIANT (with OUT) is settable from the environment for a chart that provides +# an ALTERNATIVE variant of an application: its ApplicationDefinition must point +# at that variant's ExternalArtifact, not at variants[0]'s. PACKAGE_SOURCE_FILE="../../core/platform/sources/${NAME}-application.yaml" -if [[ -f "$PACKAGE_SOURCE_FILE" ]]; then - VARIANT="$(yq -r '.spec.variants[0].name // "default"' "$PACKAGE_SOURCE_FILE")" -else - VARIANT="default" +if [[ -z "${VARIANT:-}" ]]; then + if [[ -f "$PACKAGE_SOURCE_FILE" ]]; then + VARIANT="$(yq -r '.spec.variants[0].name // "default"' "$PACKAGE_SOURCE_FILE")" + else + VARIANT="default" + fi fi # If file doesn't exist, create a minimal skeleton diff --git a/packages/apps/vpc-cozyplane/Chart.yaml b/packages/apps/vpc-cozyplane/Chart.yaml new file mode 100644 index 000000000..82e7e20b7 --- /dev/null +++ b/packages/apps/vpc-cozyplane/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: virtualprivatecloud +description: Isolated networks +icon: /logos/vpc.svg +type: application +version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process diff --git a/packages/apps/vpc-cozyplane/Makefile b/packages/apps/vpc-cozyplane/Makefile new file mode 100644 index 000000000..8d43f5715 --- /dev/null +++ b/packages/apps/vpc-cozyplane/Makefile @@ -0,0 +1,11 @@ +include ../../../hack/package.mk + +generate: + cozyvalues-gen -v values.yaml -s values.schema.json -r README.md + OUT=../../system/virtualprivatecloud-rd/cozyrds/virtualprivatecloud-cozyplane.yaml VARIANT=cozyplane ../../../hack/update-crd.sh + +test: + helm unittest . + +update: + echo diff --git a/packages/apps/vpc-cozyplane/README.md b/packages/apps/vpc-cozyplane/README.md new file mode 100644 index 000000000..469e5fd77 --- /dev/null +++ b/packages/apps/vpc-cozyplane/README.md @@ -0,0 +1,35 @@ +# VPC (cozyplane) + +A Virtual Private Cloud backed by the cozyplane CNI: an isolated overlay network for the tenant's workloads, with optional peering to other tenants' VPCs and an explicit north-south boundary. + +## Service details + +This is the VPC application for the `cozyplane` networking variant. It serves the same catalog kind as the kube-ovn/multus-backed VPC application, but creates `sdn.cozystack.io` resources: a namespaced `VPC` (the overlay, with a cluster-unique network id assigned by the platform), a `VPCBinding` that authorizes the tenant's own namespace to attach workloads (attachment is default-deny, ownership and use are separate), one `VPCPeering` half per declared peer, and an optional `VPCGateway`. + +Workloads attach to the VPC with the `sdn.cozystack.io/vpc` annotation naming the VPC; there are no secondary network interfaces and no NetworkAttachmentDefinitions on this variant. + +## Deployment notes + +VPC name must be unique within a tenant. Address ranges may overlap with other VPCs — isolation is by overlay, not address space. + +Peering is declared bidirectionally: each owner lists the other in `peers`, and the peering is live only while both declarations exist. Removing either side stops cross-VPC traffic immediately. The two VPCs' address ranges must not overlap. + +By default a VPC is a closed island. Enabling the gateway opens many-to-one egress for the VPC's workloads (`gateway.nat`) and, separately, admits `Service` type=LoadBalancer traffic onto the VPC's workloads (`gateway.ingressLoadBalancer`). Cluster-internal destinations remain refused either way; cluster DNS keeps working without the gateway. + +## Parameters + +### Common parameters + +| Name | Description | Type | Value | +| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------- | ------- | +| `cidrs` | Address ranges (IPv4 and/or IPv6) of the VPC. May overlap with other VPCs: isolation is by overlay, not address space. | `[]string` | `[]` | +| `mtu` | MTU advertised to workloads in this VPC. 0 selects the platform default. | `int` | `0` | +| `peers` | VPC peering connections (bidirectional declaration required) | `[]object` | `[]` | +| `peers[i].vpcName` | Name of the remote VPC (without "virtualprivatecloud-" prefix) | `string` | `""` | +| `peers[i].tenantNamespace` | Namespace of the remote tenant | `string` | `""` | +| `gateway` | North-south boundary of the VPC | `object` | `{}` | +| `gateway.enabled` | Open a path to the outside. Without a gateway the VPC is a closed island: no way out, no way in. | `bool` | `false` | +| `gateway.nat` | Many-to-one egress for workloads with no external address of their own. | `bool` | `true` | +| `gateway.ingressLoadBalancer` | Admit Service type=LoadBalancer traffic onto this VPC's workloads. | `bool` | `false` | +| `gateway.loadBalancerClass` | The LoadBalancer implementation that allocates the egress identity. Empty selects the cluster default. | `string` | `""` | + diff --git a/packages/apps/vpc-cozyplane/logos/vpc.svg b/packages/apps/vpc-cozyplane/logos/vpc.svg new file mode 100644 index 000000000..555bb12e8 --- /dev/null +++ b/packages/apps/vpc-cozyplane/logos/vpc.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packages/apps/vpc-cozyplane/templates/vpc.yaml b/packages/apps/vpc-cozyplane/templates/vpc.yaml new file mode 100644 index 000000000..feaedef3e --- /dev/null +++ b/packages/apps/vpc-cozyplane/templates/vpc.yaml @@ -0,0 +1,73 @@ +## Release.Namespace == tenant namespace +## Release.Name == "virtualprivatecloud-" + the VPC's catalog name + +--- +apiVersion: sdn.cozystack.io/v1alpha1 +kind: VPC +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} + labels: + cozystack.io/vpcName: {{ .Release.Name }} + cozystack.io/tenantName: {{ .Release.Namespace }} +spec: + cidrs: {{ .Values.cidrs | toJson }} + {{- with .Values.mtu }} + mtu: {{ . }} + {{- end }} +--- +# Attachment is default-deny even for the owner: the VPC's namespace expresses +# ownership, a VPCBinding expresses use — so the tenant's own namespace needs one. +apiVersion: sdn.cozystack.io/v1alpha1 +kind: VPCBinding +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} + labels: + cozystack.io/vpcName: {{ .Release.Name }} + cozystack.io/tenantName: {{ .Release.Namespace }} +spec: + vpcRef: + namespace: {{ .Release.Namespace }} + name: {{ .Release.Name }} +{{- range .Values.peers }} +--- +# One half of a symmetric peering. The remote owner declares the mirror half in +# their own VPC, and the peering is live only while both halves exist. +apiVersion: sdn.cozystack.io/v1alpha1 +kind: VPCPeering +metadata: + {{- /* The hash keeps (tenant-a, b-c) and (tenant-a-b, c) apart. */}} + name: {{ printf "%s-to-%s-%s-%s" $.Release.Name .tenantNamespace .vpcName (printf "%s/%s" .tenantNamespace .vpcName | sha256sum | trunc 8) | quote }} + namespace: {{ $.Release.Namespace }} + labels: + cozystack.io/vpcName: {{ $.Release.Name }} + cozystack.io/tenantName: {{ $.Release.Namespace }} +spec: + vpcRef: + name: {{ $.Release.Name }} + peerRef: + namespace: {{ .tenantNamespace | quote }} + name: {{ printf "virtualprivatecloud-%s" .vpcName | quote }} +{{- end }} +{{- if .Values.gateway.enabled }} +--- +apiVersion: sdn.cozystack.io/v1alpha1 +kind: VPCGateway +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} + labels: + cozystack.io/vpcName: {{ .Release.Name }} + cozystack.io/tenantName: {{ .Release.Namespace }} +spec: + vpcRef: + name: {{ .Release.Name }} + {{- with .Values.gateway.loadBalancerClass }} + loadBalancerClass: {{ . | quote }} + {{- end }} + nat: + enabled: {{ .Values.gateway.nat }} + ingress: + loadBalancer: {{ .Values.gateway.ingressLoadBalancer }} +{{- end }} diff --git a/packages/apps/vpc-cozyplane/tests/vpc_test.yaml b/packages/apps/vpc-cozyplane/tests/vpc_test.yaml new file mode 100644 index 000000000..da66aa6b7 --- /dev/null +++ b/packages/apps/vpc-cozyplane/tests/vpc_test.yaml @@ -0,0 +1,153 @@ +suite: cozyplane vpc rendering +templates: + - templates/vpc.yaml +release: + name: virtualprivatecloud-myvpc + namespace: tenant-team-a +tests: + - it: renders the VPC and the owner-namespace binding, nothing else + set: + cidrs: ["10.10.0.0/24"] + asserts: + - hasDocuments: + count: 2 + - documentSelector: + path: kind + value: VPC + equal: + path: spec.cidrs + value: ["10.10.0.0/24"] + # Attachment is default-deny even for the owner, so the release must + # carry a binding for its own namespace or no pod can ever attach. + - documentSelector: + path: kind + value: VPCBinding + equal: + path: spec.vpcRef + value: + namespace: tenant-team-a + name: virtualprivatecloud-myvpc + + - it: omits mtu at 0 so the platform default applies + set: + cidrs: ["10.10.0.0/24"] + asserts: + - documentSelector: + path: kind + value: VPC + notExists: + path: spec.mtu + + - it: sets an explicit mtu + set: + cidrs: ["10.10.0.0/24"] + mtu: 1400 + asserts: + - documentSelector: + path: kind + value: VPC + equal: + path: spec.mtu + value: 1400 + + - it: renders one peering half per peer, addressing the remote release name + set: + cidrs: ["10.10.0.0/24"] + peers: + - vpcName: other-vpc + tenantNamespace: tenant-team-b + asserts: + - documentSelector: + path: kind + value: VPCPeering + equal: + path: spec.peerRef + value: + namespace: tenant-team-b + # The catalog name resolves to the remote VPC through the same + # release prefix this chart's own objects carry. + name: virtualprivatecloud-other-vpc + - documentSelector: + path: kind + value: VPCPeering + equal: + path: spec.vpcRef + value: + name: virtualprivatecloud-myvpc + + - it: names peerings apart when their joined target names collide + set: + cidrs: ["10.10.0.0/24"] + peers: + - vpcName: c + tenantNamespace: tenant-a-b + - vpcName: b-c + tenantNamespace: tenant-a + asserts: + - documentSelector: + path: spec.peerRef.namespace + value: tenant-a + equal: + path: metadata.name + value: virtualprivatecloud-myvpc-to-tenant-a-b-c-0cc24cae + - documentSelector: + path: spec.peerRef.namespace + value: tenant-a-b + equal: + path: metadata.name + value: virtualprivatecloud-myvpc-to-tenant-a-b-c-b82e8c9a + + - it: refuses a peer namespace or VPC name that is not a DNS-1123 label + set: + cidrs: ["10.10.0.0/24"] + peers: + - vpcName: "other\n---\nkind: ClusterRoleBinding" + tenantNamespace: tenant-team-b + asserts: + - failedTemplate: + errorPattern: 'vpcName.*does not match pattern' + + - it: renders the gateway only when enabled + set: + cidrs: ["10.10.0.0/24"] + gateway: + enabled: true + nat: true + ingressLoadBalancer: false + loadBalancerClass: "" + asserts: + - documentSelector: + path: kind + value: VPCGateway + equal: + path: spec.nat.enabled + value: true + - documentSelector: + path: kind + value: VPCGateway + equal: + path: spec.ingress.loadBalancer + value: false + # Empty selects the cluster default, so the field must be absent rather + # than an empty string the apiserver would treat as a named class. + - documentSelector: + path: kind + value: VPCGateway + notExists: + path: spec.loadBalancerClass + + - it: names a loadBalancerClass when given one + set: + cidrs: ["10.10.0.0/24"] + gateway: + enabled: true + nat: true + ingressLoadBalancer: true + loadBalancerClass: metallb + asserts: + - documentSelector: + path: kind + value: VPCGateway + equal: + path: spec.loadBalancerClass + value: metallb diff --git a/packages/apps/vpc-cozyplane/values.schema.json b/packages/apps/vpc-cozyplane/values.schema.json new file mode 100644 index 000000000..cef38b4b2 --- /dev/null +++ b/packages/apps/vpc-cozyplane/values.schema.json @@ -0,0 +1,77 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "cidrs": { + "description": "Address ranges (IPv4 and/or IPv6) of the VPC. May overlap with other VPCs: isolation is by overlay, not address space.", + "type": "array", + "default": [], + "items": { + "type": "string" + } + }, + "mtu": { + "description": "MTU advertised to workloads in this VPC. 0 selects the platform default.", + "type": "integer", + "default": 0 + }, + "peers": { + "description": "VPC peering connections (bidirectional declaration required)", + "type": "array", + "default": [], + "items": { + "type": "object", + "required": [ + "tenantNamespace", + "vpcName" + ], + "properties": { + "tenantNamespace": { + "description": "Namespace of the remote tenant", + "type": "string", + "maxLength": 63, + "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" + }, + "vpcName": { + "description": "Name of the remote VPC (without \"virtualprivatecloud-\" prefix)", + "type": "string", + "maxLength": 63, + "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" + } + } + } + }, + "gateway": { + "description": "North-south boundary of the VPC", + "type": "object", + "default": {}, + "required": [ + "enabled", + "ingressLoadBalancer", + "nat" + ], + "properties": { + "enabled": { + "description": "Open a path to the outside. Without a gateway the VPC is a closed island: no way out, no way in.", + "type": "boolean", + "default": false + }, + "ingressLoadBalancer": { + "description": "Admit Service type=LoadBalancer traffic onto this VPC's workloads.", + "type": "boolean", + "default": false + }, + "loadBalancerClass": { + "description": "The LoadBalancer implementation that allocates the egress identity. Empty selects the cluster default.", + "type": "string", + "default": "" + }, + "nat": { + "description": "Many-to-one egress for workloads with no external address of their own.", + "type": "boolean", + "default": true + } + } + } + } +} diff --git a/packages/apps/vpc-cozyplane/values.yaml b/packages/apps/vpc-cozyplane/values.yaml new file mode 100644 index 000000000..6073e780d --- /dev/null +++ b/packages/apps/vpc-cozyplane/values.yaml @@ -0,0 +1,40 @@ +## +## @section Common parameters +## + +## @param {[]string} cidrs - Address ranges (IPv4 and/or IPv6) of the VPC. May overlap with other VPCs: isolation is by overlay, not address space. +cidrs: [] +## Example: +## cidrs: +## - "10.10.0.0/24" + +## @param {int} [mtu] - MTU advertised to workloads in this VPC. 0 selects the platform default. +mtu: 0 + +## @typedef {struct} Peer - VPC peering target +## @field {string} vpcName - Name of the remote VPC (without "virtualprivatecloud-" prefix) +## @maxLength 63 +## @pattern ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ +## @field {string} tenantNamespace - Namespace of the remote tenant +## @maxLength 63 +## @pattern ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + +## @param {[]Peer} peers - VPC peering connections (bidirectional declaration required) +peers: [] +## Example: +## peers: +## - vpcName: "other-vpc" +## tenantNamespace: "tenant-other" + +## @typedef {struct} Gateway - The VPC's north-south boundary +## @field {bool} enabled - Open a path to the outside. Without a gateway the VPC is a closed island: no way out, no way in. +## @field {bool} nat - Many-to-one egress for workloads with no external address of their own. +## @field {bool} ingressLoadBalancer - Admit Service type=LoadBalancer traffic onto this VPC's workloads. +## @field {string} [loadBalancerClass] - The LoadBalancer implementation that allocates the egress identity. Empty selects the cluster default. + +## @param {Gateway} gateway - North-south boundary of the VPC +gateway: + enabled: false + nat: true + ingressLoadBalancer: false + loadBalancerClass: "" diff --git a/packages/core/platform/sources/virtualprivatecloud-application.yaml b/packages/core/platform/sources/virtualprivatecloud-application.yaml index 4b813881b..16b13edf4 100644 --- a/packages/core/platform/sources/virtualprivatecloud-application.yaml +++ b/packages/core/platform/sources/virtualprivatecloud-application.yaml @@ -28,3 +28,26 @@ spec: install: namespace: cozy-system releaseName: virtualprivatecloud-rd + # The cozyplane networking variant's VPC: the same VirtualPrivateCloud + # catalog kind, backed by sdn.cozystack.io resources instead of + # kube-ovn/multus. No multus edge — this variant creates no + # NetworkAttachmentDefinitions. + - name: cozyplane + dependsOn: + - cozystack.networking + # cozystack-engine ships the ApplicationDefinition CRD rendered by the *-rd component below. + - cozystack.cozystack-engine + # The aggregated apiserver serves sdn.cozystack.io; until it lands the + # group is not served and a tenant VPC release cannot apply. + - cozystack.cozyplane-apiserver + components: + - name: virtualprivatecloud + path: apps/vpc-cozyplane + - name: virtualprivatecloud-rd + path: system/virtualprivatecloud-rd + valuesFiles: + - values.yaml + - values-cozyplane.yaml + install: + namespace: cozy-system + releaseName: virtualprivatecloud-rd diff --git a/packages/core/platform/templates/bundles/iaas.yaml b/packages/core/platform/templates/bundles/iaas.yaml index 608b1a5e5..aaaf715d3 100644 --- a/packages/core/platform/templates/bundles/iaas.yaml +++ b/packages/core/platform/templates/bundles/iaas.yaml @@ -260,12 +260,13 @@ {{include "cozystack.platform.package" (list "cozystack.kubernetes-application" "kubevirt" $) }} {{include "cozystack.platform.package" (list "cozystack.kubernetes-nodes-application" "kubevirt" $) }} {{include "cozystack.platform.package" (list "cozystack.computeplane-application" "kubevirt" $) }} -{{- /* virtualprivatecloud is Cozystack's kube-ovn/multus tenant VPC app; it - hard-depends on cozystack.multus and cannot function without kube-ovn. The - cozyplane variant runs neither and provides VPC tenancy through its own - sdn.cozystack.io model, so skip it here (otherwise its Package hangs on a - multus dependency that the variant never installs). */ -}} -{{- if ne (.Values.bundles.system.networkingVariant | default "kubeovn-cilium") "cozyplane" }} +{{- /* virtualprivatecloud follows the networking variant: the kubevirt flavor + is kube-ovn/multus-backed and would hang on a multus dependency the + cozyplane variant never installs; the cozyplane flavor serves the same + catalog kind from sdn.cozystack.io. */ -}} +{{- if eq (.Values.bundles.system.networkingVariant | default "kubeovn-cilium") "cozyplane" }} +{{include "cozystack.platform.package" (list "cozystack.virtualprivatecloud-application" "cozyplane" $) }} +{{- else }} {{include "cozystack.platform.package" (list "cozystack.virtualprivatecloud-application" "kubevirt" $) }} {{- end }} {{include "cozystack.platform.package" (list "cozystack.vm-disk-application" "kubevirt" $) }} diff --git a/packages/core/platform/tests/bundles_vpc_networking_variant_test.yaml b/packages/core/platform/tests/bundles_vpc_networking_variant_test.yaml new file mode 100644 index 000000000..7e87aaa21 --- /dev/null +++ b/packages/core/platform/tests/bundles_vpc_networking_variant_test.yaml @@ -0,0 +1,39 @@ +suite: vpc application follows the networking variant +templates: + - templates/bundles/iaas.yaml +release: + name: cozystack + namespace: cozy-system +tests: + - it: installs the kubevirt vpc flavor on the default variant + set: + bundles: + system: + enabled: true + variant: isp-full + iaas: + enabled: true + documentSelector: + path: metadata.name + value: cozystack.virtualprivatecloud-application + asserts: + - equal: + path: spec.variant + value: kubevirt + + - it: installs the cozyplane vpc flavor on the cozyplane variant + set: + bundles: + system: + enabled: true + variant: isp-full + networkingVariant: cozyplane + iaas: + enabled: true + documentSelector: + path: metadata.name + value: cozystack.virtualprivatecloud-application + asserts: + - equal: + path: spec.variant + value: cozyplane diff --git a/packages/core/platform/tests/sources_vpc_cozyplane_variant_test.yaml b/packages/core/platform/tests/sources_vpc_cozyplane_variant_test.yaml new file mode 100644 index 000000000..9e31549b8 --- /dev/null +++ b/packages/core/platform/tests/sources_vpc_cozyplane_variant_test.yaml @@ -0,0 +1,42 @@ +suite: the cozyplane vpc variant's dependency edges +# Its own suite because it renders templates/sources.yaml — see +# vpc_multus_dependency_test.yaml for why sources suites stay separate from +# bundle suites. +templates: + - templates/sources.yaml +release: + name: cozystack + namespace: cozy-system +tests: + - it: gates the cozyplane vpc flavor on the aggregated sdn apiserver, not on multus + documentSelector: + path: metadata.name + value: cozystack.virtualprivatecloud-application + asserts: + - equal: + path: spec.variants[1].name + value: cozyplane + # sdn.cozystack.io is served only by the aggregated apiserver; without + # this edge the tenant VPC release races the group's availability. + - contains: + path: spec.variants[1].dependsOn + content: cozystack.cozyplane-apiserver + # No NetworkAttachmentDefinitions in this flavor, so no multus edge — + # the cozyplane bundle never installs multus and the edge would hang. + - notContains: + path: spec.variants[1].dependsOn + content: cozystack.multus + # The rd component must select the cozyplane ApplicationDefinition, or + # the installed definition points at an artifact this variant never + # builds. + - contains: + path: spec.variants[1].components + content: + name: virtualprivatecloud-rd + path: system/virtualprivatecloud-rd + valuesFiles: + - values.yaml + - values-cozyplane.yaml + install: + namespace: cozy-system + releaseName: virtualprivatecloud-rd diff --git a/packages/system/virtualprivatecloud-rd/Makefile b/packages/system/virtualprivatecloud-rd/Makefile index 013e96b19..43a5bfbf5 100644 --- a/packages/system/virtualprivatecloud-rd/Makefile +++ b/packages/system/virtualprivatecloud-rd/Makefile @@ -2,3 +2,6 @@ export NAME=virtualprivatecloud-rd export NAMESPACE=cozy-system include ../../../hack/package.mk + +test: + helm unittest . diff --git a/packages/system/virtualprivatecloud-rd/cozyrds/virtualprivatecloud-cozyplane.yaml b/packages/system/virtualprivatecloud-rd/cozyrds/virtualprivatecloud-cozyplane.yaml new file mode 100644 index 000000000..d22acaa7d --- /dev/null +++ b/packages/system/virtualprivatecloud-rd/cozyrds/virtualprivatecloud-cozyplane.yaml @@ -0,0 +1,32 @@ +apiVersion: cozystack.io/v1alpha1 +kind: ApplicationDefinition +metadata: + name: virtualprivatecloud +spec: + application: + kind: VirtualPrivateCloud + plural: virtualprivateclouds + singular: virtualprivatecloud + openAPISchema: |- + {"title":"Chart Values","type":"object","properties":{"cidrs":{"description":"Address ranges (IPv4 and/or IPv6) of the VPC. May overlap with other VPCs: isolation is by overlay, not address space.","type":"array","default":[],"items":{"type":"string"}},"mtu":{"description":"MTU advertised to workloads in this VPC. 0 selects the platform default.","type":"integer","default":0},"peers":{"description":"VPC peering connections (bidirectional declaration required)","type":"array","default":[],"items":{"type":"object","required":["tenantNamespace","vpcName"],"properties":{"tenantNamespace":{"description":"Namespace of the remote tenant","type":"string","maxLength":63,"pattern":"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"},"vpcName":{"description":"Name of the remote VPC (without \"virtualprivatecloud-\" prefix)","type":"string","maxLength":63,"pattern":"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"}}}},"gateway":{"description":"North-south boundary of the VPC","type":"object","default":{},"required":["enabled","ingressLoadBalancer","nat"],"properties":{"enabled":{"description":"Open a path to the outside. Without a gateway the VPC is a closed island: no way out, no way in.","type":"boolean","default":false},"ingressLoadBalancer":{"description":"Admit Service type=LoadBalancer traffic onto this VPC's workloads.","type":"boolean","default":false},"loadBalancerClass":{"description":"The LoadBalancer implementation that allocates the egress identity. Empty selects the cluster default.","type":"string","default":""},"nat":{"description":"Many-to-one egress for workloads with no external address of their own.","type":"boolean","default":true}}}}} + release: + prefix: "virtualprivatecloud-" + labels: + sharding.fluxcd.io/key: tenants + chartRef: + kind: ExternalArtifact + name: cozystack-virtualprivatecloud-application-cozyplane-virtualprivatecloud + namespace: cozy-system + dashboard: + category: IaaS + singular: VPC + plural: VPCs + description: "Isolated networks" + icon: PHN2ZyB3aWR0aD0iMTQ0IiBoZWlnaHQ9IjE0NCIgdmlld0JveD0iMCAwIDE0NCAxNDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxNDQiIGhlaWdodD0iMTQ0IiByeD0iMjQiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8xMDI1XzMpIi8+CjxwYXRoIGQ9Ik0xMDkuNiA4Ni4xSDExNC4zQzExNi44ODUgODYuMSAxMTkgODguMjE1IDExOSA5MC44NDdWMTA0Ljg1M0MxMTkgMTA3LjQ4NSAxMTYuODg1IDEwOS42IDExNC4zIDEwOS42SDk1LjVDOTIuOTE1IDEwOS42IDkwLjggMTA3LjQ4NSA5MC44IDEwNC44NTNWOTAuODQ3QzkwLjggODguMjE1IDkyLjkxNSA4Ni4xIDk1LjUgODYuMUgxMDAuMlY3Ni43SDc2LjdWODYuMUg4MS40QzgzLjk4NSA4Ni4xIDg2LjEgODguMjE1IDg2LjEgOTAuODQ3VjEwNC44NTNDODYuMSAxMDcuNDg1IDgzLjk4NSAxMDkuNiA4MS40IDEwOS42SDYyLjZDNjAuMDE1IDEwOS42IDU3LjkgMTA3LjQ4NSA1Ny45IDEwNC44NTNWOTAuODQ3QzU3LjkgODguMjE1IDYwLjAxNSA4Ni4xIDYyLjYgODYuMUg2Ny4zVjc2LjdINDMuOFY4Ni4xSDQ4LjVDNTEuMDg1IDg2LjEgNTMuMiA4OC4yMTUgNTMuMiA5MC44NDdWMTA0Ljg1M0M1My4yIDEwNy40ODUgNTEuMDg1IDEwOS42IDQ4LjUgMTA5LjZIMjkuN0MyNy4xMTUgMTA5LjYgMjUgMTA3LjQ4NSAyNSAxMDQuODUzVjkwLjg0N0MyNSA4OC4yMTUgMjcuMTE1IDg2LjEgMjkuNyA4Ni4xSDM0LjRWNzYuN0MzNC40IDcxLjUzIDM4LjYzIDY3LjMgNDMuOCA2Ny4zSDY3LjNWNTcuOUg2Mi42QzYwLjAxNSA1Ny45IDU3LjkgNTUuNzg1IDU3LjkgNTMuMTUzVjM5LjE0N0M1Ny45IDM2LjUxNSA2MC4wMTUgMzQuNCA2Mi42IDM0LjRIODEuNEM4My45ODUgMzQuNCA4Ni4xIDM2LjUxNSA4Ni4xIDM5LjE0N1Y1My4xNTNDODYuMSA1NS43ODUgODMuOTg1IDU3LjkgODEuNCA1Ny45SDc2LjdWNjcuM0gxMDAuMkMxMDUuMzcgNjcuMyAxMDkuNiA3MS41MyAxMDkuNiA3Ni43Vjg2LjFaIiBmaWxsPSJ3aGl0ZSIvPgo8ZGVmcz4KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDBfbGluZWFyXzEwMjVfMyIgeDE9IjE0Mi41IiB5MT0iMTQzIiB4Mj0iMy45OTk5OSIgeTI9IjkuNDk5OTkiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iIzAwMDgyRSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyRTMwNjciLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K + keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ["metadata"], ["metadata", "name"], ["spec", "cidrs"], ["spec", "mtu"], ["spec", "peers"], ["spec", "gateway"], ["spec", "gateway", "enabled"], ["spec", "gateway", "nat"], ["spec", "gateway", "ingressLoadBalancer"], ["spec", "gateway", "loadBalancerClass"]] + secrets: + exclude: [] + include: [] + services: + exclude: [] + include: [] diff --git a/packages/system/virtualprivatecloud-rd/templates/cozyrd.yaml b/packages/system/virtualprivatecloud-rd/templates/cozyrd.yaml index e079ddcf3..b32cfdd80 100644 --- a/packages/system/virtualprivatecloud-rd/templates/cozyrd.yaml +++ b/packages/system/virtualprivatecloud-rd/templates/cozyrd.yaml @@ -1,4 +1,15 @@ -{{- range $path, $_ := .Files.Glob "cozyrds/*" }} ---- -{{ $.Files.Get $path }} +{{- /* One ApplicationDefinition per cluster: both variants register the same + VirtualPrivateCloud kind (same release prefix), so rendering more than + one is a same-name collision. The variant value picks the backing + chart's definition; the PackageSource variant sets it. */ -}} +{{- $variant := .Values.variant | default "kubevirt" -}} +{{- $file := printf "cozyrds/virtualprivatecloud-%s.yaml" $variant -}} +{{- if eq $variant "kubevirt" -}} +{{- $file = "cozyrds/virtualprivatecloud.yaml" -}} +{{- end -}} +{{- $doc := .Files.Get $file -}} +{{- if not $doc -}} +{{- fail (printf "unknown variant %q: %s does not exist" $variant $file) -}} {{- end }} +--- +{{ $doc }} diff --git a/packages/system/virtualprivatecloud-rd/tests/variant_test.yaml b/packages/system/virtualprivatecloud-rd/tests/variant_test.yaml new file mode 100644 index 000000000..0e619fa12 --- /dev/null +++ b/packages/system/virtualprivatecloud-rd/tests/variant_test.yaml @@ -0,0 +1,41 @@ +suite: ApplicationDefinition variant selection +templates: + - templates/cozyrd.yaml +release: + name: virtualprivatecloud-rd + namespace: cozy-system +tests: + # Both variants register the same VirtualPrivateCloud kind, so exactly one + # ApplicationDefinition may render, and its chartRef must name the artifact + # of the variant that was selected — a mismatch leaves every tenant VPC + # release pointing at a chart the cluster does not build. + - it: defaults to the kubevirt definition + asserts: + - hasDocuments: + count: 1 + - equal: + path: metadata.name + value: virtualprivatecloud + - equal: + path: spec.release.chartRef.name + value: cozystack-virtualprivatecloud-application-kubevirt-virtualprivatecloud + + - it: selects the cozyplane definition + set: + variant: cozyplane + asserts: + - hasDocuments: + count: 1 + - equal: + path: metadata.name + value: virtualprivatecloud + - equal: + path: spec.release.chartRef.name + value: cozystack-virtualprivatecloud-application-cozyplane-virtualprivatecloud + + - it: refuses an unknown variant + set: + variant: nonesuch + asserts: + - failedTemplate: + errorPattern: 'unknown variant "nonesuch"' diff --git a/packages/system/virtualprivatecloud-rd/values-cozyplane.yaml b/packages/system/virtualprivatecloud-rd/values-cozyplane.yaml new file mode 100644 index 000000000..ed2e63c48 --- /dev/null +++ b/packages/system/virtualprivatecloud-rd/values-cozyplane.yaml @@ -0,0 +1 @@ +variant: cozyplane diff --git a/packages/system/virtualprivatecloud-rd/values.yaml b/packages/system/virtualprivatecloud-rd/values.yaml index 0967ef424..c303b536f 100644 --- a/packages/system/virtualprivatecloud-rd/values.yaml +++ b/packages/system/virtualprivatecloud-rd/values.yaml @@ -1 +1,3 @@ -{} +# Which cozyrds/ ApplicationDefinition this release installs. The platform +# bundle selects it per networking variant through the PackageSource. +variant: kubevirt