-
Notifications
You must be signed in to change notification settings - Fork 26
Added AZ terraform scripts #37
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
Open
neal-shah
wants to merge
1
commit into
corda:master
Choose a base branch
from
neal-shah:add-terraform-scripts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Azure Kubernetes for Corda/CENM | ||
|
|
||
| ## Overview | ||
|
|
||
| > **NOTE**: FOR TEST USE ONLY | ||
|
|
||
| This is an example deployment using the `az-kubernetes` module. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| You will require an Azure Service Principal to deploy using Terraform. | ||
|
|
||
| To create one, use the following Azure-CLI command: | ||
|
|
||
| ```bash | ||
| ➜ az ad sp create-for-rbac --name <my service principal name> | ||
|
|
||
| Changing "<my service principal name>" to a valid URI of "http://<my service principal name>", which is the required format used for service principal names | ||
| Creating a role assignment under the scope of "/subscriptions/<subscription id>" | ||
| Retrying role assignment creation: 1/36 | ||
| { | ||
| "appId": "<application id (client id)>", | ||
| "displayName": "<my service principal name>", | ||
| "name": "http://<my service principal name>", | ||
| "password": "<password (client secret)>", | ||
| "tenant": "<tenant id>" | ||
| } | ||
| ``` | ||
|
|
||
| You will need to add the `AcrPull` role assignment to the newly created service principal. This also applies to existing service principals. | ||
|
|
||
| ```bash | ||
| ➜ az role assignment create --assignee <appId> --role acrpull | ||
| ``` | ||
|
|
||
| ## Quick-Start Guide | ||
|
|
||
| ### Configure Azure-CLI Login | ||
|
|
||
| 1. Login to Azure-CLI using the command: | ||
| ```az login``` | ||
| This will take you to the Azure Portal to login using your normal credentials. | ||
| 2. Set your target subscription using the following command: | ||
| ```az account set --subscription <Name or Subscription ID>``` | ||
|
|
||
| ### Terraform - Deploy Infrastructure | ||
|
|
||
| 1. Change directory into the Terraform folder in this repository. | ||
|
|
||
| 2. Create your `terraform.tfvars` file using the `terraform.tfvars.example`. | ||
|
|
||
| This file represents the variables which terraform are used to determine the infrastructure to deploy. | ||
|
|
||
| You can retrieve your Client ID using: | ||
|
|
||
| ```bash | ||
| ➜ az ad sp list --display-name <name of service principal> | grep appId | ||
| ``` | ||
|
|
||
| If you do not know your Client Secret, you can reset it with the following command: | ||
|
|
||
| ```bash | ||
| ➜ az ad sp credential reset --name <name of service principal> | ||
| ``` | ||
|
|
||
| 3. To list available local workspaces, use the following command: | ||
|
|
||
| ```terraform workspace list``` | ||
|
|
||
| 4. To create a new workspace use the following command: | ||
|
|
||
| ```terraform workspace new <Name of Workspace>``` | ||
|
|
||
| Terraform will automatically switch to the newly created workspace. | ||
|
|
||
| 5. Initialise Terraform: | ||
|
|
||
| ```terraform init``` | ||
|
|
||
| 6. Create a Terraform plan using the following command: | ||
|
|
||
| ```terraform | ||
| terraform plan -out=terraform.tfstate.d/<Name of Workspace>/terraform_plan | ||
| ``` | ||
|
|
||
| This will output a plan to file, in the `terraform.tfstate.d/<Workspace Name>` directory. | ||
|
|
||
| 7. When you are happy with the plan, run the following command to execute the deployment: | ||
|
|
||
| ```terraform | ||
| terraform apply "terraform.tfstate.d/<Name of Workspace>/terraform_plan" | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| data "azuread_service_principal" "aks_principal" { | ||
| application_id = var.client_id | ||
| } | ||
|
|
||
| resource "azurerm_resource_group" "main" { | ||
| name = var.resource_group_name | ||
| location = var.location | ||
| tags = var.tags | ||
| } | ||
|
|
||
| module "aks" { | ||
| source = "[email protected]:corda/terraform-modules-ext//modules/az-kubernetes?ref=master" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This repository seems to be a private repository.
|
||
| prefix = var.prefix | ||
| resource_group_name = azurerm_resource_group.main.name | ||
| client_id = var.client_id | ||
| client_secret = var.client_secret | ||
| application_id = data.azuread_service_principal.aks_principal.id | ||
| storage_file_shares = var.storage_file_shares | ||
| node_pool_public_ips = var.node_pool_public_ips | ||
| tags = var.tags | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| output "aks_host" { | ||
| value = module.aks.aks_host | ||
| } | ||
|
|
||
| output "aks_username" { | ||
| value = module.aks.aks_username | ||
| } | ||
|
|
||
| output "aks_password" { | ||
| value = module.aks.aks_password | ||
| } | ||
|
|
||
| output "acr_host" { | ||
| value = module.aks.acr_host | ||
| } | ||
|
|
||
| output "acr_admin_username" { | ||
| value = module.aks.acr_admin_username | ||
| } | ||
|
|
||
| output "acr_admin_password" { | ||
| value = module.aks.acr_admin_password | ||
| } | ||
|
|
||
| output "storage_account_primary_access_key" { | ||
| value = module.aks.storage_account_primary_access_key | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| provider "azurerm" { | ||
| version = ">=2.9.0" | ||
| subscription_id = var.subscription_id | ||
| client_id = var.client_id | ||
| client_secret = var.client_secret | ||
| tenant_id = var.tenant_id | ||
| features {} | ||
| } | ||
| provider "azuread" { | ||
| version = "~>0.7" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| resource_group_name = "<provide a resource group name>" | ||
| prefix = "<provide a short prefix for resources>" | ||
| storage_file_shares = { | ||
| "node-storage-1" = { | ||
| quota = 2 | ||
| } | ||
| "bridge-storage-1" = { | ||
| quota = 1 | ||
| } | ||
| "float-storage-1" = { | ||
| quota = 1 | ||
| } | ||
| } | ||
| node_pool_public_ips = { | ||
| "node-ip" = { | ||
| public_ip_dns_label = "<dns label you wish to use for node-ip>" | ||
| } | ||
| "float-ip" = { | ||
| public_ip_dns_label = "<dns label you wish to use for float-ip>" | ||
| } | ||
| } | ||
| tags = { | ||
| Owner = "<your email address>" | ||
| Environment = "<your environment>" | ||
| } | ||
| subscription_id = "<your Azure subscription id in form 00000000-0000-0000-0000-000000000000>" | ||
| client_id = "<your service principal id in form 00000000-0000-0000-0000-000000000000>" | ||
| client_secret = "<create a secret for client id and paste here>" | ||
| tenant_id = "<your tenant id in form 00000000-0000-0000-0000-000000000000>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| variable "resource_group_name" { | ||
| type = string | ||
| } | ||
| variable "client_id" { | ||
| type = string | ||
| description = "" | ||
| } | ||
| variable "client_secret" { | ||
| type = string | ||
| description = "" | ||
| } | ||
| variable "location" { | ||
| type = string | ||
| description = "" | ||
| default = "uksouth" | ||
| } | ||
| variable "prefix" { | ||
| type = string | ||
| description = "Prefix of resources" | ||
| } | ||
| variable "tags" { | ||
| type = map(string) | ||
| } | ||
| variable "storage_file_shares" { | ||
| type = map(object({ | ||
| quota = number | ||
| })) | ||
| description = "(Required) Map of file shares." | ||
| } | ||
| variable "node_pool_public_ips" { | ||
| type = map(object({ | ||
| public_ip_dns_label = string | ||
| })) | ||
| description = "(Optional) Map of public ip dns to create inside the nodepool resource group." | ||
| } | ||
| variable "subscription_id" { | ||
| type = string | ||
| } | ||
| variable "tenant_id" { | ||
| type = string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| terraform { | ||
| required_version = ">= 0.12.25" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terraform.tfvars.example does not exist, only terraform.tfvars. I guess that's fine, so probably just update this line of documentation to reflect the reality.