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: proxy http requests to downstream pods #11

Merged
merged 48 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4088c73
working deployment of pods
MicaiahReid May 16, 2023
a8e34fa
use internal ports
MicaiahReid May 16, 2023
f881e21
cleanup, use config struct, create server
MicaiahReid May 17, 2023
46995ab
add templates for pods/configmaps/services
MicaiahReid May 17, 2023
262af78
use template yaml rather than json for deployments
MicaiahReid May 17, 2023
e69c272
add missed template yaml
MicaiahReid May 18, 2023
2407988
add route to delete deployment
MicaiahReid May 18, 2023
abf2e17
make services nodeport type
MicaiahReid May 19, 2023
81ef8c4
rename var
MicaiahReid May 19, 2023
1f6d98d
fix error handling on deletion
MicaiahReid May 19, 2023
fc24c8a
deploy configmaps for chain coordinator
MicaiahReid May 19, 2023
02f5062
yaml for cluster config
MicaiahReid May 19, 2023
915e594
add user/password to devnet config
MicaiahReid May 30, 2023
9dd2936
remove mounts from kind.yaml
MicaiahReid May 30, 2023
fbe70bf
helpful scripts
MicaiahReid May 30, 2023
7e3d621
gitignore
MicaiahReid May 30, 2023
3e4e78b
rename file
MicaiahReid May 30, 2023
472a28e
provide example json
MicaiahReid May 30, 2023
c363f9d
initial pass at readme
MicaiahReid May 30, 2023
c408d9f
add some metatdata to cargo.toml
MicaiahReid May 30, 2023
104eb8d
add license
MicaiahReid May 30, 2023
5bc68fb
update readme
MicaiahReid May 31, 2023
3c28e14
add todo
MicaiahReid May 31, 2023
ffb4410
rename package import
MicaiahReid May 31, 2023
e715b46
Apply suggestions from code review
MicaiahReid Jun 1, 2023
409a6d6
add module to parse template files
MicaiahReid Jun 1, 2023
74f1004
use new template file parser
MicaiahReid Jun 1, 2023
e687519
set context on automated kubectl command
MicaiahReid Jun 1, 2023
d27fd5c
Switch to ApacheV2 license
MicaiahReid Jun 1, 2023
c619bd1
convert consts to i32
MicaiahReid Jun 1, 2023
3600770
add error handling for resource creation/deletion
MicaiahReid Jun 1, 2023
3866a64
add context to kubectl commands
MicaiahReid Jun 2, 2023
982175e
set up proxy server
MicaiahReid Jun 2, 2023
4dfd1fc
bind server to 0.0.0.0
MicaiahReid Jun 5, 2023
06d0038
create k8s manager struct
MicaiahReid Jun 7, 2023
0e4823c
add proxy routing to downstream pods
MicaiahReid Jun 7, 2023
c60fa30
add tests
MicaiahReid Jun 7, 2023
3c9d6d6
deps updatee
MicaiahReid Jun 7, 2023
1761fbd
remove NodePort type from services
MicaiahReid Jun 7, 2023
ddfe03f
create template to deploy devnet-api-server to k8s
MicaiahReid Jun 7, 2023
e572b48
docker file for devnet api
MicaiahReid Jun 7, 2023
f629c18
update port for stacks-devnet-api service
MicaiahReid Jun 7, 2023
285dc0d
use deployed pods!
MicaiahReid Jun 7, 2023
cc15a43
Merge branch 'main' into http-proxy
MicaiahReid Jun 7, 2023
0ef407b
use Always imagePullPolicy for newer images
MicaiahReid Jun 7, 2023
6bc424f
build docker image in release mode
MicaiahReid Jun 8, 2023
3d480a0
remove sleep!
MicaiahReid Jun 8, 2023
3f1b47b
add back sleep :(
MicaiahReid Jun 8, 2023
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/target/
MicaiahReid marked this conversation as resolved.
Show resolved Hide resolved
/examples/
/dockerfiles/
/Dockerfile
/.dockerignore
/.git*
/scripts/
/logs/

163 changes: 78 additions & 85 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ tokio = { version = "1.27.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.96"
serde_yaml = "0.9.21"
toml = "0.7.3"
tiny_http = "0.12.0"
url = "2.3.1"
serde_qs = "0.12.0"
hyper = { version = "0.14", features = ["full"] }
tower = "0.4.13"
http-body = "0.4.5"
MicaiahReid marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
tower-test = "0.4.0"
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM arm64v8/rust:1.67 as builder

WORKDIR ./
COPY . ./

RUN cargo build --release --manifest-path ./Cargo.toml

FROM gcr.io/distroless/cc
MicaiahReid marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=builder target/release/stacks-devnet-api /

ENTRYPOINT ["./stacks-devnet-api"]
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ cargo run
to start the server. Currently, the server is hosted on `localhost:8477` and exposes two routes:
- `POST localhost:8477/api/v1/networks` - Creates a new devnet with configuration provided in request body. See [this example](./examples/new-network.example.json) object for the required parameters.
- `DELETE localhost:8477/api/v1/network?network={namespace}` - Deletes all k8s assets deployed under the given namespace.

### Notes
This project is still very eary in development and the code is fragile and will change a lot. Some known issues:
- if a k8s deployment fails, the app crashes. K8s deployments fail for a lot of reasons, so you'll need to restart the service a lot.
- the project relies on a docker image called `stacks-network`, which is not yet deployed to docker hub. This is in progress.
1 change: 0 additions & 1 deletion scripts/kind-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
kind create cluster --config=./templates/initial-config/kind.yaml && \
docker pull hirosystems/stacks-blockchain-api:latest --platform=linux/amd64 && \
kind load docker-image hirosystems/stacks-blockchain-api && \
kind load docker-image stacks-network && \
kubectl --context kind-kind apply -f https://openebs.github.io/charts/openebs-operator.yaml && \
kubectl --context kind-kind apply -f ./templates/initial-config/storage-class.yaml
Loading