Adds liveness probe annotation, moves loadgen initcontainer into main
This commit is contained in:
parent
61dd04992b
commit
1b57e37ee1
5 changed files with 41 additions and 26 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -9,3 +9,7 @@ pkg/
|
||||||
.idea
|
.idea
|
||||||
.skaffold-*.yaml
|
.skaffold-*.yaml
|
||||||
.kubernetes-manifests-*/
|
.kubernetes-manifests-*/
|
||||||
|
istio-1.*/
|
||||||
|
install-istio.sh
|
||||||
|
mtls.yaml
|
||||||
|
istio.yaml
|
19
README.md
19
README.md
|
@ -212,35 +212,28 @@ by deploying the [release manifest](./release) directly to an existing cluster.
|
||||||
--istio-config=auth=MTLS_PERMISSIVE
|
--istio-config=auth=MTLS_PERMISSIVE
|
||||||
```
|
```
|
||||||
|
|
||||||
> NOTE: If you need to enable `MTLS_STRICT` mode, you will need to update
|
2. (Optional) Enable Stackdriver Tracing/Logging with Istio Stackdriver Adapter
|
||||||
> several manifest files:
|
|
||||||
>
|
|
||||||
> - `kubernetes-manifests/frontend.yaml`: delete "livenessProbe" and
|
|
||||||
> "readinessProbe" fields.
|
|
||||||
> - `kubernetes-manifests/loadgenerator.yaml`: delete "initContainers" field.
|
|
||||||
|
|
||||||
1. (Optional) Enable Stackdriver Tracing/Logging with Istio Stackdriver Adapter
|
|
||||||
by [following this guide](https://cloud.google.com/istio/docs/istio-on-gke/installing#enabling_tracing_and_logging).
|
by [following this guide](https://cloud.google.com/istio/docs/istio-on-gke/installing#enabling_tracing_and_logging).
|
||||||
|
|
||||||
1. Install the automatic sidecar injection (annotate the `default` namespace
|
3. Install the automatic sidecar injection (annotate the `default` namespace
|
||||||
with the label):
|
with the label):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
kubectl label namespace default istio-injection=enabled
|
kubectl label namespace default istio-injection=enabled
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Apply the manifests in [`./istio-manifests`](./istio-manifests) directory.
|
4. Apply the manifests in [`./istio-manifests`](./istio-manifests) directory.
|
||||||
(This is required only once.)
|
(This is required only once.)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
kubectl apply -f ./istio-manifests
|
kubectl apply -f ./istio-manifests
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Deploy the application with `skaffold run --default-repo=gcr.io/[PROJECT_ID]`.
|
5. Deploy the application with `skaffold run --default-repo=gcr.io/[PROJECT_ID]`.
|
||||||
|
|
||||||
1. Run `kubectl get pods` to see pods are in a healthy and ready state.
|
6. Run `kubectl get pods` to see pods are in a healthy and ready state.
|
||||||
|
|
||||||
1. Find the IP address of your Istio gateway Ingress or Service, and visit the
|
7. Find the IP address of your Istio gateway Ingress or Service, and visit the
|
||||||
application.
|
application.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
|
@ -199,6 +199,8 @@ spec:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: frontend
|
app: frontend
|
||||||
|
annotations:
|
||||||
|
sidecar.istio.io/rewriteAppHTTPProbers: "true"
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
|
@ -444,23 +446,27 @@ spec:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: loadgenerator
|
app: loadgenerator
|
||||||
|
annotations:
|
||||||
|
sidecar.istio.io/rewriteAppHTTPProbers: "true"
|
||||||
spec:
|
spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
initContainers:
|
# initContainers:
|
||||||
- name: wait-frontend
|
# - name: wait-frontend
|
||||||
image: alpine:3.6
|
# image: alpine:3.6
|
||||||
command: ['sh', '-c', 'set -x; apk add --no-cache curl &&
|
# command: ['sh', '-c', 'set -x; apk add --no-cache curl &&
|
||||||
until timeout -t 2 curl -f "http://${FRONTEND_ADDR}"; do
|
# until timeout -t 2 curl -f "http://${FRONTEND_ADDR}"; do
|
||||||
echo "waiting for http://${FRONTEND_ADDR}";
|
# echo "waiting for http://${FRONTEND_ADDR}";
|
||||||
sleep 2;
|
# sleep 2;
|
||||||
done;']
|
# done;']
|
||||||
env:
|
# env:
|
||||||
- name: FRONTEND_ADDR
|
# - name: FRONTEND_ADDR
|
||||||
value: "frontend:80"
|
# value: "frontend:80"
|
||||||
containers:
|
containers:
|
||||||
- name: main
|
- name: main
|
||||||
image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.2
|
# image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.2
|
||||||
|
image: gcr.io/megandemo/loadgen:failcurl
|
||||||
|
imagePullPolicy: Always
|
||||||
env:
|
env:
|
||||||
- name: FRONTEND_ADDR
|
- name: FRONTEND_ADDR
|
||||||
value: "frontend:80"
|
value: "frontend:80"
|
||||||
|
|
|
@ -15,4 +15,7 @@ COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN chmod +x ./loadgen.sh
|
RUN chmod +x ./loadgen.sh
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
curl
|
||||||
ENTRYPOINT ./loadgen.sh
|
ENTRYPOINT ./loadgen.sh
|
||||||
|
|
|
@ -18,10 +18,19 @@
|
||||||
set -e
|
set -e
|
||||||
trap "exit" TERM
|
trap "exit" TERM
|
||||||
|
|
||||||
if [[ -z "${FRONTEND_ADDR}" ]]; then
|
if [ -z "${FRONTEND_ADDR}" ]; then
|
||||||
echo >&2 "FRONTEND_ADDR not specified"
|
echo >&2 "FRONTEND_ADDR not specified"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
# if one request to the frontend fails, then exit
|
||||||
|
STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" http://${FRONTEND_ADDR})
|
||||||
|
if test $STATUSCODE -ne 200; then
|
||||||
|
echo "Error: cannot reach frontend, exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# else, run loadgen
|
||||||
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1
|
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" 2>&1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue