0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00

Renamed zot-exporter to zxp and added its image to zot release

Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
Alexei Dodon 2022-01-17 16:36:13 +02:00 committed by Ramkumar Chinchani
parent cec66f6bc2
commit c9a81baa10
13 changed files with 108 additions and 21 deletions

View file

@ -97,6 +97,27 @@ jobs:
tags: | tags: |
ghcr.io/${{ github.repository }}-minimal:${{ github.event.release.tag_name }} ghcr.io/${{ github.repository }}-minimal:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}-minimal:latest ghcr.io/${{ github.repository }}-minimal:latest
- name: Build zot-exporter container image
uses: docker/build-push-action@v2
with:
build-args: |
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
push: true
file: Dockerfile-zxp
tags: |
ghcr.io/${{ github.repository }}-zxp:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}-zxp:latest
- name: Build zot-exporter container image (arm64)
uses: docker/build-push-action@v2
with:
build-args: |
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
ARCH=arm64
push: true
file: Dockerfile-arch-zxp
tags: |
ghcr.io/${{ github.repository }}-arm64-zxp:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}-arm64-zxp:latest
- name: Build container image (arm64) - name: Build container image (arm64)
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:

View file

@ -68,7 +68,7 @@ make binary-container
. .
... ...
├── cmd/zot # Source code contains the main logic ├── cmd/zot # Source code contains the main logic
├── cmd/exporter # Source code contains the main logic for node exporter ├── cmd/zxp # Source code contains the main logic for node exporter
├── docs # Source code for Swagger docs ├── docs # Source code for Swagger docs
├── errors # Source code for errors ├── errors # Source code for errors
├── examples # Configuration examples to enable various features ├── examples # Configuration examples to enable various features

33
Dockerfile-arch-zxp Normal file
View file

@ -0,0 +1,33 @@
# ---
# Stage 1: Build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.17 AS builder
ARG COMMIT
ARG ARCH
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
RUN make COMMIT=$COMMIT ARCH=$ARCH clean exporter-minimal
RUN echo '{\n\
"Server": {\n\
"protocol": "http",\n\
"host": "127.0.0.1",\n\
"port": "5000"\n\
},\n\
"Exporter": {\n\
"port": "5001",\n\
"log": {\n\
"level": "debug"\n\
}\n\
}\n\
}\n' > config.json && cat config.json
# ---
# Stage 2: Final image with nothing but binary and default config file
# ---
FROM scratch AS final
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp /zxp
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
ENTRYPOINT ["/zxp"]
EXPOSE 5001
CMD ["config", "/etc/zxp/config.json"]

31
Dockerfile-zxp Normal file
View file

@ -0,0 +1,31 @@
# ---
# Stage 1: Build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.17 AS builder
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
RUN make clean exporter-minimal
RUN echo '{\n\
"Server": {\n\
"protocol": "http",\n\
"host": "127.0.0.1",\n\
"port": "5000"\n\
},\n\
"Exporter": {\n\
"port": "5001",\n\
"log": {\n\
"level": "debug"\n\
}\n\
}\n\
}\n' > config.json && cat config.json
# ---
# Stage 2: Final image with nothing but binary and default config file
# ---
FROM scratch AS final
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp /zxp
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
ENTRYPOINT ["/zxp"]
EXPOSE 5001
CMD ["config", "/etc/zxp/config.json"]

View file

@ -54,8 +54,12 @@ bench-arch:
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb
.PHONY: exporter-minimal .PHONY: exporter-minimal
exporter-minimal: swagger exporter-minimal:
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-exporter -tags minimal,containers_image_openpgp -v -trimpath ./cmd/exporter env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp
.PHONY: exporter-arch-minimal
exporter-arch-minimal:
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp-$(ARCH) -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp
.PHONY: test .PHONY: test
test: check-skopeo $(NOTATION) test: check-skopeo $(NOTATION)

View file

@ -280,7 +280,7 @@ The dist-spec-only zot exposes internal metrics into a Prometheus format through
The configuration of node exporter contains connection details for the zot server it is intend to scrape metrics from. See a [configuration example](./examples/metrics/exporter/config-minimal.json). The metrics are automatically enabled in the zot server on first scrape from the Node Exporter (no extra configuration option is needed). Similarly, the metrics are automatically disabled when Node Exporter did not perform any scrapings in a while. The configuration of node exporter contains connection details for the zot server it is intend to scrape metrics from. See a [configuration example](./examples/metrics/exporter/config-minimal.json). The metrics are automatically enabled in the zot server on first scrape from the Node Exporter (no extra configuration option is needed). Similarly, the metrics are automatically disabled when Node Exporter did not perform any scrapings in a while.
``` ```
bin/zot-exporter config _config-file_ bin/zxp config _config-file_
``` ```
## Enable Metrics ## Enable Metrics

