-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2429021
commit b072deb
Showing
47 changed files
with
767 additions
and
630 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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 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,40 @@ | ||
# Private Azure Grafana, Prometheus and Log Analytics with AKS | ||
|
||
## Introduction | ||
|
||
With AKS, you can use `Azure Monitor Workspace for Prometheus` and `Azure Managed Grafana` to collect, query and visualize the metrics from AKS. | ||
And to collect logs, you can use `Azure Log Analytics`. | ||
|
||
This lab will provide an implementation for monitoring and logging. | ||
|
||
## Architecture | ||
|
||
![](images/architecture.png) | ||
|
||
## Deploying the resources using Terraform | ||
|
||
To deploy the Terraform configuration files, run the following commands: | ||
|
||
```sh | ||
terraform init | ||
|
||
terraform plan -out tfplan | ||
|
||
terraform apply tfplan | ||
``` | ||
|
||
The following resources will be created. | ||
|
||
![](images/resources.png) | ||
|
||
## Cleanup resources | ||
|
||
To delete the creates resources, run the following command: | ||
|
||
```sh | ||
terraform destroy | ||
``` | ||
|
||
## More readings | ||
|
||
https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/azure-monitor-workspace-manage?tabs=azure-portal |
This file contains 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,22 @@ | ||
resource "azurerm_kubernetes_cluster_extension" "extension" { | ||
name = "backup-extension" | ||
cluster_id = azurerm_kubernetes_cluster.aks.id | ||
extension_type = "Microsoft.DataProtection.Kubernetes" | ||
release_train = "stable" | ||
release_namespace = "dataprotection-microsoft" | ||
configuration_settings = { | ||
"configuration.backupStorageLocation.bucket" = azurerm_storage_container.container.name | ||
"configuration.backupStorageLocation.config.resourceGroup" = azurerm_storage_account.storage.resource_group_name | ||
"configuration.backupStorageLocation.config.storageAccount" = azurerm_storage_account.storage.name | ||
"configuration.backupStorageLocation.config.subscriptionId" = data.azurerm_client_config.current.subscription_id | ||
"credentials.tenantId" = data.azurerm_client_config.current.tenant_id | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "extension_and_storage_account_permission" { | ||
scope = azurerm_storage_account.storage.id | ||
role_definition_name = "Storage Account Contributor" | ||
principal_id = azurerm_kubernetes_cluster_extension.extension.aks_assigned_identity[0].principal_id | ||
} | ||
|
||
data "azurerm_client_config" "current" {} |
This file contains 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 "azurerm_kubernetes_cluster" "aks" { | ||
name = "aks-cluster" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
dns_prefix = "aks" | ||
kubernetes_version = "1.29.0" | ||
|
||
network_profile { | ||
network_plugin = "azure" | ||
network_plugin_mode = "overlay" | ||
ebpf_data_plane = "cilium" | ||
} | ||
|
||
default_node_pool { | ||
name = "systempool" | ||
node_count = 3 | ||
vm_size = "standard_b2als_v2" | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "cluster_msi_contributor_on_snap_rg" { | ||
scope = azurerm_resource_group.rg-backup.id | ||
role_definition_name = "Contributor" | ||
principal_id = azurerm_kubernetes_cluster.aks.identity[0].principal_id | ||
} |
This file contains 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,22 @@ | ||
resource "azurerm_data_protection_backup_instance_kubernetes_cluster" "backup-instance" { | ||
name = "backup-instance" | ||
location = azurerm_resource_group.rg.location | ||
vault_id = azurerm_data_protection_backup_vault.backup-vault.id | ||
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id | ||
snapshot_resource_group_name = azurerm_resource_group.rg-backup.name | ||
backup_policy_id = azurerm_data_protection_backup_policy_kubernetes_cluster.backup-policy-aks.id | ||
|
||
backup_datasource_parameters { | ||
excluded_namespaces = ["test-excluded-namespaces"] | ||
excluded_resource_types = ["exvolumesnapshotcontents.snapshot.storage.k8s.io"] | ||
cluster_scoped_resources_enabled = true | ||
included_namespaces = ["*"] # ["test-included-namespaces"] | ||
included_resource_types = ["*"] # ["involumesnapshotcontents.snapshot.storage.k8s.io"] | ||
label_selectors = ["*"] # ["kubernetes.io/metadata.name:test"] | ||
volume_snapshot_enabled = true | ||
} | ||
|
||
depends_on = [ | ||
azurerm_role_assignment.extension_and_storage_account_permission, | ||
] | ||
} |
This file contains 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,31 @@ | ||
resource "azurerm_data_protection_backup_policy_kubernetes_cluster" "backup-policy-aks" { | ||
name = "backup-policy-aks" | ||
resource_group_name = azurerm_data_protection_backup_vault.backup-vault.resource_group_name | ||
vault_name = azurerm_data_protection_backup_vault.backup-vault.name | ||
|
||
backup_repeating_time_intervals = ["R/2023-05-23T02:30:00+00:00/P1W"] | ||
|
||
retention_rule { | ||
name = "Daily" | ||
priority = 25 | ||
|
||
life_cycle { | ||
duration = "P84D" | ||
data_store_type = "OperationalStore" | ||
} | ||
|
||
criteria { | ||
days_of_week = ["Thursday"] | ||
months_of_year = ["November"] | ||
weeks_of_month = ["First"] | ||
scheduled_backup_times = ["2023-05-23T02:30:00Z"] | ||
} | ||
} | ||
|
||
default_retention_rule { | ||
life_cycle { | ||
duration = "P14D" | ||
data_store_type = "OperationalStore" | ||
} | ||
} | ||
} |
This file contains 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,23 @@ | ||
resource "azurerm_data_protection_backup_vault" "backup-vault" { | ||
name = "backup-vault" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
location = azurerm_resource_group.rg.location | ||
datastore_type = "VaultStore" | ||
redundancy = "LocallyRedundant" | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "vault_msi_read_on_cluster" { | ||
scope = azurerm_kubernetes_cluster.aks.id | ||
role_definition_name = "Reader" | ||
principal_id = azurerm_data_protection_backup_vault.backup-vault.identity[0].principal_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "vault_msi_read_on_snap_rg" { | ||
scope = azurerm_resource_group.rg-backup.id | ||
role_definition_name = "Reader" | ||
principal_id = azurerm_data_protection_backup_vault.backup-vault.identity[0].principal_id | ||
} |
Empty file.
This file contains 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,25 @@ | ||
terraform { | ||
|
||
required_version = ">= 1.2.8" | ||
|
||
required_providers { | ||
|
||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "= 3.95.0" | ||
} | ||
|
||
time = { | ||
source = "hashicorp/time" | ||
version = "0.10.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
provider "time" { | ||
# Configuration options | ||
} |
This file contains 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,9 @@ | ||
resource "azurerm_resource_group" "rg" { | ||
name = "rg-akscluster-${var.prefix}" | ||
location = var.location | ||
} | ||
|
||
resource "azurerm_resource_group" "rg-backup" { | ||
name = "rg-aks-backup-${var.prefix}" | ||
location = var.location | ||
} |
This file contains 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,13 @@ | ||
resource "azurerm_storage_account" "storage" { | ||
name = "storage19753" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
location = azurerm_resource_group.rg.location | ||
account_tier = "Standard" | ||
account_replication_type = "LRS" | ||
} | ||
|
||
resource "azurerm_storage_container" "container" { | ||
name = "backup-container" | ||
storage_account_name = azurerm_storage_account.storage.name | ||
container_access_type = "private" | ||
} |
This file contains 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,6 @@ | ||
resource "azurerm_kubernetes_cluster_trusted_access_role_binding" "aks_cluster_trusted_access" { | ||
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id | ||
name = "trusted-access" | ||
roles = ["Microsoft.DataProtection/backupVaults/backup-operator"] | ||
source_resource_id = azurerm_data_protection_backup_vault.backup-vault.id | ||
} |
This file contains 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,7 @@ | ||
variable "prefix" { | ||
default = "80" | ||
} | ||
|
||
variable "location" { | ||
default = "swedencentral" | ||
} |
Binary file not shown.
This file contains 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
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
88_prometheus_grafana_ampls/.infracost/terraform_modules/manifest.json
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
{"Path":"d:\\Projects\\docker-kubernetes-course\\85_prometheus_grafana","Version":"2.0","Modules":[]} | ||
{"Path":"d:\\Projects\\docker-kubernetes-course\\88_prometheus_grafana_ampls","Version":"2.0","Modules":[]} |
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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 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,12 @@ | ||
You can use your own (leaf) certificate by passing the --certs [domain=]path_to_certificate option to mitmproxy. Mitmproxy then uses the provided certificate for interception of the specified domain instead of generating a certificate signed by its own CA. | ||
Check warning on line 1 in _egress_proxy/README.md GitHub Actions / spell-ckeck
|
||
|
||
The certificate file is expected to be in the PEM format. | ||
|
||
You can generate a certificate in this format using these instructions: | ||
|
||
```sh | ||
openssl genrsa -out cert.key 2048 | ||
# (Specify the mitm domain as Common Name, e.g. \*.google.com) | ||
openssl req -new -x509 -key cert.key -out cert.crt | ||
cat cert.key cert.crt > cert.pem | ||
``` |
Oops, something went wrong.