Commit 9c1d6ab1 authored by Malte Lantin's avatar Malte Lantin
Browse files

Add the initial version of the module

Add the initial version of the module, update the .gitignore file, add to readme
parent 3c05c77a
Showing with 288 additions and 316 deletions
+288 -316
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# Variable files
terraform.tfvars
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
### https://raw.github.com/github/gitignore/abad92dac5a4306f72242dae3bca6e277bce3615/Terraform.gitignore
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Compiled files
*.tfstate
*.tfstate.backup
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Terraform directory
.terraform/
terraform.tfstate.d/
logs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Go vendor directory
vendor/
# Visual Studio 2017 auto generated files
Generated\ Files/
# Files generated by terratest
.test-data/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# Terraform log file
terraform.log
# NUNIT
*.VisualState.xml
TestResult.xml
### https://raw.github.com/github/gitignore/abad92dac5a4306f72242dae3bca6e277bce3615/Global/Vim.gitignore
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# auto-generated tag files
tags
# OpenCover UI analysis results
OpenCover/
# IDE configs
.idea
# Azure Stream Analytics local run output
ASALocalRun/
# Ruby download package lock file.
Gemfile.lock
# MSBuild Binary and Structured Log
*.binlog
# Mac folder attribute file
.DS_Store
# NVidia Nsight GPU debugger configuration file
*.nvuser
.terraform.tfstate.lock.info
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# SSH Key
private_ssh_key
\ No newline at end of file
# terraform-azurerm-aks
## Deploys a Kubernetes cluster on AKS with monitoring support through Azure Log Analytics
This Terraform module deploys a Kubernetes cluster on Azure using AKS (Azure Kubernetes Service) and adds support for monitoring with Log Analytics.
## Authors
Originally created by [Damien Caro](http://github.com/dcaro) and [Malte Lantin](http://github.com/n01d)
## License
[MIT](LICENSE)
# Contributing
......
main.tf 0 → 100644
provider "azurerm" {
version = "=1.16.0"
}
resource "azurerm_resource_group" "main" {
name = "${var.prefix}-resources"
location = "${var.location}"
}
module "ssh-key" {
source = "./modules/ssh-key"
}
module "kubernetes" {
source = "./modules/kubernetes-cluster"
prefix = "${var.prefix}"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${azurerm_resource_group.main.location}"
admin_username = "azureuser"
admin_public_ssh_key = "${module.ssh-key.public_ssh_key}"
agents_size = "Standard_F2"
service_principal_client_id = "${var.CLIENT_ID}"
service_principal_client_secret = "${var.CLIENT_SECRET}"
log_analytics_workspace_id = "${module.log_analytics_workspace.id}"
}
module "log_analytics_workspace" {
source = "./modules/log-analytics-workspace"
prefix = "${var.prefix}"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${azurerm_resource_group.main.location}"
}
module "log_analytics_solution" {
source = "./modules/log-analytics-solution"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${azurerm_resource_group.main.location}"
workspace_resource_id = "${module.log_analytics_workspace.id}"
workspace_name = "${module.log_analytics_workspace.name}"
}
resource "azurerm_kubernetes_cluster" "main" {
name = "${var.prefix}-aks"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
dns_prefix = "${var.prefix}"
kubernetes_version = "1.11.3"
linux_profile {
admin_username = "${var.admin_username}"
ssh_key {
# remove any new lines using the replace interpolation function
key_data = "${replace(var.admin_public_ssh_key, "\n", "")}"
}
}
agent_pool_profile {
name = "nodepool"
count = "${var.agents_count}"
vm_size = "${var.agents_size}"
os_type = "Linux"
os_disk_size_gb = 50
}
service_principal {
client_id = "${var.service_principal_client_id}"
client_secret = "${var.service_principal_client_secret}"
}
addon_profile {
oms_agent {
enabled = true
log_analytics_workspace_id = "${var.log_analytics_workspace_id}"
}
}
tags = "${var.tags}"
}
output "cluster_id" {
value = "${azurerm_kubernetes_cluster.main.id}"
}
output "client_key" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.client_key}"
}
output "client_certificate" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.client_certificate}"
}
output "cluster_ca_certificate" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.cluster_ca_certificate}"
}
output "host" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.host}"
}
output "username" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.username}"
}
output "password" {
value = "${azurerm_kubernetes_cluster.main.kube_config.0.password}"
}
output "raw_kube_config" {
value = "${azurerm_kubernetes_cluster.main.kube_config_raw}"
}
variable "log_analytics_workspace_id" {
description = "The Log Analytics Workspace Id."
}
variable "prefix" {
description = "The prefix for the resources created in the specified Azure Resource Group."
}
variable "resource_group_name" {
description = "The name of the Resource Group in which the Virtual Network"
}
variable "location" {
description = "The Azure Region in which to create the Virtual Network"
}
variable "tags" {
default = {}
description = "Any tags that should be present on the Virtual Network resources"
type = "map"
}
variable "admin_username" {
description = "The username of the local administrator to be created on the Kubernetes cluster"
}
variable "admin_public_ssh_key" {
description = "The SSH key to be used for the username defined in the `admin_username` variable."
}
variable "agents_count" {
default = 3
description = "The number of Agents that should exist in the Agent Pool"
}
variable "agents_size" {
description = "The Azure VM Size of the Virtual Machines used in the Agent Pool"
}
variable "service_principal_client_id" {
description = "The Client ID of the Service Principal assigned to Kubernetes"
}
variable "service_principal_client_secret" {
description = "The Client Secret of the Service Principal assigned to Kubernetes"
}
resource "azurerm_log_analytics_solution" "main" {
solution_name = "Containers"
workspace_name = "${var.prefix}-log-analytics-workspace"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
workspace_resource_id = "${var.workspace_resource_id}"
workspace_name = "${var.workspace_name}"
plan {
publisher = "Microsoft"
product = "OMSGallery/Containers"
}
}
\ No newline at end of file
output "id" {
value = "${azurerm_log_analytics_solution.main.id}"
}
variable "resource_group_name" {
description = "The name of the Resource Group in which the Virtual Network"
}
variable "location" {
description = "The Azure Region in which to create the Virtual Network"
}
variable "workspace_resource_id" {
}
variable "workspace_name" {
}
resource "azurerm_log_analytics_workspace" "main" {
name = "${var.prefix}-log-analytics-workspace"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
sku = "PerGB2018"
retention_in_days = 30
}
\ No newline at end of file
output "id" {
value = "${azurerm_log_analytics_workspace.main.id}"
}
output "name" {
value = "${azurerm_log_analytics_workspace.main.name}"
}
variable "prefix" {
description = "The prefix for the resources created in the specified Azure Resource Group."
}
variable "resource_group_name" {
description = "The name of the Resource Group in which the Virtual Network"
}
variable "location" {
description = "The Azure Region in which to create the Virtual Network"
}
\ No newline at end of file
resource "tls_private_key" "ssh" {
algorithm = "RSA"
rsa_bits = 2048
}
resource "local_file" "private_key" {
content = "${tls_private_key.ssh.private_key_pem}"
filename = "./private_ssh_key"
}
output "public_ssh_key" {
value = "${tls_private_key.ssh.public_key_openssh}"
}
variable "prefix" {
description = "The prefix for the resources created in the specified Azure Resource Group."
}
variable "location" {
default = "eastus"
}
variable "app_replicas" {
default = 1
}
variable "CLIENT_ID" {}
variable "CLIENT_SECRET" {}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment