Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nightly testing eks #250

Merged
merged 91 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
b0da983
feat: add nightly testing
TristanHoladay Mar 12, 2024
74e6e79
test-eks workflow for creating packages / bundle to deploy infra and …
TristanHoladay Mar 13, 2024
51b75c5
yamllint
TristanHoladay Mar 13, 2024
611e974
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 14, 2024
cd33484
removing zarf-configs from test-infra packages; setting package vars …
TristanHoladay Mar 14, 2024
17ea113
removing cluster and iac deployment from bundle
TristanHoladay Mar 14, 2024
834582c
test workflow by switching to on pull_request for now
TristanHoladay Mar 14, 2024
0169b56
testing
TristanHoladay Mar 14, 2024
efaacf6
updated role to assume name
TristanHoladay Mar 14, 2024
ad02619
just place built infra packages in build/
TristanHoladay Mar 15, 2024
89f135d
yamllint
TristanHoladay Mar 15, 2024
38e8b2e
fix typo in bundle name
TristanHoladay Mar 15, 2024
ba6e113
add chart name to bundle overrides
TristanHoladay Mar 15, 2024
219fd60
add create-package-no-pepr and use in test-eks workflow
TristanHoladay Mar 15, 2024
c78e70e
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 15, 2024
e381196
remove set cluster name step and set as job level env
TristanHoladay Mar 15, 2024
818cbb1
fix env setting
TristanHoladay Mar 15, 2024
9c24132
setting dependant ENV in step
TristanHoladay Mar 15, 2024
0da58e3
checking for empty arn
TristanHoladay Mar 15, 2024
81c7b1c
changing deploy cluster to use uds task
TristanHoladay Mar 15, 2024
12555cf
remove --confirm from task call
TristanHoladay Mar 15, 2024
ef40145
testing with env set with ZARF_ and no uds task for deploy of infra p…
TristanHoladay Mar 15, 2024
0acf114
forget it, go back
TristanHoladay Mar 15, 2024
ce905f2
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 15, 2024
48fc6d4
fix zarf deploy of iac-aws
TristanHoladay Mar 15, 2024
bc85e67
readding explicit cluster teardown
TristanHoladay Mar 15, 2024
0062e42
bump infra test bundle to 0.16.0
TristanHoladay Mar 15, 2024
e6c0e3e
bleh
TristanHoladay Mar 15, 2024
4dba10f
testing ci package with already deployed cluster
TristanHoladay Mar 15, 2024
9092c62
fix
TristanHoladay Mar 15, 2024
f133b32
fix cat location; fix removal steps
TristanHoladay Mar 15, 2024
9ee584b
set state file to test
TristanHoladay Mar 15, 2024
b5024ea
set back for creating cluster for testing
TristanHoladay Mar 18, 2024
cac4e5e
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 18, 2024
dd652f5
update core package ref in testing bundle
TristanHoladay Mar 18, 2024
34220ad
adding iam identity mapping to eks config for dev testing access
TristanHoladay Mar 18, 2024
672e62d
update eks config and testin bundle / config
TristanHoladay Mar 19, 2024
f7da6d4
fix
TristanHoladay Mar 19, 2024
966a942
nightly bundle config and velero package changes
TristanHoladay Mar 19, 2024
91abbff
removing .terraform files and route53
TristanHoladay Mar 19, 2024
7d29827
converting create and deploy no pepr package tasks to common tasks.
TristanHoladay Mar 20, 2024
fb259e9
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 20, 2024
32254d7
typo fix
TristanHoladay Mar 20, 2024
fc43511
fixin deploy for no pepr package task
TristanHoladay Mar 20, 2024
f937c61
yamllint
TristanHoladay Mar 20, 2024
ce40c09
testing env var for task issue
TristanHoladay Mar 20, 2024
ead74e1
testing with ZARF_ prefix
TristanHoladay Mar 20, 2024
dd3f35b
explicit --set in tasks
TristanHoladay Mar 20, 2024
5bb9bdf
yamllint and typo
TristanHoladay Mar 20, 2024
968aba0
removing iamidentitymapping from eks config along with zarf vars
TristanHoladay Mar 20, 2024
7ed02ee
yamllint
TristanHoladay Mar 20, 2024
440576c
typo for ci iac var
TristanHoladay Mar 20, 2024
6116f54
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 22, 2024
ace8a4f
remove toggles for force destroy and set to always true; set nightly …
TristanHoladay Mar 22, 2024
1351bdc
merge main and resolve
TristanHoladay Mar 28, 2024
7cc2cd3
add loki s3 overrides to nightly testing bundle.
TristanHoladay Mar 28, 2024
9e2d57b
update core bundle version to 0.17.0
TristanHoladay Mar 28, 2024
4ac4a25
setting nightly testing back to schedule only; yamllint fix
TristanHoladay Mar 28, 2024
87a3f9a
converting iac packages into iac tasks
TristanHoladay Mar 29, 2024
820ce90
refactoring tf to not use zarf_vars
TristanHoladay Mar 29, 2024
1f3a686
install uds first
TristanHoladay Mar 29, 2024
8d88686
DRY out iac tasks; fix eksctl config reference
TristanHoladay Mar 29, 2024
0b9ddb3
collapsing loki and velero iac into a single module.
TristanHoladay Mar 29, 2024
a65f453
Merge branch 'main' into feat-nightly-testing
TristanHoladay Mar 29, 2024
f9f5f2d
update core pkg ref to 0.18.0
TristanHoladay Mar 29, 2024
8540288
testing new iac setup issues
TristanHoladay Mar 29, 2024
b97f39b
added STATE_KEY to iac tasks vars so UDS_ prefix in workflow works
TristanHoladay Mar 29, 2024
c69c8f7
running full test after fixing state_key error
TristanHoladay Mar 29, 2024
cec68e2
test standalone tf apply cmd
TristanHoladay Mar 29, 2024
0146ad9
make schedule midnight mountain time; change TF_VARs to lowercase for…
TristanHoladay Apr 1, 2024
09bbcb5
fix variables and kms key generation for buckets; run just IAC for te…
TristanHoladay Apr 1, 2024
61b2454
removing no longer needed configurable variables
TristanHoladay Apr 1, 2024
9d6328d
fix test vars
TristanHoladay Apr 1, 2024
e5f95d8
fix S3 module calls in loki and velero
TristanHoladay Apr 1, 2024
b539177
testing github env UDS_REGION issue
TristanHoladay Apr 1, 2024
8e053bd
testing github env UDS_REGION issue
TristanHoladay Apr 1, 2024
8576259
typo tf var permissions boundary
TristanHoladay Apr 1, 2024
3849b8c
changing env var reference
TristanHoladay Apr 1, 2024
4f61e9c
full test with fixed buckets iac
TristanHoladay Apr 1, 2024
c90da7b
fixing permissions boundary tf var and setting timeouts lower
TristanHoladay Apr 1, 2024
cdff9b2
test moving tf_vars to job level
TristanHoladay Apr 2, 2024
98b2418
test moving tf_vars to job level
TristanHoladay Apr 2, 2024
150df0b
fix cluster name ref in tf vars
TristanHoladay Apr 2, 2024
7f8c379
run full eks test
TristanHoladay Apr 2, 2024
65706fa
typo
TristanHoladay Apr 2, 2024
2bbe21f
refactoring buckets tf with loops
TristanHoladay Apr 2, 2024
d64da94
remove .tfvars from bucket iac
TristanHoladay Apr 2, 2024
baf20e0
Merge branch 'main' into feat-nightly-testing
TristanHoladay Apr 3, 2024
dee4c1b
Update .github/workflows/test-eks.yaml
TristanHoladay Apr 3, 2024
014e6b6
nightly test set to run only nightly; yamllint
TristanHoladay Apr 3, 2024
a0773e7
Update .gitignore
TristanHoladay Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/bundles/uds-bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
kind: UDSBundle
metadata:
name: uds-core-eks-nightly
description: A UDS bundle for deploying EKS and UDS Core
# x-release-please-start-version
version: "0.18.0"
# x-release-please-end

