k8s aws 部署

by Adam Watt

通过亚当·瓦特

如何在短短30分钟内使用CircleCI设置到AWS S3的持续部署 (How to setup Continuous Deployment to AWS S3 using CircleCI in just 30 minutes)

Continuous Deployment might seem complicated at first, but don’t be intimidated. In this tutorial, I’ll show you how to implement Continuous Deployment to AWS S3 for a static website using CircleCI in less than 30 minutes.

乍一看,连续部署似乎很复杂,但不要被吓倒。 在本教程中,我将向您展示如何在不到30分钟的时间内使用CircleCI将静态网站实施到AWS S3的持续部署。

You’ll need both an AWS account and a CircleCI account. If you don’t have these yet, start by opening a free account for AWS here and a free CircleCI account here . Both AWS and CircleCI have a free tier that’s more than enough for what you will need for this tutorial.

您将同时需要一个AWS账户和一个CircleCI账户。 如果您还没有这些,请先在此处开设一个免费的AWS帐户,然后在此处开设一个免费的CircleCI帐户。 AWS和CircleCI都有免费层,足以满足本教程所需。

获取代码 (Getting the code)

First you will start by forking and cloning the following project repo on Github: S3ContinuousDeploy or if you prefer you can try this tutorial with one of your own repos as long as it’s a static site.

首先,您将在Github上创建并克隆以下项目存储库: S3ContinuousDeploy,或者,如果您愿意,可以使用自己的存储库尝试本教程,只要它是静态站点即可。

Next you will add the project to your CircleCI account.

接下来,将项目添加到CircleCI帐户。

Next select the S3ContinuousDeploy repo you just cloned and click build project.

接下来,选择刚刚克隆的S3ContinuousDeploy存储库,然后单击build project。

At this point the build will run, but you will be getting an error message warning you that the settings for your project couldn’t be detected. Which is normal since we don’t have a circle.yml configuration file in place, which is what you will be doing next.

此时,构建将运行,但是您将收到一条错误消息,警告您无法检测到项目的设置。 这是正常的,因为我们没有适当的circle.yml配置文件,这是您下一步要做的。

Looking at the docs at CircleCI you can get an idea of what the circle.yml should look like. Unfortunately the circle.yml file example provided will not work as is and will need some tweaking, so let’s do that.

查看CircleCI上的文档,您可以了解circle.yml的外观。 不幸的是,提供的circle.yml文件示例无法按原样工作,并且需要进行一些调整,所以让我们开始吧。

Below is the modified circle.yml file you will be using:

以下是您将使用的修改后的circle.yml文件:

Basically CircleCI creates the build within a Docker container, and the override under dependencies property (line 3) that I added instructs CircleCI to install the AWS command line interface (awscli) that will be used in this case to help manage and facilitate deployment to AWS S3.

基本上,CircleCI在Docker容器内创建构建,我添加的覆盖项依赖项属性(第3行)之下指示CircleCI安装AWS命令行界面(awscli),在这种情况下将用于帮助管理和促进向AWS的部署S3。

So make sure you add the file and commit it to your repo. Finally make sure you push this and other commits you might have made before you proceed to the next step.

因此,请确保您添加了文件并将其提交到您的仓库中。 最后,在继续下一步之前,请确保已推送此提交以及其他可能提交的提交。

As per CircleCI documentation the command for deploying is:

根据CircleCI文档,部署命令为:

The path-to-file was a bit tricky to figure out but by looking at the error logs I was able to finally get it right: home\ubuntu\projectName. So just replace projectName with the name of your project, in my case that will be S3ContinuousDeploy.

文件路径有点棘手,但是通过查看错误日志,我终于可以正确地找到它:home \ ubuntu \ projectName。 因此,只需将projectName替换为您的项目名称,在我的情况下为S3ContinuousDeploy。

The S3://bucket-URL on the other hand is not correct and should be S3://bucket-Name. Right now we don’t have a bucket name, so let’s get ourselves a bucket.

另一方面,S3:// bucket-URL不正确,应为S3:// bucket-Name。 现在我们没有存储桶名称,所以让我们自己获得一个存储桶。

