Skip to content

Commit

Permalink
use the distroless image for development with a cluster (#41)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Bernal <[email protected]>
  • Loading branch information
jgbernalp authored Dec 23, 2024
1 parent acd96f0 commit da21371
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 56 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
!bin/manager
testbin/
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ LABEL maintainer="The Perses Authors <[email protected]>"

USER nobody

COPY --chown=nobody:nobody operator /bin/operator
COPY --chown=nobody:nobody bin/manager /bin/manager
COPY --chown=nobody:nobody LICENSE /LICENSE
COPY --from=build-env --chown=nobody:nobody /etc/mime.types /etc/mime.types

EXPOSE 8080
ENTRYPOINT [ "/bin/operator" ]
ENTRYPOINT [ "/bin/manager" ]
35 changes: 0 additions & 35 deletions Dockerfile.dev

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ run: manifests generate fmt vet ## Run a controller from your host.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: image-build
image-build: test ## Build docker image with the manager.
${CONTAINER_RUNTIME} build -f Dockerfile.dev -t ${IMG} .
image-build: build test ## Build docker image with the manager.
${CONTAINER_RUNTIME} build -f Dockerfile -t ${IMG} .

.PHONY: image-push
image-push: ## Push docker image with the manager.
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@ make install
kubectl apply -k config/samples
```

3. Build and push your image to the location specified by `IMG`:
3. Usint the the location specified by `IMG`, build and push the image to the registry, then deploy the controller to the cluster:

```sh
make image-build image-push IMG=<some-registry>/perses-operator:tag
IMG=<some-registry>/perses-operator:tag make image-build image-push deploy
```

4. Deploy the controller to the cluster with the image specified by `IMG`:

```sh
make deploy IMG=<some-registry>/perses-operator:tag
```

6. Access the Perses UI at `http://localhost:8080`
5. Access the Perses UI at `http://localhost:8080` by port-forwarding the service:

```sh
kubectl port-forward svc/perses-sample 8080:8080
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ spec:
- name: manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--metrics-bind-address=127.0.0.1:8082"
- "--leader-elect"
6 changes: 3 additions & 3 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ spec:
# - linux
securityContext:
runAsNonRoot: true
runAsGroup: 65532
runAsUser: 65532
containers:
- command:
- /manager
args:
- args:
- --leader-elect
image: controller:latest
imagePullPolicy: Always
Expand Down
4 changes: 2 additions & 2 deletions distroless-debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ LABEL maintainer="The Perses Authors <[email protected]>"

USER nobody

COPY --chown=nobody:nobody operator /bin/operator
COPY --chown=nobody:nobody bin/manager /bin/manager
COPY --chown=nobody:nobody LICENSE /LICENSE
COPY --from=build-env --chown=nobody:nobody /etc/mime.types /etc/mime.types

EXPOSE 8080
ENTRYPOINT [ "/bin/operator" ]
ENTRYPOINT [ "/bin/manager" ]
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func main() {
var enableHTTP2 bool
var persesServerURL string

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8082", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-goreleaser/.goreleaser.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
builds:
- id: "operator"
main: ./main.go
binary: "operator"
binary: "/bin/manager"
goos:
- linux
- windows
Expand Down

0 comments on commit da21371

Please sign in to comment.