packages:
- name: init
repository: ghcr.io/defenseunicorns/packages/init
# renovate: datasource=github-tags depName=defenseunicorns/zarf versioning=semver
ref: v0.32.4

- name: core
path: ../../build/
# x-release-please-start-version
ref: 0.18.0
# x-release-please-end
overrides:
velero:
velero:
variables:
- name: VELERO_USE_SECRET
description: "Toggle use secret off to use IRSA."
path: credentials.useSecret
- name: VELERO_IRSA_ANNOTATION
description: "IRSA ARN annotation to use for Velero"
path: serviceAccount.server.annotations
loki:
loki:
variables:
- name: LOKI_CHUNKS_BUCKET
description: "The object storage bucket for Loki chunks"
path: loki.storage.bucketNames.chunks
- name: LOKI_RULER_BUCKET
description: "The object storage bucket for Loki ruler"
path: loki.storage.bucketNames.ruler
- name: LOKI_ADMIN_BUCKET
description: "The object storage bucket for Loki admin"
path: loki.storage.bucketNames.admin
- name: LOKI_S3_ENDPOINT
description: "The S3 endpoint"
path: loki.storage.s3.endpoint
- name: LOKI_S3_REGION
description: "The S3 region"
path: loki.storage.s3.region
- name: LOKI_IRSA_ANNOTATION
description: "The irsa role annotation"
path: loki.serviceAccount.annotations
21 changes: 21 additions & 0 deletions .github/bundles/uds-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Overwritten by ci-iac-aws package
options:
architecture: amd64

