Skip to content

Commit

Permalink
fix: quick metrics setup in kind with prometheus (#1897)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Dodon <[email protected]>
  • Loading branch information
adodon2go authored Oct 16, 2023
1 parent fc2380b commit 12227b4
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 139 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
40 changes: 0 additions & 40 deletions examples/metrics/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions examples/metrics/Dockerfile-minimal

This file was deleted.

31 changes: 0 additions & 31 deletions examples/metrics/Dockerfile-zxp

This file was deleted.

27 changes: 0 additions & 27 deletions examples/metrics/Makefile

This file was deleted.

10 changes: 5 additions & 5 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,9 @@ 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
make binary-container
make binary-minimal-container
make binary-exporter-container
make -C ../../ binary-container
make -C ../../ binary-minimal-container
make -C ../../ binary-exporter-container

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
71 changes: 70 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,76 @@ 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"
}
}
}
}
zot_minimal.json: |
{
"distSpecVersion":"1.0.1",
"storage": {
"rootDirectory": "/var/lib/registry"
},
"http": {
"address": "0.0.0.0",
"port": "5050"
},
"log": {
"level": "debug"
}
}
zxp.json: |
{
"Server": {
"protocol": "http",
"host": "127.0.0.1",
"port": "5050"
},
"Exporter": {
"port": "5051",
"log": {
"level": "debug"
}
}
}
23 changes: 23 additions & 0 deletions examples/metrics/kubernetes/zot-minimal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,36 @@ spec:
- name: zot-minimal
image: zot-minimal:latest
imagePullPolicy: IfNotPresent
command: ["/usr/bin/zot"]
args: ["serve", "/zot-config/config.json"]
ports:
- name: zot-minimal
containerPort: 5050
protocol: TCP
volumeMounts:
- name: zot-config
mountPath: /zot-config
readOnly: false
- name: zot-exporter
image: zxp:latest
imagePullPolicy: IfNotPresent
command: ["/zxp"]
args: ["config", "/zot-config/zxp-config.json"]
ports:
- name: zot-exporter
containerPort: 5051
protocol: TCP
volumeMounts:
- name: zot-config
mountPath: /zot-config
readOnly: false
volumes:
- name: zot-config
configMap:
name: zot-config
items:
- key: zot_minimal.json
path: config.json
- key: zxp.json
path: zxp-config.json

0 comments on commit 12227b4

Please sign in to comment.