Skip to content

Commit

Permalink
Merge pull request #36 from omertuc/unouger
Browse files Browse the repository at this point in the history
Remove dependency on ouger
  • Loading branch information
omertuc authored Oct 23, 2023
2 parents 2cacaad + 86e8fe1 commit 7d2d9f2
Show file tree
Hide file tree
Showing 91 changed files with 29,108 additions and 471 deletions.
84 changes: 75 additions & 9 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ libc = "0.2.147"
clio = { version = "0.3.4", features = ["clap", "clap-parse"] }
data-url = "0.3.0"
reqwest = { version = "0.11.20", default-features = false }
prost = "0.12.1"

[build-dependencies]
prost-build = "0.12.1"

7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ RUN apt-get install -y protobuf-compiler
RUN cargo chef cook --release --recipe-path recipe.json
COPY Cargo.toml Cargo.lock .
COPY src/ src/
COPY build.rs build.rs
RUN cargo build --release --bin recert

FROM docker.io/library/golang:1.19-bookworm as ouger-builder
COPY ./ouger $GOPATH/src
WORKDIR $GOPATH/src
RUN go build -buildvcs=false -o $GOPATH/bin/ouger_server cmd/server/ouger_server.go

FROM docker.io/library/debian:bookworm AS runtime
WORKDIR app
RUN apt-get update
RUN apt-get install -y openssl
COPY --from=ouger-builder /go/bin/ouger_server /usr/local/bin
COPY --from=builder /app/target/release/recert /usr/local/bin
ENTRYPOINT ["/usr/local/bin/recert"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For more information see the [design doc](docs/design.md)

### Local Development

You need protoc (dnf install protobuf-compiler), podman, etcdctl, [ouger](https://github.com/omertuc/ouger), meld, and an IBU backup seed image. Then run `./run_seed.sh <seed pullspec>`
You need protoc (dnf install protobuf-compiler), podman, etcdctl, meld, and an IBU seed image. Then run `./run_seed.sh <seed pullspec>`

### Run on a cluster

Expand Down
24 changes: 24 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
extern crate prost_build;

use std::io::Result;

fn main() -> Result<()> {
let mut prost_build = prost_build::Config::new();

prost_build.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]");
prost_build.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");

prost_build.include_file("_includes.rs");

prost_build.compile_protos(
&[
"k8s.io/api/core/v1/generated.proto",
"k8s.io/api/admissionregistration/v1/generated.proto",
"k8s.io/api/apps/v1/generated.proto",
"route/v1/generated.proto",
],
&["./src/protobuf"],
)?;

Ok(())
}
13 changes: 6 additions & 7 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,10 @@ right places and doesn't miss anything.
#### etcd scanning

recert will fetch all etcd values of `secrets`, `configmaps`, `machineconfigs`
and a few other kinds. Since etcd doesn't store YAMLs for most resources, and
instead stores a protobuf binary encoding of the resources, `recert` for now
has to use [ouger](https://github.com/omertuc/ouger/) to convert those
resources from and to YAML (this is usually done by kube-apiserver when you
normally use kubernetes, but with recert we use direct etcd access).
and a few other kinds. Since kube-apiserver doesn't store raw JSONs in etcd for
most resources, and instead stores a protobuf binary encoding of the resources,
`recert` has to use protobuf definitions copied from the kubernetes repo in
order to be able to decode/encode those values.

For each kind of resource, `recert` has specialized code to scan it for
cryptographic objects. i.e., recert will not simply brute-force blindly
Expand Down Expand Up @@ -977,8 +976,8 @@ key gets discarded during installation.
### etcd cache

During the Commit stage mentioned above, we would do many writes to etcd. It's
very slow to go through ouger and etcd for each one, so instead we maintain an
in-memory cache of all etcd YAMLs, and all writes actually happen in memory.
very slow to go through etcd for each one, so instead we maintain an in-memory
cache of all etcd YAMLs, and all writes actually happen in memory.

In the end, we simply commit that cache back to etcd. This essentially batches
all the etcd writes of the same YAML into a single operation.
Expand Down
20 changes: 0 additions & 20 deletions example.crt

This file was deleted.

Loading

0 comments on commit 7d2d9f2

Please sign in to comment.