Skip to content

Commit 453763b

Browse files
authored
Merge pull request #4 from commitdev/add-status-about-endpoint
Add status/about endpoint for frontend to hit
2 parents 20733af + c6aa6bb commit 453763b

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

.circleci/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
### Requirements
66

77
Requires you to configure the below [CircleCI Environment Variables](https://circleci.com/docs/2.0/env-vars/):
8+
To get your ECR repositories and EKS clusters:
9+
```shell
10+
$ aws ecr describe-repositories --query "repositories[].repositoryUri"
11+
$ aws eks list-clusters --query "clusters"
12+
```
813

14+
- AWS_ACCESS_KEY_ID # AWS access key for the circleci user - this should be in AWS secret manager
15+
- AWS_SECRET_ACCESS_KEY # AWS secret for the circleci user - this should be in AWS secret manager
916
- AWS_DEFAULT_REGION # Region of your cluster
1017
- AWS_ECR_ACCOUNT_URL # {awsAccountNum}.dkr.ecr.{region}.amazonaws.com
1118
- AWS_ECR_REPO_NAME # The ECR repository name to write images to

kubernetes/base/deployment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ spec:
3737
- configMapRef:
3838
name: <% .Name %>-config
3939
env:
40+
- name: POD_NAME
41+
valueFrom:
42+
fieldRef:
43+
fieldPath: metadata.name
4044
- name: DATABASE_USERNAME
4145
valueFrom:
4246
secretKeyRef:

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"html"
78
"log"
@@ -21,6 +22,17 @@ func main() {
2122
r := http.NewServeMux()
2223
r.HandleFunc("/status/ready", readinessCheckEndpoint)
2324

25+
// Something for the example frontend to hit
26+
r.HandleFunc("/status/about", func(w http.ResponseWriter, r *http.Request) {
27+
response, err := json.Marshal(map[string]string{"podName": os.Getenv("POD_NAME")})
28+
if err == nil {
29+
w.Header().Set("Content-Type", "application/json")
30+
w.Write(response)
31+
} else {
32+
http.Error(w, err.Error(), http.StatusInternalServerError)
33+
}
34+
})
35+
2436
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
2537
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
2638
})

0 commit comments

Comments
 (0)