当前位置: 首页 > 软件库 > 云计算 > >

infrastructure-as-code-talk

授权协议 Readme
开发语言 Java
所属分类 云计算
软件类型 开源软件
地区 不详
投 递 者 贺元明
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Infrastructure as Code Talk

This repo contains the sample code for the talk Infrastructure-as-code: running microservices on AWS with Docker,Terraform, and ECS.It includes a couple sample Dockerized microservices and the Terraform code to deploy them on AWS:

Note: This repo is for demonstration purposes only and should NOT be used to run anything important. Forproduction-ready version of this code and many other types of infrastructure, check outGruntwork.

Quick start

Running the microservices locally

To run the rails-frontend and sinatra-backend on your local dev box:

  1. Install Docker.
  2. docker-compose up
  3. Test sinatra-backend by going to http://localhost:4567.
  4. Test the rails-frontend (and its connectivity to the sinatra-backend) by going to http://localhost:3000.

The docker-compose.yml file mounts rails-frontend and sinatra-backend folders as volumes in each Docker image, soany changes you make to the apps on your host OS will automatically be reflected in the running Docker container. Thislets you do iterative "make-a-change-and-refresh" style development.

Deploying the microservices in AWS

To deploy the microservices to your AWS account, see the terraform-configurations README.

Using your own Docker images

By default, docker-compose.yml and the terraform-configurationsare using the gruntwork/rails-frontend and gruntwork/sinatra-backend Docker images. These are images I pushed tothe Gruntwork Docker Hub account to make it easy for you totry this repo quickly. Obviously, in the real world, you'll want to use your own images instead.

Follow Docker's documentation to create your own Dockerimages and fill in the new image id and tag in:

  1. docker-compose.yml: the image attribute for rails_frontend or sinatra_backend.
  2. terraform-configurations/terraform.tfvars: the rails_frontend_image and rails_frontend_version orsinatra_backend_image and sinatra_backend_version variables.

Overview of the repo

Here's an overview of what's in this repo:

  1. An example sinatra-backend microservice that just returns the text "Hello, World". This appincludes a Dockerfile to package it as a Docker container.

  2. An example rails-frontend microservice that makes an HTTP call to the sinatra-backend andrenders the result as HTML. This app includes a Dockerfile to package it as a Dockercontainer.

  3. A docker-compose.yml file to deploy both Docker containers so you can see how the twomicroservices work together in the development environment. To allow the services to talk to each other, we areusing Docker Links as a simple"service discovery" mechanism.

  4. Terraform configurations to deploy both Docker containers on Amazon'sEC2 Container Service (ECS) so you can see how the two microservices work together inthe production environment. To allow the services to talk to each other, we deploy an Elastic Load Balancer(ELB) in front of each service and use Terraform to pass the ELBURLs between services. We are using the same environment variables as Docker Links, so this acts as a simple"service discovery" mechanism that works in both dev and prod.

More info

