Git Product home page Git Product logo

aws-samples / reinvent2018-dev303-code Goto Github PK

View Code? Open in Web Editor NEW
57.0 7.0 37.0 47.02 MB

Code accompanying AWS re:Invent workshop DEV 303 showcasing how to get deep application insights using Amazon EKS with AWS X-Ray and Amazon CloudWatch.

Home Page: https://speakerdeck.com/ckassen/instrumenting-kubernetes-for-observability-using-aws-x-ray-and-amazon-cloudwatch-dev303

License: MIT No Attribution

Shell 3.93% Dockerfile 10.83% Python 34.26% JavaScript 30.49% CSS 1.56% Handlebars 18.92%
aws-xray aws-eks kubernetes tracing prometheus grafana aws

reinvent2018-dev303-code's Introduction

Instrumenting Kubernetes for Observability using AWS X-Ray and Amazon CloudWatch

The goal of this workshop is to demonstrate how to build and monitor modern applications with AWS Elastic Kubernetes Services (EKS), Amazon CloudWatch Logs and AWS X-Ray.

This workshop consists of 3 labs and will walk through the following:

  1. Lab 1
    1. Prepare your environment
    2. Create an AWS EKS cluster with eksctl
    3. Deploy eCommerce microservices demo application
  2. Lab 2
    1. Deploy a log aggregation stack
    2. Deploy metrics collection and visualization
  3. Lab 3
    1. Deploy AWS X-Ray and enable tracing within the sample applications

Note

This workshops is an advanced workshop (Level 300) and requires a deep understanding of AWS capabilities as well as know-how in software development, containers, and Kubernetes.

Application Architecture

The architecture of the application we will be deploying looks like this:

alt Architecture

The services are either build in Node.js and the Express framework or Python with the Flask framework. As data store DynamoDB is used. To store the cart and the session data a self-hosted Redis is used. The orders are put into an SQS queue, where a worker process could pick them up for order-processing.

Labs

Prerequisites

Prerequisites

Lab 1 - Deploying microservices to Amazon EKS

Deploying microservices on EKS

Lab 2 - Observability for Amazon EKS

Observability for EKS

Lab 3 - Distributed Tracing with AWS X-Ray

Adding distributed tracing

Cleaning up

Cleanup instructions

Troubleshooting

Cloud9 not connecting

Make sure the Cloud9 EC2 instances is running. Check that it has a public IP attached, otherwise the Browser-Component will not be able to connect.

If you can not get Cloud9 to work use a regular EC2 Linux instance to run the commands.

EKS cluster authentication failure

Make sure that you did not create the cluster with the AWS account root user. You have to use an IAM user when creating the EKS cluster.

Doublecheck that your kubectl version is at least version 1.10.0, otherwise the integration with the IAM authenticator is not yet available causing authentication to fail.

Make sure that aws-iam-authenticator is installed and executable, so kubectl can call it when authenticating against the EKS cluster.

Load Balancer URL not accessible

When creating new services in Kubernetes it may take a while until the Elastic Load Balancer is created and becomes available. Also, propagation within DNS may take some additional time. If you can not access a newly created service please just wait a little while and then reload in your browser.

All load balancers are also visible in the EC2 Console -> Loadbalancers, check here for additional details.

Traces not visible

Make sure the X-Ray daemon is running successfully. Check the log output of the daemons to see if the permissions to send traces to AWS X-Ray have been set up correctly.

Long cluster spin up time

Creating the EKS cluster and node group should take around 10-15 minutes. If it takes longer eksctl will run into a timeout. Delete the cluster and simply try again.

Check ELB IAM role

In AWS accounts that have never created a load balancer before, it’s possible that the service role for ELB might not exist yet.

We can check for the role, and create it if it’s missing.

aws iam get-role --role-name "AWSServiceRoleForElasticLoadBalancing" || aws iam create-service-linked-role --aws-service-name "elasticloadbalancing.amazonaws.com"

Configure Storage Class

When using the latest version of eksctl a StorageClass will be automatically created.

Check if a StorageClass exists for your cluster with the command

kubectl get storageclasses

If you do not have a StorageClass installed the deployment of Prometheus and Grafana will fail.

Execute the command

kubectl create -f - <<EOF
{
  "kind": "StorageClass",
  "apiVersion": "storage.k8s.io/v1",
  "metadata": {
    "name": "prometheus",
    "namespace": "prometheus"
  },
  "provisioner": "kubernetes.io/aws-ebs",
  "parameters": {
    "type": "gp2"
  },
  "reclaimPolicy": "Retain",
  "mountOptions": [
    "debug"
  ]  
}
EOF

This will create a StorageClass in your Amazon EKS cluster.

Changelog

  • **04/15/2020 Merge xray branch into master to ease deployment and maintainability.

References & Acknowledgements

  1. Amazon EKS Workshop
  2. Sockshop - Weaveworks
  3. Google Microservices Demo

License Summary

This sample code is made available under a modified MIT license. See the LICENSE file.

reinvent2018-dev303-code's People

Contributors

ckassen avatar dependabot[bot] avatar henrybravo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

reinvent2018-dev303-code's Issues

kubectl client version issue

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues. [details here]

for eg. to update to version 1.15

sudo curl --silent --location -o /usr/local/bin/kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl

xray makes import_data fail

The import_data method in the catalog service seems to fail due to xray SegmentNotFoundException.

I managed to fix it locally by adding a begin_segment / end_segment like this:
xray_recorder.begin_segment(name="import_data")

...

end_segment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.