constellation/docs/versioned_docs/version-2.12/workflows/create.md
2023-11-09 12:51:02 +01:00

3.4 KiB

Create your cluster

:::info This recording presents the essence of this page. It's recommended to read it in full for the motivation and all details. :::


Creating your cluster requires two steps:

  1. Creating the necessary resources in your cloud environment
  2. Bootstrapping the Constellation cluster and setting up a connection

See the architecture section for details on the inner workings of this process.

:::tip If you don't have a cloud subscription, you can also set up a local Constellation cluster using virtualization for testing. :::

The create step

This step creates the necessary resources for your cluster in your cloud environment. Before you create the cluster, make sure to have a valid configuration file.

Create

constellation create

create stores your cluster's state in a constellation-terraform directory in your workspace.

Terraform allows for an easier GitOps integration as well as meeting regulatory requirements. Since the Constellation CLI also uses Terraform under the hood, you can reuse the same Terraform files.

:::info Familiarize with the Terraform usage policy before manually interacting with Terraform to create a cluster. Please also refrain from changing the Terraform resource definitions, as Constellation is tightly coupled to them. :::

Download the Terraform files for the selected CSP from the GitHub repository.

Create a terraform.tfvars file. There, define all needed variables found in variables.tf using the values from the constellation-config.yaml.

To find the image reference for your CSP and region, execute:

CONSTELL_VER=vX.Y.Z
curl -s https://cdn.confidential.cloud/constellation/v1/ref/-/stream/stable/$CONSTELL_VER/image/info.json | jq

Initialize and apply Terraform to create the configured infrastructure:

terraform init
terraform apply

The Constellation init step requires the already created constellation-config.yaml and the constellation-state.yaml. Create the constellation-state.yaml using the output from the Terraform state and the constellation-conf.yaml:

CONSTELL_IP=$(terraform output ip)
CONSTELL_INIT_SECRET=$(terraform output initSecret | jq -r | tr -d '\n' | base64)
touch constellation-state.yaml
yq eval '.version ="v1"' --inplace constellation-state.yaml
yq eval '.infrastructure.initSecret ="$CONSTELL_INIT_SECRET"' --inplace constellation-state.yaml
yq eval '.infrastructure.clusterEndpoint ="$CONSTELL_IP"' --inplace constellation-state.yaml

The init step

The following command initializes and bootstraps your cluster:

constellation init

Next, configure kubectl for your cluster:

export KUBECONFIG="$PWD/constellation-admin.conf"

🏁 That's it. You've successfully created a Constellation cluster.

Troubleshooting

In case init fails, the CLI collects logs from the bootstrapping instance and stores them inside constellation-cluster.log.