Skip to content

Commit

Permalink
fix: quick metrics setup in kind with prometheus
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Dodon <[email protected]>
  • Loading branch information
adodon2go committed Oct 11, 2023
1 parent 53f97eb commit 576e29c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 36 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ swagger:
.PHONY: update-licenses
# note: for predictable output of below sort command we use locale LC_ALL=C
update-licenses: LC_ALL=C
update-licenses:
update-licenses: check-linux
@echo "Detecting and updating licenses ... please be patient!"
go install github.com/google/go-licenses@latest
$(shell echo "Module | License URL | License" > THIRD-PARTY-LICENSES.md; echo "---|---|---" >> THIRD-PARTY-LICENSES.md; for i in $$(go list -m all | awk '{print $$1}'); do l=$$(go-licenses csv $$i 2>/dev/null); if [ $$? -ne 0 ]; then continue; fi; echo $$l | tr \, \| | tr ' ' '\n'; done | sort -u >> THIRD-PARTY-LICENSES.md)
Expand Down Expand Up @@ -362,6 +362,23 @@ run-container:
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
zot-build:latest

.PHONY: binary-minimal-container
binary-minimal-container:
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile-minimal -t zot-minimal:latest .

.PHONY: run-minimal-container
run-minimal-container:
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
zot-minimal:latest

.PHONY: binary-exporter-container
binary-exporter-container:
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile-zxp -t zxp:latest .

.PHONY: run-exporter-container
run-exporter-container:
${CONTAINER_RUNTIME} run --rm --security-opt label=disable zxp:latest

.PHONY: oci-image
oci-image: $(STACKER)
${STACKER} --debug build \
Expand Down
2 changes: 1 addition & 1 deletion examples/metrics/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# Stage 1: Install certs, build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.19 AS builder
FROM ghcr.io/project-zot/golang:1.20 AS builder
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion examples/metrics/Dockerfile-minimal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# Stage 1: Install certs, build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.19 AS builder
FROM ghcr.io/project-zot/golang:1.20 AS builder
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion examples/metrics/Dockerfile-zxp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# Stage 1: Build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.19 AS builder
FROM ghcr.io/project-zot/golang:1.20 AS builder
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand Down
27 changes: 0 additions & 27 deletions examples/metrics/Makefile

This file was deleted.

6 changes: 4 additions & 2 deletions examples/metrics/kind_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set -e
CLUSTER_NAME=zot

# Script tested with below kubectl & kind versions
KUBECTL_VERSION=v1.17.5
KIND_VERSION=v0.7.0
KUBECTL_VERSION=v1.27.3
KIND_VERSION=v0.20.0

function install_bin() {
if [ "$EUID" -ne 0 ]
Expand Down Expand Up @@ -41,9 +41,11 @@ kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:v0
kind load docker-image quay.io/prometheus/prometheus:v2.22.1 --name ${CLUSTER_NAME}

## Build zot & zxp images
pushd ../../
make binary-container
make binary-minimal-container
make binary-exporter-container
popd

kind load docker-image zot-build:latest --name ${CLUSTER_NAME}
kind load docker-image zot-minimal:latest --name ${CLUSTER_NAME}
Expand Down
4 changes: 2 additions & 2 deletions examples/metrics/kubernetes/prometheus/prom_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ServiceAccount
metadata:
name: prometheus
---
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus
Expand All @@ -28,7 +28,7 @@ rules:
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus
Expand Down
43 changes: 42 additions & 1 deletion examples/metrics/kubernetes/zot-extended/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,48 @@ spec:
- name: zot-extended
image: zot-build:latest
imagePullPolicy: IfNotPresent
command: ["/usr/bin/zot"]
args: ["serve", "/zot-config/config.json"]
ports:
- name: zot-extended
containerPort: 5000

protocol: TCP
volumeMounts:
- name: zot-config
mountPath: /zot-config
readOnly: false
volumes:
- name: zot-config
configMap:
name: zot-config
items:
- key: zot_config.json
path: config.json
---
apiVersion: v1
kind: ConfigMap
metadata:
name: zot-config
data:
zot_config.json: |
{
"distSpecVersion":"1.0.1",
"storage": {
"rootDirectory": "/var/lib/registry"
},
"http": {
"address": "0.0.0.0",
"port": "5000"
},
"log": {
"level": "debug"
},
"extensions": {
"metrics": {
"enable": true,
"prometheus": {
"path": "/metrics"
}
}
}
}

0 comments on commit 576e29c

Please sign in to comment.