For more info, check out the talk Infrastructure-as-code: running microservices on AWS with Docker, Terraform, andECS,including the video andslides.For a deeper look at Terraform, check out the book Terraform: Up & Running.

  • 摘要: Wireless ad hoc networks provide a new dimension to computing by allowing a group of portable devices to talk to each other without any additional infrastructure and have been the focus of researc

  • AtCoder Beginner Contest 161 F.Division or Subtraction 题目链接 Problem Statement Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation

  • AtCoder Beginner Contest 172.F - Unfair Nim 传送门 思路:异或的性质+构造。 显然题目背景是 N i m Nim Nim游戏,我们目的是让后手胜,显然 n n n堆石子异或为 0 0 0时,后手必胜。接下我们需要构造来使 n n n堆石子异或和为 0 0 0。 因为题目要求我们只能将移动第一堆石子给第二堆石子。 我们记第一堆和第二堆石子个数分别为 a ,

  • C. Keshi Is Throwing a Party time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Keshi is throwing a party and he wants everybody in the party

  • AtCoder Beginner Contest 152 E.Flatten 题目来源 Problem Statement Given are N N N positive integers A 1 , . . . , A N . A_1,...,A_N. A1​,...,AN​. Consider positive integers B 1 , . . . , B N . B_1,...,B_N

  • 第一次使用csdn的blog 试试水,写和发布还是蛮方便的,就是页面内的广告有点多啊,太乱了! 留下一句最喜欢的话:Talk is cheap,show me your code!!!

  • A 题意: 有一个开关,每天s点开,t点关(可能在第2天或第n天),判断x点时开着还是关着。 思路: 按照是否需要隔夜分个类。 #include<bits/stdc++.h> using namespace std; int main(){ int s, t, x; cin>>s>>t>>x; if(s<t){ if(x>=s&&x<t)cout<<"Yes

  • AtCoder Beginner Contest 159 F.napsack for All Segments 题目链接 Problem Statement Given are a sequence of N N N integers A 1 , A 2 , … , A N A_1, A_2, …, A_N A1​,A2​,…,AN​ and a positive integer S. For a

  • 我摆烂了 平均数会吧?(小学芝士) 费马求逆元会吧?(OIer必背备) 树状数组会吧?(树状数组你不会你打什么ABC?) 那这题你会了。(逃 题目大意 MYi不会翻译 给定一个长度为 N N N 的序列 A A A ,对于每个 K ( 1 ≤ K ≤ N ) K (1 \leq K \leq N) K(1≤K≤N),求: 从 A A A 的前 K K K 个数中选出一个数 A x A_x Ax​

  • 看了文档 : 1天 直接写框架 学习tokio 异步编程 技术选型 技术选型,主要是选择市面上主流的框架,看他们的源码是怎么玩的, web 选择的是rocket ,rocket内部的选型是tokio +hyper 所以,我的框架也会是根据tokio+hyper 然后,先看tokio 是怎么用的, 然后再看hyper 怎么嵌入, hyper 是bind tcpListener, 然后围绕tcpLis

  • https://atcoder.jp/contests/abc187/tasks/abc187_f 有点像小米决赛的G题啊,所以就秒了 dp[i]表示i这个状压状态,最少可以是多少连通块组成 先预处理看这一个状态能不能用一个连通块,即全联通,那就枚举每个点看他与其他点有没有连上,可以预处理出每个点与哪些点相连了,然后用位运算O(1)判断 然后再枚举i的所有子集,看能不能合并 复杂度就是3^n #i

  •   Pass代表转换和优化的基础设施。本文档提供MLIR基础设施-Pass的概要说明已经使用方式。   阅读MLIR specification章节可以获得跟多MLIR的核心内容,例如IR结构与操作。   阅读MLIR Rewrites章节可以快速入门MLIR的图重写,如果一个转换涉及到匹配操作DAGs,这将是一个好的开始。 操作Pass(Operation Pass)   操作是MLIR中抽象和

  • 传送门 学了一个技巧 求最大、最小值,相加除以二就可以了,具体是怎么得到的我也不知道,题目要求找最佳位置,把位置和时间相加 取最大值,位置减时间,取最小值,得到最大值最小值,相加除以二即可。 1. 技巧 #include<bits/stdc++.h> using namespace std; struct p { int x,t; }q[101010]; int main() { int i,

  • A - CAPS LOCK 题意:小写变大写 翻译:水 #include<bits/stdc++.h> using namespace std; int main() { string str;cin >> str; int end = str.size(); for(int i = 0;i < end;i++) cout << (char)(str[i] - 32); } B - Y

  • F - Main Street——AtCoder Beginner Contest 258 题目 多组数据,每组数据,给定 B,K,Sx,Sy,Gx,Gy。在一个二维平面上,每次可以上下左右移动一个单位,要从起点(Sx,Sy)移动到终点(Gx,Gy)。 有大路和小路两种路。大路是 [公式] (t 为任意整数), [公式] 对应的直线。不在这些直线上的路是小路。走大路每移动一个单位花费 1 单位时间

  • 题目链接 点我跳转 题目大意 给定 \(N\) 个物品和一个 \(X\) ,第 \(i\) 个物品的重量为 \(ai\),你可以从中选择任意个物品(不能不选) 假定选择了 \(S\) 个物品,物品的总重量为 \(V\) 那么再满足 \((X - V) \% S = 0\) 的前提下还需要支付 \((X - V) / S\) 的 \(money\) 问最少需要支付多少 \(money\) 解题思路

  • N Set to 1 when the result of the operation was negative, cleared to 0 otherwise. Z Set to 1 when the result of the operation was zero, cleared to 0 otherwise. C Set to 1 when the operation resulted i

  • AtCoder Beginner Contest 234 点击进入 我的博客 阅读观感更佳 A - Weird Function 思路:模拟 Code: #include <bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long ll; ll t; ll f(ll x){ return x*x+2*x+3

  • 题目链接:A - On and Off (atcoder.jp) Problem Statement Takahashi turns on the light of his room at S o'clock (on the 2424-hour clock) every day and turns it off at T o'clock every day. The date may change

  • F - Shortest Good Path 题意: 给你n个点,m条边,无重边,无自环 一个数列如果满足,所有的都在1-N并且两点之间有边连就可以 还有1 0表示路径经过i点的次数是奇数还是偶数 题解: 1.如何表示? (1)输入时用一个vector表示,后续用auto得到对应的值。 (2)dis[i][j]表示现在状态是i「用二进制来表示」,数为j。 2.如何做? (1)为什么一开始要u-1,

  • 题目传送门 F - Two Strings (atcoder.jp) 题目大意 我们定义 f ( S , i ) f(S,i) f(S,i) 是将字符串 S S S 的前 i i i 个字符删掉拼接到末尾的字符串。如 f ( ′ a b d   ′ , 2 ) = ′ d a b   ′ f('abd~',2)='dab~' f(′abd ′,2)=′dab ′。 给定两个长度为 n n n 的字

  • A - Shift 简单模拟。 #include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int i = a;i<n;i++) #define per(i,a,n) for(int i = n-1;i>=a;i--) #define pb push_back #define mp make_pair #define eb

 相关资料
  • Infrastructure As Code Tutorial This tutorial is intended to show what the Infrastructure as Code (IaC) is, why we need it, and how it can help you manage your infrastructure more efficiently. It is p

  • Code as Policies 是一种以机器人为中心的语言模型生成的程序在物理系统上执行的表述。CaP 扩展了 PaLM-SayCan,使语言模型能够通过通用 Python 代码的完整表达来完成更复杂的机器人任务。通过 CaP,Google 建议使用语言模型,通过少量的提示来直接编写机器人代码。实验证明,与直接学习机器人任务和输出自然语言动作相比,CaP 输出代码表现更好。CaP 允许单一系统执

  • Microservices infrastructure 是一个为快速部署全球分布式服务的现代平台。 基础平台包括可以用来管理集群和资源节点数量的控制节点。容器可以自动在 DNS 上注册,从而使其他服务能够定位到它们 一旦 WAN 配置好了,每个集群可以通过 DNS 或者 Consul API 在其他数据中心定位服务。 平台架构: 单数据中心: 多数据中心: 控制节点: 资源节点: Core Co

  • Infrastructure模式 经由无线基地台(access point),让PSP™主机与网络联机的模式。与网络联机前,需先新建网络联机。 准备必需的物品 新建网络联机 - 标准设置 - 进阶设定 使用公众无线LAN服务 将移动电话等Bluetooth®(蓝牙)装置当作调制解调器使用   选项选单 测试联机 机器认证

  • VMware Infrastructure (vSphere) Java API 提供了一个全功能的Java 类库用来控制和管理 VMware 虚拟机和服务器的。2.0 版本包含一个高性能的Web服务。

  • 问题内容: 在升级到Swift 1.2之前,我可以编写以下行: 现在它迫使我写这一行: 我的问题是,如果我被迫如上所述编写代码,难道我不能只编写下面的代码,它会做同样的事情吗?在imageDetails的所有值中都可以得到相同的结果吗? 问题答案: as关键字用于进行上下转换: 从派生类到基类的转换可以在编译时检查,并且永远不会失败。 但是,向下转换可能会失败,因为您无法始终确定特定的类别。如果您