{"id":18524486,"url":"https://github.com/stelligent/mu-workshop-lab3","last_synced_at":"2025-06-26T09:32:48.795Z","repository":{"id":145835631,"uuid":"93798743","full_name":"stelligent/mu-workshop-lab3","owner":"stelligent","description":"Lab for learning mu","archived":false,"fork":false,"pushed_at":"2020-01-07T15:42:30.000Z","size":466,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-26T00:26:56.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stelligent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-08T23:04:38.000Z","updated_at":"2020-01-07T15:42:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"7515ae30-22bb-4c73-968b-449a0cc9498b","html_url":"https://github.com/stelligent/mu-workshop-lab3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stelligent","download_url":"https://codeload.github.com/stelligent/mu-workshop-lab3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239242066,"owners_count":19605946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T17:42:01.032Z","updated_at":"2025-02-17T05:42:06.055Z","avatar_url":"https://github.com/stelligent.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nThis repository contains a lab for the [mu](https://github.com/stelligent/mu) workshop.  The goal of this lab is to add service discovery for microservice to microservice commnication based on the service from the [first lab](https://github.com/stelligent/mu-workshop-lab1).\n\n![Architecture Diagram](architecture.png)\n\n\n# Continue from lab 2\nThis lab assumes that you have a pipeline successfully deployed in the first and second labs.  You can see a completed version of the second lab on the [solution](https://github.com/stelligent/mu-workshop-lab2/tree/solution) branch.\n\n# Limit to 1 instance\nSince we are running an in-memory database that is not shared between all instances of the banana service, we need to update it to only run a single instance.  Update the `mu.yml` file and set the `desiredCount` to `1`.  For more details, see the [Services](https://github.com/stelligent/mu/wiki/Services#configuration) section of the wiki.\n\n# Enable Consul\nUpdate the `mu.yml` file in your `banana-service` to enable Consul service discovery for the dev and production environments.  Details can be found in the [mu wiki](https://github.com/stelligent/mu/wiki/Service-Discovery)\n\nCommit and push the change to apply the change:\n\n```\ngit add --all\ngit commit -m \"enable consul\"\ngit push\n```\n\n# Pull down milkshake service\nLet's start by pulling down a second spring boot microservice:\n\n```\ngit clone git@github.com:stelligent/mu-workshop-lab3.git milkshake-service\n\ncd milkshake-service\n```\n\nNow, let's create a CodeCommit repo in our AWS account and push the service to the new CodeCommit repo.  If you are working a region other than **us-east-1**, then be sure to update the URL for the CodeCommit repo:\n\n```\naws codecommit create-repository --repository-name milkshake-service\n\ngit remote set-url origin https://git-codecommit.us-east-1.amazonaws.com/v1/repos/milkshake-service\n```\n\n# Initialize mu.yml\nWe want to setup our `mu.yml` file so that mu can manage our service.  The easiest way to start is with `mu init`.  This doesn't actually do anything in your AWS account, just in your local mu.yml file.  Do NOT pass the `--env` flag since we are going to share the same environment that is being managed by the `banana-service` from Lab 1.\n\n```\nmu init\n```\n\nThis generates 2 new files, `mu.yml` and `buildspec.yml`.  We need to make some updates to both to reflect run our microservice.\n\n# Configure service\nUse the [Services](https://github.com/stelligent/mu/wiki/Services#configuration) section of the wiki to configure the following for your service:\n\n* Path pattern: update to only route `/milkshakes*`\n\n# Configure pipeline\nUse the [Pipelines](https://github.com/stelligent/mu/wiki/Pipelines#configuration) section of the wiki to configure the following for your service pipeline:\n\n* Build image: Update the [image](http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html#build-env-ref-available) that CodeBuild uses to `aws/codebuild/java:openjdk-8`\n\n# Configure CodeBuild\nUpdate the [buildspec.yml](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax) to run `gradle build`.\n\n#  Pipeline\nNow that our service is ready to test, let's update the pipeline for the service:\nhttps://github.com/stelligent/mu/wiki/Service-Discovery\n\n```\nmu pipeline up\n```\n\nFinally, push the changes to trigger a pipeline invocation:\n\n```\ngit add --all\ngit commit -m \"mu testing\"\ngit push\n```\n\n\n# Explore and wait...\nWhile we wait for the pipeline to run, let's explore what mu created:\n\n* **Source code** - BananaProvider.java\n    * Look at the BananaProvider class in the milkshake-service.  How does the milkshake-service call he banana-service?\n    * What is the significance of the hostname in the URL for the call that milkshake service makes to the banana service?\n    * What would have happened if we hadn't forced the banana service to be `desiredCount` of `1`?\n\n* **CloudFormation console** - Whats's new?\n    * Navigate to the CloudFormation console.  What's included in the new `mu-consul-dev` stack?\n\n* **ECS console** - Whats's new?\n    * Check out the new `mu-consul-dev` cluster.  What tasks are running?  How many ECS container instances?  Why?\n    * Check out the prior `mu-cluster-dev` cluster.  How many tasks are running?  What containers are running for the `consul-agent` task?\n\n* **mu cli** - Environment logs\n    * Use `mu` to search the logs for Consul activity in last 30 minutes for the `dev` environment: `mu env logs -t 30m dev consul`\n\n* **Consul UI** -\n    * Get the bastion host and ECS instance IP via `mu env show dev`\n    * Login to bastion host `ssh -i ~/.ssh/id_rsa ec2-user@\u003cbastion-ip\u003e`\n    * Get the URL for the Consul UI: `aws cloudformation describe-stacks --stack-name mu-consul-dev --query \"Stacks[].Outputs[?OutputKey=='ConsulUiUrl'].OutputValue\" --output text`\n    * Configure your SOCKS5 proxy to `localhost:8080`\n    * Navigate to `http://\u003cConsul UI ELB\u003e/ui/`\n    * If unable to configure proxy, try curl and notice how many of each server is running.  What is the `ServicePort`?\n\n```\ncurl -x socks5h://localhost:8080 http://\u003cConsul UI ELB\u003e/v1/catalog/service/milkshake-service | jq\ncurl -x socks5h://localhost:8080 http://\u003cConsul UI ELB\u003e/v1/catalog/service/banana-service | jq\n```\n\n* **Test the service** - Once the pipeline is successfully deployed to the **dev** environment, test it!\n    * Get the base URL of the ELB via `mu env show dev`\n    * Create a new vanilla milkshake: `curl \u003cbaseurl\u003e/milkshakes -F flavor=Vanilla`\n    * Create a new banana milkshake: `curl \u003cbaseurl\u003e/milkshakes -F flavor=Banana`\n    * Create some bananas: `curl \u003cbaseurl\u003e/bananas -d \"{}\" -H \"Content-Type: application/json\"\n    * Create a new banana milkshake: `curl \u003cbaseurl\u003e/milkshakes -F flavor=Banana`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Fmu-workshop-lab3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstelligent%2Fmu-workshop-lab3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Fmu-workshop-lab3/lists"}