Skip to content

Commit

Permalink
Split repo into workspace (#95)
Browse files Browse the repository at this point in the history
We convert this project into a Rust workspace and move the failover controller into a member.  This is to prepare for adding the CLI as a separate member from the controller.

Co-authored-by: Eliza Weisman <[email protected]>
  • Loading branch information
adleong and hawkw authored Mar 9, 2022
1 parent 3966837 commit 65d9ce4
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"

[[package]]
name = "linkerd-failover"
name = "linkerd-failover-controller"
version = "0.1.0"
dependencies = [
"anyhow",
Expand Down Expand Up @@ -1094,9 +1094,9 @@ dependencies = [

[[package]]
name = "regex"
version = "1.5.4"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"regex-syntax",
]
Expand Down
46 changes: 3 additions & 43 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,4 @@
[package]
name = "linkerd-failover"
version = "0.1.0"
authors = ["Linkerd authors <[email protected]>"]
edition = "2018"
license = "Apache-2.0"

[dependencies]
anyhow = "1"
clap = { version = "3", default-features = false, features = ["derive", "env", "std"] }
futures = "0.3"
k8s-openapi = { version = "0.14", default-features = false, features = ["v1_20"] }
schemars = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio-stream = "0.1"
tracing = "0.1"

[dependencies.kube]
version = "0.69.1"
default-features = false
features = [
"client",
"derive",
"native-tls",
"runtime",
[workspace]
members = [
"controller",
]

[dependencies.kubert]
version = "0.3.3"
default-features = false
features = [
"clap",
"runtime",
]

[dependencies.tokio]
version = "1"
features = ["macros", "parking_lot", "rt", "rt-multi-thread"]

[dev-dependencies]
tokio-stream = "0.1"
tokio-test = "0.4"
tracing-subscriber = "0.3"
10 changes: 5 additions & 5 deletions amd64.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ FROM $RUST_IMAGE as build
ARG TARGETARCH
WORKDIR /build
COPY Cargo.toml Cargo.lock .
COPY src /build/src
COPY controller /build/
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo fetch --locked
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo build --frozen --target=x86_64-unknown-linux-gnu --release --package=linkerd-failover && \
mv target/x86_64-unknown-linux-gnu/release/linkerd-failover /tmp/
cargo build --frozen --target=x86_64-unknown-linux-gnu --release --package=linkerd-failover-controller && \
mv target/x86_64-unknown-linux-gnu/release/linkerd-failover-controller /tmp/

# Creates a minimal runtime image with the operator binary.
FROM $RUNTIME_IMAGE
COPY --from=build /tmp/linkerd-failover /bin/
ENTRYPOINT ["/bin/linkerd-failover"]
COPY --from=build /tmp/linkerd-failover-controller /bin/
ENTRYPOINT ["/bin/linkerd-failover-controller"]
10 changes: 5 additions & 5 deletions arm.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ RUN apt-get update && \
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
WORKDIR /build
COPY Cargo.toml Cargo.lock .
COPY src /build/src
COPY controller /build/
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo fetch --locked
# XXX(ver) we can't easily cross-compile against openssl, so use rustls on arm.
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo build --frozen --release --target=armv7-unknown-linux-gnueabihf \
--package=linkerd-failover --no-default-features --features="rustls" && \
mv target/armv7-unknown-linux-gnueabihf/release/linkerd-failover /tmp/
--package=linkerd-failover-controller --no-default-features --features="rustls" && \
mv target/armv7-unknown-linux-gnueabihf/release/linkerd-failover-controller /tmp/

# Creates a minimal runtime image with the operator binary.
FROM --platform=linux/arm $RUNTIME_IMAGE
COPY --from=build /tmp/linkerd-failover /bin/
ENTRYPOINT ["/bin/linkerd-failover"]
COPY --from=build /tmp/linkerd-failover-controller /bin/
ENTRYPOINT ["/bin/linkerd-failover-controller"]
10 changes: 5 additions & 5 deletions arm64.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ RUN apt-get update && \
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
WORKDIR /build
COPY Cargo.toml Cargo.lock .
COPY src /build/src
COPY controller /build/
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo fetch --locked
# XXX(ver) we can't easily cross-compile against openssl, so use rustls on arm.
RUN --mount=type=cache,target=target \
--mount=type=cache,from=rust:1.59.0,source=/usr/local/cargo,target=/usr/local/cargo \
cargo build --frozen --release --target=aarch64-unknown-linux-gnu \
--package=linkerd-failover --no-default-features --features="rustls-tls" && \
mv target/aarch64-unknown-linux-gnu/release/linkerd-failover /tmp/
--package=linkerd-failover-controller --no-default-features --features="rustls-tls" && \
mv target/aarch64-unknown-linux-gnu/release/linkerd-failover-controller /tmp/

# Creates a minimal runtime image with the operator binary.
FROM --platform=linux/arm64 $RUNTIME_IMAGE
COPY --from=build /tmp/linkerd-failover /bin/
ENTRYPOINT ["/bin/linkerd-failover"]
COPY --from=build /tmp/linkerd-failover-controller /bin/
ENTRYPOINT ["/bin/linkerd-failover-controller"]
44 changes: 44 additions & 0 deletions controller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "linkerd-failover-controller"
version = "0.1.0"
authors = ["Linkerd Authors <[email protected]>"]
edition = "2018"
license = "Apache-2.0"

[dependencies]
anyhow = "1"
clap = { version = "3", default-features = false, features = ["derive", "env", "std"] }
futures = "0.3"
k8s-openapi = { version = "0.14", default-features = false, features = ["v1_20"] }
schemars = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio-stream = "0.1"
tracing = "0.1"

[dependencies.kube]
version = "0.69.1"
default-features = false
features = [
"client",
"derive",
"native-tls",
"runtime",
]

[dependencies.kubert]
version = "0.3.3"
default-features = false
features = [
"clap",
"runtime",
]

[dependencies.tokio]
version = "1"
features = ["macros", "parking_lot", "rt", "rt-multi-thread"]

[dev-dependencies]
tokio-stream = "0.1"
tokio-test = "0.4"
tracing-subscriber = "0.3"
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/main.rs → controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use anyhow::{bail, Result};
use clap::Parser;
use kube::api::ListParams;
use linkerd_failover::{endpoints, traffic_split, Ctx};
use linkerd_failover_controller::{endpoints, traffic_split, Ctx};
use tokio::{sync::mpsc, time};
use tracing::Instrument;

Expand Down
File renamed without changes.

0 comments on commit 65d9ce4

Please sign in to comment.