Giter Club home page Giter Club logo

terraform-azurerm-backupstorage's Introduction

Terraform Azure backup storage

This module creates the Azure Blob Storage infrastructure needed to backup an AKS cluster using Velero.

This module only automates creating the needed infrastructure and it does not deploy a cluster or Velero inside the cluster.

Prerequisites

For this module to make sense you need to have deployed an Azure Kubernetes Service that where you would like to run Velero.

Overview

This module creates the following resources.

  • azurerm_resource_group.backup
  • azurerm_storage_account.backup
  • azurerm_storage_container.velero

It supports the following variables.

  • location (Required)
  • name
  • account_tier
  • account_replication_type
  • bucket

It outputs the following information.

  • backup_subscription_id
  • backup_tenant_id
  • backup_client_id
  • backup_client_secret
  • backup_resource_group
  • backup_storage_account_name

Usage

module "backup" {
  source  = "adfinis-sygroup/backupstorage/azurerm"
  version = "0.0.0"
}

Grab the output from terraform and use it to create a Kubernetes secret for Velero.

backupNamespace="velero"
backupCloudCredentials="velero-azure-credentials"

# grab needed information from AKS deployment (outside of this modules scope)
aksName="aks-..."
aksResourceGroup="rg-..."
aksMcResourceGroup=`az aks show \
  --resource-group "${aksResourceGroup}" \
  --name "${aksName}" -ojson | jq -r '.nodeResourceGroup'`

# grab information from terraform output
subscriptionId=`terraform output -json \
  | jq -r '.backup_subscription_id | .value' \
  | sed 's@/subscriptions/@@'`
tenantId=`terraform output -json | jq -r '.backup_tenant_id | .value'`
clientId=`terraform output -json | jq -r '.backup_client_id | .value'`
clientSecret=`terraform output -json | jq -r '.backup_client_secret | .value'`


# create namspace and secret
kubectl create namespace "${backupNamespace}"

kubectl create secret generic "${backupCloudCredentials}" \
  --namespace "${backupNamespace}" \
  --from-literal="AZURE_SUBSCRIPTION_ID=${subscriptionId}" \
  --from-literal="AZURE_TENANT_ID=${tenantId}" \
  --from-literal="AZURE_CLIENT_ID=${clientId}" \
  --from-literal="AZURE_CLIENT_SECRET=${clientSecret}" \
  --from-literal="AZURE_RESOURCE_GROUP=${aksMcResourceGroup}" \
  --from-literal="AZURE_CLOUD_NAME=AzurePublicCloud"

Create a values.yaml to use with helm install stable/velero (also outside of the scope of this module.

backupResourceGroup=`terraform output -json \
  | jq -r '.backup_resource_group | .value'`
backupStorageAccountName=`terraform output -json \
  | jq -r '.backup_storage_account_name | .value'`

cat > velero.values.yaml <<EOYAML
configuration:
  provider: azure
  backupStorageLocation:
    name: azure
    bucket: velero
    config:
      resourceGroup: ${backupResourceGroup}
      storageAccount: ${backupStorageAccountName}
  volumeSnapshotLocation:
    name: azure
    config:
      resourceGroup: ${backupResourceGroup}
EOYAML

License

This module is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.

Copyright

Copyright (c) 2019 Adfinis SyGroup AG

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.