Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webservice
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
masi9606
webservice
Commits
210e3868
Commit
210e3868
authored
6 months ago
by
schnarkus
Browse files
Options
Downloads
Patches
Plain Diff
add prometheus dev
parent
ef493223
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#68973
passed
6 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
local-environment/prometheus.yml
+13
-0
13 additions, 0 deletions
local-environment/prometheus.yml
local-environment/setup-local.sh
+43
-13
43 additions, 13 deletions
local-environment/setup-local.sh
with
56 additions
and
13 deletions
local-environment/prometheus.yml
0 → 100644
+
13
−
0
View file @
210e3868
global
:
scrape_interval
:
15s
scrape_configs
:
-
job_name
:
"
prometheus"
scrape_interval
:
5s
static_configs
:
-
targets
:
[
"
localhost:9090"
]
-
job_name
:
"
webservice"
scrape_interval
:
15s
static_configs
:
-
targets
:
[
"
10.89.0.2:8080"
]
This diff is collapsed.
Click to expand it.
local-environment/setup-local.sh
+
43
−
13
View file @
210e3868
#!/bin/bash
#!/bin/bash
# webservice container
IMAGE_NAME
=
"registry.bht-berlin.de:443/masi9606/webservice:dev"
IMAGE_NAME
=
"registry.bht-berlin.de:443/masi9606/webservice:dev"
CONTAINER_NAME
=
"webservice_container"
CONTAINER_NAME
=
"webservice_container"
CONTAINER_HTTP_PORT
=
"8080"
CONTAINER_HTTP_PORT
=
"8080"
CONTAINER_HTTPS_PORT
=
"8443"
CONTAINER_HTTPS_PORT
=
"8443"
NGINX_CONF
=
"/etc/nginx/sites-available/default"
NGINX_CONF
=
"/etc/nginx/sites-available/default"
CERT_DIR
=
"/etc/nginx/certs"
CERT_DIR
=
"/etc/nginx/certs"
DOMAIN_NAME
=
"webservice.local"
WEB_SERVICE_DOMAIN
=
"webservice.local"
# prometheus container
PROMETHEUS_IMAGE
=
"prom/prometheus:latest"
PROMETHEUS_CONTAINER_NAME
=
"prometheus_monitor"
PROMETHEUS_PORT
=
"9090"
PROMETHEUS_DOMAIN
=
"monitoring.local"
PROMETHEUS_CONFIG_FILE
=
"prometheus.yml"
# local network
NETWORK_NAME
=
"dev_network"
# Stop old containers
# Stop old containers
podman stop
$CONTAINER_NAME
podman stop
$CONTAINER_NAME
podman
rm
-f
$CONTAINER_NAME
podman
rm
-f
$CONTAINER_NAME
podman stop
$PROMETHEUS_CONTAINER_NAME
podman
rm
-f
$PROMETHEUS_CONTAINER_NAME
# Pull image
# Pull image
s
podman pull
$IMAGE_NAME
podman pull
$IMAGE_NAME
podman pull
$PROMETHEUS_IMAGE
# Run container on both ports
# Run webservice container
podman run
-d
-p
$CONTAINER_HTTP_PORT
:
$CONTAINER_HTTP_PORT
-p
$CONTAINER_HTTPS_PORT
:
$CONTAINER_HTTPS_PORT
--name
$CONTAINER_NAME
$IMAGE_NAME
podman run
-d
\
--name
"
$CONTAINER_NAME
"
\
--network
"
$NETWORK_NAME
"
\
--ip
"10.89.0.2"
\
-p
"
$CONTAINER_HTTP_PORT
:
$CONTAINER_HTTP_PORT
"
\
-p
"
$CONTAINER_HTTPS_PORT
:
$CONTAINER_HTTPS_PORT
"
\
"
$IMAGE_NAME
"
# Install packages
# Install packages
podman
exec
-it
$CONTAINER_NAME
apt-get update
podman
exec
-it
$CONTAINER_NAME
apt-get update
...
@@ -26,7 +46,7 @@ podman exec -it $CONTAINER_NAME apt-get install -y openssl nginx systemctl curl
...
@@ -26,7 +46,7 @@ podman exec -it $CONTAINER_NAME apt-get install -y openssl nginx systemctl curl
podman
exec
-it
$CONTAINER_NAME
bash
-c
"mkdir -p
$CERT_DIR
&&
\
podman
exec
-it
$CONTAINER_NAME
bash
-c
"mkdir -p
$CERT_DIR
&&
\
openssl req -x509 -nodes -days 365 -newkey rsa:4096
\
openssl req -x509 -nodes -days 365 -newkey rsa:4096
\
-keyout
$CERT_DIR
/nginx.key -out
$CERT_DIR
/nginx.crt
\
-keyout
$CERT_DIR
/nginx.key -out
$CERT_DIR
/nginx.crt
\
-subj '/CN=
$DOMAIN
_NAME
'"
-subj '/CN=
$
WEB_SERVICE_
DOMAIN
'"
podman
cp
default.conf
$CONTAINER_NAME
:
$NGINX_CONF
podman
cp
default.conf
$CONTAINER_NAME
:
$NGINX_CONF
...
@@ -37,19 +57,29 @@ podman exec -it $CONTAINER_NAME systemctl restart nginx
...
@@ -37,19 +57,29 @@ podman exec -it $CONTAINER_NAME systemctl restart nginx
podman
exec
-it
$CONTAINER_NAME
sleep
5
podman
exec
-it
$CONTAINER_NAME
sleep
5
# Add entry to /etc/hosts
# Add entry to /etc/hosts
podman
exec
-it
$CONTAINER_NAME
bash
-c
"echo '127.0.0.1 webservice.local' >> /etc/hosts"
podman
exec
-it
$CONTAINER_NAME
bash
-c
"echo '127.0.0.1
$WEB_SERVICE_DOMAIN
' >> /etc/hosts"
echo
"Setup complete..."
echo
"Testing from inside..."
echo
"Testing from inside..."
podman
exec
-it
$CONTAINER_NAME
curl
-k
https://
$DOMAIN
_NAME
:
$CONTAINER_HTTPS_PORT
/
podman
exec
-it
$CONTAINER_NAME
curl
-k
https://
$
WEB_SERVICE_
DOMAIN
:
$CONTAINER_HTTPS_PORT
/
echo
"Testing from outside..."
echo
"Testing from outside..."
sudo
bash
-c
"echo '127.0.0.1
webservice.local
' >> /etc/hosts"
sudo
bash
-c
"echo '127.0.0.1
$WEB_SERVICE_DOMAIN
' >> /etc/hosts"
curl
-k
https://
$DOMAIN
_NAME
:
$CONTAINER_HTTPS_PORT
/
curl
-k
https://
$
WEB_SERVICE_
DOMAIN
:
$CONTAINER_HTTPS_PORT
/
echo
"Testing Redis..."
echo
"Testing Redis..."
curl
-k
-X
PUT
--header
'Content-Type: text/plain; charset=utf-8'
--data
'foo'
https://
$DOMAIN
_NAME
:
$CONTAINER_HTTPS_PORT
/state/bar
curl
-k
-X
PUT
--header
'Content-Type: text/plain; charset=utf-8'
--data
'foo'
https://
$
WEB_SERVICE_
DOMAIN
:
$CONTAINER_HTTPS_PORT
/state/bar
# Check the value in the database
# Check the value in the database
podman
exec
-it
$CONTAINER_NAME
redis-cli KEYS
'*'
podman
exec
-it
$CONTAINER_NAME
redis-cli KEYS
'*'
\ No newline at end of file
# Run Prometheus container
podman run
-d
\
--name
$PROMETHEUS_CONTAINER_NAME
\
--network
$NETWORK_NAME
--ip
"10.89.0.3"
\
-p
$PROMETHEUS_PORT
:
$PROMETHEUS_PORT
\
-v
$PWD
/
$PROMETHEUS_CONFIG_FILE
:/etc/prometheus/prometheus.yml:Z
\
$PROMETHEUS_IMAGE
--config
.file
=
/etc/prometheus/prometheus.yml
# Test Prometheus
sudo
bash
-c
"echo '127.0.0.1
$PROMETHEUS_DOMAIN
' >> /etc/hosts"
curl http://
$PROMETHEUS_DOMAIN
:
$PROMETHEUS_PORT
/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment