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

Add projects config. Add CLI config. Add vendir config #59

Merged
merged 9 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@

**/.build-harness
**/build-harness

*.lock.*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ build-harness
*.tfstate.backup
.idea
*.iml
*.lock.*
73 changes: 54 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
FROM cloudposse/geodesic:0.132.1
ARG CLI_NAME=atmos

FROM cloudposse/geodesic:0.137.0 as cli

RUN apk add -u go variant2@cloudposse

# Configure Go
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH

# Build a minimal variant binary in order to download all the required libraries and save them in a Docker layer cache
COPY cli/build-cache /tmp
WORKDIR /tmp/build-cache
RUN variant2 export binary $PWD variant-echo

# Build the CLI
WORKDIR /usr/cli
COPY cli/ .
ARG CGO_ENABLED=1
ARG CLI_NAME
RUN variant2 export binary $PWD $CLI_NAME

# Verify the CLI
RUN ./"$CLI_NAME" help


FROM cloudposse/geodesic:0.137.0

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

ENV DOCKER_IMAGE="cloudposse/reference-architectures"
ENV DOCKER_TAG="latest"
ENV NAMESPACE="eg"

# Geodesic banner message
ENV BANNER="sweet ops"
ENV BANNER="SweetOps"

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

# Install terraform
RUN apk add terraform@cloudposse
# Pin kubectl to version 1.17 (must be within 1 minor version of cluster version)
RUN apk add kubectl-1.17@cloudposse

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

# Install saml2aws
# https://github.com/Versent/saml2aws#linux
RUN apk add saml2aws@cloudposse

# Install assume-role
RUN apk add assume-role@cloudposse

# Install variant2 overwriting variant
RUN apk add variant2@cloudposse

# Install the "docker" command to interact with the host's Docker daemon
RUN apk add -u docker-cli

# Limit Makefile searches set up by Geodesic
# Allow a single Makefile to serve all child directories
ENV MAKE_INCLUDES="Makefile.settings ../Makefile.parent Makefile"
# Install vendir
RUN apk add vendir@cloudposse

COPY rootfs/ /
# Install variant2
RUN apk add variant2@cloudposse
RUN update-alternatives --set variant /usr/share/variant/2/bin/variant

COPY projects/ /projects/
# Install CLI
ARG CLI_NAME
COPY --from=cli /usr/cli/$CLI_NAME /usr/local/bin

COPY rootfs/ /
COPY stacks/ /stacks/
COPY vendor/ /vendor/

WORKDIR /projects/
WORKDIR /
19 changes: 19 additions & 0 deletions cli/build-cache/build-cache.variant
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env variant
# vim: filetype=hcl

# Minimal variant project for creating a build cache to speed up Docker build

job "echo" {
description = "Echoes message to the console"
private = true

parameter "message" {
description = "A message to output"
type = string
}

exec {
command = "echo"
args = [param.message]
}
}
73 changes: 73 additions & 0 deletions cli/main.variant
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env variant
# vim: filetype=hcl

option "region" {
default = "us-east-2"
description = "AWS region"
type = string
}

option "namespace" {
default = "eg"
description = "Namespace"
type = string
}

option "dry-run" {
default = false
description = "Disable execution of any commands and echo the commands instead"
type = bool
}

option "kubeconfig-path" {
default = "/dev/shm"
description = "folder to save kubeconfig"
type = string
}

option "kubeconfig-profile-pattern" {
default = "$$namespace-$$environment-$$stage-helm"
description = "AWS profile pattern for kubeconfig"
type = string
}

option "cluster-name-pattern" {
default = "$$namespace-$$environment-$$stage-eks-cluster"
description = "Cluster name pattern"
type = string
}

option "terraform-dir" {
default = "./components/terraform"
description = "Terraform components directory"
type = string
}

option "helmfile-dir" {
default = "./components/helmfiles"
description = "Helmfile components directory"
type = string
}

option "config-dir" {
default = "./stacks"
description = "Stacks config directory"
type = string
}

option "vendor-config-path" {
default = "./vendor/vendir.yml"
description = "Path to the vendor configuration file"
type = string
}

imports = [
"git::https://git@github.com/cloudposse/atmos@modules/shell?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/kubeconfig?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/terraform?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/helmfile?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/helm?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/workflow?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/istio?ref=tags/0.3.0",
"git::https://git@github.com/cloudposse/atmos@modules/vendor?ref=tags/0.3.0"
]
70 changes: 0 additions & 70 deletions projects/Makefile.parent

This file was deleted.

62 changes: 0 additions & 62 deletions projects/README.md

This file was deleted.

28 changes: 28 additions & 0 deletions stacks/ue2-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
projects:
globals:
stage: dev

terraform:
vpc:
vars:
cidr_block: "10.100.0.0/18"
# ...

eks:
command: "/usr/bin/terraform-0.13"
vars:
cluster_kubernetes_version: "1.17"
# ...

helmfile:
ingress-nginx:
vars:
installed: true

workflows:
deploy-all:
description: Deploy 'eks' terraform project and helmfiles
steps:
- job: terraform deploy vpc
- job: terraform deploy eks
- job: helmfile deploy ingress-nginx
3 changes: 3 additions & 0 deletions stacks/ue2-globals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace: eg
region: us-east-2
environment: ue2
20 changes: 20 additions & 0 deletions stacks/ue2-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
projects:
globals:
stage: prod

terraform:
vpc:
vars:
cidr_block: "10.102.0.0/18"
# ...

eks:
command: "/usr/bin/terraform-0.13"
vars:
cluster_kubernetes_version: "1.17"
# ...

helmfile:
ingress-nginx:
vars:
installed: true
Loading