Skip to content

Commit 37313ce

Browse files
committed
added ability to run tagging workshop from docker hub images
1 parent 2353782 commit 37313ce

12 files changed

+461
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# This setup script will:
4+
# (1) Deploy the services in kubernetes using images from Docker Hub
5+
# (2) Find and delete existing pods (to force redeployment)
6+
#
7+
# (1) Deploy the services in kubernetes using images from Docker Hub
8+
kubectl apply -f creditcheckservice/creditcheckservice-dockerhub.yaml
9+
kubectl apply -f creditprocessorservice/creditprocessorservice-dockerhub.yaml
10+
kubectl apply -f loadgenerator/loadgenerator-dockerhub.yaml
11+
12+
# (2) Find and delete existing pods (to force redeployment)
13+
podlist=$(kubectl get pods)
14+
re="(creditcheckservice[^[:space:]]+)"
15+
if [[ $podlist =~ $re ]]; then
16+
POD=${BASH_REMATCH[1]};
17+
echo "Restarting creditcheckservice pod:"
18+
kubectl delete po $POD
19+
fi
20+
21+
re="(creditprocessorservice[^[:space:]]+)"
22+
if [[ $podlist =~ $re ]]; then
23+
POD=${BASH_REMATCH[1]};
24+
echo "Restarting creditprocessorservice pod:"
25+
kubectl delete po $POD
26+
fi
27+
28+
re="(loadgenerator[^[:space:]]+)"
29+
if [[ $podlist =~ $re ]]; then
30+
POD=${BASH_REMATCH[1]};
31+
echo "Restarting loadgenerator pod:"
32+
kubectl delete po $POD
33+
fi
34+
35+
echo ""
36+
echo Deployed the creditcheckservice, creditprocessorservice, and loadgenerator from Docker Hub images
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# This setup script will:
4+
# (1) Deploy the services in kubernetes using images from Docker Hub
5+
# (2) Find and delete existing pods (to force redeployment)
6+
#
7+
# (1) Deploy the services in kubernetes using images from Docker Hub
8+
kubectl apply -f creditcheckservice-with-tags/creditcheckservice-dockerhub.yaml
9+
kubectl apply -f creditprocessorservice/creditprocessorservice-dockerhub.yaml
10+
kubectl apply -f loadgenerator/loadgenerator-dockerhub.yaml
11+
12+
# (2) Find and delete existing pods (to force redeployment)
13+
podlist=$(kubectl get pods)
14+
re="(creditcheckservice[^[:space:]]+)"
15+
if [[ $podlist =~ $re ]]; then
16+
POD=${BASH_REMATCH[1]};
17+
echo "Restarting creditcheckservice pod:"
18+
kubectl delete po $POD
19+
fi
20+
21+
re="(creditprocessorservice[^[:space:]]+)"
22+
if [[ $podlist =~ $re ]]; then
23+
POD=${BASH_REMATCH[1]};
24+
echo "Restarting creditprocessorservice pod:"
25+
kubectl delete po $POD
26+
fi
27+
28+
re="(loadgenerator[^[:space:]]+)"
29+
if [[ $podlist =~ $re ]]; then
30+
POD=${BASH_REMATCH[1]};
31+
echo "Restarting loadgenerator pod:"
32+
kubectl delete po $POD
33+
fi
34+
35+
echo ""
36+
echo Deployed the creditcheckservice, creditprocessorservice, and loadgenerator from Docker Hub images
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
#!/bin/bash
22

3-
# This setup script will replace the main.py file for the credit check service
4-
# with a version that already includes the tagging changes
3+
# This setup script will:
4+
# (1) Build the credit-check-service app that includes the changes for tagging
5+
# (2) Export the image from docker
6+
# (3) Import it into k3s
7+
# (Steps 2 and 3 are so we don't need to use a public registry)
8+
# (4) Deploy the service in kubernetes
9+
# (5) Find and delete the pod (so it is redeployed)
510
#
6-
cp creditcheckservice/main-with-tags.py creditcheckservice/main.py
11+
# (1) Build the credit-check-service app
12+
docker build -t credit-check-service:latest creditcheckservice-with-tags
13+
14+
# (2) Export the image from docker
15+
docker save --output credit-check-service.tar credit-check-service:latest
16+
17+
# (3) Import it into k3s
18+
sudo k3s ctr images import credit-check-service.tar
19+
20+
# (4) Deploy the service in kubernetes
21+
kubectl apply -f creditcheckservice-with-tags/creditcheckservice.yaml
22+
23+
# (5) Find and delete the pod (so it is redeployed)
24+
podlist=$(kubectl get pods)
25+
re="(creditcheckservice[^[:space:]]+)"
26+
if [[ $podlist =~ $re ]]; then
27+
POD=${BASH_REMATCH[1]};
28+
echo "Restarting creditcheckservice pod:"
29+
kubectl delete po $POD
30+
fi
731