variables:
core:
loki_chunks_bucket: ${ZARF_VAR_LOKI_S3_BUCKET}
loki_ruler_bucket: ${ZARF_VAR_LOKI_S3_BUCKET}
loki_admin_bucket: ${ZARF_VAR_LOKI_S3_BUCKET}
loki_s3_region: ${ZARF_VAR_LOKI_S3_AWS_REGION}
loki_s3-endpoint: ""
loki_irsa_annotation:
eks.amazonaws.com/role-arn: ${ZARF_VAR_LOKI_S3_ROLE_ARN}
velero_use_secret: false
velero_irsa_annotation:
eks.amazonaws.com/role-arn: "${ZARF_VAR_VELERO_S3_ROLE_ARN}"
velero_bucket: ${ZARF_VAR_VELERO_S3_BUCKET}
velero_bucket_region: ${ZARF_VAR_VELERO_S3_AWS_REGION}
velero_bucket_provider_url: ""
velero_bucket_credential_name: ""
velero_bucket_credential_key: ""
28 changes: 28 additions & 0 deletions .github/test-infra/buckets-iac/loki.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "aws_iam_policy" "loki_policy" {
name = "${local.bucket_configurations.loki.name}-irsa-${random_id.unique_id.hex}"
path = "/"
description = "IAM policy for Loki to have necessary permissions to use S3 for storing logs."
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = ["s3:ListBucket"]
Resource = ["arn:${data.aws_partition.current.partition}:s3:::${module.S3["loki"].bucket_name}"]
},
{
Effect = "Allow"
Action = ["s3:*Object"]
Resource = ["arn:${data.aws_partition.current.partition}:s3:::${module.S3["loki"].bucket_name}/*"]
},
{
Effect = "Allow"
Action = [
"kms:GenerateDataKey",
"kms:Decrypt"
]
Resource = [local.kms_key_arns["loki"].kms_key_arn]
}
]
})
}
130 changes: 130 additions & 0 deletions .github/test-infra/buckets-iac/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
provider "aws" {
region = var.region

default_tags {
tags = {
PermissionsBoundary = var.permissions_boundary_name
}
}
}

terraform {
required_version = "1.5.7"
backend "s3" {
}
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0, != 5.17.0"
}

random = {
source = "hashicorp/random"
version = "3.5.1"
}
}
}

resource "random_id" "default" {
byte_length = 2
}

data "aws_eks_cluster" "existing" {
name = var.name
}

data "aws_caller_identity" "current" {}

data "aws_partition" "current" {}

data "aws_region" "current" {}

locals {
oidc_url_without_protocol = substr(data.aws_eks_cluster.existing.identity[0].oidc[0].issuer, 8, -1)
oidc_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.oidc_url_without_protocol}"
iam_role_permissions_boundary = var.use_permissions_boundary ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/${var.permissions_boundary_name}" : null

bucket_configurations = {
for instance in var.bucket_configurations :
instance.name => {
name = "${var.name}-${instance.name}"
service_account = instance.service_account
namespace = instance.namespace
}
}

kms_key_arns = module.generate_kms

iam_policies = {
"loki" = resource.aws_iam_policy.loki_policy.arn
"velero" = resource.aws_iam_policy.velero_policy.arn
}
}

resource "random_id" "unique_id" {
byte_length = 4
}

module "generate_kms" {
for_each = local.bucket_configurations
source = "github.com/defenseunicorns/terraform-aws-uds-kms?ref=v0.0.2"

key_owners = var.key_owner_arns
# A list of IAM ARNs for those who will have full key permissions (`kms:*`)
kms_key_alias_name_prefix = "${each.value.name}-" # Prefix for KMS key alias.
kms_key_deletion_window = var.kms_key_deletion_window
# Waiting period for scheduled KMS Key deletion. Can be 7-30 days.
kms_key_description = "${var.name} UDS Core deployment Loki Key" # Description for the KMS key.
tags = {
Deployment = "UDS Core ${each.value.name}"
}
}

