Skip to content

Commit

Permalink
Remove docker buildx from tagged releases too (#540)
Browse files Browse the repository at this point in the history
* Remove docker buildx from tagged releases too

This wasn't cleaned up here, but we should just publish our tagged cli releases to ghcr and call it a day.

* mv base dir from setup to bootstrap
  • Loading branch information
michaeljguarino authored Sep 12, 2024
1 parent 7099c71 commit a0ff709
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 106 deletions.
143 changes: 42 additions & 101 deletions .github/workflows/goreleaser-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,70 +142,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::312272277431:role/github-actions/buildx-deployments
role-session-name: PluralCLI
- name: Setup kubectl
uses: azure/setup-kubectl@v3
- name: Get EKS credentials
run: aws eks update-kubeconfig --name pluraldev
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/pluralsh/${{ matrix.image }}
gcr.io/pluralsh/${{ matrix.image }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@v3
with:
cleanup: true
driver: kubernetes
platforms: linux/amd64
driver-opts: |
namespace=buildx
requests.cpu=1.5
requests.memory=3.5Gi
"nodeselector=plural.sh/scalingGroup=buildx-spot-x86"
"tolerations=key=plural.sh/capacityType,value=SPOT,effect=NoSchedule;key=plural.sh/reserved,value=BUILDX,effect=NoSchedule"
- name: Append ARM buildx builder from AWS
run: |
docker buildx create \
--append \
--bootstrap \
--name ${{ steps.builder.outputs.name }} \
--driver=kubernetes \
--platform linux/arm64 \
--node=${{ steps.builder.outputs.name }}-arm64 \
--buildkitd-flags "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host" \
--driver-opt namespace=buildx \
--driver-opt requests.cpu=1.5 \
--driver-opt requests.memory=3.5Gi \
'--driver-opt="nodeselector=plural.sh/scalingGroup=buildx-spot-arm64"' \
'--driver-opt="tolerations=key=plural.sh/capacityType,value=SPOT,effect=NoSchedule;key=plural.sh/reserved,value=BUILDX,effect=NoSchedule"'
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- name: Login to gcr
run: gcloud auth configure-docker -q
- name: Login to plural registry
uses: docker/login-action@v2
with:
registry: dkr.plural.sh
username: [email protected]
password: ${{ secrets.PLURAL_ACCESS_TOKEN }}
# - name: Login to plural registry
# uses: docker/login-action@v2
# with:
# registry: dkr.plural.sh
# username: [email protected]
# password: ${{ secrets.PLURAL_ACCESS_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -243,52 +197,39 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
if: always()
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::312272277431:role/github-actions/buildx-deployments
role-session-name: PluralCLI
- name: Manually cleanup buildx
if: always()
run: |
docker buildx stop ${{ steps.builder.outputs.name }}
sleep 10
docker buildx rm ${{ steps.builder.outputs.name }}
packer:
name: Build EKS AMI
runs-on: ubuntu-latest
needs: release
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::654897662046:role/github-actions/plural-cli-amis-packer
role-session-name: CLIAmisPacker
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: 1.9.2
- name: Run `packer init`
id: init
run: "packer init ./packer/"
- name: Run `packer validate`
id: validate
env:
PKR_VAR_k8s_cli_version: ${{ github.ref_name}}
run: "packer validate ./packer/"
- name: Run `packer build`
id: build
# always is used here to ensure the builds can't get cancelled and leave dangling resources
if: always()
env:
PKR_VAR_k8s_cli_version: ${{ github.ref_name}}
run: "packer build ./packer/"
# packer:
# name: Build EKS AMI
# runs-on: ubuntu-latest
# needs: release
# permissions:
# contents: 'read'
# id-token: 'write'
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: us-east-2
# role-to-assume: arn:aws:iam::654897662046:role/github-actions/plural-cli-amis-packer
# role-session-name: CLIAmisPacker
# - name: Setup `packer`
# uses: hashicorp/setup-packer@main
# id: setup
# with:
# version: 1.9.2
# - name: Run `packer init`
# id: init
# run: "packer init ./packer/"
# - name: Run `packer validate`
# id: validate
# env:
# PKR_VAR_k8s_cli_version: ${{ github.ref_name}}
# run: "packer validate ./packer/"
# - name: Run `packer build`
# id: build
# # always is used here to ensure the builds can't get cancelled and leave dangling resources
# if: always()
# env:
# PKR_VAR_k8s_cli_version: ${{ github.ref_name}}
# run: "packer build ./packer/"
32 changes: 27 additions & 5 deletions pkg/up/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (ctx *Context) Generate() (dir string, err error) {
return
}

if err = git.PathClone("https://github.com/pluralsh/bootstrap.git", "more-up-improvements", dir); err != nil {
if err = git.PathClone("https://github.com/pluralsh/bootstrap.git", "resources-refactor", dir); err != nil {
return
}

Expand Down Expand Up @@ -69,8 +69,9 @@ func (ctx *Context) Generate() (dir string, err error) {
copies := []templatePair{
{from: ctx.path("terraform/modules/clusters"), to: "terraform/modules/clusters"},
{from: ctx.path(fmt.Sprintf("terraform/clouds/%s", prov)), to: "terraform/mgmt/cluster"},
{from: ctx.path("setup"), to: "setup"},
{from: ctx.path("setup"), to: "bootstrap"},
{from: ctx.path("templates"), to: "templates"},
{from: ctx.path("resources"), to: "resources"},
}

for _, copy := range copies {
Expand All @@ -84,19 +85,40 @@ func (ctx *Context) Generate() (dir string, err error) {
}

if ctx.Cloud {
toRemove := []string{"setup/console.yaml", "setup/flux.yaml"}
toRemove := []string{"bootstrap/console.yaml", "bootstrap/flux.yaml"}
for _, f := range toRemove {
os.Remove(f)
}
}

ctx.changeDelims()
overwrites := []templatePair{
{from: "setup/setup.yaml", to: "setup/setup.yaml"},
{from: "setup/pr-automation/cluster-creator.yaml", to: "setup/pr-automation/cluster-creator.yaml"},
{from: "bootstrap/setup.yaml", to: "bootstrap/setup.yaml"},
{from: "bootstrap/pr-automation", to: "bootstrap/pr-automation"},
}

for _, tpl := range overwrites {
if utils.IsDir(tpl.from) {
files, err := utils.ListDirectory(tpl.from)
if err != nil {
return dir, err
}

for _, file := range files {
destFile, err := filepath.Rel(tpl.from, file)
if err != nil {
return dir, err
}

destFile = filepath.Join(string(tpl.to), destFile)
if err = ctx.templateFrom(file, destFile); err != nil {
return dir, err
}
}

continue
}

if err = ctx.templateFrom(tpl.from, tpl.to); err != nil {
return
}
Expand Down

0 comments on commit a0ff709

Please sign in to comment.