创建S3存储桶 (Creating the S3 bucket)

In this step we will be heading to the AWS Console to create the S3 bucket for this project:

在此步骤中,我们将前往AWS控制台为该项目创建S3存储桶:

Enter the bucket name you would like to use for this project as well as the region. (The best practice is to use the region nearest to your site’s audience.)

输入您要用于此项目的存储区名称以及区域。 (最佳做法是使用距您的网站受众最近的区域。)

You will skip the other steps for now so press “Next” and then press “Create bucket” on the review screen.

您现在将跳过其他步骤,因此在查看屏幕上按“下一步”,然后按“创建存储桶”。

At this point if you go back to CircleCI and try to run the build again CircleCI will return a fatal error: Unable to locate credentials. So why don’t we fix that next.

此时,如果您返回CircleCI并尝试再次运行该构建,CircleCI将返回一个致命错误:无法找到凭据。 那么,为什么我们接下来不解决这个问题呢?

We need to first get the credentials from AWS and then provide them to CircleCI in order to allow the AWS cli to access and manage the S3 bucket. Best practice for this is to create a new Identity and Access Management (IAM) user specifically for CircleCI.

我们需要首先从AWS获取证书,然后将其提供给CircleCI,以允许AWS cli访问和管理S3存储桶。 最佳做法是为CircleCI创建一个新的身份和访问管理(IAM)用户。

On the AWS console go to Security, Identity & Compliance and press IAM and then Add user.

在AWS控制台上,转到安全,身份和合规性,然后按IAM,然后按添加用户。

In the Add User window type in CircleCI for User name, I already have an IAM user named CircleCI setup, So for the purposes of this tutorial and to illustrate these steps I will be using CircleCI2. Make sure you check Programmatic access for Access type.

在CircleCI中为用户名输入Add User窗口中,我已经有一个名为CircleCI setup的IAM用户,因此,出于本教程的目的并说明这些步骤,我将使用CircleCI2。 确保选中“访问程序类型”的“程序访问”。

For permissions choose Attach existing policies directly, and under Policy name check ‘AdministratorAccess’ and then click Create policy. This will provide your IAM user full access to your AWS S3 bucket.

对于权限,选择“直接附加现有策略”,然后在“策略名称”下选中“ AdministratorAccess”,然后单击“创建策略”。 这将为您的IAM用户提供对您的AWS S3存储桶的完全访问权限。

After creating the IAM user, make sure you keep both the Access key ID and the Secret access key, as we will need them in the next step.

创建IAM用户后,请确保同时保留访问密钥ID和秘密访问密钥,因为在下一步中我们将需要它们。

Now back to CircleCI, click on the settings button next to your project name to reveal the project settings menu then click on AWS Permissions. This is where you will paste the ID and Key from the previous step and then click “Save AWS keys.”

现在回到CircleCI,单击项目名称旁边的设置按钮以显示项目设置菜单,然后单击AWS Permissions。 在此处,您将粘贴上一步中的ID和密钥,然后单击“保存AWS密钥”。

Now our CircleCI Container has both the AWS Command Line Interface tool and the credentials to access the AWS S3 bucket. The following steps will show you how to reveal your static site to the world.

现在,我们的CircleCI容器同时具有AWS Command Line Interface工具和访问AWS S3存储桶的凭据。 以下步骤将向您展示如何向世界展示您的静态站点。

In the AWS console go to Storage and then click on S3 and then click on the bucket we created earlier in this tutorial.

在AWS控制台中,转到存储,然后单击S3,然后单击我们在本教程前面创建的存储桶。

You will notice that the code from the repo has already been successfully deployed.

您会注意到,来自存储库的代码已经成功部署。

Now before you can access this static site you need to configure your S3 bucket for website hosting.

现在,在您可以访问此静态站点之前,您需要配置S3存储桶以用于网站托管。

On the same screen click on Properties and then on Static website hosting.

在同一屏幕上,单击“属性”,然后单击“静态网站托管”。

In the following screen select Use this bucket to host a website and make sure you type in index.html for Index document.

