-
Notifications
You must be signed in to change notification settings - Fork 139
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
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
terraform-environments/aws/dev/helm/kubernetes-external-secrets/README.md
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 @@ | ||
# Kubernetes-external-secrets | ||
|
||
|
||
## Creating a secret | ||
|
||
String: | ||
``` | ||
aws secretsmanager create-secret --name myapp/password --secret-string "1234" | ||
aws secretsmanager create-secret --name myapp/some-key --secret-string "5678" | ||
``` | ||
|
||
Binary file: | ||
``` | ||
aws secretsmanager create-secret --name myapp-dev/file1 --secret-binary fileb://~/Downloads/Testing_MATCH_API-sandbox.p12 | ||
``` | ||
|
||
|
||
## Using the secret | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: mypod | ||
spec: | ||
containers: | ||
- name: mypod | ||
image: redis | ||
volumeMounts: | ||
- name: foo | ||
mountPath: "/etc/foo" | ||
readOnly: true | ||
volumes: | ||
- name: foo | ||
secret: | ||
secretName: mysecret | ||
``` | ||
The secret will be mounted into `/etc/foo` | ||
|
77 changes: 77 additions & 0 deletions
77
terraform-environments/aws/dev/helm/kubernetes-external-secrets/main.tf
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,77 @@ | ||
locals { | ||
aws_region = "us-east-1" | ||
environment_name = "dev" | ||
secrets_prefix = "managedkube/" | ||
tags = { | ||
ops_env = "${local.environment_name}" | ||
ops_managed_by = "terraform", | ||
ops_source_repo = "kubernetes-ops", | ||
ops_source_repo_path = "terraform-environments/aws/${local.environment_name}/helm/kubernetes-external-secrets", | ||
ops_owners = "devops", | ||
} | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 3.37.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
} | ||
} | ||
|
||
backend "remote" { | ||
organization = "managedkube" | ||
|
||
workspaces { | ||
name = "kubernetes-ops-dev-helm-kubernetes-external-secrets" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = local.aws_region | ||
} | ||
|
||
data "terraform_remote_state" "eks" { | ||
backend = "remote" | ||
config = { | ||
organization = "managedkube" | ||
workspaces = { | ||
name = "kubernetes-ops-${local.environment_name}-20-eks" | ||
} | ||
} | ||
} | ||
|
||
# | ||
# EKS authentication | ||
# # https://registry.terraform.io/providers/hashicorp/helm/latest/docs#exec-plugins | ||
provider "helm" { | ||
kubernetes { | ||
host = data.terraform_remote_state.eks.outputs.cluster_endpoint | ||
cluster_ca_certificate = base64decode(data.terraform_remote_state.eks.outputs.cluster_certificate_authority_data) | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1alpha1" | ||
args = ["eks", "get-token", "--cluster-name", local.environment_name] | ||
command = "aws" | ||
} | ||
} | ||
} | ||
|
||
# | ||
# Helm - kube-prometheus-stack | ||
# | ||
module "kubernetes-external-secrets" { | ||
source = "github.com/ManagedKube/kubernetes-ops//terraform-modules/aws/helm/kubernetes-external-secrets?ref=v1.0.20" | ||
|
||
eks_cluster_oidc_issuer_url = data.terraform_remote_state.eks.outputs.cluster_oidc_issuer_url | ||
helm_values = file("${path.module}/values.yaml") | ||
environment_name = local.environment_name | ||
secrets_prefix = local.secrets_prefix | ||
|
||
depends_on = [ | ||
data.terraform_remote_state.eks | ||
] | ||
} |
4 changes: 4 additions & 0 deletions
4
terraform-environments/aws/dev/helm/kubernetes-external-secrets/values.yaml
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,4 @@ | ||
--- | ||
env: | ||
AWS_REGION: us-east-1 | ||
AWS_DEFAULT_REGION: us-east-1 |