We are happy to announce the release of Rock, Paper, Scissors, Lizard, Spock sample application running in Azure presented at Microsoft Ignite 2019 by Scott Hanselman and friends.
Rock, Paper, Scissors, Lizard, Spock is the geek version of the classic Rock, Paper, Scissors game. Rock, Paper, Scissors, Lizard, Spock is created by Sam Kass and Karen Bryla.
The Rock, Paper, Scissors, Lizard, Spock - Sample Application shows a multilanguage application built with Visual Studio and Visual Studio Code, deployed with GitHub Actions, and running on Azure Kubernetes Service (AKS). The sample application also uses Machine Learning and Azure Cognitive Services (Custom Vision API).
Languages used in this application include .NET, Node.js, Python, Java, and PHP.
-
Missed the session? Watch it now.
-
Play the game hosted in our Azure Subscription: https://RockPaperScissorsLizardSpock.dev
-
Get everything that you need to deploy the code and run in your subscription from this repo as well.
You will need an Azure subscription to work with this demo code. You can:
- Open an account for free Azure subscription. You get credits that can be used to try out paid Azure services. Even after the credits are used up, you can keep the account and use free Azure services and features, such as the Web Apps feature in Azure App Service.
- Activate Visual Studio subscriber benefits. Your Visual Studio subscription gives you credits every month that you can use for paid Azure services.
- Create an Azure Student Account and get free credit when you create your account.
Learn more about it with Microsoft Learn - Introduction to Azure.
- You will need Visual Studio 2019 on Windows 10.
- You will need Docker Desktop.
If you want to deploy this solution in Azure:
- You will need and Azure Subscription in order to deploy this.
- Azure CLI.
- Download and install helm.
You can either go through all steps and customizing its configuration or run one single command.
Execute the script located in Deploy folder with the following parameters:
.\Deploy-Unified.ps1 -resourceGroup <resource-group-name> -location <location> -clientId <service-principal-id> -password <service-principal-password> -subscription <subscription-id>
resourceGroup
: The name of your resource group where all infrastructure will be createdRequired
location
: Select where you want to create your resource group, for example:eastus
Required
clientId
: Id of the service principal used to create the AKSOptional
password
: Password of the service principalOptional
subscription
: Id of your subscription where you are going to deploy your resource groupRequired
If service principal credentials are not passed a new one will be created.
To run RPSLS you need to create the Azure infrastructure. There are two ways to do it. Using Azure portal or using a Powershell script.
An ARM template is provided so you can create the whole infrastructure requried for RPSLS
servicePrincipalId
: Id of the service principal used to create the AKSRequired
servicePrincipalSecret
: Password of the service principalRequired
aksVersion
: AKS version to use.Required
The deployment could take more than 10 minutes, and once finished all needed resources will be created.
You can use the CLI to deploy the ARM script. Open a Powershell window from the /Deploy
folder and run the Deploy-Arm-Azure.ps1
with following parameters:
-resourceGroup
: Name of the resource groupRequired
-location
: Location of the resource groupRequired if resourceGroup does not exist
-clientId
: Id of the service principal uesd to create the AKSOptional
-password
: Password of the service principalOptional
If service principal credentials are not passed a new one will be created.
Once script finishes, everything is installed. If a service principal has been created, the script will output the service principal details - please, take note of the appId and password properties for use them in the AKS deployment
Pre-requisites for this deployment are to have:
- The AKS and all related resources deployed in Azure
- A terminal with Powershell environment
- Azure CLI 2.0 installed.
- Kubectl installed with the last version (v1.16.0 at this moment).
- Docker installed
A Service Principal is needed for creating the AKS. If you use the CLI for create the resources. You need the client id and password of a Service Principal to install RPSLS.
In case you use Azure Portal for the resources' creation, you can also reuse a SP or create manually a new one for passing the credentials to the template.
From the terminal type:
az login
and follow instructions to log into your Azure.- If you have more than one subscription type
az account list -o table
to list all your Azure subscriptions. Then typeaz account set --subscription <subscription-id>
to select your subscription az aks get-credentials -n <your-aks-name> -g <resource-group-name>
to download the configuration files thatkubectl
needs to connect to your AKS.
At this point if you type kubectl config current-context
the name of your AKS cluster should be displayed. That means that kubectl
is ready to use your AKS
Helm is a tool to deploy resources in a Kubernetes cluster in a clean and simple manner. It is composed of two tools, one client-side (the Helm client) that needs to be installed on your machine, and a server component called Tiller that has to be installed on the Kubernetes cluster.
To install Helm, refer to its installation page. Once Helm is installed, Tiller must be deployed on the cluster. For deploying Tiller run the ./Add-Tiller.ps1
(from Powershell).
Once installed, helm commands like helm ls
should work without any error.
Before deploying services using Helm, you need to setup the configuration. We refer to the configuration file with the name of gvalues file. This file contains all secrets so beware to not commit in your repo accidentally.
An example of this file is in helm/gvalues.yaml
. The deployment scripts use this file by default, but do not rely on editing this file. Instead create a copy of it a folder outside the repository and use the -valuesFile
parameter of the deployment script.
Note: The folder
/Deploy/helm/__values/
is added to.gitignore
, so you can keep all your configuration files in it, to avoid accidental pushes.
Please refer to the comments of the file for its usage.
Generating a valid gvalues file can be a bit harder, so there is a Powershell script that can do all work by you. This script assumes that all resources are deployed in the same resource group, and this resource group contains only the RPSLS resources. Also assumes the Azure resources have been created using the tools provided in this repo.
Note The Generate-Config.ps1 uses the application-insights CLI extension to find the application insights id. Install it with
az extension add --name application-insights
To auto-generate your gvalues file just go to /Deploy/powershell
folder and from a Powershell window, type the following:
.\Generate-Config.ps1 -resourceGroup <your-resource-group> -outputFile ..\helm\__values\<name-of-your-file>
The Generate-Config.ps1
script accepts so many parameters. Here you can find a list of them all.
The script checks that all needed resources exists in the resource group. If some resource is missing or there is an unexpected resource, the script exits.
You can manually use docker-compose to build and push the images to the ACR. If using compose you can set following environment variables:
TAG
: Will contain the generated docker images tagREGISTRY
: Registry to use. This variable should be set to the login server of the ACR
Once set, you can use docker-compose build
and docker-compose push
to build and push the images.
Additionaly there is a Powershell script in the Deploy
folder, named Build-Push.ps1
. You can use this script for building and pushing ALL images to ACR. Parameters of this script are:
resourceGroup
: Resource group where ACR is. Required.acrName
: ACR name (not login server). Required.dockerTag
: Tag to use for generated images (defaults tolatest
)dockerBuild
: If$true
(default value) docker images will be built usingdocker-compose build
.dockerPush
: If$true
(default value) docker images will be push to ACR usingdocker-compose push
.
This script uses az
CLI to get ACR information, and then uses docker-compose
to build and push the images to ACR.
To build and push images tagged with v1 to a ACR named my-acr in resource group named my-rg, execute the following command inside /Deploy/powershell
.\Build-Push.ps1 -resourceGroup my-rg -dockerTag v1 -acrName my-acr
To just push the images (without building them before):
.\Build-Push.ps1 -resourceGroup my-rg -dockerTag v1 -acrName my-acr -dockerBuild $false
You need to use Powershell and run ./Deploy-Images-Aks.ps1
. A typical call is:
.\Deploy-Image-Aks.ps1 -resourceGroup $resourceGroup -aksName $myAks -acrName $myAcr -valuesFile $myValuesFilePath
Note: Read the documentation of this script for a list of all parameters.
This script will install all services using Helm and your custom configuration from the configuration file set by -valuesFile
parameter.
The parameter charts
allow for a selective installation of charts. Is a list of comma-separated values that mandates the services to deploy in the AKS. Values are:
cs
C# Player.nj
NodeJS Player.py
Python Player.php
PHP Player.jv
Java Player.web
Websitegm
Game Manager
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.