|
1 | 1 | #!/bin/bash |
2 | 2 |
|
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) |
5 | 10 | # |
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 |
7 | 31 |
|
8 | 32 | echo "" |
9 | | -echo Applied the tagging changes to creditcheckservice. |
| 33 | +echo Redeployed creditcheckservice-with-tags. |
0 commit comments