Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pump, Cedric
lab-tracing
Commits
e83a0c46
Commit
e83a0c46
authored
Dec 27, 2020
by
Nane Kratzke
Browse files
space service
parent
faa400a1
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
e83a0c46
...
...
@@ -7,7 +7,7 @@ variables:
KUBECTL
:
"
transit/kubectl-plus:v1.19.4"
CLUSTER
:
"
rig.th-luebeck.dev"
container
:
hiphop-
container
:
stage
:
build
image
:
name
:
gcr.io/kaniko-project/executor:debug
...
...
@@ -23,6 +23,22 @@ container:
-
cd hiphop
-
/kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/hiphop:latest
space-container
:
stage
:
build
image
:
name
:
gcr.io/kaniko-project/executor:debug
entrypoint
:
[
"
"
]
only
:
changes
:
-
.gitlab-ci.yml
-
space/*
-
space/*/*
script
:
-
mkdir -p /kaniko/.docker
-
echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
-
cd space
-
/kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/space:latest
secrets
:
stage
:
build
image
:
$KUBECTL
...
...
@@ -50,6 +66,16 @@ hiphop:
-
TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
-
TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
space
:
stage
:
deploy
image
:
$KUBECTL
script
:
-
kubectl apply -f deploy/tracing.yaml
-
NS=$(kubectl config view -o jsonpath="{..namespace}")
-
kubectl label ns $NS istio-injection=disabled --overwrite
-
kubectl delete -f deploy/space-deploy+svc.yaml ||
true
-
kubectl apply -f deploy/space-deploy+svc.yaml
shutdown
:
stage
:
teardown
image
:
$KUBECTL
...
...
@@ -60,6 +86,7 @@ shutdown:
-
TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
-
TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
-
TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
-
kubectl delete -f deploy/space-deploy+svc.yaml
-
kubectl delete -f deploy/tracing.yaml
-
kubectl label ns $NS istio-injection=disabled --overwrite
deploy/space-deploy+svc.yaml
0 → 100644
View file @
e83a0c46
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
space-deployment-{{ TIER }}
labels
:
app
:
space
annotations
:
"
sidecar.jaegertracing.io/inject"
:
"
tracing"
spec
:
replicas
:
1
selector
:
matchLabels
:
app
:
space
template
:
metadata
:
labels
:
app
:
space
spec
:
imagePullSecrets
:
-
name
:
gitlab-registry-credentials
containers
:
-
name
:
hiphop
image
:
git.mylab.th-luebeck.de:4181/cloud-native/lab-tracing/space:latest
imagePullPolicy
:
Always
resources
:
limits
:
cpu
:
"
50m"
ports
:
-
containerPort
:
80
env
:
-
name
:
SERVICE
value
:
"
space-svc"
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
space-svc
labels
:
app
:
space
spec
:
selector
:
app
:
space
ports
:
-
protocol
:
TCP
port
:
80
targetPort
:
80
hiphop/Dockerfile
View file @
e83a0c46
...
...
@@ -3,7 +3,6 @@ FROM python:3.9-alpine
COPY
. /app/
WORKDIR
/app
RUN
apk update
&&
apk upgrade
&&
apk add
--no-cache
bash git openssh
RUN
pip3
install
-r
requirements.txt
EXPOSE
80
...
...
space/Dockerfile
0 → 100644
View file @
e83a0c46
FROM
python:3.9-alpine
COPY
. /app/
WORKDIR
/app
RUN
pip3
install
-r
requirements.txt
EXPOSE
80
ENTRYPOINT
["python3", "-u", "service.py"]
\ No newline at end of file
space/requirements.txt
0 → 100644
View file @
e83a0c46
flask
requests
opentracing
jaeger-client
\ No newline at end of file
space/service.py
0 → 100644
View file @
e83a0c46
from
flask
import
Flask
,
redirect
,
request
,
jsonify
from
jaeger_client
import
Config
import
opentracing
import
requests
import
traceback
import
os
import
json
# A very boring and basic space-service to demonstrate
# observability via tracing.
service
=
os
.
environ
.
get
(
'SERVICE'
,
'space'
)
app
=
Flask
(
__name__
)
config
=
Config
(
config
=
{
'sampler'
:
{
'type'
:
'const'
,
'param'
:
1
},
'logging'
:
True
,
'reporter_batch_size'
:
1
},
service_name
=
service
)
tracer
=
config
.
initialize_tracer
()
@
app
.
route
(
'/'
)
def
index
():
return
redirect
(
'/space'
)
@
app
.
route
(
'/space'
)
def
space
():
with
tracer
.
start_span
(
operation_name
=
"space"
)
as
parent_span
:
try
:
lat
=
float
(
request
.
args
.
get
(
'lat'
,
"0.0001"
))
lon
=
float
(
request
.
args
.
get
(
'lon'
,
"0.0001"
))
except
Exception
as
ex
:
print
(
ex
)
return
"Bad request (lat/lon not numeric)"
,
400
queries
=
{
"astros"
:
"http://api.open-notify.org/astros.json"
,
"position"
:
"http://api.open-notify.org/iss-now.json"
,
"passtime"
:
f
"http://api.open-notify.org/iss-pass.json?lat=
{
lat
}
&lon=
{
lon
}
"
}
result
=
{}
for
key
,
url
in
queries
.
items
():
with
tracer
.
start_span
(
operation_name
=
key
,
child_of
=
parent_span
)
as
span
:
result
[
key
]
=
json
.
loads
(
requests
.
get
(
url
).
content
)
print
(
result
)
return
jsonify
(
result
)
app
.
run
(
host
=
"0.0.0.0"
,
port
=
80
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment