Skip to content

Commit

Permalink
deploy using terraform
Browse files Browse the repository at this point in the history
- remove some apps (cowsay, transparency, estargz)
- start to move DNS zone management into TF too (optional)
- update GH workflow to deploy using TF

TODO:
- store state in GCS
- define one-time setup to grant GHA SA permissions it needs to deploy
- documentation for Future Jason
- cosign_verify base images
- cosign_sign images and cosign_verify before deploy
  • Loading branch information
imjasonh committed Apr 25, 2023
1 parent 2e1f107 commit d194a4f
Show file tree
Hide file tree
Showing 29 changed files with 559 additions and 1,721 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ jobs:
permissions:
id-token: write
contents: read
env:
KO_DOCKER_REPO=gcr.io/kontaindotme
steps:
- uses: actions/checkout@v3

# Install tools.
- uses: actions/setup-go@v2
with:
go-version: 1.18
- uses: imjasonh/setup-ko@v0.6
env:
KO_DOCKER_REPO: gcr.io/kontaindotme
go-version: 1.20.x
- uses: hashicorp/setup-terraform@v2
- uses: imjasonh/setup-crane@v0.1

# Setup OIDC->SA auth
Expand All @@ -35,11 +34,20 @@ jobs:
- uses: google-github-actions/setup-gcloud@v0.6.0
with:
project_id: kontaindotme
install_components: beta

# Deploy and test.
- run: ./deploy.sh
env:
KOCACHE: ~/ko
- name: Terraform Plan
run: |
cat > terraform.tfvars <<EOF
project_id = "${{ env.PROJECT_ID }}"
EOF
terraform init
terraform plan -input=false -lock=false -out=plan.tmp
terraform show -no-color plan.tmp
- name: Terraform Apply
if: ${{ github.event_name == 'push' }}
run: terraform apply -auto-approve -input=false plan.tmp

- run: ./test.sh

38 changes: 10 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
Expand All @@ -21,32 +26,9 @@ override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

###
# https://github.com/github/gitignore/blob/master/Go.gitignore

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
plan.tmp
43 changes: 43 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ These include:
APK packages, using [`apko`](https://apko.dev).
* [`buildpack.kontain.me`](./cmd/buildpack), which builds a GitHub repo using [CNCF
Buildpacks](https://buildpacks.io).
* [`estargz.kontain.me`](./cmd/estargz), which optimizes an image's layers for
partial image pulls using
[estargz](https://github.com/containerd/stargz-snapshotter).
* [`wait.kontain.me`](./cmd/wait), which enqueues a background task to serve a
random image after some amount of time.

Expand Down
5 changes: 0 additions & 5 deletions cmd/apko/Dockerfile.base

This file was deleted.

15 changes: 0 additions & 15 deletions cmd/apko/deploy.sh

This file was deleted.

1 change: 0 additions & 1 deletion cmd/apko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func (s *server) build(ctx context.Context, ic types.ImageConfiguration) (v1.Ima

bc, err := build.New(wd,
build.WithImageConfiguration(ic),
build.WithProot(true),
build.WithArch(amd64), // TODO: multiarch
build.WithBuildDate(time.Time{}.Format(time.RFC3339)),
build.WithAssertions(build.RequireGroupFile(true), build.RequirePasswdFile(true)))
Expand Down
14 changes: 0 additions & 14 deletions cmd/buildpack/deploy.sh

This file was deleted.

31 changes: 0 additions & 31 deletions cmd/cowsay/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions cmd/cowsay/deploy.sh

This file was deleted.

83 changes: 0 additions & 83 deletions cmd/cowsay/main.go

This file was deleted.

20 changes: 0 additions & 20 deletions cmd/estargz/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions cmd/estargz/deploy.sh

This file was deleted.

Loading

0 comments on commit d194a4f

Please sign in to comment.