├── .dockerignore ├── .editorconfig ├── .github ├── configs │ └── draft-release.yml └── workflows │ ├── feature-branch.yml │ ├── main-branch.yaml │ └── release.yaml ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── README.yaml ├── deploy ├── helmfile.yaml └── releases │ └── app.yaml ├── main.go ├── public ├── dashboard.html ├── index.html └── shutdown.html └── test ├── docker-compose.yml ├── test.env └── test.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .idea 3 | *.iml 4 | .editorconfig 5 | build-harness 6 | .build-harness 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Override for Makefile 2 | [{Makefile, makefile, GNUmakefile}] 3 | indent_style = tab 4 | indent_size = 4 5 | 6 | [Makefile.*] 7 | indent_style = tab 8 | indent_size = 4 9 | 10 | [*.yaml] 11 | indent_style = spaces 12 | indent_size = 2 -------------------------------------------------------------------------------- /.github/configs/draft-release.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | version-template: '$MAJOR.$MINOR.$PATCH' 4 | version-resolver: 5 | major: 6 | labels: 7 | - 'major' 8 | minor: 9 | labels: 10 | - 'minor' 11 | - 'enhancement' 12 | - 'hotfix' 13 | default: 'minor' 14 | 15 | categories: 16 | - title: '🚀 Enhancements' 17 | labels: 18 | - 'enhancement' 19 | - 'patch' 20 | - 'shell' 21 | - 'scripts' 22 | - 'terraform' 23 | - title: '🐛 Bug Fixes' 24 | labels: 25 | - 'fix' 26 | - 'bugfix' 27 | - 'bug' 28 | - 'hotfix' 29 | - title: '🧰 Included Tools' 30 | labels: 31 | - 'packages' 32 | - 'docker' 33 | - title: '📚️ Documentation' 34 | labels: 35 | - 'docs' 36 | - title: '🏗️ Build/Release Maintenance' 37 | labels: 38 | - 'github' 39 | 40 | autolabeler: 41 | - label: 'hotfix' 42 | branch: 43 | - '/release\/.+/' 44 | 45 | change-template: | 46 |
47 | $TITLE @$AUTHOR (#$NUMBER) 48 | $BODY 49 |
50 | template: | 51 | $CHANGES 52 | replacers: 53 | # Remove irrelevant information from Renovate bot 54 | - search: '/(?<=---\s+)^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm' 55 | replace: '' 56 | # Remove Renovate bot banner image 57 | - search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm' 58 | replace: '' -------------------------------------------------------------------------------- /.github/workflows/feature-branch.yml: -------------------------------------------------------------------------------- 1 | name: Feature Branch 2 | on: 3 | pull_request: 4 | branches: [ 'master' ] 5 | types: [opened, synchronize, reopened, closed, labeled, unlabeled] 6 | 7 | permissions: 8 | pull-requests: write 9 | deployments: write 10 | id-token: write 11 | contents: read 12 | 13 | jobs: 14 | do: 15 | uses: cloudposse/github-actions-workflows-docker-ecr-eks-helmfile/.github/workflows/feature-branch.yml@main 16 | with: 17 | organization: "${{ github.event.repository.owner.login }}" 18 | repository: "${{ github.event.repository.name }}" 19 | open: ${{ github.event.pull_request.state == 'open' }} 20 | labels: ${{ toJSON(github.event.pull_request.labels.*.name) }} 21 | ref: ${{ github.event.pull_request.head.ref }} 22 | secrets: 23 | github-private-actions-pat: "${{ secrets.PUBLIC_AND_PRIVATE_REPO_ACCESS_TOKEN }}" 24 | registry: "${{ secrets.ECR_REGISTRY }}" 25 | secret-outputs-passphrase: "${{ secrets.GHA_SECRET_OUTPUT_PASSPHRASE }}" 26 | ecr-region: "${{ secrets.ECR_REGION }}" 27 | ecr-iam-role: "${{ secrets.ECR_IAM_ROLE }}" 28 | -------------------------------------------------------------------------------- /.github/workflows/main-branch.yaml: -------------------------------------------------------------------------------- 1 | name: Main Branch 2 | on: 3 | push: 4 | branches: [ master ] 5 | 6 | permissions: 7 | contents: write 8 | id-token: write 9 | 10 | jobs: 11 | do: 12 | uses: cloudposse/github-actions-workflows-docker-ecr-eks-helmfile/.github/workflows/main-branch.yml@main 13 | with: 14 | organization: "${{ github.event.repository.owner.login }}" 15 | repository: "${{ github.event.repository.name }}" 16 | secrets: 17 | github-private-actions-pat: "${{ secrets.PUBLIC_AND_PRIVATE_REPO_ACCESS_TOKEN }}" 18 | registry: "${{ secrets.ECR_REGISTRY }}" 19 | secret-outputs-passphrase: "${{ secrets.GHA_SECRET_OUTPUT_PASSPHRASE }}" 20 | ecr-region: "${{ secrets.ECR_REGION }}" 21 | ecr-iam-role: "${{ secrets.ECR_IAM_ROLE }}" 22 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | release: 4 | types: [published] 5 | 6 | permissions: 7 | id-token: write 8 | contents: write 9 | 10 | jobs: 11 | perform: 12 | uses: cloudposse/github-actions-workflows-docker-ecr-eks-helmfile/.github/workflows/release.yml@main 13 | with: 14 | organization: "${{ github.event.repository.owner.login }}" 15 | repository: "${{ github.event.repository.name }}" 16 | version: ${{ github.event.release.tag_name }} 17 | secrets: 18 | github-private-actions-pat: "${{ secrets.PUBLIC_AND_PRIVATE_REPO_ACCESS_TOKEN }}" 19 | registry: "${{ secrets.ECR_REGISTRY }}" 20 | secret-outputs-passphrase: "${{ secrets.GHA_SECRET_OUTPUT_PASSPHRASE }}" 21 | ecr-region: "${{ secrets.ECR_REGION }}" 22 | ecr-iam-role: "${{ secrets.ECR_IAM_ROLE }}" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | release/* 2 | .build-harness 3 | build-harness/ 4 | .idea 5 | *.iml 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:alpine3.11 AS builder 2 | 3 | # Copy source into builder 4 | ADD . /src 5 | 6 | # Build the app 7 | RUN cd /src && \ 8 | go build -o example-app 9 | 10 | # Build the final image 11 | FROM alpine:3.11 as final 12 | 13 | # Install the cloudposse alpine repository 14 | ADD https://apk.cloudposse.com/ops@cloudposse.com.rsa.pub /etc/apk/keys/ 15 | RUN echo "@cloudposse https://apk.cloudposse.com/3.11/vendor" >> /etc/apk/repositories 16 | 17 | # Expose port of the app 18 | EXPOSE 8080 19 | 20 | # Set the runtime working directory 21 | WORKDIR /app 22 | 23 | # Copy the helmfile deployment configuration 24 | COPY deploy/ /deploy/ 25 | COPY public/ /app/public/ 26 | 27 | # Install the app 28 | COPY --from=builder /src/example-app /app/ 29 | 30 | # Define the entrypoint 31 | ENTRYPOINT ["./example-app"] 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCKER_IMAGE_NAME ?= example-app 2 | SHELL = /bin/bash 3 | 4 | PATH:=$(PATH):$(GOPATH)/bin 5 | 6 | -include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness) 7 | 8 | build: go/build 9 | @exit 0 10 | 11 | run: 12 | docker run -it -p 8080:8080 --rm $(DOCKER_IMAGE_NAME) 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # example-app-on-eks [![Latest Release](https://img.shields.io/github/release/cloudposse/example-app-on-eks.svg)](https://github.com/cloudposse/example-app-on-eks/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 4 | 5 | 6 | [![README Header][readme_header_img]][readme_header_link] 7 | 8 | [![Cloud Posse][logo]](https://cpco.io/homepage) 9 | 10 | 11 | 12 | 31 | 32 | Example Dockerized application deployed on EKS with Helmfile. 33 | 34 | --- 35 | 36 | This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. 37 | [][share_email] 38 | [][share_googleplus] 39 | [][share_facebook] 40 | [][share_reddit] 41 | [][share_linkedin] 42 | [][share_twitter] 43 | 44 | 45 | 46 | 47 | It's 100% Open Source and licensed under the [APACHE2](LICENSE). 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | ## Introduction 61 | 62 | * [Docker](https://docs.docker.com/engine/reference/builder/) for developing, shipping, and running, 63 | * [ECR](https://aws.amazon.com/ecr/) to store the Docker images 64 | * [EKS](https://aws.amazon.com/eks) for running application in scale 65 | * [Helmfile](https://github.com/roboll/helmfile) as declarative deploy manifest 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | ## Share the Love 80 | 81 | Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/example-app-on-eks)! (it helps us **a lot**) 82 | 83 | Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) 84 | 85 | 86 | 87 | ## Related Projects 88 | 89 | Check out these related projects. 90 | 91 | - [github-actions-workflows](https://github.com/cloudposse/github-actions-workflows) - Reusable workflows for different types of projects 92 | 93 | ## Help 94 | 95 | **Got a question?** We got answers. 96 | 97 | File a GitHub [issue](https://github.com/cloudposse/example-app-on-eks/issues), send us an [email][email] or join our [Slack Community][slack]. 98 | 99 | [![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] 100 | 101 | ## DevOps Accelerator for Startups 102 | 103 | 104 | We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. 105 | 106 | [![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] 107 | 108 | Work directly with our team of DevOps experts via email, slack, and video conferencing. 109 | 110 | We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. 111 | 112 | - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. 113 | - **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. 114 | - **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. 115 | - **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. 116 | - **GitOps.** You'll be able to operate your infrastructure via Pull Requests. 117 | - **Training.** You'll receive hands-on training so your team can operate what we build. 118 | - **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. 119 | - **Troubleshooting.** You'll get help to triage when things aren't working. 120 | - **Code Reviews.** You'll receive constructive feedback on Pull Requests. 121 | - **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. 122 | 123 | ## Slack Community 124 | 125 | Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. 126 | 127 | ## Discourse Forums 128 | 129 | Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account. 130 | 131 | ## Newsletter 132 | 133 | Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. 134 | 135 | ## Office Hours 136 | 137 | [Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone! 138 | 139 | [![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours] 140 | 141 | ## Contributing 142 | 143 | ### Bug Reports & Feature Requests 144 | 145 | Please use the [issue tracker](https://github.com/cloudposse/example-app-on-eks/issues) to report any bugs or file feature requests. 146 | 147 | ### Developing 148 | 149 | If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. 150 | 151 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 152 | 153 | 1. **Fork** the repo on GitHub 154 | 2. **Clone** the project to your own machine 155 | 3. **Commit** changes to your own branch 156 | 4. **Push** your work back up to your fork 157 | 5. Submit a **Pull Request** so that we can review your changes 158 | 159 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! 160 | 161 | 162 | ## Copyright 163 | 164 | Copyright © 2017-2022 [Cloud Posse, LLC](https://cpco.io/copyright) 165 | 166 | 167 | 168 | ## License 169 | 170 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 171 | 172 | See [LICENSE](LICENSE) for full details. 173 | 174 | ```text 175 | Licensed to the Apache Software Foundation (ASF) under one 176 | or more contributor license agreements. See the NOTICE file 177 | distributed with this work for additional information 178 | regarding copyright ownership. The ASF licenses this file 179 | to you under the Apache License, Version 2.0 (the 180 | "License"); you may not use this file except in compliance 181 | with the License. You may obtain a copy of the License at 182 | 183 | https://www.apache.org/licenses/LICENSE-2.0 184 | 185 | Unless required by applicable law or agreed to in writing, 186 | software distributed under the License is distributed on an 187 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 188 | KIND, either express or implied. See the License for the 189 | specific language governing permissions and limitations 190 | under the License. 191 | ``` 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | ## Trademarks 202 | 203 | All other trademarks referenced herein are the property of their respective owners. 204 | 205 | ## About 206 | 207 | This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! 208 | 209 | [![Cloud Posse][logo]][website] 210 | 211 | We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. 212 | 213 | We offer [paid support][commercial_support] on all of our projects. 214 | 215 | Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. 216 | 217 | 218 | 219 | ### Contributors 220 | 221 | 222 | | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | 223 | |---| 224 | 225 | 226 | [goruha_homepage]: https://github.com/goruha 227 | [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png 228 | 229 | [![README Footer][readme_footer_img]][readme_footer_link] 230 | [![Beacon][beacon]][website] 231 | 232 | [logo]: https://cloudposse.com/logo-300x69.svg 233 | [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=docs 234 | [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=website 235 | [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=github 236 | [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=jobs 237 | [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=hire 238 | [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=slack 239 | [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=linkedin 240 | [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=twitter 241 | [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=testimonial 242 | [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=office_hours 243 | [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=newsletter 244 | [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=discourse 245 | [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=email 246 | [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=commercial_support 247 | [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=we_love_open_source 248 | [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=terraform_modules 249 | [readme_header_img]: https://cloudposse.com/readme/header/img 250 | [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=readme_header_link 251 | [readme_footer_img]: https://cloudposse.com/readme/footer/img 252 | [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=readme_footer_link 253 | [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img 254 | [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-app-on-eks&utm_content=readme_commercial_support_link 255 | [share_twitter]: https://twitter.com/intent/tweet/?text=example-app-on-eks&url=https://github.com/cloudposse/example-app-on-eks 256 | [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=example-app-on-eks&url=https://github.com/cloudposse/example-app-on-eks 257 | [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/example-app-on-eks 258 | [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/example-app-on-eks 259 | [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/example-app-on-eks 260 | [share_email]: mailto:?subject=example-app-on-eks&body=https://github.com/cloudposse/example-app-on-eks 261 | [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/example-app-on-eks?pixel&cs=github&cm=readme&an=example-app-on-eks 262 | 263 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # This is the canonical configuration for the `README.md` 4 | # Run `make readme` to rebuild the `README.md` 5 | # 6 | 7 | # Name of this project 8 | name: example-app-on-eks 9 | 10 | # Tags of this project 11 | tags: 12 | - example-app 13 | - github-action 14 | - Docker 15 | - ECR 16 | - EKS 17 | - Helmfile 18 | - CI/CD 19 | 20 | # Logo for this project 21 | #logo: docs/logo.png 22 | 23 | # License of this project 24 | license: "APACHE2" 25 | 26 | # Canonical GitHub repo 27 | github_repo: cloudposse/example-app-on-eks 28 | 29 | # Badges to display 30 | badges: 31 | - name: "Latest Release" 32 | image: "https://img.shields.io/github/release/cloudposse/example-app-on-eks.svg" 33 | url: "https://github.com/cloudposse/example-app-on-eks/releases/latest" 34 | - name: "Slack Community" 35 | image: "https://slack.cloudposse.com/badge.svg" 36 | url: "https://slack.cloudposse.com" 37 | 38 | related: 39 | - name: "github-actions-workflows" 40 | description: "Reusable workflows for different types of projects" 41 | url: "https://github.com/cloudposse/github-actions-workflows" 42 | 43 | # Short description of this project 44 | description: |- 45 | Example Dockerized application deployed on EKS with Helmfile. 46 | 47 | introduction: |- 48 | * [Docker](https://docs.docker.com/engine/reference/builder/) for developing, shipping, and running, 49 | * [ECR](https://aws.amazon.com/ecr/) to store the Docker images 50 | * [EKS](https://aws.amazon.com/eks) for running application in scale 51 | * [Helmfile](https://github.com/roboll/helmfile) as declarative deploy manifest 52 | 53 | # Contributors to this project 54 | contributors: 55 | - name: "Igor Rodionov" 56 | github: "goruha" -------------------------------------------------------------------------------- /deploy/helmfile.yaml: -------------------------------------------------------------------------------- 1 | # Ordered list of releases. 2 | environments: 3 | default: 4 | preview: 5 | staging: 6 | production: 7 | 8 | helmfiles: 9 | - path: "releases/app.yaml" 10 | values: 11 | - 12 | {{ .Values | toYaml | indent 8 }} 13 | -------------------------------------------------------------------------------- /deploy/releases/app.yaml: -------------------------------------------------------------------------------- 1 | environments: 2 | default: 3 | values: 4 | - platform: 5 | region: us-east-2 6 | default_ingress_domain: example.com 7 | default_alb_ingress_group: default 8 | preview: 9 | staging: 10 | production: 11 | 12 | 13 | repositories: 14 | # Cloud Posse incubator repo of helm charts 15 | - name: "cloudposse-incubator" 16 | url: "https://charts.cloudposse.com/incubator/" 17 | 18 | releases: 19 | # 20 | # References: 21 | # - https://github.com/cloudposse/charts/blob/master/incubator/monochart 22 | # 23 | - name: 'example-app-helm' 24 | labels: 25 | preview: "true" 26 | chart: "cloudposse-incubator/monochart" 27 | version: "0.26.0" 28 | wait: true 29 | force: true 30 | recreatePods: false 31 | values: 32 | - image: 33 | repository: '{{ env "IMAGE_NAME" | default "cloudposse/example-app" }}' 34 | tag: '{{ env "IMAGE_TAG" | default "0.1.0" }}' 35 | pullPolicy: Always 36 | replicaCount: 2 37 | # Deployment configuration 38 | deployment: 39 | enabled: true 40 | strategy: 41 | type: "RollingUpdate" 42 | rollingUpdate: 43 | maxUnavailable: 1 44 | revisionHistoryLimit: 10 45 | 46 | # Configuration Settings 47 | configMaps: 48 | default: 49 | enabled: true 50 | 51 | # Service endpoint 52 | service: 53 | enabled: true 54 | type: ClusterIP 55 | ports: 56 | default: 57 | internal: 8080 58 | external: 80 59 | 60 | ingress: 61 | default: 62 | enabled: true 63 | port: default 64 | annotations: 65 | external-dns.alpha.kubernetes.io/target: {{ .Values.platform.default_ingress_domain }} 66 | alb.ingress.kubernetes.io/group.name: {{ .Values.platform.default_alb_ingress_group }} 67 | kubernetes.io/ingress.class: alb 68 | alb.ingress.kubernetes.io/scheme: internet-facing 69 | alb.ingress.kubernetes.io/actions.ssl-redirect: '{"RedirectConfig":{"Port":"443","Protocol":"HTTPS","StatusCode":"HTTP_301"},"Type":"redirect"}' 70 | alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]' 71 | alb.ingress.kubernetes.io/ssl-redirect: "443" 72 | alb.ingress.kubernetes.io/target-type: ip 73 | {{- if eq .Environment.Name "preview" }} 74 | external-dns.alpha.kubernetes.io/hostname: example-app-pr-{{ .Namespace }}.{{ .Values.platform.default_ingress_domain }} 75 | outputs.webapp-url: "https://example-app-pr-{{ .Namespace }}.{{ .Values.platform.default_ingress_domain }}/dashboard" 76 | hosts: 77 | "example-app-pr-{{ .Namespace }}.{{ .Values.platform.default_ingress_domain }}": /* 78 | {{- else }} 79 | external-dns.alpha.kubernetes.io/hostname: example-app.{{ .Values.platform.default_ingress_domain }} 80 | outputs.webapp-url: "https://example-app.{{ .Values.platform.default_ingress_domain }}/dashboard" 81 | hosts: 82 | "example-app.{{ .Values.platform.default_ingress_domain }}": /* 83 | {{- end }} 84 | 85 | probes: 86 | # Probe that ensures service is healthy 87 | livenessProbe: 88 | httpGet: 89 | path: /healthz 90 | port: default 91 | scheme: HTTP 92 | periodSeconds: 3 93 | initialDelaySeconds: 3 94 | timeoutSeconds: 3 95 | successThreshold: 1 96 | failureThreshold: 2 97 | 98 | # Probe that ensures service has started 99 | readinessProbe: 100 | httpGet: 101 | path: /healthz 102 | port: default 103 | scheme: HTTP 104 | periodSeconds: 3 105 | initialDelaySeconds: 3 106 | timeoutSeconds: 3 107 | successThreshold: 1 108 | failureThreshold: 2 109 | 110 | resources: 111 | requests: 112 | memory: 10Mi 113 | cpu: 100m 114 | limits: 115 | memory: 10Mi 116 | cpu: 100m 117 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | "net/http" 9 | "os" 10 | ) 11 | 12 | func main() { 13 | c := os.Getenv("COLOR") 14 | if len(c) == 0 { 15 | c = "cyan" 16 | } 17 | 18 | addr := os.Getenv("LISTEN") 19 | if len(addr) == 0 { 20 | addr = ":8080" 21 | } 22 | 23 | count := 0 24 | 25 | m := http.NewServeMux() 26 | s := http.Server{Addr: addr, Handler: m} 27 | 28 | log.Printf("Server started\n") 29 | 30 | // Healthcheck endpoint 31 | m.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { 32 | fmt.Fprintf(w, "OK") 33 | }) 34 | 35 | // Simulate failure 36 | boom, _ := ioutil.ReadFile("public/shutdown.html") 37 | m.HandleFunc("/shutdown", func(w http.ResponseWriter, r *http.Request) { 38 | fmt.Fprintf(w, string(boom)) 39 | log.Printf("Received shutdown request\n") 40 | go func() { 41 | if err := s.Shutdown(context.Background()); err != nil { 42 | log.Fatal(err) 43 | } 44 | }() 45 | }) 46 | 47 | // Dashboard 48 | dashboard, _ := ioutil.ReadFile("public/dashboard.html") 49 | m.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) { 50 | fmt.Fprintf(w, string(dashboard)) 51 | log.Printf("GET %s\n", r.URL.Path) 52 | }) 53 | 54 | // Default 55 | index, _ := ioutil.ReadFile("public/index.html") 56 | m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 57 | count += 1 58 | fmt.Fprintf(w, string(index), c, count) 59 | //log.Printf("GET %s\n", r.URL.Path) 60 | }) 61 | 62 | if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed { 63 | log.Fatal(err) 64 | } 65 | log.Printf("Exiting") 66 | } 67 | -------------------------------------------------------------------------------- /public/dashboard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | %v 20 | 21 | -------------------------------------------------------------------------------- /public/shutdown.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | BOOM!!! 18 | 19 | -------------------------------------------------------------------------------- /test/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | app: 4 | build: ../ 5 | ports: 6 | - "8080:8080" 7 | -------------------------------------------------------------------------------- /test/test.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudposse-examples/example-app-on-eks/fa3ebf7e6b8ed91edfbff08af81b3d5a79c36e1c/test/test.env -------------------------------------------------------------------------------- /test/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | apk add --update curl 6 | 7 | /app/example-app& 8 | 9 | sleep 3 10 | 11 | set -o pipefail 12 | 13 | 14 | curl -fsSL http://app:8080/ | grep "background-color: ${COLOR}" 15 | --------------------------------------------------------------------------------