module "S3" {
for_each = local.bucket_configurations
source = "github.com/defenseunicorns/terraform-aws-uds-s3?ref=v0.0.6"
name_prefix = "${each.value.name}-"
kms_key_arn = local.kms_key_arns[each.key].kms_key_arn
force_destroy = "true"
create_bucket_lifecycle = true
}

module "irsa" {
for_each = local.bucket_configurations
source = "github.com/defenseunicorns/terraform-aws-uds-irsa?ref=v0.0.2"
name = each.value.name
kubernetes_service_account = each.value.service_account
kubernetes_namespace = each.value.namespace
oidc_provider_arn = local.oidc_arn
role_permissions_boundary_arn = local.iam_role_permissions_boundary

role_policy_arns = tomap({
"${each.key}" = local.iam_policies[each.key]
})
}

resource "aws_s3_bucket_policy" "bucket_policy" {
for_each = local.bucket_configurations
bucket = module.S3[each.key].bucket_name

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject"
]
Effect = "Allow"
Principal = {
AWS = module.irsa[each.key].role_arn
}
Resource = [
module.S3[each.key].bucket_arn,
"${module.S3[each.key].bucket_arn}/*"
]
}
]
})
}
27 changes: 27 additions & 0 deletions .github/test-infra/buckets-iac/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
output "aws_region" {
value = data.aws_region.current.name
}

output "loki_irsa_role_arn" {
value = module.irsa["loki"].role_arn
}

output "loki_s3" {
value = module.S3["loki"]
}

output "loki_s3_bucket" {
value = module.S3["loki"].bucket_name
}

output "velero_irsa_role_arn" {
value = module.irsa["velero"].role_arn
}

output "velero_s3" {
value = module.S3["velero"]
}

output "velero_s3_bucket" {
value = module.S3["velero"].bucket_name
}
55 changes: 55 additions & 0 deletions .github/test-infra/buckets-iac/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
variable "region" {
description = "AWS region"
type = string
}

variable "name" {
description = "Name for cluster"
type = string
}

variable "permissions_boundary_name" {
description = "The name of the permissions boundary for IAM resources. This will be used for tagging and to build out the ARN."
type = string
default = null
}

variable "use_permissions_boundary" {
description = "Whether to use IAM permissions boundary for resources."
type = bool
default = true
}

variable "key_owner_arns" {
description = "ARNS of KMS key owners, needed for use of key"
type = list(string)
default = []
}

# taken from zarf bb repo
variable "kms_key_deletion_window" {
description = "Waiting period for scheduled KMS Key deletion. Can be 7-30 days."
type = number
default = 7
}

variable "bucket_configurations" {
type = map(object({
name = string
service_account = string
namespace = string
}))
default = {
loki = {
name = "loki"
service_account = "logging-loki"
namespace = "logging"
}
velero = {
name = "velero"
service_account = "velero-server"
namespace = "velero"
}
}
}

59 changes: 59 additions & 0 deletions .github/test-infra/buckets-iac/velero.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
resource "aws_iam_policy" "velero_policy" {
name = "${local.bucket_configurations.velero.name}-irsa-${random_id.unique_id.hex}"
path = "/"
description = "Policy to give Velero necessary permissions for cluster backups."

# Terraform expression result to valid JSON syntax.
policy = jsonencode(
{
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"ec2:DescribeVolumes",
"ec2:DescribeSnapshots",
"ec2:CreateTags",
"ec2:CreateVolume",
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot"
]
Resource = [
"*"
]
},
{
Effect = "Allow"
Action = [
"s3:GetObject",
"s3:DeleteObject",
"s3:PutObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts"
]
Resource = [
"arn:${data.aws_partition.current.partition}:s3:::${module.S3["velero"].bucket_name}/*"
]
},
{
Effect = "Allow",
Action = [
"s3:ListBucket"
],
Resource = [
"arn:${data.aws_partition.current.partition}:s3:::${module.S3["velero"].bucket_name}/*"
]
},
{
Effect = "Allow"
Action = [
"kms:GenerateDataKey",
"kms:Decrypt"
]
Resource = [local.kms_key_arns["velero"].kms_key_arn]
}

]
})
}

12 changes: 12 additions & 0 deletions .github/workflows/nightly-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Nightly Testing

on:
schedule:
- cron: '0 6 * * *' # Runs at midnight Mountain every day
pull_request:

jobs:
nightly-testing:
name: Test Core on EKS
uses: ./.github/workflows/test-eks.yaml
secrets: inherit
Loading