在以下屏幕中,选择“使用此存储桶托管网站”,并确保您输入Index.html作为“索引”文档。

By the way, the HTTP address provided above is your access endpoint. But if you try it in the browser unfortunately it won’t work and you will get an access denied error message. But that’s normal you still have one step to do: Set up your bucket policy.

顺便说一下,上面提供的HTTP地址是您的访问端点。 但是,不幸的是,如果您在浏览器中尝试它,它将无法正常工作,并且您将收到拒绝访问的错误消息。 但这是正常的,您仍然有一个步骤要做:设置存储桶策略。

This Bucket policy will allow access to the AWS S3 bucket to anyone via a browser.

此存储桶策略将允许任何人通过浏览器访问AWS S3存储桶。

You can read up here on bucket policies and examples if you want to learn more.

如果您想了解更多信息,可以在这里阅读存储桶策略和示例。

Now you can copy the code snippet above and paste it in your Bucket policy Editor and Voila!

现在,您可以复制上面的代码片段并将其粘贴到存储桶策略编辑器和Voila中!

If you see the screen above, then Congratulations! You have successfully set up Continuous Deployment to an AWS S3 bucket using CircleCI.

如果您看到上面的屏幕,那么恭喜! 您已使用CircleCI成功设置了对AWS S3存储桶的持续部署。

Now every time you push changes to your Github repo, CircleCI will automatically deploy the changes to your AWS S3 bucket.

现在,每次将更改推送到Github存储库时,CircleCI都会自动将更改部署到您的AWS S3存储桶。

You might have noticed that even though the deployment was successful CircleCI shows you a red NO TESTS warning.

您可能已经注意到,即使部署成功,CircleCI也会显示红色的NO TESTS警告。

This is normal because in a Test Driven Development (TDD) environment you would write tests first, and then before going to production your code needs to pass all the tests. An example with tests is beyond the scope of this tutorial, but suffice it to say that had we written tests, CircleCI would only have deployed if all our tests passed.

这是正常现象,因为在测试驱动开发(TDD)环境中,您将首先编写测试,然后在生产之前,您的代码需要通过所有测试。 关于测试的示例不在本教程的讨论范围之内,但是可以说,如果我们编写了测试,那么只有在所有测试通过的情况下,CircleCI才会部署。

Using your own domain name to access this static site is also beyond the scope of this tutorial, but feel free to look here for instructions on how to configure Amazon Route 53 to route Internet traffic to your new site.

使用您自己的域名访问此静态站点也超出了本教程的范围,但是请随时在此处查找有关如何配置Amazon Route 53将Internet流量路由到新站点的说明。

I am hoping to do a tutorial involving a Continuous Integration/Deployment example with a full battery of tests sometimes in the future. Meanwhile, if you have a moment, answer a short survey about this tutorial here, like it on LinkedIn or post a comment in the comments section.

我希望将来能做一个涉及持续集成/部署示例的教程,其中包含全部测试。 同时,如果您有时间,请在此处回答有关本教程的简短调查,在LinkedIn上喜欢它,或在评论部分中发表评论。

Thanks for reading!

谢谢阅读!

翻译自: https://www.freecodecamp.org/news/how-to-set-up-continuous-deployment-to-aws-s3-using-circleci-in-under-30-minutes-a8e268284098/

k8s aws 部署

