2022-07-13 08:04:46 -04:00
|
|
|
name: Constellation create
|
|
|
|
description: |
|
2022-10-21 04:16:44 -04:00
|
|
|
Create a new Constellation cluster using latest OS image.
|
2022-05-03 05:15:53 -04:00
|
|
|
inputs:
|
|
|
|
workerNodesCount:
|
|
|
|
description: "Number of worker nodes to spawn."
|
|
|
|
required: true
|
|
|
|
controlNodesCount:
|
|
|
|
description: "Number of control-plane nodes to spawn."
|
|
|
|
required: true
|
|
|
|
cloudProvider:
|
|
|
|
description: "Either 'gcp' or 'azure'."
|
|
|
|
required: true
|
2022-08-29 02:55:36 -04:00
|
|
|
gcpClusterServiceAccountKey:
|
|
|
|
description: "Service account to use inside the created Constellation cluster on GCP."
|
|
|
|
required: false
|
2022-05-03 05:15:53 -04:00
|
|
|
machineType:
|
|
|
|
description: "Machine type of VM to spawn."
|
2022-09-02 06:09:45 -04:00
|
|
|
required: false
|
2022-10-21 04:16:44 -04:00
|
|
|
osImage:
|
|
|
|
description: "OS image to use. The default value 'debug-latest' will select the latest available debug image."
|
2022-08-09 09:29:39 -04:00
|
|
|
required: true
|
|
|
|
isDebugImage:
|
2022-10-21 04:16:44 -04:00
|
|
|
description: "Is OS img a debug img?"
|
2022-08-09 09:29:39 -04:00
|
|
|
required: true
|
2022-08-09 04:02:15 -04:00
|
|
|
kubernetesVersion:
|
|
|
|
description: "Kubernetes version to create the cluster from."
|
|
|
|
required: false
|
2022-08-30 07:42:14 -04:00
|
|
|
azureClientSecret:
|
|
|
|
description: "The client secret value of the used secret"
|
|
|
|
required: false
|
2022-09-02 06:43:04 -04:00
|
|
|
azureResourceGroup:
|
|
|
|
description: "The resource group to use for Constellation cluster"
|
|
|
|
required: false
|
2022-05-03 05:15:53 -04:00
|
|
|
runs:
|
2022-08-09 04:02:15 -04:00
|
|
|
using: "composite"
|
2022-05-03 05:15:53 -04:00
|
|
|
steps:
|
2022-08-09 04:02:15 -04:00
|
|
|
- name: Install kubectl
|
|
|
|
run: |
|
2022-09-14 10:30:13 -04:00
|
|
|
HOSTOS="$(go env GOOS)"
|
|
|
|
HOSTARCH="$(go env GOARCH)"
|
|
|
|
curl -sLO https://dl.k8s.io/release/v1.23.0/bin/{$HOSTOS}/{$HOSTARCH}/kubectl
|
2022-08-09 04:02:15 -04:00
|
|
|
install kubectl /usr/local/bin
|
|
|
|
shell: bash
|
2022-06-20 04:30:59 -04:00
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
- name: Constellation config generate
|
|
|
|
run: |
|
|
|
|
constellation config generate ${{ inputs.cloudProvider }}
|
2022-06-20 04:30:59 -04:00
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
yq eval -i \
|
|
|
|
"(.provider | select(. | has(\"azure\")).azure.subscription) = \"0d202bbb-4fa7-4af8-8125-58c269a05435\" |
|
|
|
|
(.provider | select(. | has(\"azure\")).azure.tenant) = \"adb650a8-5da3-4b15-b4b0-3daf65ff7626\" |
|
2022-08-18 10:44:44 -04:00
|
|
|
(.provider | select(. | has(\"azure\")).azure.location) = \"West US\" |
|
2022-08-30 07:42:14 -04:00
|
|
|
(.provider | select(. | has(\"azure\")).azure.userAssignedIdentity) = \"/subscriptions/0d202bbb-4fa7-4af8-8125-58c269a05435/resourceGroups/e2e-test-creds/providers/Microsoft.ManagedIdentity/userAssignedIdentities/e2e-test-user-assigned-id\" |
|
2022-09-02 06:43:04 -04:00
|
|
|
(.provider | select(. | has(\"azure\")).azure.resourceGroup) = \"${{ inputs.azureResourceGroup }}\" |
|
2022-08-30 07:42:14 -04:00
|
|
|
(.provider | select(. | has(\"azure\")).azure.appClientID) = \"b657a00e-813a-4dc7-9b09-fa498a254d71\" |
|
|
|
|
(.provider | select(. | has(\"azure\")).azure.clientSecretValue) = \"${{ inputs.azureClientSecret }}\" |
|
2022-08-15 03:34:31 -04:00
|
|
|
(.provider | select(. | has(\"azure\")).azure.enforcedMeasurements) = [11,12]" \
|
2022-08-09 04:02:15 -04:00
|
|
|
constellation-conf.yaml
|
|
|
|
yq eval -i \
|
|
|
|
"(.provider | select(. | has(\"gcp\")).gcp.project) = \"constellation-331613\" |
|
|
|
|
(.provider | select(. | has(\"gcp\")).gcp.region) = \"europe-west3\" |
|
2022-08-15 04:32:23 -04:00
|
|
|
(.provider | select(. | has(\"gcp\")).gcp.zone) = \"europe-west3-b\" |
|
2022-09-05 03:57:11 -04:00
|
|
|
(.provider | select(. | has(\"gcp\")).gcp.enforcedMeasurements) = [11,12] |
|
|
|
|
(.provider | select(. | has(\"gcp\")).gcp.serviceAccountKeyPath) = \"serviceAccountKey.json\"" \
|
2022-08-09 04:02:15 -04:00
|
|
|
constellation-conf.yaml
|
2022-06-20 04:30:59 -04:00
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
if [ ${{ inputs.kubernetesVersion != '' }} = true ]; then
|
|
|
|
yq eval -i "(.kubernetesVersion) = ${{ inputs.kubernetesVersion }}" constellation-conf.yaml
|
|
|
|
fi
|
|
|
|
shell: bash
|
2022-06-20 04:30:59 -04:00
|
|
|
|
2022-08-09 09:29:39 -04:00
|
|
|
- name: Set image
|
2022-08-09 04:02:15 -04:00
|
|
|
run: |
|
|
|
|
case $CSP in
|
|
|
|
azure)
|
2022-10-21 04:16:44 -04:00
|
|
|
if [ "${{ inputs.osImage == 'debug-latest' }}" = true ]
|
2022-08-09 09:29:39 -04:00
|
|
|
then
|
2022-08-26 11:34:46 -04:00
|
|
|
IMAGE_DEFINITION=$(az sig image-definition list --resource-group constellation-images --gallery-name Constellation_Debug_CVM --query "[].name" -o tsv | sort --version-sort | tail -n 1)
|
|
|
|
AZURE_IMAGE=$(az sig image-version list --resource-group constellation-images --gallery-name Constellation_Debug_CVM --gallery-image-definition ${IMAGE_DEFINITION} --query "sort_by([], &publishingProfile.publishedDate)[].id" -o table | tail -n 1)
|
2022-08-09 09:29:39 -04:00
|
|
|
else
|
2022-10-21 04:16:44 -04:00
|
|
|
AZURE_IMAGE=${{ inputs.osImage }}
|
2022-08-09 09:29:39 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
yq eval -i "(.provider.azure.image) = \"${AZURE_IMAGE}\"" constellation-conf.yaml
|
2022-08-09 04:02:15 -04:00
|
|
|
;;
|
|
|
|
gcp)
|
2022-10-21 04:16:44 -04:00
|
|
|
if [ "${{ inputs.osImage == 'debug-latest' }}" = true ]
|
2022-08-09 09:29:39 -04:00
|
|
|
then
|
2022-09-13 04:01:44 -04:00
|
|
|
GCP_IMAGE_NAME=$(gcloud compute images list --project constellation-images --filter="name ~ constellation-\d{10} AND family~constellation-debug-v\d+-\d+-\d+" --sort-by=creationTimestamp --format="table(name)" | tail -n 1)
|
2022-08-09 09:29:39 -04:00
|
|
|
GCP_IMAGE="projects/constellation-images/global/images/${GCP_IMAGE_NAME}"
|
|
|
|
else
|
2022-10-21 04:16:44 -04:00
|
|
|
GCP_IMAGE=${{ inputs.osImage }}
|
2022-08-09 09:29:39 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
yq eval -i "(.provider.gcp.image) = \"${GCP_IMAGE}\"" constellation-conf.yaml
|
2022-08-09 04:02:15 -04:00
|
|
|
;;
|
|
|
|
esac
|
2022-08-09 09:29:39 -04:00
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
CSP: ${{ inputs.cloudProvider }}
|
|
|
|
|
2022-09-02 06:09:45 -04:00
|
|
|
- name: Set instanceType
|
|
|
|
if: ${{ inputs.machineType && inputs.machineType != 'default' }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
yq eval -i "(.provider | select(. | has(\"azure\")).azure.instanceType) = \"${{ inputs.machineType }}\"" constellation-conf.yaml
|
|
|
|
yq eval -i "(.provider | select(. | has(\"gcp\")).gcp.instanceType) = \"${{ inputs.machineType }}\"" constellation-conf.yaml
|
|
|
|
|
2022-09-05 03:36:30 -04:00
|
|
|
- name: Create serviceAccountKey.json
|
|
|
|
if: ${{ inputs.cloudProvider == 'gcp' }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "$GCP_CLUSTER_SERVICE_ACCOUNT_KEY" > serviceAccountKey.json
|
|
|
|
env:
|
|
|
|
GCP_CLUSTER_SERVICE_ACCOUNT_KEY: ${{ inputs.gcpClusterServiceAccountKey }}
|
|
|
|
|
2022-09-06 04:38:14 -04:00
|
|
|
- name: Enable debugCluster flag
|
2022-08-09 09:29:39 -04:00
|
|
|
run: |
|
2022-09-06 04:38:14 -04:00
|
|
|
yq eval -i '(.debugCluster) = true' constellation-conf.yaml
|
2022-08-09 09:29:39 -04:00
|
|
|
shell: bash
|
|
|
|
if: ${{ inputs.isDebugImage == 'true' }}
|
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
- name: Constellation create
|
|
|
|
run: |
|
|
|
|
echo "Creating cluster using config:"
|
|
|
|
cat constellation-conf.yaml
|
2022-09-07 10:54:41 -04:00
|
|
|
constellation create -c ${{ inputs.controlNodesCount }} -w ${{ inputs.workerNodesCount }} --name e2e-test -y
|
2022-08-09 04:02:15 -04:00
|
|
|
shell: bash
|
|
|
|
- name: Upload constellation-state.json
|
2022-10-12 12:05:58 -04:00
|
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
|
2022-08-09 04:02:15 -04:00
|
|
|
with:
|
|
|
|
name: constellation-state.json
|
|
|
|
path: constellation-state.json
|
|
|
|
if: ${{ always() && !env.ACT }}
|
|
|
|
|
2022-08-09 09:29:39 -04:00
|
|
|
- name: Cdbg deploy
|
|
|
|
run: |
|
2022-09-02 06:44:20 -04:00
|
|
|
echo "::group::cdbg deploy"
|
2022-09-14 11:41:47 -04:00
|
|
|
chmod +x $GITHUB_WORKSPACE/build/cdbg
|
2022-08-31 06:25:27 -04:00
|
|
|
cdbg deploy --bootstrapper $GITHUB_WORKSPACE/build/bootstrapper
|
2022-09-02 06:44:20 -04:00
|
|
|
echo "::endgroup::"
|
2022-08-09 09:29:39 -04:00
|
|
|
shell: bash
|
|
|
|
if: ${{ inputs.isDebugImage == 'true' }}
|
|
|
|
|
2022-08-09 04:02:15 -04:00
|
|
|
- name: Constellation init
|
2022-09-09 07:28:53 -04:00
|
|
|
id: constellation-init
|
2022-08-09 04:02:15 -04:00
|
|
|
run: |
|
2022-09-20 04:38:38 -04:00
|
|
|
constellation init
|
2022-10-12 05:43:32 -04:00
|
|
|
echo "KUBECONFIG=$(pwd)/constellation-admin.conf" >> $GITHUB_OUTPUT
|
2022-08-09 04:02:15 -04:00
|
|
|
shell: bash
|
2022-09-05 12:12:46 -04:00
|
|
|
|
2022-09-09 07:28:53 -04:00
|
|
|
- name: Wait for nodes to join and become ready
|
|
|
|
run: |
|
|
|
|
echo "::group::Wait for nodes"
|
|
|
|
NODES_COUNT=$((${{ inputs.controlNodesCount }} + ${{ inputs.workerNodesCount }}))
|
|
|
|
JOINWAIT=0
|
|
|
|
until [ "$(kubectl get nodes -o json | jq '.items | length')" == "${NODES_COUNT}" ] || [ $JOINWAIT -gt $JOINTIMEOUT ];
|
|
|
|
do
|
|
|
|
echo "$(kubectl get nodes -o json | jq '.items | length')/"${NODES_COUNT}" nodes have joined.. waiting.."
|
|
|
|
JOINWAIT=$((JOINWAIT+30))
|
|
|
|
sleep 30
|
|
|
|
done
|
|
|
|
if [ $JOINWAIT -gt $JOINTIMEOUT ]; then
|
|
|
|
echo "Timed out waiting for nodes to join"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$(kubectl get nodes -o json | jq '.items | length')/"${NODES_COUNT}" nodes have joined"
|
|
|
|
kubectl wait --for=condition=ready --all nodes --timeout=10m
|
|
|
|
echo "::endgroup::"
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
KUBECONFIG: "${{ steps.constellation-init.outputs.KUBECONFIG }}"
|
|
|
|
JOINTIMEOUT: "1200" # 20 minutes timeout for all nodes to join
|
|
|
|
|
2022-09-05 12:12:46 -04:00
|
|
|
- name: Download boot logs
|
|
|
|
run: |
|
|
|
|
echo "::group::Download boot logs"
|
|
|
|
case $CSP in
|
|
|
|
azure)
|
|
|
|
AZURE_RESOURCE_GROUP=$(yq eval ".provider.azure.resourceGroup" constellation-conf.yaml)
|
|
|
|
./.github/actions/constellation_create/az-logs.sh ${AZURE_RESOURCE_GROUP}
|
|
|
|
;;
|
|
|
|
gcp)
|
|
|
|
CONTROL_NODES=$(jq -r '.gcpcontrolplaneinstancegroup' constellation-state.json)
|
|
|
|
WORKER_NODES=$(jq -r '.gcpworkerinstancegroup' constellation-state.json)
|
|
|
|
ZONE=$(jq -r '.gcpzone' constellation-state.json)
|
|
|
|
./.github/actions/constellation_create/gcp-logs.sh ${CONTROL_NODES} ${WORKER_NODES} ${ZONE}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "::endgroup::"
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
CSP: ${{ inputs.cloudProvider }}
|
|
|
|
continue-on-error: true
|
|
|
|
if: ${{ always() }}
|
|
|
|
- name: Upload boot logs
|
2022-10-12 12:05:58 -04:00
|
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
|
2022-09-05 12:12:46 -04:00
|
|
|
with:
|
|
|
|
name: serial-logs
|
2022-09-06 04:38:14 -04:00
|
|
|
path: "*.log"
|
2022-09-05 12:12:46 -04:00
|
|
|
if: ${{ always() && !env.ACT }}
|