Hello World Walkthrough on Google Cloud
About this tutorial
This tutorial will walk you through deploying your first blueprint, a python webserver that says “Hello World” with a Cloudify logo, on Google Cloud Platform.
Install Cloudify Manager and Upload Plugins
1. Spin up a Cloudify Manager on your local machine. This requires Docker to be installed as well. Copy and paste the below into your terminal and wait for that to finish:
sudo docker run --name cfy_manager_local -d --restart unless-stopped -v /sys/fs/cgroup:/sys/fs/cgroup:ro --tmpfs /run --tmpfs /run/lock --security-opt seccomp:unconfined --cap-add SYS_ADMIN -p 80:80 -p 8000:8000 cloudifyplatform/community:18.10.4
2. SSH into the Docker machine with
docker exec -it cfy_manager_local /bin/bash
3. Install the plugins bundle (this installs 11 plugins, not all of which are necessary for this example). Copy and paste the below into your terminal:
cfy plugins bundle-upload
Create secrets
Secrets are a more secure way to pass inputs such as passwords and keys for your deployments. You can create secrets using the terminal or from Cloudify Console (the UI) – both options are presented below.
Option 1: Using the Terminal
*Replace “[value]” with the actual value for the secret.
cfy secrets create gcp_client_x509_cert_url --secret-string [value] cfy secrets create gcp_client_email --secret-string [value] cfy secrets create gcp_client_id --secret-string [value] cfy secrets create gcp_project_id --secret-string [value] cfy secrets create gcp_private_key_id --secret-string [value] cfy secrets create gcp_private_key --secret-string [value] cfy secrets create gcp_project_id --secret-string [value] cfy secrets create gcp_zone --secret-string [value]
Option 2: Using Cloudify Console (UI)
1. Open your browser to 127.0.0.1
and login with username admin and password admin
2. Click on “System Resources” from the side menu
3. Click the “Create” button in the Secret Store Management widget
a
4. Add the key and value for each secret individually (using the list above in Option 1), then click “Create”
Deploying the application
Now let’s deploy our application. We will offer both a terminal as well as UI option.
Option 1: Using the Terminal
The below command will deploy the Hello World application on your cloud of choice.
*Replace information inside [] with actual values, without the []
cfy install https://github.com/cloudify-cosmo/cloudify-hello-world-example/archive/master.zip -n gcp.yaml -b hello-world-gcp region=[YOUR REGION]
Next, run
cfy deployment outputs [DEPLOYMENT ID]
The Deployment ID will be “hello-world-gcp” or similar and the output will look like this:
cfy deployment outputs hello-world-gcp Retrieving outputs for deployment hello-world-gcp... - "application_endpoint": Description: The external endpoint of the application. Value: http://IP_ADDRESS_OF_APP:80
Find the “Value” and enter that IP address into your browser and if you see the below image, you did it!
To tear down the deployment, simply run the command below and the application, as well as blueprint, will be deleted.
cfy uninstall [DEPLOYMENT ID]
Option 2: Using Cloudify Console (UI)
1. In the Cloudify UI, navigate to Local Blueprints select Upload.
2. Right-click and copy this link. Paste the URL where it says Blueprint package. Provide a name, such as hello-world-gcp, in the field labeled Blueprint name. Select gcp.yaml blueprint for the relevant IaaS you wish to deploy on from the Blueprint YAML file dropdown and click Upload.
3. After the new blueprint has been created, click the button and enter your Deployment name such as hello-world-gcp and any other required inputs. Then click, the Deploy button.
4. Navigate to the Deployments page, find your new deployment, select Install from the menu and then Execute.
5. You can click on the deployment name to see the logs. Once the operation is complete, you will see the following in the logs:
6. Above the logs you will find the Deployment Outputs widget with the IP address of your application. Paste that address into your browser and if you see the below image, you did it!
7. To tear down the deployment, go back to the Deployments page, click on the and choose Uninstall from the menu, then click Execute. When the uninstall workflow is complete, you can also remove the deployment by choosing Delete option from that same menu and clicking Execute.