-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into health-status-agent-v2
- Loading branch information
Showing
23 changed files
with
357 additions
and
53 deletions.
There are no files selected for viewing
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 @@ | ||
hermit |
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 @@ | ||
.aws-iam-authenticator-0.5.12.pkg |
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
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,27 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
*.tfplan | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Exclude all .tfvars files, which are likely to contain sentitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
*.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc |
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,40 +1,74 @@ | ||
# Cloud Deployment | ||
|
||
**Motivation** | ||
Provide an easy and deterministic way to setup latest cloud environment so it can be monitored and used properly. | ||
**Motivation** | ||
Provide an easy and deterministic way to set up latest cloud environment, so it can be monitored and used properly. | ||
|
||
This guide deploys both an Elastic cloud environment, and an AWS EKS cluster. To only deploy specific resources, check out the examples section. | ||
|
||
**Prerequisite** | ||
* [terraform](https://www.terraform.io/) | ||
* [Terraform](https://developer.hashicorp.com/terraform/downloads) | ||
* the AWS CLI, [installed](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) and [configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) | ||
* [AWS IAM Authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html) | ||
* the [Kubernetes CLI](https://kubernetes.io/docs/tasks/tools/install-kubectl/), also known as `kubectl` | ||
|
||
|
||
**How To** | ||
Create environment | ||
1. Create an [API token](https://cloud.elastic.co/deployment-features/keys) from your cloud console account. | ||
|
||
1.1 use the token `export EC_API_KEY={TOKEN}` | ||
|
||
2. run `cd deploy/cloud` | ||
3. run `terraform init` | ||
4. run `terraform apply --auto-approve` to create the environment from the latest version (the latest version is vary in cloud/regions combinations). | ||
To connect to the environment use the console ui or see the details how to connect to the environment, use `terraform output -json` | ||
2. to create the environment from the latest version (the latest version is varying in cloud/regions combinations). | ||
```bash | ||
cd deploy/cloud | ||
terraform init | ||
terraform apply --auto-approve | ||
3. Run the following command to retrieve the access credentials for your EKS cluster and configure kubectl. | ||
```bash | ||
aws eks --region $(terraform output -raw eks_region) update-kubeconfig \ | ||
--name $(terraform output -raw eks_cluster_name) | ||
Delete environment | ||
1. `terraform destroy --auto-approve` | ||
To connect to the environment use the console UI or see the details how to connect to the environment, using: | ||
```bash | ||
terraform output -json | ||
**Delete environment:** | ||
```bash | ||
terraform destroy --auto-approve | ||
**Next Steps** | ||
* [Setup](https://github.com/elastic/security-team/blob/main/docs/cloud-security-posture-team/onboarding/deploy-agent-cloudbeat-on-eks.mdx) EKS cluster | ||
* Setup Vanila cluster | ||
* Enable rules add slack webhook to connctor | ||
* Setup Self-Managed cluster | ||
* Enable rules add slack webhook to connector | ||
# Examples | ||
## Specific version | ||
To create an environment with specific version use | ||
To create an environment with specific version use | ||
`terraform apply --auto-approve -var="stack_version=8.5.1"` | ||
When working with non production versions it is required to also update the deployment regions. | ||
For example, to deploy `8.6.0-SNAPSHOT` use | ||
For example, to deploy `8.6.0-SNAPSHOT` use | ||
`terraform apply --auto-approve -var="stack_version=8.6.0-SNAPSHOT" -var="ess_region=gcp-us-west2"` | ||
## Named environment | ||
To give your environment a different prefix in the name use | ||
To give your environment a different prefix in the name use | ||
`terraform apply --auto-approve -var="deployment_name_prefix=elastic-deployment"` | ||
## Deploy specific resources | ||
To deploy specific resources use the `-target` flag. | ||
### Deploy only Elastic Cloud with no EKS cluster or Dashboard | ||
`terraform apply --auto-approve -target "module.ec_deployment"` | ||
### Deploy only Dashboard on an existing Elastic Cloud deployment | ||
`terraform apply --auto-approve -target "null_resource.rules" -target "null_resource.store_local_dashboard"` | ||
### Deploy only EKS cluster | ||
`terraform apply --auto-approve -target "module.eks"` |
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 @@ | ||
Based on the [Provision an EKS Cluster tutorial](https://developer.hashicorp.com/terraform/tutorials/kubernetes/eks), and [repo](https://github.com/hashicorp/learn-terraform-provision-eks-cluster). |
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,49 @@ | ||
module "eks" { | ||
source = "terraform-aws-modules/eks/aws" | ||
version = "18.26.6" | ||
|
||
cluster_name = local.cluster_name | ||
cluster_version = "1.24" | ||
|
||
vpc_id = module.vpc.vpc_id | ||
subnet_ids = module.vpc.private_subnets | ||
|
||
eks_managed_node_group_defaults = { | ||
ami_type = "AL2_x86_64" | ||
|
||
attach_cluster_primary_security_group = true | ||
|
||
# Disabling and using externally provided security groups | ||
create_security_group = false | ||
} | ||
|
||
eks_managed_node_groups = { | ||
one = { | ||
name = "${var.cluster_name_prefix}-1" | ||
|
||
instance_types = ["t3.small"] | ||
|
||
min_size = 1 | ||
max_size = 3 | ||
desired_size = 2 | ||
|
||
vpc_security_group_ids = [ | ||
aws_security_group.node_group_one.id | ||
] | ||
} | ||
|
||
two = { | ||
name = "${var.cluster_name_prefix}-2" | ||
|
||
instance_types = ["t3.medium"] | ||
|
||
min_size = 1 | ||
max_size = 2 | ||
desired_size = 1 | ||
|
||
vpc_security_group_ids = [ | ||
aws_security_group.node_group_two.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,19 @@ | ||
# Kubernetes provider | ||
# https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider | ||
# To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/terraform/kubernetes/deploy-nginx-kubernetes | ||
# The Kubernetes provider is included in this file so the EKS module can complete successfully. Otherwise, it throws an error when creating `kubernetes_config_map.aws_auth`. | ||
# You should **not** schedule deployments and services in this workspace. This keeps workspaces modular (one for provision EKS, another for scheduling Kubernetes resources) as per best practices. | ||
provider "kubernetes" { | ||
host = module.eks.cluster_endpoint | ||
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
data "aws_availability_zones" "available" {} | ||
|
||
locals { | ||
cluster_name = var.cluster_name_prefix | ||
} |
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,24 @@ | ||
output "cluster_id" { | ||
description = "EKS cluster ID" | ||
value = module.eks.cluster_id | ||
} | ||
|
||
output "cluster_endpoint" { | ||
description = "Endpoint for EKS control plane" | ||
value = module.eks.cluster_endpoint | ||
} | ||
|
||
output "cluster_security_group_id" { | ||
description = "Security group ids attached to the cluster control plane" | ||
value = module.eks.cluster_security_group_id | ||
} | ||
|
||
output "region" { | ||
description = "AWS region" | ||
value = var.region | ||
} | ||
|
||
output "cluster_name" { | ||
description = "Kubernetes Cluster Name" | ||
value = local.cluster_name | ||
} |
Oops, something went wrong.