Skip to content

Commit

Permalink
terraform: provide required configuration for yawol on OpenStack
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Feb 12, 2024
1 parent bab27fb commit b5e848a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cli/internal/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ func (c *Client) ShowInfrastructure(ctx context.Context, provider cloudprovider.
LoadBalancerName: loadBalancerName,
AttestationURL: attestationURL,
}
case cloudprovider.OpenStack:
networkIDOutput, ok := tfState.Values.Outputs["network_id"]
if !ok {
return state.Infrastructure{}, errors.New("no network_id output found")
}
networkID, ok := networkIDOutput.Value.(string)
if !ok {
return state.Infrastructure{}, errors.New("invalid type in network_id output: not a string")
}
res.OpenStack = &state.OpenStack{
NetworkID: networkID,
}
}
return res, nil
}
Expand Down
2 changes: 2 additions & 0 deletions internal/constellation/helm/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func extraConstellationServicesValues(
"yawolFloatingID": openStackCfg.FloatingIPPoolID,
"yawolFlavorID": openStackCfg.YawolFlavorID,
"yawolImageID": openStackCfg.YawolImageID,
"yawolNetworkID": output.OpenStack.NetworkID,
"yawolAPIHost": fmt.Sprintf("https://%s:%d", output.InClusterEndpoint, constants.KubernetesPort),
}
}
case cloudprovider.GCP:
Expand Down
10 changes: 10 additions & 0 deletions internal/constellation/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ type Infrastructure struct {
// description: |
// Values specific to a Constellation cluster running on GCP.
GCP *GCP `yaml:"gcp,omitempty"`
// description: |
// Values specific to a Constellation cluster running on OpenStack.
OpenStack *OpenStack `yaml:"openstack,omitempty"`
}

// GCP describes the infra state related to GCP.
Expand Down Expand Up @@ -168,6 +171,13 @@ type Azure struct {
AttestationURL string `yaml:"attestationURL"`
}

// OpenStack describes the infra state related to OpenStack.
type OpenStack struct {
// description: |
// ID of the network
NetworkID string `yaml:"networkID"`
}

// New creates a new cluster state (file).
func New() *State {
return &State{
Expand Down
29 changes: 28 additions & 1 deletion internal/constellation/state/state_doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions terraform/infrastructure/openstack/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ output "ip_cidr_node" {
value = local.cidr_vpc_subnet_nodes
description = "CIDR block of the node network."
}

# OpenStack-specific outputs

output "network_id" {
value = openstack_networking_network_v2.vpc_network.id
description = "The OpenStack network id the cluster is deployed in."
}

0 comments on commit b5e848a

Please sign in to comment.