Skip to content

Commit 4c520bb

Browse files
committed
add helm scripts + backup role
1 parent 6abada1 commit 4c520bb

4 files changed

Lines changed: 88 additions & 4 deletions

File tree

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
AWS_PROFILE ?= default
2+
CLUSTER_NAME = tofu -chdir=terraform output cluster_name
3+
S3_BACKUP_ROLE = tofu -chdir=terraform output s3_backup_role
4+
5+
PGO_CHART_VERSION = 5.7.4
6+
EOAPI_CHART_VERSION = 0.7.1
7+
8+
.DEFAULT_GOAL := help
9+
10+
$(VERBOSE).SILENT:
11+
12+
.PHONY: help
13+
14+
help: Makefile
15+
@echo
16+
@echo "Usage: make [target]"
17+
@echo
18+
@echo "Targets:"
19+
@sed -n 's/^##//p' $< | column -t -s ':'
20+
@echo
21+
22+
## kubeconfig: Configure kubectl to connect to EKS cluster
23+
kubeconfig:
24+
aws eks update-kubeconfig --name $(CLUSTER_NAME)
25+
26+
## init-eoapi: Add eoAPI repo and install dependencies
27+
init-eoapi:
28+
command -v helm >/dev/null 2>&1 || { echo "Helm is required but not installed"; exit 1; }
29+
echo "Installing PostgresQL operator chart (eoAPI dependency)"
30+
helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo --version $(PGO_CHART_VERSION)
31+
echo "Adding eoAPI repository."
32+
helm repo add eoapi https://devseed.com/eoapi-k8s/
33+
34+
## deploy-eoapi: Upgrade or install eoAPI release
35+
deploy-eoapi:
36+
helm repo list | grep "eoapi" >/dev/null 2>&1 || { echo "Not initialized, run 'make init-eoapi' before retrying"; exit 1; }
37+
helm upgrade --install --namespace eoapi --create-namespace eoapi eoapi/eoapi --version $(EOAPI_CHART_VERSION) -f kubernetes/helm/eoapi.yaml --set previousVersion=0.7.1
38+
kubectl --namespace eoapi annotate postgresclusters eoapi --overwrite eks.amazonaws.com/role-arn=$(S3_BACKUP_ROLE)

kubernetes/helm/eoapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ingress:
2+
annotations:
3+
# increase the max body size to 100MB
4+
nginx.ingress.kubernetes.io/proxy-body-size: "100m"
5+
nginx.ingress.kubernetes.io/enable-cors: "true"
6+
nginx.ingress.kubernetes.io/enable-access-log: "true"
7+
8+
9+
postgrescluster:
10+
# # TODO: bridge alternatives for TF output to CRD annotations
11+
# metadata:
12+
# annotations:
13+
# eks.amazonaws.com/role-arn: ""
14+
backupsEnabled: true
15+
s3:
16+
bucket: "pgstac-backup"
17+
endpoint: "s3.us-east-1.amazonaws.com"
18+
region: "us-east-1"
19+
keyType: "web-id"
20+
instances:
21+
- name: eoapi
22+
replicas: 1
23+
dataVolumeClaimSpec:
24+
# TODO: gp3 SC
25+
storageClassName: "gp2"
26+
accessModes:
27+
- "ReadWriteOnce"
28+
resources:
29+
requests:
30+
storage: "10Gi"
31+
cpu: "1024m"
32+
memory: "3048Mi"
33+
34+
pgstacBootstrap:
35+
image:
36+
name: ghcr.io/stac-utils/pgstac-pypgstac
37+
tag: v0.9.6

terraform/outputs.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
output "cluster_sg" {
2-
description = "the cluster security group"
3-
value = aws_eks_cluster.cluster.vpc_config[0].cluster_security_group_id
1+
output "cluster_name" {
2+
value = aws_eks_cluster.cluster.name
3+
}
4+
5+
output "s3_backup_role" {
6+
value = aws_iam_role.bucket_access.arn
47
}

terraform/s3.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ locals {
2727
s3_policy_arn = length(var.bucket_names) > 0 ? aws_iam_policy.eks_s3_access[0].arn : ""
2828
}
2929

30+
resource "aws_iam_role" "bucket_access" {
31+
name = "${local.cluster_prefix}-bucket-access"
32+
assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc.json
33+
permissions_boundary = var.permissions_boundary
34+
}
35+
3036
resource "aws_iam_role_policy_attachment" "s3_access" {
3137
count = length(var.bucket_names) > 0 ? 1 : 0
32-
role = aws_iam_role.nodegroup.name
38+
role = aws_iam_role.bucket_access.name
3339
policy_arn = local.s3_policy_arn
3440
}

0 commit comments

Comments
 (0)