k8s aws 部署_如何在短短30分钟内使用CircleCI设置到AWS S3的持续部署相关推荐

  1. 开源短地址_如何在短短5分钟内完成您的第一个开源贡献

    开源短地址 by Roshan Jossey 罗珊·乔西(Roshan Jossey) 如何在短短5分钟内完成您的第一个开源贡献 (How to make your first open source ...

  2. git 短写设置_如何在短短几分钟内设置一个Git客户端

    git 短写设置 Today we're going to talk about Git. You're going to learn what Git is and how to set up a ...

  3. 机器人坐标系建立_如何在30分钟内建立一个简单的搜索机器人

    机器人坐标系建立 by Quinn Langille 奎因·兰吉尔(Quinn Langille) 如何在30分钟内建立一个简单的搜索机器人 (How to Build A Simple Search ...

  4. 如何零基础零费用的在30分钟内用hugo+github pages创建一个专属于你的个人博客 - 简单快捷到建议人手一个

    写这篇文章的原因是在网上看了很多的教程,踩了不少的坑,更多的白费了很多功夫,也没找到一篇从头到尾完整有效的个人建站方法. 有些教程年代久远,有些教程极为繁琐,有些教程压根跑不通. 为了方便自己,做个记 ...

  5. 如何实现生成订单30分钟内未支付则自动取消?

    如何实现生成订单30分钟内未支付则自动取消? 数据库轮询 JDK的延迟队列 Quartz 时间轮算法 使用消息队列 数据库轮询 不是很推荐的一种方式,需要定时扫描数据库,借助定时任务工具,如果是多服务 ...

  6. 30分钟内使用MongoDB

    最近,我被NoSQL错误咬住了-或是我的同事Mark Atwell提出的"燃烧在哪里!" 运动. 尽管我无意于在不久的将来或可预见的将来回避友好的" SELECT ... ...

  7. 请使用recaptcha_如何在30分钟内使用ReCaptcha和PHP构建Bootstrap电子邮件表单

    请使用recaptcha by Ondrej Svestka 通过Ondrej Svestka 如何在30分钟内使用ReCaptcha和PHP构建Bootstrap电子邮件表单 (How to bui ...

  8. Retrace AV推出新型涂料添加剂,可在30分钟内灭杀新冠病毒

    新型涂料添加剂可在30分钟内消灭新冠病毒,为家庭和工作场所提供高达99.99%的保护   伦敦--(美国商业资讯)--全球数十亿人正尝试重返办公室.学校和社交场所.政府和企业主需要尽其所能提振信心,让 ...

  9. 使用 ChatGPT 在短短 5 分钟内创建您的个人简历网站(并免费托管)

    在这篇博文中,我们将向您展示如何使用 ChatGPT 这种强大的语言模型,在短短 5 分钟内创建一个个人简历网站.我们还将向您展示如何在 ChatGPT 的帮助下免费托管您的网站! 在当今的数字时代, ...

最新文章

  1. Firefox 多版本共存
  2. Android性能优化之运算篇
  3. JS基础篇之作用域、执行上下文、this、闭包
  4. cannot import name 'ImageRecordInt8Iter'
  5. connection timed out是什么意思_Java 中的内存溢出和内存泄露是什么?我给你举个有味道的例子...
  6. VMware8.0虚拟机中安装Ubuntu12.04使用NAT设置连接网络
  7. 线性代数应该这样讲(三)-向量2范数与模型泛化
  8. PyQT5-QProgressBar
  9. HandlerInterceptor与MethodInterceptor
  10. PATH与CLASSPATH的区别
  11. [SDOI2012]Longge的问题 phi运用
  12. LayaAir Geolocation 获取地理位置
  13. Android 四大组件 之 服务(Service)
  14. Windows程序设计与C语言的主要区别是什么?
  15. 第11课:郭盛华课程_VB编程之Timer倒计时控件怎么用
  16. 郭天祥 新概念51单片机C语言教程.入门、提高、开发.pdf下载地址
  17. Linux的PDF工具,Linux 系统中的pdf阅读器以及工具
  18. Java——银行业务调度系统
  19. 经济学和金融学的区别
  20. vue2支付宝网页授权登录

热门文章

  1. Vmware Workstation VMX 在资源管理器中杀不掉(虚拟机繁忙导致无法关机)
  2. 64位游戏找call_替换Unity可执行文件为64位,改善游戏性能
  3. 只有20%的iOS程序员能看懂:详解intrinsicContentSize 及 约束优先级/content Hugging/content Compression Resistance
  4. Android Binder概述
  5. ubuntu如何修改字符集编码
  6. Nagios监控笔记上
  7. 清科-2018年中国金融科技领域10强
  8. Spring Cloud企业微服务分布式云架构技术点整合
  9. 配置Tomcat和在Eclipse中创建Web工程
  10. CSS3-多媒体查询