Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cloud/etc/deploy-openstack-hypervisor/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ moved {
to = juju_integration.hypervisor-ovn[0]
}

moved {
from = juju_integration.hypervisor-cinder-ceph[0]
to = juju_integration.hypervisor-extra-integration["cinder-volume-ceph-ceph-access"]
}

resource "juju_integration" "hypervisor-ovn" {
# Should be deployed if ovn-relay-offer-url set
count = (var.ovn-relay-offer-url != null) ? 1 : 0
Expand Down Expand Up @@ -147,18 +152,20 @@ resource "juju_integration" "hypervisor-ceilometer" {
}
}

resource "juju_integration" "hypervisor-cinder-ceph" {
count = (var.cinder-volume-ceph-application-name != null) ? 1 : 0
resource "juju_integration" "hypervisor-extra-integration" {
for_each = {
for i in var.extra_integrations : "${i.application_name}-${i.endpoint_name}" => i
}
model_uuid = data.juju_model.machine_model.uuid

application {
name = juju_application.openstack-hypervisor.name
endpoint = "ceph-access"
endpoint = each.value.hypervisor_endpoint_name
}

application {
name = var.cinder-volume-ceph-application-name
endpoint = "ceph-access"
name = each.value.application_name
endpoint = each.value.endpoint_name
}
}

Expand Down
12 changes: 8 additions & 4 deletions cloud/etc/deploy-openstack-hypervisor/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ variable "ceilometer-offer-url" {
default = null
}

variable "cinder-volume-ceph-application-name" {
description = "Name for cinder-volume-ceph application"
type = string
default = null
variable "extra_integrations" {
description = "Additional juju integrations for the hypervisor"
type = set(object({
application_name = string
endpoint_name = string
hypervisor_endpoint_name = string
}))
default = []
}

# Mandatory relation, no defaults
Expand Down
3 changes: 3 additions & 0 deletions cloud/etc/deploy-storage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module "backends" {

model_uuid = data.juju_model.model.uuid

application_name = each.value.application_name
units = each.value.units
name = each.key
principal_application = each.value.principal_application
charm_name = each.value.charm_name
Expand All @@ -32,6 +34,7 @@ module "backends" {
charm_config = each.value.charm_config
endpoint_bindings = each.value.endpoint_bindings
secrets = each.value.secrets
extra_integrations = each.value.extra_integrations
}

module "cinder-volume" {
Expand Down
53 changes: 45 additions & 8 deletions cloud/etc/deploy-storage/modules/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,55 @@ data "juju_application" "cinder-volume" {
model_uuid = data.juju_model.model.uuid
}

moved {
from = juju_secret.secret
to = juju_secret.secret[0]
}

resource "juju_secret" "secret" {
count = length(local.secret_values) > 0 ? 1 : 0
model_uuid = data.juju_model.model.uuid
name = "${var.name}-config-secret"
value = {
# Only template secrets that have a corresponding charm config value
for k, v in var.secrets : v => var.charm_config[k] if can(var.charm_config[k])
}
value = local.secret_values
}

moved {
from = juju_access_secret.secret-access
to = juju_access_secret.secret-access[0]
}

resource "juju_access_secret" "secret-access" {
count = length(local.secret_values) > 0 ? 1 : 0
model_uuid = data.juju_model.model.uuid
secret_id = juju_secret.secret.secret_id
secret_id = juju_secret.secret[0].secret_id
applications = [juju_application.storage-backend.name]
}

locals {
application_name = var.application_name != null ? var.application_name : var.name

secret_values = {
# Only template secrets that have a corresponding charm config value
for k, v in var.secrets : v => var.charm_config[k] if can(var.charm_config[k])
}

charm_config = merge(
{ volume-backend-name = var.name },
var.charm_config,
# Only template secrets uris in charm config if they have a value
{ for k, v in var.secrets : k => juju_secret.secret.secret_uri if can(var.charm_config[k]) }
{
for k, v in var.secrets :
k => juju_secret.secret[0].secret_uri
if length(local.secret_values) > 0 && can(var.charm_config[k])
}
)
}

# Deploy Storage backend charms
resource "juju_application" "storage-backend" {
name = var.name
name = local.application_name
model_uuid = data.juju_model.model.uuid
units = 1
units = var.units

charm {
name = var.charm_name
Expand Down Expand Up @@ -77,3 +97,20 @@ resource "juju_integration" "storage-backend-to-cinder-volume" {
endpoint = "cinder-volume"
}
}

resource "juju_integration" "backend-extra-integration" {
for_each = {
for i in var.extra_integrations : "${i.application_name}-${i.endpoint_name}" => i
}
model_uuid = data.juju_model.model.uuid

application {
name = juju_application.storage-backend.name
endpoint = each.value.backend_endpoint_name
}

application {
name = each.value.application_name
endpoint = each.value.endpoint_name
}
}
23 changes: 23 additions & 0 deletions cloud/etc/deploy-storage/modules/backend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ variable "principal_application" {
default = "cinder-volume"
}

variable "application_name" {
description = "Juju application name for the deployed backend"
type = string
default = null
}

variable "units" {
description = "Requested unit count for the backend application"
type = number
default = 1
nullable = true
}

variable "charm_name" {
description = "Name of the Storage charm"
type = string
Expand Down Expand Up @@ -57,3 +70,13 @@ variable "secrets" {
type = map(string)
default = {}
}

variable "extra_integrations" {
description = "Additional juju integrations for this backend"
type = set(object({
application_name = string
endpoint_name = string
backend_endpoint_name = string
}))
default = []
}
7 changes: 7 additions & 0 deletions cloud/etc/deploy-storage/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ variable "cinder-volumes" {
variable "backends" {
description = "Map of storage backend configurations"
type = map(object({
application_name = optional(string)
units = optional(number)
principal_application = string
charm_name = string
charm_base = string
Expand All @@ -36,6 +38,11 @@ variable "backends" {
charm_config = map(string)
endpoint_bindings = set(map(string))
secrets = map(string)
extra_integrations = optional(set(object({
application_name = string
endpoint_name = string
backend_endpoint_name = string
})), [])
}))
default = {}
}
26 changes: 4 additions & 22 deletions sunbeam-python/sunbeam/commands/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from rich.console import Console

from sunbeam.clusterd.client import Client
from sunbeam.core.ceph import is_internal_ceph_enabled
from sunbeam.core.common import click_option_topology, run_plan
from sunbeam.core.deployment import Deployment
from sunbeam.core.juju import JujuHelper
from sunbeam.core.terraform import TerraformInitStep
from sunbeam.steps.cinder_volume import DeployCinderVolumeApplicationStep
from sunbeam.steps.k8s import PatchCoreDNSStep
from sunbeam.steps.microceph import (
from sunbeam.features.ceph.microceph import (
DeployMicrocephApplicationStep,
SetCephMgrPoolSizeStep,
)
from sunbeam.steps.k8s import PatchCoreDNSStep
from sunbeam.steps.openstack import DeployControlPlaneStep
from sunbeam.utils import click_option_show_hints

Expand Down Expand Up @@ -48,7 +48,6 @@ def resize(

openstack_tfhelper = deployment.get_tfhelper("openstack-plan")
microceph_tfhelper = deployment.get_tfhelper("microceph-plan")
cinder_volume_tfhelper = deployment.get_tfhelper("cinder-volume-plan")
jhelper = JujuHelper(deployment.juju_controller)

storage_nodes = client.cluster.list_nodes_by_role("storage")
Expand All @@ -58,7 +57,7 @@ def resize(
LOG.warning("WARNING: Option --force is deprecated and the value is ignored.")

plan = []
if len(storage_nodes):
if len(storage_nodes) and is_internal_ceph_enabled(client):
# Change default-pool-size based on number of storage nodes
plan.extend(
[
Expand Down Expand Up @@ -94,23 +93,6 @@ def resize(
]
)

if len(storage_nodes):
# DeployCinderVolumeApplicationStep depends on openstack-tfhelper
# to get outputs, so let OpenStack deployment complete first
plan.extend(
[
TerraformInitStep(cinder_volume_tfhelper),
DeployCinderVolumeApplicationStep(
deployment,
client,
cinder_volume_tfhelper,
jhelper,
manifest,
deployment.openstack_machines_model,
),
]
)

run_plan(plan, console, show_hints)

click.echo("Resize complete.")
Loading
Loading