{"id":18524488,"url":"https://github.com/stelligent/mu-workshop-lab1","last_synced_at":"2025-05-14T19:17:05.849Z","repository":{"id":145835604,"uuid":"93798521","full_name":"stelligent/mu-workshop-lab1","owner":"stelligent","description":"Lab for learning mu","archived":false,"fork":false,"pushed_at":"2020-01-07T15:41:36.000Z","size":427,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-26T00:26:53.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://getmu.io","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:00:30.000Z","updated_at":"2020-01-07T15:41:38.000Z","dependencies_parsed_at":"2023-07-15T21:00:59.776Z","dependency_job_id":null,"html_url":"https://github.com/stelligent/mu-workshop-lab1","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-lab1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelligent%2Fmu-workshop-lab1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stelligent","download_url":"https://codeload.github.com/stelligent/mu-workshop-lab1/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.744Z","updated_at":"2025-02-17T05:42:06.654Z","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 run a simple spring boot microservice on ECS.\n\n![Architecture Diagram](architecture.png)\n\n\n# Workspace setup\n\nFirst, the following prerequisites should be installed on your machine:\n\n* **aws-cli**: [Install](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) and [configure](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration)\n* **git**: Any git cli will do, however we will be using AWS CodeCommit for our source code.  In order to use https URLs, you'll need to configure git to use the AWS CLI for generating temporary credentials:\n\n```\ngit config --global credential.helper '!aws codecommit credential-helper $@'\ngit config --global credential.UseHttpPath true\n```\n* **ssh**: Any ssh client will do.  You will need have a [key](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) to explore the instances that mu creates.  The key needs to be imported into AWS via:\n\n```\naws ec2 import-key-pair --key-name mu-key --public-key-material \"$(cat ~/.ssh/id_rsa.pub)\"\n```\n\n* **mu**: `curl -s http://getmu.io/install.sh | sh`\n\n\n# Pull down banana service\nLet's start by pulling down the sample spring boot microservice:\n\n```\ngit clone git@github.com:stelligent/mu-workshop-lab1.git banana-service\n\ncd banana-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 banana-service\n\ngit remote set-url origin https://git-codecommit.us-east-1.amazonaws.com/v1/repos/banana-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.  Pass the `--env` flag to have mu also setup the environment for your service:\n\n```\nmu init --env\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 environments\nUse the [Environments](https://github.com/stelligent/mu/wiki/Environments#configuration) section of the wiki to configure the following for your environments:\n\n* ECS container instance type: Configure as **m4.large**\n* EC2 keypair: Configure as **mu-key** that we imported earlier\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 `/bananas*`\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# Push changes to CodeCommit\n```\ngit add --all\ngit commit -m \"mu init\"\ngit push\n```\n\n# Create Pipeline\nNow that our service is ready to deploy, let's create a pipeline for the service:\n\n```\nmu pipeline up\n```\n\n# Explore and wait...\nWhile we wait for the pipeline to run, let's explore what mu created:\n\n* **CodePipeline console** - Open the AWS console and navigate to CodePipeline.  Check out the different stages and actions in the pipeline.\n    * What is the difference between the *Artifact* and *Image* actions in the *Build* stage?\n    * What `mu` commands are being run in the *Deploy* actions?\n\n* **mu cli** - Monitor the progress of the pipeline with `mu`\n    * How can you view the logs from the CodeBuild executions [hint](https://github.com/stelligent/mu/wiki/Pipelines#commands)?\n    * How can you see the status of the pipeline with `mu` [hint](https://github.com/stelligent/mu/wiki/Services#commands)?\n\n* **CloudFormation console** - Open the AWS console and navigate to CloudFormation.  Check out the different stacks and resources created.\n    * What is the difference between the pipeline, vpc, cluster and service stacks?\n    * Is it possible to target an existing VPC rather than have mu create the VPC [hint](https://github.com/stelligent/mu/wiki/Environments#configuration)?\n    * Check out the subnets in the VPC console.  Are the ECS subnets public or private?  ELB subnets?\n\n* **Service output** - Use `mu` to view the logs for your service.\n    * Do you see any errors in the service logs [hint](https://github.com/stelligent/mu/wiki/Services#commands)?\n    * What do the errors mean?\n\n* **EC2 instances** - Use the bastion host that `mu` created to login to your ECS instance\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    * Login to ECS instance\n    * How many docker containers are running? (hint: `docker ps`)\n    * How much CPU/memory are the containers using? (hint: `docker stats`)\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    * Test the service via `curl \u003cbaseurl\u003e/bananas/`\n    * What does the response look like?\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Fmu-workshop-lab1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstelligent%2Fmu-workshop-lab1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelligent%2Fmu-workshop-lab1/lists"}