VMware Cloud Foundation APIs: Deploying VCF Automation
Whilst VCF Automation is typically deployed during the initial VMware Cloud Foundation deployment phase via VCF Installer it is possible to skip the deployment initially for various reasons such as may you don't have a use case initially or you want to deploy to a different network that is not available at the time. Under such scenarios you can easily deploy as a Day N task.
In this post we will look at how the VCF Automation component can be deployed using the public APIs, this is achieved via the VCF Fleet Lifecycle Service which is tightly integrated into VCF Operations.
VCF Fleet Lifecycle Service APIs Used
- POST /api/v1/identity/token
- GET /fleet-lcm/v1/sddc-lcms
- POST /fleet-lcm/v1/components/validations
- POST /fleet-lcm/v1/components
- GET /fleet-lcm/v1/tasks/{taskId}
Procedure
Connect to a system that has access to the infrastructure and is capable of running CURL.
Replace the values in the sample code with values for your VCF Fleet Lifecycle Service and paste the commands in the console. If your not sure which endpoint this FQDN should be log into VCF Operations, go to Build > Lifecycle > VCF Management and select the Components tab and locate the component named Fleet lifecycle the FQDN is shown in the FQDN column.
1export vcfFleetLifecycleFqdn='flt-fc01.rainpole.io'
2export vcfFleetLifecycleUser='[email protected]'
3export vcfFleetLifecyclePass='VMw@re1!VMw@re1!'
- Authenticate to the VCF Fleet Lifecycle Service and obtain a token by running the following command:
1vcfFleetLifecycleToken=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/api/v1/identity/token" \
2 -H 'Content-Type: application/x-www-form-urlencoded' \
3 --data "grant_type=password" \
4 --data "username=$vcfFleetLifecycleUser" \
5 --data "password=$vcfFleetLifecyclePass" \
6 | jq -r '.access_token')
- Verify you successfully obtained an authentication token by running the following command:
1echo $vcfFleetLifecycleToken
Example Output:
1eyJhbGciOiJFZERTQSIsImtpZCI6Ilg4Mk5veGNJRlVCVEFiY0xPM1NUdU12UTF6Qlo4d01xeUxDTGNuOGZYdFUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2ZsdC1mYzAxLnJhaW5wb2xlLmlvIiwic3ViIjoiYWRtaW5AdnNwLmxvY2FsIiwiYXVkIjpbInZzcCJdLCJleHAiOjE3ODM0MzU1NTIsImlhdCI6MTc4MzQyMTE1MiwianRpIjoiMjA3OTg0MDgtZGE3OC00N2UzLTgxMDctNDAyMThkNjM1ZThmIiwiYXpwIjoicGFzc3dvcmRfZ3JhbnRfY2xpZW50IiwiYWNjdCI6ImFkbWluQHZzcC5sb2NhbCIsImF1dGhvcml6YXRpb25fZGV0YWlscyI6bnVsbH0.OsXjW3cgwZaEMXwZC6MOqOped5MX1wdf3wpUmjZLaRiXeug4rtm9dnWHvPrp5pM74MNsVEjhbeT3u0TJjgIIBQ
- First we retrieve the unique ID of the SDDC instance by running the following command:
1primarySddcLcms=$(curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/sddc-lcms" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq -r '.sddcLcms[] | select(.isPrimary == true) | .id')
- Verify you successfully obtained the SDDC instance by running the following command:
1echo $primarySddcLcms
Example Output:
13e8d0034-906b-49cb-9c47-3afa8d919192
- Replace the values in the sample code with values for the deployment of your VCF Automation instance and paste the commands in the console.
1export automationFqdn='flt-auto01.rainpole.io'
2export automationPlatformFqdn='flt-vcfa-sr01.rainpole.io'
3export automationIpRangeStart='10.11.10.46'
4export automationIpRangeEnd='10.11.10.50'
5export automationSize='small'
6export automationAdminPass='VMw@re1!VMw@re1!'
7export automationSystemPass='VMw@re1!VMw@re1!'
- Create the JSON payload for the VCF Automation instance deployment by running the following command:
1cat << EOF > automation-deploy.json
2{
3 "componentSpecs": [
4 {
5 "componentType": "VCFA",
6 "deploymentType": "VspComponentSpec",
7 "sddcLcmId": "${primarySddcLcms}",
8 "fqdn": "${automationFqdn}",
9 "version": "9.1.0.0",
10 "configSpec": {
11 "size": "${automationSize}",
12 "adminSystemPassword": "${automationAdminPass}"
13 },
14 "vspClusterSpec": {
15 "deploymentType": "VspClusterSpec",
16 "sddcLcmId": "${primarySddcLcms}",
17 "platformFqdn": "${automationPlatformFqdn}",
18 "systemUserPassword": "${automationSystemPass}",
19 "size": "${automationSize}",
20 "ipv4Pool": {
21 "ipRange": {
22 "startIpAddress": "${automationIpRangeStart}",
23 "endIpAddress": "${automationIpRangeEnd}"
24 }
25 }
26 }
27 }
28 ]
29}
30EOF
- Verify the JSON payload has been populated correctly by running the following command:
1cat automation-deploy.json
Example Output:
1{
2 "componentSpecs": [
3 {
4 "componentType": "VCFA",
5 "deploymentType": "VspComponentSpec",
6 "sddcLcmId": "3e8d0034-906b-49cb-9c47-3afa8d919192",
7 "fqdn": "flt-auto01.rainpole.io",
8 "version": "9.1.0.0",
9 "configSpec": {
10 "size": "small",
11 "adminSystemPassword": "VMw@re1!VMw@re1!"
12 },
13 "vspClusterSpec": {
14 "deploymentType": "VspClusterSpec",
15 "sddcLcmId": "3e8d0034-906b-49cb-9c47-3afa8d919192",
16 "platformFqdn": "flt-vcfa-sr01.rainpole.io",
17 "systemUserPassword": "VMw@re1!VMw@re1!",
18 "size": "small",
19 "ipv4Pool": {
20 "ipRange": {
21 "startIpAddress": "10.11.10.46",
22 "endIpAddress": "10.11.10.50"
23 }
24 }
25 }
26 }
27 ]
28}
- Validate the JSON payload by running the following command:
1validationId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components/validations" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 -d @automation-deploy.json | jq -r ".id")
- Check the status of the validation by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq
- The command in step 11 may need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq '{status: .status}' \
6 | grep -q "RUNNING"; do
7 echo "Still in 'RUNNING' state... waiting 2 seconds."
8 sleep 2
9done
- Start the deployment by running the following command:
1deploymentId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 -d @automation-deploy.json | jq -r ".id")
- Check the status of the deployment by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq
- The command in step 11 would need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq '{status: .status}' \
6 | grep -q "RUNNING"; do
7 echo "Still in 'RUNNING' state... waiting 60 seconds."
8 sleep 60
9done