832
echo ""
9-
echo Applied the tagging changes to creditcheckservice.
33+
echo Redeployed creditcheckservice-with-tags.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# This setup script will:
4+
# (1) Build the creditcheckservice, creditprocessorservice, and loadgenerator images
5+
# (2) Push the images to Docker Hub
6+
#
7+
# In the event that workshop attendees experiences issues building images locally
8+
# they can use the pre-built images from Docker Hub instead. For the credit check
9+
# service, we'll build images both without tags (1.0) and with tags (1.1).
10+
11+
# (1) Build the creditcheckservice, creditprocessorservice, and loadgenerator images
12+
docker build -t derekmitchell399/credit-check-service:1.0 creditcheckservice
13+
docker build -t derekmitchell399/credit-check-service:1.1 creditcheckservice-with-tags
14+
docker build -t derekmitchell399/credit-processor-service:1.0 creditprocessorservice
15+
docker build -t derekmitchell399/loadgenerator:1.0 loadgenerator
16+
17+
echo ""
18+
echo ""
19+
echo ""
20+
echo Built the creditcheckservice, creditprocessorservice, and loadgenerator images successfully
21+
22+
docker push derekmitchell399/credit-check-service:1.0
23+
docker push derekmitchell399/credit-check-service:1.1
24+
docker push derekmitchell399/credit-processor-service:1.0
25+
docker push derekmitchell399/loadgenerator:1.0
26+
27+
echo ""
28+
echo ""
29+
echo ""
30+
echo Pushed the images to Docker Hub successfully
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.11-slim
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# Copy requirements over
7+
COPY requirements.txt .
8+
9+
RUN apt update && apt install gcc -y
10+
11+
# Install Python dependencies
12+
RUN pip install --no-cache-dir -r requirements.txt
13+
14+
# Copy main app
15+
COPY main.py .
16+
17+
# Bootstrap OTel
18+
RUN splunk-py-trace-bootstrap
19+
20+
# Set the entrypoint command to run the application
21+
CMD ["splunk-py-trace", "python3", "main.py"]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: creditcheckservice
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: creditcheckservice
9+
template:
10+
metadata:
11+
labels:
12+
app: creditcheckservice
13+
spec:
14+
tolerations:
15+
nodeSelector:
16+
terminationGracePeriodSeconds: 5
17+
containers:
18+
- name: creditcheckservice
19+
image: derekmitchell399/credit-check-service:1.1
20+
imagePullPolicy: Never
21+
ports:
22+
- containerPort: 8888
23+
env:
24+
- name: PORT
25+
value: "8888"
26+
- name: NODE_IP
27+
valueFrom:
28+
fieldRef:
29+
fieldPath: status.hostIP
30+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
31+
value: "http://$(NODE_IP):4317"
32+
- name: OTEL_SERVICE_NAME
33+
value: "creditcheckservice"
34+
- name: OTEL_PROPAGATORS
35+
value: "tracecontext,baggage"
36+
resources:
37+
requests:
38+
cpu: 110m
39+
memory: 90Mi
40+
limits:
41+
cpu: 130m
42+
memory: 128Mi
43+
---
44+
apiVersion: v1
45+
kind: Service
46+
metadata:
47+
name: creditcheckservice
48+
spec:
49+
type: ClusterIP
50+
selector:
51+
app: creditcheckservice
52+
ports:
53+
- protocol: TCP
54+
port: 8888
55+
targetPort: 8888
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: creditcheckservice
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: creditcheckservice
9+
template:
10+
metadata:
11+
labels:
12+
app: creditcheckservice
13+
spec:
14+
tolerations:
15+
nodeSelector:
16+
terminationGracePeriodSeconds: 5
17+
containers:
18+
- name: creditcheckservice
19+
image: docker.io/library/credit-check-service:latest
20+
imagePullPolicy: Never
21+
ports:
22+
- containerPort: 8888
23+
env:
24+
- name: PORT
25+
value: "8888"
26+
- name: NODE_IP
27+
valueFrom:
28+
fieldRef:
29+
fieldPath: status.hostIP
30+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
31+
value: "http://$(NODE_IP):4317"
32+
- name: OTEL_SERVICE_NAME
33+
value: "creditcheckservice"
34+
- name: OTEL_PROPAGATORS
35+
value: "tracecontext,baggage"
36+
resources:
37+
requests:
38+
cpu: 110m
39+
memory: 90Mi
40+
limits:
41+
cpu: 130m
42+
memory: 128Mi
43+
---
44+
apiVersion: v1
45+
kind: Service
46+
metadata:
47+
name: creditcheckservice
48+
spec:
49+
type: ClusterIP
50+
selector:
51+
app: creditcheckservice
52+
ports:
53+
- protocol: TCP
54+
port: 8888
55+
targetPort: 8888
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Flask==2.2.5
2+
Werkzeug==2.3.8
3+
requests
4+
waitress
5+
splunk-opentelemetry[all]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: creditcheckservice
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: creditcheckservice
9+
template:
10+
metadata:
11+
labels:
12+
app: creditcheckservice
13+
spec:
14+
tolerations:
15+
nodeSelector:
16+
terminationGracePeriodSeconds: 5
17+
containers:
18+
- name: creditcheckservice
19+
image: derekmitchell399/credit-check-service:1.0
20+
imagePullPolicy: Never
21+
ports:
22+
- containerPort: 8888
23+
env:
24+
- name: PORT
25+
value: "8888"
26+
- name: NODE_IP
27+
valueFrom:
28+
fieldRef:
29+
fieldPath: status.hostIP
30+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
31+
value: "http://$(NODE_IP):4317"
32+
- name: OTEL_SERVICE_NAME
33+
value: "creditcheckservice"
34+
- name: OTEL_PROPAGATORS
35+
value: "tracecontext,baggage"
36+
resources:
37+
requests:
38+
cpu: 110m
39+
memory: 90Mi
40+
limits:
41+
cpu: 130m
42+
memory: 128Mi
43+
---
44+
apiVersion: v1
45+
kind: Service
46+
metadata:
47+
name: creditcheckservice
48+
spec:
49+
type: ClusterIP
50+
selector:
51+
app: creditcheckservice
52+
ports:
53+
- protocol: TCP
54+
port: 8888
55+
targetPort: 8888

0 commit comments

Comments
 (0)