View file

@ -1,5 +1,5 @@
# --- # ---
# Stage 1: Install certs, build binary, create default config file # Stage 1: Build binary, create default config file
# --- # ---
FROM ghcr.io/project-zot/golang:1.17 AS builder FROM ghcr.io/project-zot/golang:1.17 AS builder
RUN mkdir -p /go/src/github.com/project-zot/zot RUN mkdir -p /go/src/github.com/project-zot/zot
@ -21,12 +21,11 @@ RUN echo '{\n\
}\n' > config.json && cat config.json }\n' > config.json && cat config.json
# --- # ---
# Stage 2: Final image with nothing but certs, binary, and default config file # Stage 2: Final image with nothing but binary and default config file
# --- # ---
FROM scratch AS final FROM scratch AS final
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zot-exporter /zot-exporter COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp /zxp
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
ENTRYPOINT ["/zot-exporter"] ENTRYPOINT ["/zxp"]
EXPOSE 5051 EXPOSE 5051
VOLUME ["/var/lib/registry"] CMD ["config", "/etc/zxp/config.json"]
CMD ["config", "/etc/zot/config.json"]

View file

@ -20,9 +20,8 @@ run-minimal-container:
.PHONY: binary-exporter-container .PHONY: binary-exporter-container
binary-exporter-container: binary-exporter-container:
${CONTAINER_RUNTIME} build -f Dockerfile-exporter -t zot-exporter:latest ../../. ${CONTAINER_RUNTIME} build -f Dockerfile-zxp -t zxp:latest ../../.
.PHONY: run-exporter-container .PHONY: run-exporter-container
run-exporter-container: run-exporter-container:
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd)/../..:/go/src/github.com/project-zot/zot \ ${CONTAINER_RUNTIME} run --rm --security-opt label=disable zxp:latest
zot-exporter:latest

View file

@ -24,5 +24,5 @@ At the end of the script below ports are locally available (using *kubectl port-
* 9090 - for accessing Prometheus server * 9090 - for accessing Prometheus server
* 5000 - for zot with all extensions enabled * 5000 - for zot with all extensions enabled
* 5050 - for accessing dist-spec-only zot server * 5050 - for accessing dist-spec-only zot server
* 5051 - for zot-exporter access (a Prometheus Node exporter) * 5051 - for zxp access (a Prometheus Node exporter)

View file

@ -40,14 +40,14 @@ kind load docker-image quay.io/prometheus-operator/prometheus-operator:v0.51.2 -
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:v0.51.2 --name ${CLUSTER_NAME} kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:v0.51.2 --name ${CLUSTER_NAME}
kind load docker-image quay.io/prometheus/prometheus:v2.22.1 --name ${CLUSTER_NAME} kind load docker-image quay.io/prometheus/prometheus:v2.22.1 --name ${CLUSTER_NAME}
## Build zot & zot-exporter related images ## Build zot & zxp images
make binary-container make binary-container
make binary-minimal-container make binary-minimal-container
make binary-exporter-container make binary-exporter-container
kind load docker-image zot-build:latest --name ${CLUSTER_NAME} kind load docker-image zot-build:latest --name ${CLUSTER_NAME}
kind load docker-image zot-minimal:latest --name ${CLUSTER_NAME} kind load docker-image zot-minimal:latest --name ${CLUSTER_NAME}
kind load docker-image zot-exporter:latest --name ${CLUSTER_NAME} kind load docker-image zxp:latest --name ${CLUSTER_NAME}
## Deploy prometheus operator ## Deploy prometheus operator
kubectl create -f kubernetes/prometheus/bundle.yaml kubectl create -f kubernetes/prometheus/bundle.yaml

View file

@ -22,7 +22,7 @@ spec:
- name: zot-minimal - name: zot-minimal
containerPort: 5050 containerPort: 5050
- name: zot-exporter - name: zot-exporter
image: zot-exporter:latest image: zxp:latest
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
ports: ports:
- name: zot-exporter - name: zot-exporter

View file

@ -41,9 +41,9 @@ func NewExporterCmd() *cobra.Command {
// "node_exporter" // "node_exporter"
exporterCmd := &cobra.Command{ exporterCmd := &cobra.Command{
Use: "zot_exporter", Use: "zxp",
Short: "`zot_exporter`", Short: "`zxp`",
Long: "`zot_exporter`", Long: "`zxp`",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Usage() _ = cmd.Usage()
cmd.SilenceErrors = false cmd.SilenceErrors = false