|
| 1 | +data "aws_caller_identity" "this" {} |
| 2 | + |
| 3 | +data "aws_eks_cluster" "this" { |
| 4 | + name = "my-cluster-name" |
| 5 | +} |
| 6 | + |
| 7 | +locals { |
| 8 | + openid_connect_provider_uri = replace(aws_iam_openid_connect_provider.this.url, "https://", "") |
| 9 | +} |
| 10 | + |
| 11 | +resource "aws_iam_openid_connect_provider" "this" { |
| 12 | + client_id_list = ["sts.amazonaws.com"] |
| 13 | + thumbprint_list = [data.tls_certificate.this.certificates[0].sha1_fingerprin] |
| 14 | + url = aws_eks_cluster.this.identity[0].oidc[0].issuer |
| 15 | +} |
| 16 | + |
| 17 | +module "velero" { |
| 18 | + source = "terraform-module/velero/kubernetes" |
| 19 | + version = "~> 1" |
| 20 | + |
| 21 | + count = 1 |
| 22 | + |
| 23 | + namespace_deploy = "velero" |
| 24 | + app_deploy = true |
| 25 | + cluster_name = "my-cluster-name" |
| 26 | + openid_connect_provider_uri = local.openid_connect_provider_uri |
| 27 | + bucket = "my-cluster-name" |
| 28 | + app = { |
| 29 | + name = "velero" |
| 30 | + version = "2.29.4" |
| 31 | + chart = "velero" |
| 32 | + force_update = false |
| 33 | + wait = true |
| 34 | + recreate_pods = true |
| 35 | + deploy = false |
| 36 | + max_history = 1 |
| 37 | + image = null |
| 38 | + tag = null |
| 39 | + } |
| 40 | + tags = {} |
| 41 | + |
| 42 | + values = [<<EOF |
| 43 | +# https://github.com/vmware-tanzu/helm-charts/tree/master/charts/velero |
| 44 | +
|
| 45 | +image: |
| 46 | + repository: velero/velero |
| 47 | + tag: v1.8.1 |
| 48 | +
|
| 49 | +# https://aws.amazon.com/blogs/containers/backup-and-restore-your-amazon-eks-cluster-resources-using-velero/ |
| 50 | +# https://github.com/vmware-tanzu/velero-plugin-for-aws |
| 51 | +initContainers: |
| 52 | + - name: velero-plugin-for-aws |
| 53 | + image: velero/velero-plugin-for-aws:v1.4.1 |
| 54 | + imagePullPolicy: IfNotPresent |
| 55 | + volumeMounts: |
| 56 | + - mountPath: /target |
| 57 | + name: plugins |
| 58 | +
|
| 59 | +# Install CRDs as a templates. Enabled by default. |
| 60 | +installCRDs: true |
| 61 | +
|
| 62 | +# SecurityContext to use for the Velero deployment. Optional. |
| 63 | +# Set fsGroup for `AWS IAM Roles for Service Accounts` |
| 64 | +# see more informations at: https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html |
| 65 | +securityContext: |
| 66 | + fsGroup: 1337 |
| 67 | + # fsGroup: 65534 |
| 68 | +
|
| 69 | +## |
| 70 | +## Parameters for the `default` BackupStorageLocation and VolumeSnapshotLocation, |
| 71 | +## and additional server settings. |
| 72 | +## |
| 73 | +configuration: |
| 74 | + provider: aws |
| 75 | +
|
| 76 | + backupStorageLocation: |
| 77 | + name: default |
| 78 | + provider: aws |
| 79 | + bucket: "velero-backups" |
| 80 | + prefix: "velero/sandbox/my-cluster-name" |
| 81 | + config: |
| 82 | + region: eu-west-1 |
| 83 | +
|
| 84 | + volumeSnapshotLocation: |
| 85 | + name: default |
| 86 | + provider: aws |
| 87 | + # Additional provider-specific configuration. See link above |
| 88 | + # for details of required/optional fields for your provider. |
| 89 | + config: |
| 90 | + region: eu-west-1 |
| 91 | +
|
| 92 | + # These are server-level settings passed as CLI flags to the `velero server` command. Velero |
| 93 | + # uses default values if they're not passed in, so they only need to be explicitly specified |
| 94 | + # here if using a non-default value. The `velero server` default values are shown in the |
| 95 | + # comments below. |
| 96 | + # -------------------- |
| 97 | + # `velero server` default: 1m |
| 98 | + backupSyncPeriod: |
| 99 | + # `velero server` default: 1h |
| 100 | + resticTimeout: |
| 101 | + # `velero server` default: namespaces,persistentvolumes,persistentvolumeclaims,secrets,configmaps,serviceaccounts,limitranges,pods |
| 102 | + restoreResourcePriorities: |
| 103 | + # `velero server` default: false |
| 104 | + restoreOnlyMode: |
| 105 | +
|
| 106 | + extraEnvVars: |
| 107 | + AWS_CLUSTER_NAME: my-cluster-name |
| 108 | +
|
| 109 | + # Set log-level for Velero pod. Default: info. Other options: debug, warning, error, fatal, panic. |
| 110 | + logLevel: info |
| 111 | +
|
| 112 | +## |
| 113 | +## End of backup/snapshot location settings. |
| 114 | +## |
| 115 | +
|
| 116 | +## |
| 117 | +## Settings for additional Velero resources. |
| 118 | +## |
| 119 | +rbac: |
| 120 | + create: true |
| 121 | + clusterAdministrator: true |
| 122 | +
|
| 123 | +credentials: |
| 124 | + # Whether a secret should be used as the source of IAM account |
| 125 | + # credentials. Set to false if, for example, using kube2iam or |
| 126 | + # kiam to provide IAM credentials for the Velero pod. |
| 127 | + useSecret: false |
| 128 | +
|
| 129 | +backupsEnabled: true |
| 130 | +snapshotsEnabled: true |
| 131 | +deployRestic: false |
| 132 | +EOF |
| 133 | + ] |
| 134 | +} |
0 commit comments