Skip to content

Commit 834aaab

Browse files
authored
Merge pull request #17 from hotosm/infra/193-eoapi
build: install eoAPI chart
2 parents 2708434 + ee6bb2e commit 834aaab

20 files changed

Lines changed: 710 additions & 55 deletions

.github/pull_request_template.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## What type of PR is this? (check all applicable)
2+
3+
- [ ] 🍕 Feature
4+
- [ ] 🐛 Bug Fix
5+
- [ ] 📝 Documentation
6+
- [ ] 🧑‍💻 Refactor
7+
- [ ] ✅ Test
8+
- [ ] 🤖 Build or CI
9+
- [ ] ❓ Other (please specify)
10+
11+
## Related Issue
12+
13+
Example: Fixes #123
14+
15+
## Describe this PR
16+
17+
A brief description of how this solves the issue.
18+
19+
## Screenshots
20+
21+
Please provide screenshots of the change.
22+
23+
## Alternative Approaches Considered
24+
25+
Did you attempt any other approaches that are not documented in code?
26+
27+
## Review Guide
28+
29+
Notes for the reviewer. How to test this change?
30+
31+
## Checklist before requesting a review
32+
33+
- 📖 Read the HOT Contributing Guide: <https://docs.hotosm.org/become-a-contributor/>
34+
- 📖 Read the HOT Code of Conduct: <https://docs.hotosm.org/code-of-conduct>
35+
- 👷‍♀️ Create small PRs. In most cases, this will be possible.
36+
- ✅ Provide tests for your changes.
37+
- 📝 Use descriptive commit messages.
38+
- 📗 Update any related documentation and include any relevant screenshots.
39+
- 🔠 Does this PR introduce or change any environment variables? If so, make sure to specify this change in the description.
40+
41+
## [optional] What gif best describes this PR or how it makes you feel?

.github/workflows/ci.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Terraform
1+
name: Deploy Changes
22
on:
33
push:
44
branches:
@@ -35,12 +35,30 @@ jobs:
3535
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
3636
- name: Provision TF
3737
uses: op5dev/tf-via-pr@v13
38+
env:
39+
TF_VAR_cluster_ci_access_role_arn: ${{ secrets.AWS_OIDC_ROLE }}
40+
TF_VAR_cluster_admin_access_role_arns: ${{ secrets.CLUSTER_ADMIN_ACCESS_ROLE_ARNS }}
3841
with:
42+
# command: 'apply'
3943
command: ${{ github.event_name == 'push' && 'apply' || 'plan' }}
4044
tool: tofu
4145
working-directory: terraform
4246
validate: true
4347
format: true
4448
arg-var-file: ${{ env.VAR_FILE }}
45-
arg-var: cluster_ci_access_role_arn=${{ secrets.AWS_OIDC_ROLE }}
46-
label-pr: false
49+
- name: Get TF Outputs
50+
run: |
51+
echo "S3_BACKUP_ROLE=$(tofu -chdir=terraform output -var-file=vars/production.tfvars s3_backup_role)" >> $GITHUB_ENV
52+
echo "CLUSTER_NAME=$(tofu -chdir=terraform output -var-file=vars/production.tfvars cluster_name)" >> $GITHUB_ENV
53+
- name: Pull kubeconfig
54+
run: |
55+
aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }}
56+
- name: Apply manifests
57+
run: |
58+
kubectl apply -f kubernetes/manifests/ ${{ github.event_name == 'pull_request' && '--dry-run' || '' }}
59+
- name: Deploy eoAPI Chart
60+
uses: helmfile/helmfile-action@v2.0.4
61+
with:
62+
helmfile-args: 'apply'
63+
# helmfile-args: ${{ github.event_name == 'push' && 'apply' || 'diff' }}
64+
helmfile-workdirectory: kubernetes/helm

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWS_PROFILE ?= default
2-
CLUSTER_NAME = $(shell tofu -chdir=terraform output cluster_name)
3-
S3_BACKUP_ROLE = $(shell tofu -chdir=terraform output s3_backup_role)
2+
CLUSTER_NAME = $(shell tofu -chdir=terraform output -var-file=vars/local.tfvars cluster_name)
3+
S3_BACKUP_ROLE = $(shell tofu -chdir=terraform output -var-file=vars/local.tfvars s3_backup_role)
44

