Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding back crank tool #10717

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/Crank/Agent/Linux/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM crank-agent

ENTRYPOINT [ "/app/crank-agent", "--url", "http://*:5010" ]
3 changes: 3 additions & 0 deletions tools/Crank/Agent/Linux/Docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker build -t functions-crank-agent -f Dockerfile ../../
5 changes: 5 additions & 0 deletions tools/Crank/Agent/Linux/Docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

docker run -it --name functions-crank-agent -d --network host --restart always --privileged \
--mount type=bind,source=/home/Functions/FunctionApps/HelloApp,target=/home/Functions/FunctionApps/HelloApp \
-v /var/run/docker.sock:/var/run/docker.sock functions-crank-agent "$@"
4 changes: 4 additions & 0 deletions tools/Crank/Agent/Linux/Docker/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

docker stop functions-crank-agent
docker rm functions-crank-agent
15 changes: 15 additions & 0 deletions tools/Crank/Agent/Linux/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

mkdir ~/github
cd ~/github
git clone https://github.com/Azure/azure-functions-host.git
cd azure-functions-host
git checkout dev

cd tools/Crank/Agent
sudo find . -name "*.sh" -exec sudo chmod +xr {} \;
sudo find . -name "*.ps1" -exec sudo chmod +xr {} \;

Linux/install-powershell.sh

./setup-crank-agent-raw.ps1 $1 -Verbose
30 changes: 30 additions & 0 deletions tools/Crank/Agent/Linux/install-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Following instructions at https://docs.docker.com/engine/install/ubuntu

sudo apt-get update

sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

sudo groupadd docker
sudo usermod -aG docker Functions
newgrp docker

sudo setfacl --modify user:Functions:rw /var/run/docker.sock

sudo systemctl enable docker
18 changes: 18 additions & 0 deletions tools/Crank/Agent/Linux/install-powershell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# From https://docs.microsoft.com/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7#ubuntu-1804

# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of products
sudo apt-get update

# Enable the "universe" repositories
sudo add-apt-repository universe

# Install PowerShell
sudo apt-get install -y powershell
271 changes: 271 additions & 0 deletions tools/Crank/Agent/VmDeployment/create-resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
@description('The location of the resources')
param location string = resourceGroup().location

@description('The names of the virtual machines')
param vmNames array

@description('The admin username for the virtual machines')
param adminUsername string

@description('The admin password for the virtual machines')
@secure()
param adminPassword string

@description('Base64 encoded JSON parameters')
param parametersJsonBase64 string

@description('Windows local admin username')
param windowsLocalAdminUserName string

@description('Base64 encoded Windows local admin password')
param windowsLocalAdminPasswordBase64 string

@description('The operating system type')
param osType string = 'Windows'

@description('The name of the virtual network')
param virtualNetworkName string = 'shared-vnet'

@description('The name of the subnet')
param subnetName string = 'default'

@description('The name of the network security group')
param networkSecurityGroupName string = 'shared-nsg'

@description('The name of the private DNS zone')
param privateDnsZoneName string = 'shared.private'

@description('The size of the virtual machines')
param vmSize string

@description('The type of the OS disk')
param osDiskType string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-02-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: '10.0.0.0/24'
}
}
]
}
}

resource networkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2021-02-01' = {
name: networkSecurityGroupName
location: location
properties: {
securityRules: [
{
name: 'AllowInternetOutbound'
properties: {
priority: 100
protocol: '*'
access: 'Allow'
direction: 'Outbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: 'Internet'
destinationPortRange: '*'
}
}
{
name: 'SSH'
properties: {
priority: 1000
protocol: 'TCP'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '22'
}
}
{
name: 'RDP'
properties: {
priority: 1001
protocol: 'TCP'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '3389'
}
}
{
name: 'DotNet-Crank'
properties: {
priority: 1011
protocol: '*'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '5010'
}
}
{
name: 'Benchmark-App'
properties: {
priority: 1012
protocol: '*'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '5000'
}
}
]
}
}

resource publicIPAddresses 'Microsoft.Network/publicIPAddresses@2021-02-01' = [
for (vmName, index) in vmNames: {
name: '${vmName}-pip'
location: location
properties: {
publicIPAllocationMethod: 'Dynamic'
dnsSettings: {
domainNameLabel: vmName
}
}
}
]

resource networkInterfaces 'Microsoft.Network/networkInterfaces@2021-02-01' = [
for (vmName, index) in vmNames: {
name: '${vmName}-nic'
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: {
id: virtualNetwork.properties.subnets[0].id
}
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: publicIPAddresses[index].id
}
}
}
]
networkSecurityGroup: {
id: networkSecurityGroup.id
}
}
}
]

resource virtualMachines 'Microsoft.Compute/virtualMachines@2021-07-01' = [
for (vmName, index) in vmNames: {
name: vmName
location: location
properties: {
hardwareProfile: {
vmSize: vmSize
}
osProfile: {
computerName: vmName
adminUsername: adminUsername
adminPassword: adminPassword
}
storageProfile: {
imageReference: {
publisher: 'MicrosoftWindowsServer'
offer: 'WindowsServer'
sku: '2022-Datacenter'
version: 'latest'
}
osDisk: {
createOption: 'FromImage'
managedDisk: {
storageAccountType: osDiskType
}
}
}
networkProfile: {
networkInterfaces: [
{
id: networkInterfaces[index].id
}
]
}
}
}
]

resource customScriptExtensions 'Microsoft.Compute/virtualMachines/extensions@2021-03-01' = [
for (vmName, index) in vmNames: if (osType == 'Windows') {
name: '${vmName}-bootstrap'
parent: virtualMachines[index]
location: location
properties: {
publisher: 'Microsoft.Compute'
type: 'CustomScriptExtension'
typeHandlerVersion: '1.10'
autoUpgradeMinorVersion: true
settings: {
fileUris: [
'https://raw.githubusercontent.com/Azure/azure-functions-host/refs/heads/dev/tools/Crank/Agent/Windows/bootstrap.ps1'
]
commandToExecute: 'powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File .\\bootstrap.ps1 -ParametersJsonBase64 ${parametersJsonBase64} -WindowsLocalAdminUserName ${windowsLocalAdminUserName} -WindowsLocalAdminPasswordBase64 ${windowsLocalAdminPasswordBase64}'
}
}
}
]

resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
name: privateDnsZoneName
location: 'global'
}

resource virtualNetworkLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
name: '${privateDnsZoneName}-vnet-link'
parent: privateDnsZone
location: 'global'
properties: {
virtualNetwork: {
id: virtualNetwork.id
}
registrationEnabled: true
}
}

resource aRecords 'Microsoft.Network/privateDnsZones/A@2020-06-01' = [
for (vmName, index) in vmNames: {
name: '${vmName}.${privateDnsZoneName}'
parent: privateDnsZone
properties: {
ttl: 3600
aRecords: [
{
ipv4Address: networkInterfaces[index].properties.ipConfigurations[0].properties.privateIPAddress
}
]
}
}
]

output adminUsername string = adminUsername
output hostnames array = [for (vmName, index) in vmNames: publicIPAddresses[index].properties.dnsSettings.fqdn]
output sshCommands array = [
for (vmName, index) in vmNames: 'ssh ${adminUsername}@${publicIPAddresses[index].properties.dnsSettings.fqdn}'
]
Loading
Loading