├── .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 | $TITLE @$AUTHOR (#$NUMBER)
48 | $BODY
49 | ][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 | [][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 | [][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 | [](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 |