From d85c1dd2edf755f0cc6867510cd9733b33ba4726 Mon Sep 17 00:00:00 2001 From: Ross Smith Date: Thu, 10 Nov 2022 21:00:54 +0000 Subject: [PATCH] Install CCF on AzureVM (#4502) --- README.md | 3 +- doc/build_apps/install_bin.rst | 9 ++++ getting_started/README.md | 6 +++ getting_started/azure_vm/README.md | 15 +++++++ getting_started/azure_vm/ccf-cloudinit.yml | 42 +++++++++++++++++++ .../azure_vm/install_ccf_on_azure_vm.sh | 38 +++++++++++++++++ 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 getting_started/README.md create mode 100644 getting_started/azure_vm/README.md create mode 100644 getting_started/azure_vm/ccf-cloudinit.yml create mode 100755 getting_started/azure_vm/install_ccf_on_azure_vm.sh diff --git a/README.md b/README.md index 65aa6b14b630..7f6f766ed0a9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ and performant applications that focus on multi-party compute and data. - Read the [CCF overview](https://ccf.microsoft.com/) and get familiar with [CCF's core concepts](https://microsoft.github.io/CCF/main/overview/what_is_ccf.html) - [Install](https://microsoft.github.io/CCF/main/build_apps/install_bin.html) CCF on Linux -- Quickly build and run the [sample CCF application](https://github.com/microsoft/ccf-app-template) +- Get familiar with CCF core developer API with the [template CCF app](https://github.com/microsoft/ccf-app-template) +- Quickly build and run [sample CCF apps](https://github.com/microsoft/ccf-app-samples) - [Build new CCF applications](https://microsoft.github.io/CCF/main/build_apps/index.html) in TypeScript/JavaScript or C++ ## Contribute diff --git a/doc/build_apps/install_bin.rst b/doc/build_apps/install_bin.rst index 7939e43619e9..298715db7f9c 100644 --- a/doc/build_apps/install_bin.rst +++ b/doc/build_apps/install_bin.rst @@ -88,3 +88,12 @@ From Source ----------- To build and install CCF from source, please see :doc:`/contribute/build_ccf`. + +In Azure +-------- + +CCF can be installed on an Azure Virtual Machine by running a single script; + +.. code-block:: bash + + /getting_started/azure_vm/install_ccf_on_azure_vm.sh diff --git a/getting_started/README.md b/getting_started/README.md new file mode 100644 index 000000000000..138c79ba9815 --- /dev/null +++ b/getting_started/README.md @@ -0,0 +1,6 @@ +# Running CCF on a virtual machine + +This folder contains two separate ways of setting up a development environment for CCF itself and apps. + +1. [azure_vm](./azure_vm/README.md) provides an opinionated way of creating a Virtual Machine on Azure and install CCF for you by cloud-init. +2. `setup_vm` assumes that a bare environment is already available (VM or container) and provides Ansible scripts to setup the development environment by either cloning this repository or installing the CCF Debian package diff --git a/getting_started/azure_vm/README.md b/getting_started/azure_vm/README.md new file mode 100644 index 000000000000..d4707db94853 --- /dev/null +++ b/getting_started/azure_vm/README.md @@ -0,0 +1,15 @@ +# Creating a Virtual Machine in Azure to run CCF + +This guide is here to give you the bare minimum to get started with CCF. It will walk you through the steps to create a virtual machine in Azure and install CCF on it. + +## Prerequisites + +You must run this from a bash terminal that you have already logged in to Azure with. If you have not done this, please follow the instructions [here](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest). + +## Create a Virtual Machine + +Run the following script : + +```bash +./getting_started/azure_vm/install_ccf_on_azure_vm.sh +``` diff --git a/getting_started/azure_vm/ccf-cloudinit.yml b/getting_started/azure_vm/ccf-cloudinit.yml new file mode 100644 index 000000000000..42d28e78fca2 --- /dev/null +++ b/getting_started/azure_vm/ccf-cloudinit.yml @@ -0,0 +1,42 @@ +#cloud-config +package_update: true +package_upgrade: true +apt: + sources: + docker.list: + source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable + keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 + +packages: + - apt-transport-https + - ca-certificates + - curl + - gnupg-agent + - software-properties-common + - docker-ce + - docker-ce-cli + - containerd.io + - git + - jq + +# Enable ipv4 forwarding, required on CIS hardened machines +write_files: + - path: /etc/sysctl.d/enabled_ipv4_forwarding.conf + content: | + net.ipv4.conf.all.forwarding=1 + +# create the docker group +groups: + - docker + +# Add default auto created user to docker group +system_info: + default_user: + groups: [docker] + +runcmd: + - cd /home/azureuser && git clone https://github.com/microsoft/CCF.git ccf-install -b release/2.x + - sudo -u azureuser /home/azureuser/ccf-install/getting_started/setup_vm/run.sh /home/azureuser/ccf-install/getting_started/setup_vm/app-run.yml + - export CCF_VERSION=$(curl -ILs -o /dev/null -w %{url_effective} https://github.com/microsoft/CCF/releases/latest | sed 's/^.*ccf-//') + - wget https://github.com/microsoft/CCF/releases/download/ccf-${CCF_VERSION}/ccf_${CCF_VERSION}_amd64.deb + - apt install /home/azureuser/ccf_${CCF_VERSION}_amd64.deb -y diff --git a/getting_started/azure_vm/install_ccf_on_azure_vm.sh b/getting_started/azure_vm/install_ccf_on_azure_vm.sh new file mode 100755 index 000000000000..a13e773b7bea --- /dev/null +++ b/getting_started/azure_vm/install_ccf_on_azure_vm.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache 2.0 License. + +# !!! These are defaults and you can change these if you wish !!! +resourceGroup=rg_ccf_demo +vm_name=ccfdemo +location=westeurope +# This is the smallest VM, you may wish to change this. +vm_size=Standard_DC1s_v2 +vnetName=ccf +subnetName=nodes +vnetAddressPrefix=10.0.0.0/16 +ccfAddressPrefix=10.0.0.0/24 + +az group create --name $resourceGroup --location $location + +az network vnet create \ + --name $vnetName \ + --resource-group $resourceGroup \ + --address-prefixes $vnetAddressPrefix \ + --subnet-name $subnetName \ + --subnet-prefixes $ccfAddressPrefix + +# Automatically generates a ssh key if one is not present +# https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-ssh-keys-detailed#generate-keys-automatically-during-deployment +az vm create \ + --resource-group $resourceGroup \ + --name $vm_name \ + --image canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202210180 \ + --vnet-name $vnetName \ + --subnet $subnetName \ + --size $vm_size \ + --public-ip-sku Standard \ + --admin-username azureuser \ + --custom-data ccf-cloudinit.yml \ + --generate-ssh-keys \ + --output json