VMware Cloud Foundation APIs: Deploying Log Management
Once your VCF fleet has successfully been deployed and is up and running you can configure or add additional capabilities to the VMware Cloud Foundation platform. The first capability we will look at is Log Management. It is no longer installed as a standalone, heavy virtual appliance. Instead, it is deployed as a native containerized service running inside the consolidated VCF Management Services framework.
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
Exmaple 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:
1e35632dc-2777-432e-8985-7e1f0a32acf3
- Replace the values in the sample code with values for the deployment of your Log Management instance and paste the commands in the console.
1export logManagementFqdn='flt-logs01.rainpole.io'
2export logManagementSize='small'
3export logManagementNodeCount='1'
- Create the JSON payload for the Log Management instance deployment by running the following command:
1cat << EOF > log-management-deploy.json
2{
3 "componentSpecs": [
4 {
5 "sddcLcmId": "${primarySddcLcms}",
6 "componentType": "OPS_LOGS",
7 "deploymentType": "VspComponentSpec",
8 "version": "9.1.0.0",
9 "fqdn": "${logManagementFqdn}",
10 "configSpec": {
11 "size": "${logManagementSize}",
12 "numberOfNodes": ${logManagementNodeCount}
13 }
14 }
15 ]
16}
17EOF
- Verify the JSON payload has been populated correctly by running the following command:
1 cat log-management-deploy.json
Example Output:
1{
2 "componentSpecs": [
3 {
4 "sddcLcmId": "e35632dc-2777-432e-8985-7e1f0a32acf3",
5 "componentType": "OPS_LOGS",
6 "deploymentType": "VspComponentSpec",
7 "version": "9.1.0.0",
8 "fqdn": "flt-logs01a.rainpole.io",
9 "configSpec": {
10 "size": "small",
11 "numberOfNodes": 1
12 }
13 }
14 ]
15}
- 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 @log-management-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 @log-management-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