Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Commit 93f7b33

Browse files
authored
Add projects config. Add CLI config. Add vendir config (#59)
* Add projects config. Add CLI config. Add `vendir` config * Add projects config. Add CLI config. Add `vendir` config * Add projects config. Add CLI config. Add `vendir` config * Add projects config. Add CLI config. Add `vendir` config * Add projects config. Add CLI config. Add `vendir` config * Update to latest * Update to latest * Update CLI * Update vendir
1 parent cccd7b7 commit 93f7b33

18 files changed

+643
-151
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515

1616
**/.build-harness
1717
**/build-harness
18+
19+
*.lock.*

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ build-harness
99
*.tfstate.backup
1010
.idea
1111
*.iml
12+
*.lock.*

Dockerfile

+54-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
FROM cloudposse/geodesic:0.132.1
1+
ARG CLI_NAME=atmos
2+
3+
FROM cloudposse/geodesic:0.137.0 as cli
4+
5+
RUN apk add -u go variant2@cloudposse
6+
7+
# Configure Go
8+
ENV GOROOT /usr/lib/go
9+
ENV GOPATH /go
10+
ENV PATH /go/bin:$PATH
11+
12+
# Build a minimal variant binary in order to download all the required libraries and save them in a Docker layer cache
13+
COPY cli/build-cache /tmp
14+
WORKDIR /tmp/build-cache
15+
RUN variant2 export binary $PWD variant-echo
16+
17+
# Build the CLI
18+
WORKDIR /usr/cli
19+
COPY cli/ .
20+
ARG CGO_ENABLED=1
21+
ARG CLI_NAME
22+
RUN variant2 export binary $PWD $CLI_NAME
23+
24+
# Verify the CLI
25+
RUN ./"$CLI_NAME" help
26+
27+
28+
FROM cloudposse/geodesic:0.137.0
229

330
# Geodesic message of the Day
431
ENV MOTD_URL="https://geodesic.sh/motd"
@@ -11,39 +38,47 @@ ENV DIRENV_ENABLED=false
1138

1239
ENV DOCKER_IMAGE="cloudposse/reference-architectures"
1340
ENV DOCKER_TAG="latest"
14-
ENV NAMESPACE="eg"
1541

1642
# Geodesic banner message
17-
ENV BANNER="sweet ops"
43+
ENV BANNER="SweetOps"
1844

19-
# Pin kubectl to version 1.15
20-
RUN apk add kubectl-1.15@cloudposse
45+
# Enable advanced AWS assume role chaining for tools using AWS SDK
46+
# https://docs.aws.amazon.com/sdk-for-go/api/aws/session/
47+
ENV AWS_SDK_LOAD_CONFIG=1
48+
ENV AWS_DEFAULT_REGION=us-east-2
2149

22-
# Install terraform
23-
RUN apk add terraform@cloudposse
50+
# Pin kubectl to version 1.17 (must be within 1 minor version of cluster version)
51+
RUN apk add kubectl-1.17@cloudposse
2452

25-
# Install helmfile
26-
RUN apk add helmfile@cloudposse
53+
# Install terraform
54+
# Install the latest 0.12 and 0.13 versions of terraform
55+
RUN apk add -u terraform-0.12@cloudposse terraform-0.13@cloudposse~=0.13.3
56+
# Set Terraform 0.12.x as the default `terraform`. You can still use
57+
# `terraform-0.12` or `terraform-0.13` to be explicit when needed.
58+
RUN update-alternatives --set terraform /usr/share/terraform/0.12/bin/terraform
2759

28-
# Install saml2aws
2960
# https://github.com/Versent/saml2aws#linux
3061
RUN apk add saml2aws@cloudposse
3162

3263
# Install assume-role
3364
RUN apk add assume-role@cloudposse
3465

35-
# Install variant2 overwriting variant
36-
RUN apk add variant2@cloudposse
37-
3866
# Install the "docker" command to interact with the host's Docker daemon
3967
RUN apk add -u docker-cli
4068

41-
# Limit Makefile searches set up by Geodesic
42-
# Allow a single Makefile to serve all child directories
43-
ENV MAKE_INCLUDES="Makefile.settings ../Makefile.parent Makefile"
69+
# Install vendir
70+
RUN apk add vendir@cloudposse
4471

45-
COPY rootfs/ /
72+
# Install variant2
73+
RUN apk add variant2@cloudposse
74+
RUN update-alternatives --set variant /usr/share/variant/2/bin/variant
4675

47-
COPY projects/ /projects/
76+
# Install CLI
77+
ARG CLI_NAME
78+
COPY --from=cli /usr/cli/$CLI_NAME /usr/local/bin
79+
80+
COPY rootfs/ /
81+
COPY stacks/ /stacks/
82+
COPY vendor/ /vendor/
4883

49-
WORKDIR /projects/
84+
WORKDIR /

cli/build-cache/build-cache.variant

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env variant
2+
# vim: filetype=hcl
3+
4+
# Minimal variant project for creating a build cache to speed up Docker build
5+
6+
job "echo" {
7+
description = "Echoes message to the console"
8+
private = true
9+
10+
parameter "message" {
11+
description = "A message to output"
12+
type = string
13+
}
14+
15+
exec {
16+
command = "echo"
17+
args = [param.message]
18+
}
19+
}

cli/main.variant

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env variant
2+
# vim: filetype=hcl
3+
4+
option "region" {
5+
default = "us-east-2"
6+
description = "AWS region"
7+
type = string
8+
}
9+
10+
option "namespace" {
11+
default = "eg"
12+
description = "Namespace"
13+
type = string
14+
}
15+
16+
option "dry-run" {
17+
default = false
18+
description = "Disable execution of any commands and echo the commands instead"
19+
type = bool
20+
}
21+
22+
option "kubeconfig-path" {
23+
default = "/dev/shm"
24+
description = "folder to save kubeconfig"
25+
type = string
26+
}
27+
28+
option "kubeconfig-profile-pattern" {
29+
default = "$$namespace-$$environment-$$stage-helm"
30+
description = "AWS profile pattern for kubeconfig"
31+
type = string
32+
}
33+
34+
option "cluster-name-pattern" {
35+
default = "$$namespace-$$environment-$$stage-eks-cluster"
36+
description = "Cluster name pattern"
37+
type = string
38+
}
39+
40+
option "terraform-dir" {
41+
default = "./components/terraform"
42+
description = "Terraform components directory"
43+
type = string
44+
}
45+
46+
option "helmfile-dir" {
47+
default = "./components/helmfiles"
48+
description = "Helmfile components directory"
49+
type = string
50+
}
51+
52+
option "config-dir" {
53+
default = "./stacks"
54+
description = "Stacks config directory"
55+
type = string
56+
}
57+
58+
option "vendor-config-path" {
59+
default = "./vendor/vendir.yml"
60+
description = "Path to the vendor configuration file"
61+
type = string
62+
}
63+
64+
imports = [
65+
"git::https://git@github.com/cloudposse/atmos@modules/shell?ref=tags/0.3.0",
66+
"git::https://git@github.com/cloudposse/atmos@modules/kubeconfig?ref=tags/0.3.0",
67+
"git::https://git@github.com/cloudposse/atmos@modules/terraform?ref=tags/0.3.0",
68+
"git::https://git@github.com/cloudposse/atmos@modules/helmfile?ref=tags/0.3.0",
69+
"git::https://git@github.com/cloudposse/atmos@modules/helm?ref=tags/0.3.0",
70+
"git::https://git@github.com/cloudposse/atmos@modules/workflow?ref=tags/0.3.0",
71+
"git::https://git@github.com/cloudposse/atmos@modules/istio?ref=tags/0.3.0",
72+
"git::https://git@github.com/cloudposse/atmos@modules/vendor?ref=tags/0.3.0"
73+
]

projects/Makefile.parent

-70
This file was deleted.

projects/README.md

-62
This file was deleted.

stacks/ue2-dev.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
projects:
2+
globals:
3+
stage: dev
4+
5+
terraform:
6+
vpc:
7+
vars:
8+
cidr_block: "10.100.0.0/18"
9+
# ...
10+
11+
eks:
12+
command: "/usr/bin/terraform-0.13"
13+
vars:
14+
cluster_kubernetes_version: "1.17"
15+
# ...
16+
17+
helmfile:
18+
ingress-nginx:
19+
vars:
20+
installed: true
21+
22+
workflows:
23+
deploy-all:
24+
description: Deploy 'eks' terraform project and helmfiles
25+
steps:
26+
- job: terraform deploy vpc
27+
- job: terraform deploy eks
28+
- job: helmfile deploy ingress-nginx

stacks/ue2-globals.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace: eg
2+
region: us-east-2
3+
environment: ue2

stacks/ue2-prod.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
projects:
2+
globals:
3+
stage: prod
4+
5+
terraform:
6+
vpc:
7+
vars:
8+
cidr_block: "10.102.0.0/18"
9+
# ...
10+
11+
eks:
12+
command: "/usr/bin/terraform-0.13"
13+
vars:
14+
cluster_kubernetes_version: "1.17"
15+
# ...
16+
17+
helmfile:
18+
ingress-nginx:
19+
vars:
20+
installed: true

0 commit comments

Comments
 (0)