-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor endpoint handling and reconcilliation (#21)
* Disable cgo As part of the Go 1.20 release it seems like the default for `CGO_ENABLED` is no longer carried over from the tools. This leads to linking issues on systems that use different versions of glibc from what the base image uses. See golang/go#58550 for more details. This change should fix #16 * Slim down the final image. Use `scratch` as a base image since we're generating a static binary anyway. Also be more explicity about the platform and target OS during the build. * Refactor endpoint handling and reconcilliation. DRAFT With the release of Nomad 1.6 it's possible to get the network address of the allocation from Nomad. The change to enable this is only in the client library and does not require updating the Nomad server. The IP was sent back by older Nomad versions, it just wasn't available in the client. This enables refactoring the endpoint reconcilliation to make use of the IP address to identify the endpoint within Cilium. There is no longer a dependency on Consul for policies. Additional, endpoints are now labelled with the task group and task information as services can be created at those levels. * Tidy * Update the readme and add some basic tests. Remove unused flags from the readme and command line and refactor the code to allow for testing. * Slightly better logging of labels * Always update labels on reconcile. * Fixes and align with upstream Dockerfile * Missed one * Reduce Dockerfile diff further * Restore periodic reconcilliation of endpoints * Remove stray return
- Loading branch information
1 parent
345e3f9
commit db0802d
Showing
9 changed files
with
384 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
FROM golang:1.20-bullseye as builder | ||
WORKDIR /netreap | ||
COPY . /netreap | ||
COPY go.mod go.sum /netreap/ | ||
RUN go mod download | ||
COPY . /netreap/ | ||
ARG VERSION | ||
RUN go build -ldflags "-s -w -X 'main.Version=$VERSION'" | ||
|
||
FROM gcr.io/distroless/base-debian11 | ||
WORKDIR / | ||
COPY --from=builder /netreap/netreap /usr/bin/netreap | ||
ENTRYPOINT ["/usr/bin/netreap"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ docker: | |
|
||
ci: | ||
docker buildx build --platform $(platforms) --tag $(repo):$(VERSION) --push . | ||
|
||
test: | ||
go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package reapers | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cilium/cilium/api/v1/models" | ||
nomad_api "github.com/hashicorp/nomad/api" | ||
) | ||
|
||
type AllocationInfo interface { | ||
Info(allocID string, q *nomad_api.QueryOptions) (*nomad_api.Allocation, *nomad_api.QueryMeta, error) | ||
} | ||
|
||
type EventStreamer interface { | ||
Stream(ctx context.Context, topics map[nomad_api.Topic][]string, index uint64, q *nomad_api.QueryOptions) (<-chan *nomad_api.Events, error) | ||
} | ||
|
||
type EndpointLister interface { | ||
EndpointList() ([]*models.Endpoint, error) | ||
} | ||
|
||
type EndpointGetter interface { | ||
EndpointGet(id string) (*models.Endpoint, error) | ||
} | ||
|
||
type EndpointPatcher interface { | ||
EndpointPatch(id string, ep *models.EndpointChangeRequest) error | ||
} | ||
|
||
type EndpointUpdater interface { | ||
EndpointLister | ||
EndpointGetter | ||
EndpointPatcher | ||
} |
Oops, something went wrong.