55
PGO_CHART_VERSION = 5.7.4
66
EOAPI_CHART_VERSION = 0.7.1
@@ -34,4 +34,4 @@ init-eoapi:
3434
## deploy-eoapi: Upgrade or install eoAPI release
3535
deploy-eoapi:
3636
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=$(EOAPI_CHART_VERSION) --set postgrescluster.metadata.annotations.eks.amazonaws.com/role-arn=$(S3_BACKUP_ROLE)
37+
helm upgrade --install --namespace eoapi --create-namespace eoapi eoapi/eoapi --version $(EOAPI_CHART_VERSION) -f kubernetes/helm/eoapi-values.yaml --set previousVersion=$(EOAPI_CHART_VERSION) --set postgrescluster.metadata.annotations."eks\.amazonaws\.com/role-arn"=$(S3_BACKUP_ROLE)

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,30 @@ See the [inital proposal](docs/proposal.md) for more background.
1111

1212
#### Required Tools
1313

14-
[AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
15-
[OpenTofu](https://opentofu.org/docs/intro/install/)
16-
[kubectl](https://kubernetes.io/docs/tasks/tools/)
17-
[Helm](https://helm.sh/docs/intro/install/)
14+
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
15+
- [OpenTofu](https://opentofu.org/docs/intro/install/)
16+
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
17+
- [Helm](https://helm.sh/docs/intro/install/)
1818

19-
// TODO 🚧
19+
20+
### Areas for Further (Initial) Development
21+
22+
#### Variable Management
23+
24+
- Duplication exists between TF inputs, CI workflows, and local scripts.
25+
- A tool like https://github.com/helmfile/helmfile may help with sourcing variables by environment.
26+
- A basic version has been added to deploy revision deltas, further templating would be required.
27+
- As more HOT applications + services are moved to cluster, this will only grow.
28+
29+
#### Deployment
30+
31+
- Provisioning is currently done in the same workflow (TF, K8s, Helm), mostly as byproduct of initial development phase. Can be further refined.
32+
- GitOps tools like ArgoCD are [under consideration](https://github.com/hotosm/k8s-infra/issues/14)
33+
- Flux [Tofu controller](https://github.com/flux-iac/tofu-controller) may be an analog for base infrastructure (further investigation required).
34+
35+
#### Bridging TF and Kubernetes
36+
37+
- TF-managed information often needs to be referenced on the cluster
38+
- ex: PostgresCluster CRD requires the role ARN authorized for backups. Role and bucket are created in TF.
39+
- Global cluster resources are provisioned through TF, but argument can be made for their management by K8s.
40+
- Ideal solution enables cluster resources to reference, mount, inject, etc. TF-managed information with minimal developer intervention.

kubernetes/README.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Cluster Applications
2+
3+
See [initial migration outline](../proposal.md) for main HOT OSM applications.
4+
5+
Relevant Docs:
6+
- [kubectl]
7+
- [Helm]
8+
9+
## Global
10+
11+
### ClusterIssuer
12+
13+
Issue TLS certificates for the cluster via [cert-manager]. See also [eoAPI TLS section](#transport-layer-security-tls).
14+
15+
Install:
16+
```sh
17+
# ** See helm/eoapi-values.yaml for initial setup **
18+
$ kubectl apply -f kubernetes/manifests/cluster-issuer.yaml
19+
```
20+
21+
## eoAPI
22+
23+
Open source Earth Observation (EO) backend supporting Open Aerial Map (OAM).
24+
25+
Site: https://eoapi.dev/
26+
Chart: https://github.com/developmentseed/eoapi-k8s
27+
28+
Install:
29+
```sh
30+
$ helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo --version $PGO_VERSION
31+
$ helm repo add eoapi https://devseed.com/eoapi-k8s/
32+
$ helm upgrade --install --namespace eoapi --create-namespace eoapi eoapi/eoapi \
33+
--version $EOAPI_CHART_VERSION \
34+
-f kubernetes/helm/eoapi-values.yaml \
35+
--set previousVersion=$EOAPI_CHART_VERSION \
36+
--set postgrescluster.metadata.annotations."eks\.amazonaws\.com/role-arn"=$S3_BACKUP_ROLE
37+
```
38+
39+
#### helmfile
40+
41+
A basic [helmfile] has been added for GitHub Actions, but its recommended to use outside of CI workflows to maintain consistency.
42+
43+
```sh
44+
$ helmfile apply
45+
```
46+
47+
Provided the values match, a similar workflow can be achieved with the Makefile commands if the additional install isn't desired.
48+
49+
### Configuration
50+
51+
See [eoAPI chart docs]. The following sections provide a basic outline of overlays, customizations, and considerations specific to HOT's initial implementation.
52+
53+
#### Transport Layer Security (TLS)
54+
55+
See [cert-manager docs] and [eoAPI guidance on cert-manager setup].
56+
57+
- Requires a domain controlled by HOT
58+
- Issuer manifests and chart settings have been made available to provision certificates using [ingress annotations] and Let's Encrypt/[ACME]
59+
- Recommend going through staging issuer first to avoid hitting rate limits
60+
61+
#### Backups
62+
63+
Enabled with default settings, see the [PostgresOperator docs] for further customization.
64+
65+
Uses an [OIDC auth setup] to access S3, which requires propagating TF-managed information to K8s.
66+
67+
> [!NOTE]
68+
> Further development to bridge and/or reorganize TF and K8s-provisioned resources may remove the need to set a `role-arn` annotation on each release.
69+
70+
#### Monitoring / Observability / Autoscaling
71+
72+
The eoAPI support chart adds Prometheus and Grafana tooling to enable systems analysis, visualization, and custom metrics for autoscaling.
73+
74+
- [eoAPI support chart setup]: in-depth walkthrough
75+
- [eoAPI chart configuration]: set HPA behavior for services
76+
- [eoAPI support chart dependencies]: explore further customization, provider documentation
77+
78+
_Currently set to install once TLS is enabled in eoAPI._
79+
80+
## Tips + Commands
81+
82+
### Setup
83+
84+
#### Local Context
85+
86+
```sh
87+
$ aws eks update-kubeconfig --name <cluster_name>
88+
```
89+
90+
### Debugging
91+
92+
CLI manual will be most helpful:
93+
```sh
94+
$ kubectl --help
95+
```
96+
97+
#### Examples
98+
99+
Basic cluster overview:
100+
```sh
101+
$ kubectl get pod,svc,deploy -A
102+
```
103+
104+
Shell into default container on pod:
105+
```sh
106+
$ kubectl -n <ns> exec -it <pod> -- bash
107+
# $
108+
```
109+
110+
Inspect ingress details:
111+
```sh
112+
$ kubectl -n <ns> describe ingress/<ingress>
113+
```
114+
115+
Redirect pod log output to file:
116+
```sh
117+
$ kubectl -n <ns> logs <pod> --all-containers=true >> file.log
118+
```
119+
120+
[kubectl]:
121+
https://kubernetes.io/docs/reference/kubectl/
122+
[Helm]:
123+
https://helm.sh/docs/
124+
[Let's Encrypt]:
125+
https://letsencrypt.org/
126+
[cert-manager]:
127+
https://cert-manager.io/
128+
[cert-manager docs]:
129+
https://cert-manager.io/docs/configuration/
130+
[helmfile]:
131+
https://github.com/helmfile/helmfile
132+
[eoAPI chart docs]:
133+
https://github.com/developmentseed/eoapi-k8s/tree/975a26639fa3b8be7d3338220d6ea9c4470d8d15/docs
134+
[iframing]:
135+
https://developmentseed.slack.com/archives/C08B8L61QTT/p1747740182369159?thread_ts=1747314980.658339&cid=C08B8L61QTT
136+
[eoAPI guidance on cert-manager setup]:
137+
https://github.com/developmentseed/eoapi-k8s/blob/main/docs/unified-ingress.md#setting-up-tls-with-cert-manager
138+
[ingress annotations]:
139+
https://cert-manager.io/docs/usage/ingress/
140+
[ACME]:
141+
https://cert-manager.io/docs/configuration/acme/
142+
[PostgresOperator docs]:
143+
https://access.crunchydata.com/documentation/postgres-operator/latest/tutorials/backups-disaster-recovery/backups
144+
[OIDC auth setup]:
145+
https://access.crunchydata.com/documentation/postgres-operator/latest/tutorials/backups-disaster-recovery/backups#using-an-aws-integrated-identity-provider-and-role
146+
[eoAPI support chart setup]:
147+
https://github.com/developmentseed/eoapi-k8s/blob/975a26639fa3b8be7d3338220d6ea9c4470d8d15/docs/autoscaling.md
148+
[eoAPI chart configuration]:
149+
https://github.com/developmentseed/eoapi-k8s/blob/975a26639fa3b8be7d3338220d6ea9c4470d8d15/docs/configuration.md
150+
[eoAPI support chart dependencies]:
151+
https://github.com/developmentseed/eoapi-k8s/blob/975a26639fa3b8be7d3338220d6ea9c4470d8d15/helm-chart/eoapi-support/Chart.yaml
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
prometheus-adapter:
2+
prometheus:
3+
url: http://eoapi-support-prometheus-server.eoapi-support.svc.cluster.local
4+
5+
prometheus:
6+
server:
7+
service:
8+
type: ClusterIP
9+
annotations: { }
10+
ingress:
11+
annotations:
12+
nginx.ingress.kubernetes.io/auth-type: basic
13+
nginx.ingress.kubernetes.io/auth-secret: eoapi-support-prometheus
14+
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required'
15+
nginx.ingress.kubernetes.io/enable-cors: "true"
16+
nginx.ingress.kubernetes.io/enable-access-log: "true"
17+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
18+
enabled: true
19+
ingressClassName: nginx
20+
hosts:
21+
- metrics.k8s-prod.hotosm.org
22+
tls:
23+
- secretName: prometheus-server-tls
24+
hosts:
25+
- metrics.k8s-prod.hotosm.org
26+
persistentVolume:
27+
storageClass: gp2
28+
29+
grafana:
30+
service:
31+
type: ClusterIP
32+
annotations: { }
33+
ingress:
34+
annotations:
35+
nginx.ingress.kubernetes.io/enable-cors: "true"
36+
nginx.ingress.kubernetes.io/enable-access-log: "true"
37+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
38+
enabled: true
39+
ingressClassName: nginx
40+
hosts:
41+
- dashboard.k8s-prod.hotosm.org
42+
tls:
43+
- secretName: grafana-tls
44+
hosts:
45+
- dashboard.k8s-prod.hotosm.org
46+
datasources:
47+
datasources.yaml:
48+
datasources:
49+
- name: prometheus
50+
orgId: 1
51+
type: prometheus
52+
url: http://eoapi-support-prometheus-server.eoapi-support.svc.cluster.local
53+
access: proxy
54+
jsonData:
55+
timeInterval: "5s"
56+
isDefault: true
57+
editable: true
58+
version: 1 # This number should be increased when changes are made to update the datasource

0 commit comments

Comments
 (0)