Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #6863

Closed
wants to merge 84 commits into from
Closed

Testing #6863

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
097f231
Create build-aim.yml
cartermckinnon Jan 27, 2022
4bc45f2
Create test-file
cartermckinnon Jan 27, 2022
7a17896
Update build-ami.yml
cartermckinnon Jan 27, 2022
93fa4be
Create require-labels.yml
cartermckinnon Jan 27, 2022
83c0c7f
Update require-labels.yml
cartermckinnon Jan 27, 2022
0a28eb2
Update require-labels.yml
cartermckinnon Jan 27, 2022
452efdd
Update build-ami.yml
cartermckinnon Jan 27, 2022
c2be290
Update require-labels.yml
cartermckinnon Jan 27, 2022
3782121
Update build-ami.yml
cartermckinnon Jan 27, 2022
3ee4f12
Create mirror-to-codecommit.yml
cartermckinnon Jan 27, 2022
d4a9c43
Update mirror-to-codecommit.yml
cartermckinnon Jan 27, 2022
c76f4aa
Update mirror-to-codecommit.yml
cartermckinnon Jan 27, 2022
3d71d4f
Update mirror-to-codecommit.yml
cartermckinnon Jan 27, 2022
0ddedfb
Delete require-labels.yml
cartermckinnon Jan 28, 2022
9399fb4
Update build-ami.yml
cartermckinnon Jan 28, 2022
5185f3c
Update build-ami.yml
cartermckinnon Jan 28, 2022
f222f99
Merge branch 'master' into test-file
cartermckinnon Jan 28, 2022
9499072
Update build-ami.yml
cartermckinnon Jan 28, 2022
dda444e
Merge branch 'master' into test-file
cartermckinnon Jan 28, 2022
02deff3
Merge pull request #1 from cartermckinnon/test-file
cartermckinnon Jan 28, 2022
6e058c3
Update test-file
cartermckinnon Jan 28, 2022
b810f74
Update mirror-to-codecommit.yml
cartermckinnon Jan 29, 2022
36706ca
Update mirror-to-codecommit.yml
cartermckinnon Jan 29, 2022
f0f04e5
Update mirror-to-codecommit.yml
cartermckinnon Jan 29, 2022
41b1f14
Update test-file
cartermckinnon Feb 1, 2022
ec1769c
Update test-file
cartermckinnon Feb 1, 2022
4b71db4
Update test-file
cartermckinnon Feb 4, 2022
f1736a1
Merge branch 'awslabs:master' into master
cartermckinnon Feb 18, 2022
0874730
Merge branch 'awslabs:master' into master
cartermckinnon Aug 20, 2022
4c7ff58
Merge branch 'awslabs:master' into master
cartermckinnon Oct 12, 2022
64c745a
Merge branch 'awslabs:master' into master
cartermckinnon Nov 4, 2022
cfd1540
Merge CI workflow with upstream
cartermckinnon Nov 4, 2022
82cf114
Use combined CI/CD workflow
cartermckinnon Nov 5, 2022
252c35d
FIx syntax issues
cartermckinnon Nov 5, 2022
4e26afd
Echo AMI_ID after build
cartermckinnon Nov 5, 2022
0483a3c
Create cluster + nodegroup after successful build
cartermckinnon Nov 5, 2022
0a0daaa
Reusable workflows for build and integration tests
cartermckinnon Nov 5, 2022
9b7434e
Install eksctl
cartermckinnon Nov 5, 2022
c524bed
Install sonobuoy
cartermckinnon Nov 5, 2022
29c3102
Properly structure reusable workflows
cartermckinnon Nov 5, 2022
469e2fb
Inherit secrets
cartermckinnon Nov 5, 2022
00691df
Reference matrix correctly
cartermckinnon Nov 5, 2022
7dbe755
Fix malformed cluster config YAML
cartermckinnon Nov 5, 2022
373b25c
Fix eksctl config file, allow workflow dispatch for testing
cartermckinnon Nov 5, 2022
3c2ec36
Sanitize k8s version for cluster name
cartermckinnon Nov 5, 2022
1db466f
Correctly reference github context
cartermckinnon Nov 5, 2022
7ce7dff
Fix outputs from launch to sonobuoy
cartermckinnon Nov 5, 2022
3ed58b4
Move reusable workflows, sanitize k8s_version correctly
cartermckinnon Nov 5, 2022
a3d23f7
Don't move reusable workflows
cartermckinnon Nov 5, 2022
018efc4
Fix workflow reference
cartermckinnon Nov 5, 2022
1fe0d50
Quiet down wget
cartermckinnon Nov 5, 2022
031655f
Fix wget flag
cartermckinnon Nov 5, 2022
dbdde5d
Fix indentation of eksctl YAML
cartermckinnon Nov 5, 2022
6e4f717
Use correct cluster name in bootstrap override
cartermckinnon Nov 5, 2022
0a4fa13
Add janitor with cluster sweeper
cartermckinnon Nov 5, 2022
7d83468
Fix input types, allow manual dispatch
cartermckinnon Nov 5, 2022
9020dd9
Syntax issue
cartermckinnon Nov 5, 2022
a21a7fe
Use correct cluster name
cartermckinnon Nov 5, 2022
4eeb1a5
Fix workflow path
cartermckinnon Nov 6, 2022
2180821
Pass secrets to child workflows
cartermckinnon Nov 6, 2022
f1a510c
Name workflows consistently
cartermckinnon Nov 6, 2022
ff85b2e
Reuse clusters, sweep existing nodegroups
cartermckinnon Nov 6, 2022
9bb952e
Fix workflow paths
cartermckinnon Nov 6, 2022
a1285e4
Add AMI sweeper
cartermckinnon Nov 6, 2022
91cd474
Cluster existence check
cartermckinnon Nov 6, 2022
6323c34
Correctly pass cluster_name from launch job to sonobuoy
cartermckinnon Nov 8, 2022
8393545
Clean up nodegroups based on time
cartermckinnon Nov 10, 2022
3855e7a
Remove unused variable
cartermckinnon Nov 11, 2022
d164d22
Use m5.large
cartermckinnon Nov 11, 2022
c0dc191
Merge branch 'awslabs:master' into master
cartermckinnon Nov 22, 2022
7a53991
Merge branch 'awslabs:master' into master
cartermckinnon Dec 2, 2022
e39c19b
Increase credential lifetime, use node16 branch
cartermckinnon Dec 9, 2022
edc0024
Add 1.24 to CI, tighten sonobuoy cred timeout
cartermckinnon Dec 9, 2022
09bb2ca
Merge branch 'awslabs:master' into master
cartermckinnon Dec 10, 2022
bc78aec
Merge branch 'awslabs:master' into master
cartermckinnon Dec 13, 2022
16d0e90
Output sonobuoy results
cartermckinnon Dec 14, 2022
b48b78b
Do not reuse integration test clusters
cartermckinnon Dec 14, 2022
49cda59
Use short SHA in build ID
cartermckinnon Dec 14, 2022
dae8e5a
Declare dependency on 'setup' job
cartermckinnon Dec 14, 2022
9f24f01
Increase nodegroup size to 3
cartermckinnon Dec 20, 2022
20d5cc3
Merge branch 'awslabs:master' into master
cartermckinnon Jan 6, 2023
d073fd3
Merge branch 'awslabs:master' into master
cartermckinnon Jan 26, 2023
5d6133f
Remove 1.20 from CI
cartermckinnon Jan 26, 2023
4973d36
Update test-file
cartermckinnon Jan 27, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Close stale issues'
name: '[Admin] Close stale issues'
on:
schedule:
# once a day at noon
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: '[CI] Build'
on:
workflow_dispatch:
workflow_call:
inputs:
k8s_version:
required: true
type: string
build_id:
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
- run: echo "AMI_NAME=amazon-eks-node-${{ inputs.k8s_version }}-${{ inputs.build_id }}" >> $GITHUB_ENV
- run: make ${{ inputs.k8s_version }} ami_name=${{ env.AMI_NAME }}
- id: ami_id
run: echo "ami_id=$(jq -r .builds[0].artifact_id "${{ env.AMI_NAME }}-manifest.json" | cut -d ':' -f 2)" >> $GITHUB_OUTPUT
outputs:
ami_id: ${{ steps.ami_id.outputs.ami_id }}
integration-test:
needs: build
uses: ./.github/workflows/ci-integration-test.yml
with:
k8s_version: ${{ inputs.k8s_version }}
build_id: ${{ inputs.build_id }}
ami_id: ${{ needs.build.outputs.ami_id }}
secrets: inherit
78 changes: 78 additions & 0 deletions .github/workflows/ci-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: '[CI] Integration test'
on:
workflow_dispatch:
workflow_call:
inputs:
build_id:
required: true
type: string
ami_id:
required: true
type: string
k8s_version:
required: true
type: string
jobs:
launch:
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
runs-on: ubuntu-latest
outputs:
cluster_name: ${{ steps.launch.outputs.cluster_name }}
steps:
- uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
- id: launch
run: |
#!/usr/bin/env bash

