From 550c2b86b23e547402e421168a59487908587858 Mon Sep 17 00:00:00 2001 From: Rahul Jagad Date: Tue, 1 Sep 2020 19:50:21 -0700 Subject: [PATCH] Support for Datadog tracing in CartService and RedisDB. Updated the README documentation --- README.md | 32 +++++++++++++++++++++++++++ kubernetes-manifests/cartservice.yaml | 24 ++++++++++++++++++++ kubernetes-manifests/redis.yaml | 4 ++++ src/cartservice/Dockerfile | 5 +++++ src/cartservice/Program.cs | 2 +- src/loadgenerator/locustfile.py | 2 +- 6 files changed, 67 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 358f868..7457398 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,38 @@ If you’re using this demo, please **★Star** this repository to show your int Looking for the old Hipster Shop frontend interface? Use the [manifests](https://github.com/GoogleCloudPlatform/microservices-demo/tree/v0.1.5/kubernetes-manifests) in release [v0.1.5](https://github.com/GoogleCloudPlatform/microservices-demo/releases/v0.1.5). +## Quick Start (For Relyance developer) +Run the following commands, if you want to get the online boutique app quickly up and running + +1. Enable kubernetes using "Docker For Desktop" (Docker -> Preference -> Kuberentes -> Enable Kuberentes -> Apply & Restart). + +2. Login to your google cloud account (if not already done ) +``` +gcloud auth login +gcloud auth configure-docker +``` + +3. Create the secret for docker registry (which is used to pull the images from relyance-internal project) +``` +kubectl --namespace=default create secret docker-registry gcr --docker-server=https://gcr.io --docker-username=oauth2accesstoken --docker-password="$(gcloud auth print-access-token)" --docker-email=engineer@relyance.ai +``` + +4. Patch the service account with newly created secret +``` +kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gcr"}]}' +``` +5. Configure Datadog agent permissions ( skip if you dont care about APM tools) +``` +kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/clusterrole.yaml" +kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/serviceaccount.yaml" +kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/clusterrolebinding.yaml" +``` + +6. Run the Online Boutique App +``` +kubectl apply -f release/kubernetes-manifests.yaml +``` + ## Screenshots | Home Page | Checkout Screen | diff --git a/kubernetes-manifests/cartservice.yaml b/kubernetes-manifests/cartservice.yaml index 31175da..dd79d56 100644 --- a/kubernetes-manifests/cartservice.yaml +++ b/kubernetes-manifests/cartservice.yaml @@ -36,8 +36,32 @@ spec: value: "redis-cart:6379" - name: PORT value: "7070" + - name: DD_AGENT_HOST + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: DD_ENV + value: "prod" + - name: DD_LOGS_INJECTION + value: "true" + - name: DD_TRACE_ENABLED + value: "true" + - name: DD_SERVICE + value: "cartservice" + - name: DD_VERSION + value: "latest" - name: LISTEN_ADDR value: "0.0.0.0" + - name: CORECLR_ENABLE_PROFILING + value: "1" + - name: CORECLR_PROFILER + value: "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}" + - name: CORECLR_PROFILER_PATH + value: /opt/datadog/Datadog.Trace.ClrProfiler.Native.so + - name: DD_INTEGRATIONS + value: /opt/datadog/integrations.json + - name: DD_DOTNET_TRACER_HOME + value: /opt/datadog resources: requests: cpu: 200m diff --git a/kubernetes-manifests/redis.yaml b/kubernetes-manifests/redis.yaml index e18b08b..139e9f5 100644 --- a/kubernetes-manifests/redis.yaml +++ b/kubernetes-manifests/redis.yaml @@ -39,6 +39,10 @@ spec: value: prod - name: DD_SERVICE value: redis-cart + - name: DD_VERSION + value: latest + - name: DD_LOGS_INJECTION + value: "true" ports: - containerPort: 6379 readinessProbe: diff --git a/src/cartservice/Dockerfile b/src/cartservice/Dockerfile index 331deb0..4a7d577 100644 --- a/src/cartservice/Dockerfile +++ b/src/cartservice/Dockerfile @@ -37,6 +37,11 @@ RUN apk add --no-cache \ libstdc++ \ libintl \ icu + +RUN apk --no-cache add curl +RUN mkdir -p /opt/datadog +RUN curl -L https://github.com/DataDog/dd-trace-dotnet/releases/download/v1.19.2/datadog-dotnet-apm-1.19.2-musl.tar.gz | tar xzf - -C /opt/datadog +RUN sh /opt/datadog/createLogPath.sh WORKDIR /app COPY --from=builder /cartservice . ENTRYPOINT ["./cartservice", "start"] diff --git a/src/cartservice/Program.cs b/src/cartservice/Program.cs index cf5269b..37cb283 100644 --- a/src/cartservice/Program.cs +++ b/src/cartservice/Program.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System; +using System; using System.IO; using System.Threading; using System.Threading.Tasks; diff --git a/src/loadgenerator/locustfile.py b/src/loadgenerator/locustfile.py index b134538..7007f2d 100644 --- a/src/loadgenerator/locustfile.py +++ b/src/loadgenerator/locustfile.py @@ -78,4 +78,4 @@ class UserBehavior(TaskSet): class WebsiteUser(HttpLocust): task_set = UserBehavior - wait_time = between(1, 10) + wait_time = between(10, 30)