From 54bb6345532d4e2af16ee82c88115b15027d9a0c Mon Sep 17 00:00:00 2001 From: Evan Jones Date: Thu, 18 Apr 2024 22:21:15 -0400 Subject: [PATCH] chore(cargo workspace): unifies crates as workspace Combines all rust crates under a single workspace to simplify management of rust packaging, with the exception of ebpf which needs independent tooling and packages to properly build. Author: Evan Jones --- {dataplane/.cargo => .cargo}/config.toml | 0 .dockerignore | 2 - .github/workflows/build.yaml | 10 +- .github/workflows/ci.yaml | 13 +- .gitignore | 3 + dataplane/Cargo.lock => Cargo.lock | 326 ++++++++++++------ Cargo.toml | 38 ++ Makefile | 111 ++++-- dataplane/.dockerignore | 3 - dataplane/Cargo.toml | 2 - dataplane/Makefile | 57 --- dataplane/api-server/Cargo.toml | 30 +- dataplane/common/Cargo.toml | 16 +- dataplane/ebpf/Cargo.lock | 2 +- dataplane/loader/Cargo.toml | 29 +- dataplane/xtask/Cargo.toml | 13 - Dockerfile => service.controlplane.Dockerfile | 0 ...Dockerfile => service.dataplane.Dockerfile | 27 +- service.udp_server.Dockerfile | 34 ++ tools/udp-test-server/.dockerignore | 2 - tools/udp-test-server/Cargo.toml | 6 +- tools/udp-test-server/Dockerfile | 29 -- tools/udp-test-server/Makefile | 18 - xtask/Cargo.toml | 15 + {dataplane/xtask => xtask}/src/build_ebpf.rs | 2 +- {dataplane/xtask => xtask}/src/build_proto.rs | 4 +- {dataplane/xtask => xtask}/src/grpc.rs | 0 {dataplane/xtask => xtask}/src/main.rs | 0 {dataplane/xtask => xtask}/src/run.rs | 0 29 files changed, 473 insertions(+), 319 deletions(-) rename {dataplane/.cargo => .cargo}/config.toml (100%) rename dataplane/Cargo.lock => Cargo.lock (84%) create mode 100644 Cargo.toml delete mode 100644 dataplane/.dockerignore delete mode 100644 dataplane/Cargo.toml delete mode 100644 dataplane/Makefile delete mode 100644 dataplane/xtask/Cargo.toml rename Dockerfile => service.controlplane.Dockerfile (100%) rename dataplane/Dockerfile => service.dataplane.Dockerfile (68%) create mode 100644 service.udp_server.Dockerfile delete mode 100644 tools/udp-test-server/.dockerignore delete mode 100644 tools/udp-test-server/Dockerfile delete mode 100644 tools/udp-test-server/Makefile create mode 100644 xtask/Cargo.toml rename {dataplane/xtask => xtask}/src/build_ebpf.rs (97%) rename {dataplane/xtask => xtask}/src/build_proto.rs (80%) rename {dataplane/xtask => xtask}/src/grpc.rs (100%) rename {dataplane/xtask => xtask}/src/main.rs (100%) rename {dataplane/xtask => xtask}/src/run.rs (100%) diff --git a/dataplane/.cargo/config.toml b/.cargo/config.toml similarity index 100% rename from dataplane/.cargo/config.toml rename to .cargo/config.toml diff --git a/.dockerignore b/.dockerignore index 6d31fb46..8eeb3001 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,8 +3,6 @@ .github/ bin/ testbin/ -dataplane/ -tools/ bin/ config/ *.md diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c8f0b25f..aaf1f663 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,16 +36,10 @@ jobs: # TODO: Once we migrate the controller from Go to Rust, # add the controller build step here. - - name: Build dataplane - working-directory: ./dataplane + - name: Build all rust crates (dataplane, test server) run: | - make build + make build.rust - - name: Build UDP Test Server - working-directory: ./tools/udp-test-server - run: | - make build - - name: Check formatting run: | make check.format.rust diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cc11685c..b0a99ceb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,7 +29,7 @@ jobs: id: control-plane-changed with: files: | - Dockerfile + service.controlplane.Dockerfile go.mod go.sum main.go @@ -40,12 +40,11 @@ jobs: id: dataplane-changed with: files: | - dataplane/Dockerfile + service.dataplane.Dockerfile dataplane/go.mod dataplane/go.sum dataplane/main.go dataplane/xdp.c - dataplane/Makefile dataplane/LICENCE - name: Check if any of the workflow files have changed uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f @@ -80,6 +79,7 @@ jobs: uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 with: context: . + file: service.controlplane.Dockerfile cache-from: type=gha cache-to: type=gha,mode=max tags: kubernetes-sigs/blixt-controlplane:pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} @@ -92,7 +92,8 @@ jobs: - name: Docker build - Dataplane uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 with: - context: dataplane + context: . + file: service.dataplane.Dockerfile cache-from: type=gha cache-to: type=gha,mode=max tags: kubernetes-sigs/blixt-dataplane:pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} @@ -130,6 +131,7 @@ jobs: uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 with: context: . + file: service.controlplane.Dockerfile push: false # TODO: https://github.com/kubernetes-sigs/blixt/issues/106 cache-from: type=gha cache-to: type=gha,mode=max @@ -137,7 +139,8 @@ jobs: - name: Docker build - Data Plane uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 with: - context: dataplane + context: . + file: service.dataplane.Dockerfile push: false # TODO: https://github.com/kubernetes-sigs/blixt/issues/106 cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index 6151d082..0ae4531e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ *.dylib bin/* +# xtask targets +target/ + # Test binary, built with `go test -c` *.test diff --git a/dataplane/Cargo.lock b/Cargo.lock similarity index 84% rename from dataplane/Cargo.lock rename to Cargo.lock index 854c7157..af5c9d58 100644 --- a/dataplane/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anstream" @@ -100,7 +100,7 @@ checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "api-server" -version = "0.1.0" +version = "0.3.0" dependencies = [ "anyhow", "aya", @@ -111,6 +111,7 @@ dependencies = [ "regex", "tokio", "tonic", + "tonic-build", "tonic-health", ] @@ -144,9 +145,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -280,6 +281,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "bitflags" version = "1.3.2" @@ -300,9 +307,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -338,7 +345,7 @@ version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn", @@ -358,7 +365,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "common" -version = "0.1.0" +version = "0.3.0" dependencies = [ "aya", ] @@ -374,9 +381,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "env_filter" @@ -385,7 +392,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ "log", - "regex", ] [[package]] @@ -394,10 +400,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ - "anstream", - "anstyle", "env_filter", - "humantime", "log", ] @@ -476,9 +479,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -526,12 +529,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -544,15 +541,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.12" @@ -587,12 +575,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.28" @@ -651,9 +633,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -684,7 +666,7 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "loader" -version = "0.1.0" +version = "0.3.0" dependencies = [ "anyhow", "api-server", @@ -697,6 +679,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.21" @@ -743,9 +735,9 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "num_cpus" @@ -792,6 +784,29 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -830,9 +845,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -877,12 +892,12 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" dependencies = [ "bytes", - "heck 0.4.1", + "heck", "itertools", "log", "multimap", @@ -894,7 +909,6 @@ dependencies = [ "regex", "syn", "tempfile", - "which", ] [[package]] @@ -912,18 +926,18 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ "prost", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -958,6 +972,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "regex" version = "1.10.4" @@ -987,6 +1010,21 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1006,11 +1044,58 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.0", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" @@ -1050,6 +1135,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" version = "0.5.6" @@ -1060,17 +1151,29 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1126,6 +1229,7 @@ dependencies = [ "libc", "mio", "num_cpus", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -1154,6 +1258,17 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -1188,7 +1303,7 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64", + "base64 0.21.7", "bytes", "h2", "http", @@ -1198,7 +1313,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost", + "rustls-pemfile", + "rustls-pki-types", "tokio", + "tokio-rustls", "tokio-stream", "tower", "tower-layer", @@ -1301,12 +1419,25 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "udp-test-server" +version = "0.3.0" +dependencies = [ + "tokio", +] + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "utf8parse" version = "0.2.1" @@ -1334,18 +1465,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1361,7 +1480,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -1381,17 +1500,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -1402,9 +1522,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -1414,9 +1534,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -1426,9 +1546,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -1438,9 +1564,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -1450,9 +1576,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -1462,9 +1588,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -1474,13 +1600,13 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "xtask" -version = "0.1.0" +version = "0.3.0" dependencies = [ "anyhow", "api-server", @@ -1510,3 +1636,9 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..676d093f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,38 @@ +[workspace] +members = [ + "dataplane/api-server", + "dataplane/common", + "dataplane/loader", + "tools/udp-test-server", + "xtask", +] + +[workspace.package] +edition = "2021" +license = "Apache-2.0" +repository = "https://github.com/kubernetes-sigs/blixt" +version = "0.3.0" + +[workspace.dependencies] +anyhow = { version = "1", default-features = false } +api-server = { version = "0.3.0", path = "./dataplane/api-server" } +aya = { version = "0.12.0", default-features = false } +aya-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false } +aya-log = { version = "0.2.0", default-features = false } +aya-log-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false } +clap = { version = "4.4", default-features = true } +common = { version = "0.3.0", path = "./dataplane/common" } +env_logger = { version = "0.11", default-features = false } +libc = { version = "0.2", default-features = false } +loader = { version = "0.3.0", path = "./dataplane/loader" } +log = { version = "0.4", default-features = false } +memoffset = { version = "0.9", default-features = false } +network-types = { version = "0.0.5", default-features = false } +prost = { version = "0.12.4", default-features = false } +regex = { version = "1", default-features = true } +tokio = { version = "1.32.0", default-features = false } +tonic = { version = "0.11.0", default-features = false } +tonic-build = { version = "0.11.0", default-features = false } +tonic-health = { version = "0.11.0", default-features = false } +udp-test-server = { version = "0.3.0", path = "./tools/udp-test-server" } +xtask = { version = "0.3.0", path = "./dataplane/xtask" } diff --git a/Makefile b/Makefile index 68c61403..00f35b2a 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ BLIXT_CONTROLPLANE_IMAGE ?= ghcr.io/kubernetes-sigs/blixt-controlplane BLIXT_DATAPLANE_IMAGE ?= ghcr.io/kubernetes-sigs/blixt-dataplane BLIXT_UDP_SERVER_IMAGE ?= ghcr.io/kubernetes-sigs/blixt-udp-test-server +# Dockerfile paths for each service +CONTROLPLANE_DOCKERFILE ?= service.controlplane.Dockerfile +DATAPLANE_DOCKERFILE ?= service.dataplane.Dockerfile +UDP_SERVER_DOCKERFILE ?= service.udp_server.Dockerfile + # Other testing variables EXISTING_CLUSTER ?= @@ -15,6 +20,7 @@ BUILD_PLATFORMS ?= linux/amd64 endif BUILD_ARGS ?= --load + # VERSION defines the project version for the bundle. # Update this value when you upgrade the version of your project. # To re-generate a bundle for another specific version without changing the standard setup, you can: @@ -127,35 +133,24 @@ vet: ## Run go vet against code. go vet ./... .PHONY: lint -lint: +lint: ## Lint go code golangci-lint run -.PHONY: check.format.rust.helper -check.format.rust.helper: - @echo "Checking formatting $(DIRECTORY)..." - cargo fmt --manifest-path $(DIRECTORY)/Cargo.toml --all -- --check - -.PHONY: fix.format.rust.helper -fix.format.rust.helper: - @echo "Fixing formatting $(DIRECTORY)..." - cargo fmt --manifest-path $(DIRECTORY)/Cargo.toml --all +.PHONY: clean +clean: ## Cargo clean + cargo clean .PHONY: fix.format.rust -fix.format.rust: - @find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) fix.format.rust.helper DIRECTORY={} +fix.format.rust: ## Autofix rust code formatting + cargo fmt --manifest-path Cargo.toml --all .PHONY: check.format.rust -check.format.rust: - @find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) check.format.rust.helper DIRECTORY={} - -.PHONY: lint.rust.helper -lint.rust.helper: - @echo "Linting $(DIRECTORY)..." - @cd $(DIRECTORY) && cargo clippy --all -- -D warnings +check.format.rust: ## Check rust code formatting + cargo fmt --manifest-path Cargo.toml --all -- --check .PHONY: lint.rust -lint.rust: - @find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) lint.rust.helper DIRECTORY={} +lint.rust: ## Lint rust code + cargo clippy --all -- -D warnings .PHONY: test test: manifests generate fmt vet envtest ## Run tests. @@ -206,26 +201,67 @@ debug.conformance: manifests generate fmt vet ##@ Build -.PHONY: build -build: generate fmt vet ## Build manager binary. +.PHONY: build.go +build.go: generate fmt vet ## Build manager binary. go build -o bin/manager main.go -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. +.PHONY: build.rust +build.rust: ## Build dataplane + cargo xtask build-ebpf + cargo build + +.PHONY: build.rust.release +build.rust.release: ## Build dataplane release + cargo xtask build-ebpf --release + cargo build --release + +.PHONY: run.go +run.go: manifests generate fmt vet ## Run a controller from your host. go run ./main.go -.PHONY: debug -debug: manifests generate fmt vet ## Run a controller from your host via debugger. +.PHONY: debug.go +debug.go: manifests generate fmt vet ## Run a controller from your host via debugger. dlv debug ./main.go -.PHONY: build.image -build.image: - DOCKER_BUILDKIT=1 docker buildx build --platform=$(BUILD_PLATFORMS) $(BUILD_ARGS) -t $(BLIXT_CONTROLPLANE_IMAGE):$(TAG) . +.PHONY: build.image.controlplane +build.image.controlplane: + DOCKER_BUILDKIT=1 docker buildx build --platform=$(BUILD_PLATFORMS) --file=$(CONTROLPLANE_DOCKERFILE) $(BUILD_ARGS) -t $(BLIXT_CONTROLPLANE_IMAGE):$(TAG) . + +.PHONY: build.image.udp_server +build.image.udp_server: + DOCKER_BUILDKIT=1 docker buildx build --platform=$(BUILD_PLATFORMS) --file=$(UDP_SERVER_DOCKERFILE) -t $(BLIXT_UDP_SERVER_IMAGE):$(TAG) . + +.PHONY: build.image.dataplane +build.image.dataplane: + DOCKER_BUILDKIT=1 docker buildx build --platform $(BUILD_PLATFORMS) $(BUILD_ARGS) --file=$(DATAPLANE_DOCKERFILE) -t $(BLIXT_DATAPLANE_IMAGE):$(TAG) ./ .PHONY: build.all.images -build.all.images: build.image - cd dataplane/ && make build.image TAG=$(TAG) - cd tools/udp-test-server && make build.image TAG=$(TAG) +build.all.images: + $(MAKE) build.image.controlplane + $(MAKE) build.image.dataplane + $(MAKE) build.image.udp_server + +.PHONY: build.bytecode.images +build.bytecode.images: build + docker build \ + --build-arg PROGRAM_NAME=blixt-tc-ingress \ + --build-arg BPF_FUNCTION_NAME=tc_ingress \ + --build-arg PROGRAM_TYPE=tc \ + --build-arg BYTECODE_FILENAME=loader \ + -f https://raw.githubusercontent.com/bpfd-dev/bpfd/main/packaging/container-deployment/Containerfile.bytecode \ + ./target/bpfel-unknown-none/debug -t quay.io/bpfd-bytecode/blixt-tc-ingress:latest + docker build \ + --build-arg PROGRAM_NAME=blixt-tc-egress \ + --build-arg BPF_FUNCTION_NAME=tc_egress \ + --build-arg PROGRAM_TYPE=tc \ + --build-arg BYTECODE_FILENAME=loader \ + -f https://raw.githubusercontent.com/bpfd-dev/bpfd/main/packaging/container-deployment/Containerfile.bytecode \ + ./target/bpfel-unknown-none/debug -t quay.io/bpfd-bytecode/blixt-tc-egress:latest + +.PHONY: push.bytecode.images +push.bytecode.images: build.bytecode.images + docker push quay.io/bpfd-bytecode/blixt-tc-egress:latest + docker push quay.io/bpfd-bytecode/blixt-tc-ingress:latest ##@ Deployment @@ -361,12 +397,17 @@ KIND_CLUSTER ?= blixt-dev build.cluster: $(KTF) # builds a KIND cluster which can be used for testing and development PATH="$(LOCALBIN):${PATH}" $(KTF) env create --name $(KIND_CLUSTER) --addon metallb -.PHONY: load.image -load.image: build.image +.PHONY: load.image.controlplane +load.image.controlplane: build.image.controlplane kind load docker-image $(BLIXT_CONTROLPLANE_IMAGE):$(TAG) --name $(KIND_CLUSTER) && \ kubectl -n blixt-system get deployment blixt-controlplane >/dev/null 2>&1 && \ kubectl -n blixt-system rollout restart deployment blixt-controlplane || true +.PHONY: load.image.dataplane +load.image.dataplane: build.image.dataplane + kind load docker-image $(IMAGE):$(TAG) --name $(KIND_CLUSTER) && \ + kubectl -n blixt-system rollout restart daemonset blixt-dataplane + .PHONY: load.all.images load.all.images: build.all.images kind load docker-image $(BLIXT_CONTROLPLANE_IMAGE):$(TAG) --name $(KIND_CLUSTER) && \ diff --git a/dataplane/.dockerignore b/dataplane/.dockerignore deleted file mode 100644 index 91e25c5d..00000000 --- a/dataplane/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -.vim/ -target/ -*.md diff --git a/dataplane/Cargo.toml b/dataplane/Cargo.toml deleted file mode 100644 index c15780a1..00000000 --- a/dataplane/Cargo.toml +++ /dev/null @@ -1,2 +0,0 @@ -[workspace] -members = ["api-server", "loader", "common", "xtask"] diff --git a/dataplane/Makefile b/dataplane/Makefile deleted file mode 100644 index 6b76d06f..00000000 --- a/dataplane/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -IMAGE ?= ghcr.io/kubernetes-sigs/blixt-dataplane -TAG ?= latest -KIND_CLUSTER ?= blixt-dev - -ifeq ($(shell uname -m),arm64) -BUILD_PLATFORMS ?= linux/arm64 -else -BUILD_PLATFORMS ?= linux/amd64 -endif -BUILD_ARGS ?= --load - -all: build - -.PHONY: -clean: - cargo clean - -.PHONY: build -build: - cargo xtask build-ebpf - cargo build - -.PHONY: build.release -build.release: - cargo xtask build-ebpf --release - cargo build --release - -.PHONY: build.image -build.image: - DOCKER_BUILDKIT=1 docker buildx build --platform $(BUILD_PLATFORMS) $(BUILD_ARGS) -t $(IMAGE):$(TAG) ./ - -.PHONY: load.image -load.image: build.image - kind load docker-image $(IMAGE):$(TAG) --name $(KIND_CLUSTER) && \ - kubectl -n blixt-system rollout restart daemonset blixt-dataplane - -.PHONY: build.bytecode.images -build.bytecode.images: build - docker build \ - --build-arg PROGRAM_NAME=blixt-tc-ingress \ - --build-arg BPF_FUNCTION_NAME=tc_ingress \ - --build-arg PROGRAM_TYPE=tc \ - --build-arg BYTECODE_FILENAME=loader \ - -f https://raw.githubusercontent.com/bpfd-dev/bpfd/main/packaging/container-deployment/Containerfile.bytecode \ - ./target/bpfel-unknown-none/debug -t quay.io/bpfd-bytecode/blixt-tc-ingress:latest - docker build \ - --build-arg PROGRAM_NAME=blixt-tc-egress \ - --build-arg BPF_FUNCTION_NAME=tc_egress \ - --build-arg PROGRAM_TYPE=tc \ - --build-arg BYTECODE_FILENAME=loader \ - -f https://raw.githubusercontent.com/bpfd-dev/bpfd/main/packaging/container-deployment/Containerfile.bytecode \ - ./target/bpfel-unknown-none/debug -t quay.io/bpfd-bytecode/blixt-tc-egress:latest - -.PHONY: push.bytecode.images -push.bytecode.images: build.bytecode.images - docker push quay.io/bpfd-bytecode/blixt-tc-egress:latest - docker push quay.io/bpfd-bytecode/blixt-tc-ingress:latest diff --git a/dataplane/api-server/Cargo.toml b/dataplane/api-server/Cargo.toml index 6377edd9..637983ac 100644 --- a/dataplane/api-server/Cargo.toml +++ b/dataplane/api-server/Cargo.toml @@ -1,17 +1,21 @@ [package] name = "api-server" -version = "0.1.0" -edition = "2021" -publish = false +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true [dependencies] -prost = "0.12.4" -tonic = "0.11.0" -tonic-health = "0.11.0" -anyhow = "1" -log = "0.4" -aya = { version = "0.12.0", features=["async_tokio"] } -tokio = { version = "1.32", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } -common = { path = "../common", features=["user"] } -regex = "1" -libc = "0.2" +anyhow = { workspace = true } +aya = { workspace = true, features = ["async_tokio"] } +common = { workspace = true, features = ["user"] } +libc = { workspace = true } +log = { workspace = true } +prost = { workspace = true } +regex = { workspace = true } +tokio = { workspace = true , features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } +tonic = { workspace = true, features = ["tls"] } +tonic-health = { workspace = true } + +[build-dependencies] +tonic-build = { workspace = true } diff --git a/dataplane/common/Cargo.toml b/dataplane/common/Cargo.toml index ce23a473..0ec5ff04 100644 --- a/dataplane/common/Cargo.toml +++ b/dataplane/common/Cargo.toml @@ -1,15 +1,17 @@ [package] name = "common" -version = "0.1.0" -edition = "2021" -publish = false +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true + +[lib] +name = "common" +path = "src/lib.rs" [features] default = [] user = [ "aya" ] [dependencies] -aya = { version = ">=0.11", optional=true } - -[lib] -path = "src/lib.rs" +aya = { workspace = true, optional=true } diff --git a/dataplane/ebpf/Cargo.lock b/dataplane/ebpf/Cargo.lock index f40a2c86..426702df 100644 --- a/dataplane/ebpf/Cargo.lock +++ b/dataplane/ebpf/Cargo.lock @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "common" -version = "0.1.0" +version = "0.3.0" [[package]] name = "ebpf" diff --git a/dataplane/loader/Cargo.toml b/dataplane/loader/Cargo.toml index 8cf77de9..08b856a1 100644 --- a/dataplane/loader/Cargo.toml +++ b/dataplane/loader/Cargo.toml @@ -1,20 +1,21 @@ [package] name = "loader" -version = "0.1.0" -edition = "2021" -publish = false - -[dependencies] -aya = { version = "0.12.0", features=["async_tokio"] } -aya-log = "0.2.0" -common = { path = "../common", features=["user"] } -clap = { version = "4.4", features = ["derive"] } -env_logger = "0.11" -log = "0.4" -tokio = { version = "1.32.0", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } -api-server = { path = "../api-server" } -anyhow = "1" +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true [[bin]] name = "loader" path = "src/main.rs" + +[dependencies] +anyhow = { workspace = true } +api-server = { workspace = true } +aya = { workspace = true , features=["async_tokio"] } +aya-log = { workspace = true } +common = { workspace = true, features=["user"] } +clap = { workspace = true, features = ["derive"] } +env_logger = { workspace = true } +log = { workspace = true } +tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } diff --git a/dataplane/xtask/Cargo.toml b/dataplane/xtask/Cargo.toml deleted file mode 100644 index 06dfe83a..00000000 --- a/dataplane/xtask/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "xtask" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1" -clap = { version = "4.4", features = ["derive"] } -prost = "0.12.4" -tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] } -tonic = "0.11.0" -api-server = { path = "../api-server" } -tonic-build = "0.11.0" diff --git a/Dockerfile b/service.controlplane.Dockerfile similarity index 100% rename from Dockerfile rename to service.controlplane.Dockerfile diff --git a/dataplane/Dockerfile b/service.dataplane.Dockerfile similarity index 68% rename from dataplane/Dockerfile rename to service.dataplane.Dockerfile index 53953a61..cbf1c1d7 100644 --- a/dataplane/Dockerfile +++ b/service.dataplane.Dockerfile @@ -3,7 +3,12 @@ FROM rust:1.75-slim-bookworm as builder ARG TARGETARCH RUN apt-get update -RUN apt-get install --yes build-essential protobuf-compiler pkg-config llvm-16 +RUN apt-get install --yes \ + build-essential \ + protobuf-compiler \ + pkg-config \ + llvm-16 \ + musl-tools RUN rustup default stable RUN rustup install nightly @@ -21,7 +26,11 @@ RUN if [ "$TARGETARCH" = "amd64" ]; \ fi RUN rustup target add $(eval cat arch)-unknown-linux-musl -COPY . . +COPY dataplane dataplane +COPY tools/udp-test-server tools/udp-test-server +COPY xtask xtask +COPY Cargo.toml Cargo.toml +COPY .cargo .cargo # We need to tell bpf-linker where it can find LLVM's shared library file. # Ref: https://github.com/aya-rs/rustc-llvm-proxy/blob/cbcb3c6/src/lib.rs#L48 @@ -32,9 +41,13 @@ RUN --mount=type=cache,target=/workspace/target/ \ cargo xtask build-ebpf --release RUN --mount=type=cache,target=/workspace/target/ \ --mount=type=cache,target=/root/.cargo/registry \ - RUSTFLAGS=-Ctarget-feature=+crt-static cargo build --release --target=$(eval cat arch)-unknown-linux-musl + RUSTFLAGS=-Ctarget-feature=+crt-static cargo build \ + --workspace \ + --exclude ebpf \ + --release \ + --target=$(eval cat arch)-unknown-linux-musl RUN --mount=type=cache,target=/workspace/target/ \ - cp /workspace/target/$(eval cat arch)-unknown-linux-musl/release/loader /workspace/dataplane + cp /workspace/target/$(eval cat arch)-unknown-linux-musl/release/loader /workspace/dataplane-release FROM alpine @@ -43,9 +56,9 @@ LABEL org.opencontainers.image.licenses=GPL-2.0-only,BSD-2-Clause WORKDIR /opt/blixt/ -COPY --from=builder /workspace/dataplane /opt/blixt/dataplane +COPY --from=builder /workspace/dataplane-release /opt/blixt/dataplane -COPY LICENSE.GPL-2.0 /opt/blixt/LICENSE.GPL-2.0 -COPY LICENSE.BSD-2-Clause /opt/blixt/LICENSE.BSD-2-Clause +COPY dataplane/LICENSE.GPL-2.0 /opt/blixt/LICENSE.GPL-2.0 +COPY dataplane/LICENSE.BSD-2-Clause /opt/blixt/LICENSE.BSD-2-Clause ENTRYPOINT ["/opt/blixt/dataplane"] diff --git a/service.udp_server.Dockerfile b/service.udp_server.Dockerfile new file mode 100644 index 00000000..54292116 --- /dev/null +++ b/service.udp_server.Dockerfile @@ -0,0 +1,34 @@ +FROM rust as builder + +RUN apt-get update && \ + apt-get install musl-tools -yq && \ + rustup target add x86_64-unknown-linux-musl + +WORKDIR /workspace + +COPY Cargo.toml Cargo.lock ./ +COPY dataplane dataplane +COPY tools/udp-test-server/Cargo.toml tools/udp-test-server/Cargo.toml +COPY tools/udp-test-server/Cargo.lock tools/udp-test-server/Cargo.lock +COPY tools/udp-test-server/src/main.rs tools/udp-test-server/src/main.rs +COPY xtask xtask + +RUN --mount=type=cache,target=/workspace/target/ \ + --mount=type=cache,target=/usr/local/cargo/registry/ \ + RUSTFLAGS=-Ctarget-feature=+crt-static cargo build \ + --package=udp-test-server \ + --release \ + --target=x86_64-unknown-linux-musl + +RUN --mount=type=cache,target=/workspace/target/ \ + cp /workspace/target/x86_64-unknown-linux-musl/release/udp-test-server /workspace/udp-test-server + +FROM alpine + +LABEL org.opencontainers.image.source https://github.com/kubernetes-sigs/blixt + +WORKDIR / + +COPY --from=builder /workspace/udp-test-server /udp-test-server + +ENTRYPOINT ["/udp-test-server"] diff --git a/tools/udp-test-server/.dockerignore b/tools/udp-test-server/.dockerignore deleted file mode 100644 index e52e93f5..00000000 --- a/tools/udp-test-server/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -*.md diff --git a/tools/udp-test-server/Cargo.toml b/tools/udp-test-server/Cargo.toml index 0da74d76..9ab8e5dd 100644 --- a/tools/udp-test-server/Cargo.toml +++ b/tools/udp-test-server/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "udp-test-server" -version = "0.1.0" -edition = "2021" +edition.workspace = true +version.workspace = true publish = false [dependencies] -tokio = { version = "1", features = ["full"] } +tokio = { workspace = true, features = ["full"] } diff --git a/tools/udp-test-server/Dockerfile b/tools/udp-test-server/Dockerfile deleted file mode 100644 index 65113536..00000000 --- a/tools/udp-test-server/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM rust as builder - -RUN apt-get update -RUN apt-get install musl-tools -yq - -RUN rustup target add x86_64-unknown-linux-musl - -WORKDIR /workspace - -COPY Cargo.toml Cargo.toml -COPY Cargo.lock Cargo.lock -COPY src/main.rs src/main.rs - -RUN --mount=type=cache,target=/workspace/target/ \ - --mount=type=cache,target=/usr/local/cargo/registry/ \ - RUSTFLAGS=-Ctarget-feature=+crt-static cargo build --release --target=x86_64-unknown-linux-musl - -RUN --mount=type=cache,target=/workspace/target/ \ - cp /workspace/target/x86_64-unknown-linux-musl/release/udp-test-server /workspace/udp-test-server - -FROM alpine - -LABEL org.opencontainers.image.source https://github.com/kubernetes-sigs/blixt - -WORKDIR / - -COPY --from=builder /workspace/udp-test-server /udp-test-server - -ENTRYPOINT ["/udp-test-server"] diff --git a/tools/udp-test-server/Makefile b/tools/udp-test-server/Makefile deleted file mode 100644 index ab32cb5d..00000000 --- a/tools/udp-test-server/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -IMAGE ?= ghcr.io/kubernetes-sigs/blixt-udp-test-server -TAG ?= latest - -.PHONY: -clean: - cargo clean - -.PHONY: build -build: - cargo build - -.PHONY: build.image -build.image: - DOCKER_BUILDKIT=1 docker build -t $(IMAGE):$(TAG) ./ - -.PHONY: push.image -push.image: build.image - docker push $(IMAGE):$(TAG) diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 00000000..d5cd8a58 --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "xtask" +edition.workspace = true +license.workspace = true +repository.workspace = true +version.workspace = true + +[dependencies] +api-server = { workspace = true } +anyhow = { workspace = true } +clap = { workspace = true, features = ["derive"] } +prost = { workspace = true } +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tonic = { workspace = true } +tonic-build = { workspace = true, features = ["prost"] } diff --git a/dataplane/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs similarity index 97% rename from dataplane/xtask/src/build_ebpf.rs rename to xtask/src/build_ebpf.rs index f4af73cc..ed852f25 100644 --- a/dataplane/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -45,7 +45,7 @@ pub struct Options { } pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { - let dir = PathBuf::from("ebpf"); + let dir = PathBuf::from("dataplane/ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ "+nightly", diff --git a/dataplane/xtask/src/build_proto.rs b/xtask/src/build_proto.rs similarity index 80% rename from dataplane/xtask/src/build_proto.rs rename to xtask/src/build_proto.rs index 89ccb9b6..f0fc4fb5 100644 --- a/dataplane/xtask/src/build_proto.rs +++ b/xtask/src/build_proto.rs @@ -10,14 +10,14 @@ use clap::Parser; pub struct Options {} pub(crate) fn build_proto(_opts: Options) -> Result<(), anyhow::Error> { - let proto_file = "./api-server/proto/backends.proto"; + let proto_file = "./dataplane/api-server/proto/backends.proto"; println!("building proto {}", proto_file); tonic_build::configure() .protoc_arg("--experimental_allow_proto3_optional") .build_server(true) - .out_dir("./api-server/src") + .out_dir("./dataplane/api-server/src") .compile(&[proto_file], &["."])?; Ok(()) diff --git a/dataplane/xtask/src/grpc.rs b/xtask/src/grpc.rs similarity index 100% rename from dataplane/xtask/src/grpc.rs rename to xtask/src/grpc.rs diff --git a/dataplane/xtask/src/main.rs b/xtask/src/main.rs similarity index 100% rename from dataplane/xtask/src/main.rs rename to xtask/src/main.rs diff --git a/dataplane/xtask/src/run.rs b/xtask/src/run.rs similarity index 100% rename from dataplane/xtask/src/run.rs rename to xtask/src/run.rs