wget --no-verbose -O eksctl.tar.gz "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
tar xf eksctl.tar.gz && chmod +x ./eksctl

SANITIZED_K8S_VERSION=$(echo ${{ inputs.k8s_version }} | tr -d '.')
CLUSTER_NAME="$SANITIZED_K8S_VERSION-${{ inputs.build_id }}"

echo '---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: "'$CLUSTER_NAME'"
region: "${{ secrets.AWS_REGION }}"
version: "${{ inputs.k8s_version }}"
nodeGroups:
- name: "${{ inputs.build_id }}"
instanceType: m5.large
minSize: 3
maxSize: 3
desiredCapacity: 3
ami: "${{ inputs.ami_id }}"
overrideBootstrapCommand: |
#!/bin/bash
source /var/lib/cloud/scripts/eksctl/bootstrap.helper.sh
/etc/eks/bootstrap.sh "'$CLUSTER_NAME'" --kubelet-extra-args "--node-labels=${NODE_LABELS}"' >> cluster.yaml
cat cluster.yaml

./eksctl create cluster --config-file cluster.yaml
echo "cluster_name=$CLUSTER_NAME" >> $GITHUB_OUTPUT
sonobuoy:
needs: launch
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
# 2 hours (job usually completes in 90 minutes)
role-duration-seconds: 7200
- run: |
aws eks update-kubeconfig --name ${{ needs.launch.outputs.cluster_name }}
wget --no-verbose -O sonobuoy.tar.gz "https://github.com/vmware-tanzu/sonobuoy/releases/download/v0.56.11/sonobuoy_0.56.11_linux_amd64.tar.gz"
tar xf sonobuoy.tar.gz && chmod +x ./sonobuoy
./sonobuoy run --wait
./sonobuoy results $(./sonobuoy retrieve)
24 changes: 0 additions & 24 deletions .github/workflows/ci.yaml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: '[CI] Entrypoint'
on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
setup:
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.variables.outputs.sha_short }}
steps:
- id: variables
run: echo "sha_short=$(echo ${{ github.sha }} | rev | cut -c-7 | rev)" >> $GITHUB_OUTPUT
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- run: go install mvdan.cc/sh/v3/cmd/shfmt@latest
- run: make lint
unit-test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make test
version-workflow:
name: ${{ matrix.k8s_version }}
needs:
- setup
- unit-test
strategy:
matrix:
k8s_version: ['1.21', '1.22', '1.23', '1.24']
uses: ./.github/workflows/ci-build.yml
with:
k8s_version: ${{ matrix.k8s_version }}
build_id: ${{ github.event_name }}-${{ needs.setup.outputs.sha_short }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
secrets: inherit
54 changes: 54 additions & 0 deletions .github/workflows/janitor-ami-sweeper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: '[Janitor] AMI sweeper'
on:
workflow_dispatch:
inputs:
max_age_seconds:
required: true
type: number
workflow_call:
inputs:
max_age_seconds:
required: true
type: number
jobs:
ami-sweeper:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
- run: |
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

function jqb64() {
if [ "$#" -lt 2 ]; then
echo "usage: jqb64 BASE64_JSON JQ_ARGS..."
exit 1
fi
BASE64_JSON="$1"
shift
echo "$BASE64_JSON" | base64 --decode | jq $@
}

for IMAGE_DETAILS in $(aws ec2 describe-images --owners self --output json | jq -r '.Images[] | @base64'); do
NAME=$(jqb64 "$IMAGE_DETAILS" -r '.Name')
IMAGE_ID=$(jqb64 "$IMAGE_DETAILS" -r '.ImageId')
CREATION_DATE=$(jqb64 "$IMAGE_DETAILS" -r '.CreationDate')
CREATION_DATE_SECONDS=$(date -d "$CREATION_DATE" '+%s')
CURRENT_TIME_SECONDS=$(date '+%s')
MIN_CREATION_DATE_SECONDS=$(($CURRENT_TIME_SECONDS - ${{ inputs.max_age_seconds }}))
if [ "$CREATION_DATE_SECONDS" -lt "$MIN_CREATION_DATE_SECONDS" ]; then
aws ec2 deregister-image --image-id "$IMAGE_ID"
for SNAPSHOT_ID in $(jqb64 "$IMAGE_DETAILS" -r '.BlockDeviceMappings[].Ebs.SnapshotId'); do
aws ec2 delete-snapshot --snapshot-id "$SNAPSHOT_ID"
done
echo "Deleted $IMAGE_ID: $NAME"
fi
done
65 changes: 65 additions & 0 deletions .github/workflows/janitor-cluster-sweeper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: '[Janitor] Cluster sweeper'
on:
workflow_dispatch:
inputs:
max_age_seconds:
required: true
type: number
workflow_call:
inputs:
max_age_seconds:
required: true
type: number
jobs:
cluster-sweeper:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
- run: |
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

function iso8601_is_eligible_for_deletion() {
local TIME_IN_ISO8601="$1"
local TIME_IN_SECONDS=$(date -d "$TIME_IN_ISO8601" '+%s')
local CURRENT_TIME_IN_SECONDS=$(date '+%s')
MIN_TIME_SECONDS=$(($CURRENT_TIME_IN_SECONDS - ${{ inputs.max_age_seconds }}))
[ "$TIME_IN_SECONDS" -lt "$MIN_TIME_SECONDS" ]
}

function cluster_is_eligible_for_deletion() {
local CLUSTER_NAME="$1"
local CREATED_AT_ISO8601=$(aws eks describe-cluster --name $CLUSTER_NAME --query 'cluster.createdAt' --output text)
iso8601_is_eligible_for_deletion "$CREATED_AT_ISO8601"
}

function nodegroup_is_eligible_for_deletion() {
local CLUSTER_NAME="$1"
local NODEGROUP_NAME="$2"
local CREATED_AT_ISO8601=$(aws eks describe-nodegroup --cluster-name "$CLUSTER_NAME" --nodegroup-name $NODEGROUP_NAME --query 'nodegroup.createdAt' --output text)
iso8601_is_eligible_for_deletion "$CREATED_AT_ISO8601"
}

wget --no-verbose -O eksctl.tar.gz "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
tar xf eksctl.tar.gz && chmod +x ./eksctl
for CLUSTER in $(aws eks list-clusters --query 'clusters[]' --output text); do
for NODEGROUP in $(aws eks list-nodegroups --cluster-name $CLUSTER --query 'nodegroups[]' --output text); do
if nodegroup_is_eligible_for_deletion $CLUSTER $NODEGROUP; then
./eksctl delete nodegroup --cluster $CLUSTER --name $NODEGROUP
fi
done
if [ "$(aws eks list-nodegroups --cluster-name $CLUSTER --output json | jq '.nodegroups | length')" -gt 0 ]; then
echo "Skipping cluster $CLUSTER"
elif cluster_is_eligible_for_deletion $CLUSTER; then
echo "Deleting cluster $CLUSTER"
./eksctl delete cluster --name "$CLUSTER"
fi
done
18 changes: 18 additions & 0 deletions .github/workflows/janitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: '[Janitor] Entrypoint'
on:
schedule:
# hourly at the top of the hour
- cron: '0 * * * *'
jobs:
cluster-sweeper:
uses: ./.github/workflows/janitor-cluster-sweeper.yml
secrets: inherit
with:
# 6 hours
max_age_seconds: 21600
ami-sweeper:
uses: ./.github/workflows/janitor-ami-sweeper.yml
secrets: inherit
with:
# 30 days
max_age_seconds: 2592000
26 changes: 26 additions & 0 deletions .github/workflows/sync-to-codecommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: '[Sync] Push to CodeCommit'

on:
push:
branches:
- 'master'

jobs:
mirror:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
- run: git config credential.helper '!aws codecommit credential-helper $@'
- run: git config credential.UseHttpPath true
- run: git remote add mirror ${{ secrets.AWS_CODECOMMIT_REPO_URL }}
- run: git push mirror
3 changes: 3 additions & 0 deletions test-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This file exists to test the PR workflow.

Revision: 1