Skip to content

Commit 1de7661

Browse files
committed
Add new steps to the workflows to update the helm release on the canaries and tf
1 parent ecae74e commit 1de7661

File tree

6 files changed

+226
-6
lines changed

6 files changed

+226
-6
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 📞 k8s canaries helm update
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
AWS_ROLE_ARN:
7+
required: true
8+
AWS_VPC_SUBNET:
9+
required: true
10+
11+
inputs:
12+
image-tag:
13+
required: true
14+
type: string
15+
cluster_name:
16+
required: true
17+
type: string
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
infra:
24+
name: Prepare infra
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Configure AWS Credentials
30+
uses: aws-actions/configure-aws-credentials@v4
31+
with:
32+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
33+
aws-region: us-east-2
34+
35+
- name: Set branch name
36+
run: |
37+
# Short name for current branch. For PRs, use target branch (base ref)
38+
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
39+
# Is the ref a tag? If so, remove refs/tags/ prefix
40+
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
41+
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
42+
43+
- uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
47+
- name: Upgrade helm release
48+
uses: newrelic/fargate-runner-action@main
49+
with:
50+
aws_region: us-east-2
51+
container_make_target: "IMAGE_TAG=${{ inputs.image-tag }} CLUSTER_NAME=${{ inputs.cluster_name }} HELM_DIR=test/k8s-canaries/helm test/k8s-canaries/helm"
52+
ecs_cluster_name: caos_super_agent_releases
53+
task_definition_name: super_agent-releases
54+
cloud_watch_logs_group_name: /ecs/test-prerelease-super_agent-releases
55+
cloud_watch_logs_stream_name: ecs/test-super_agent-releases
56+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
57+
repo_name: "newrelic/newrelic-super-agent"
58+
git_clone_url: "ssh://git@github.com/newrelic/newrelic-super-agent.git"
59+
ref: "${{ env.GIT_BRANCH }}"

.github/workflows/nightly.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ jobs:
9191
AWS_ROLE_ARN: ${{ secrets.TMP_AWS_ROLE_ARN }}
9292
AWS_VPC_SUBNET: ${{ secrets.TMP_AWS_VPC_SUBNET }}
9393

94+
k8s_canaries:
95+
uses: ./.github/workflows/component_k8s_canaries.yml
96+
needs: [ build-image ]
97+
with:
98+
image-tag: nightly
99+
cluster_name: Agent_Control_Canaries_Staging-Cluster
100+
secrets:
101+
AWS_ROLE_ARN: ${{ secrets.TMP_AWS_ROLE_ARN }}
102+
AWS_VPC_SUBNET: ${{ secrets.TMP_AWS_VPC_SUBNET }}
103+
94104
notify-failure:
95105
if: ${{ always() && failure() }}
96106
needs: [ build-image ]

.github/workflows/prerelease.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ jobs:
131131
# AWS_ROLE_ARN: ${{ secrets.TMP_AWS_ROLE_ARN }}
132132
# AWS_VPC_SUBNET: ${{ secrets.TMP_AWS_VPC_SUBNET }}
133133

134+
k8s_canaries:
135+
uses: ./.github/workflows/component_k8s_canaries.yml
136+
needs: [ build-image ]
137+
with:
138+
image-tag: ${{ github.event.release.tag_name }}-rc
139+
cluster_name: Agent_Control_Canaries_Production-Cluster
140+
secrets:
141+
AWS_ROLE_ARN: ${{ secrets.TMP_AWS_ROLE_ARN }}
142+
AWS_VPC_SUBNET: ${{ secrets.TMP_AWS_VPC_SUBNET }}
143+
134144
get_previous_tag:
135145
runs-on: ubuntu-latest
136146
outputs:
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
permissions:
2+
id-token: write
3+
contents: read
4+
on:
5+
pull_request:
6+
paths:
7+
- test/k8s-canaries/terraform/**
8+
concurrency:
9+
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
10+
cancel-in-progress: false
11+
name: plan k8s canaries changes
12+
13+
jobs:
14+
infra:
15+
name: Prepare infra
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Configure AWS Credentials
19+
uses: aws-actions/configure-aws-credentials@v4
20+
with:
21+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
22+
aws-region: us-east-2
23+
24+
- uses: actions/checkout@v4
25+
26+
- name: Set branch name
27+
run: |
28+
# Short name for current branch. For PRs, use target branch (base ref)
29+
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
30+
# Is the ref a tag? If so, remove refs/tags/ prefix
31+
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
32+
echo "GIT_BRANCH=$GIT_BRANCH" >> "$GITHUB_ENV"
33+
34+
- name: Plan k8s staging canary changes
35+
uses: newrelic/fargate-runner-action@main
36+
with:
37+
aws_region: us-east-2
38+
container_make_target: "TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=staging test/k8s-canaries/plan"
39+
ecs_cluster_name: agent_control
40+
task_definition_name: agent_control
41+
cloud_watch_logs_group_name: /ecs/test-prerelease-agent_control
42+
cloud_watch_logs_stream_name: ecs/test-agent_control
43+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
44+
repo_name: "newrelic/newrelic-super-agent"
45+
git_clone_url: "ssh://git@github.com/newrelic/newrelic-super-agent.git"
46+
ref: "${{ env.GIT_BRANCH }}"
47+
48+
- name: Plan k8s production canary changes
49+
uses: newrelic/fargate-runner-action@main
50+
with:
51+
aws_region: us-east-2
52+
container_make_target: "TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=production test/k8s-canaries/plan"
53+
ecs_cluster_name: agent_control
54+
task_definition_name: agent_control
55+
cloud_watch_logs_group_name: /ecs/test-prerelease-agent_control
56+
cloud_watch_logs_stream_name: ecs/test-agent_control
57+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
58+
repo_name: "newrelic/newrelic-super-agent"
59+
git_clone_url: "ssh://git@github.com/newrelic/newrelic-super-agent.git"
60+
ref: "${{ env.GIT_BRANCH }}"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
permissions:
2+
id-token: write
3+
contents: read
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- test/k8s-canaries/terraform/**
10+
concurrency:
11+
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
12+
cancel-in-progress: false
13+
name: sync k8s canaries
14+
15+
jobs:
16+
infra:
17+
name: Prepare infra
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Configure AWS Credentials
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
24+
aws-region: us-east-2
25+
26+
- uses: actions/checkout@v4
27+
28+
- name: Set branch name
29+
run: |
30+
# Short name for current branch. For PRs, use target branch (base ref)
31+
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
32+
# Is the ref a tag? If so, remove refs/tags/ prefix
33+
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
34+
echo "GIT_BRANCH=$GIT_BRANCH" >> "$GITHUB_ENV"
35+
36+
- name: Sync k8s staging canary
37+
uses: newrelic/fargate-runner-action@main
38+
with:
39+
aws_region: us-east-2
40+
container_make_target: "TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=staging test/k8s-canaries/sync"
41+
ecs_cluster_name: caos_super_agent_releases
42+
task_definition_name: super_agent-releases
43+
cloud_watch_logs_group_name: /ecs/test-prerelease-super_agent-releases
44+
cloud_watch_logs_stream_name: ecs/test-super_agent-releases
45+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
46+
repo_name: "newrelic/newrelic-super-agent"
47+
git_clone_url: "ssh://git@github.com/newrelic/newrelic-super-agent.git"
48+
ref: "${{ env.GIT_BRANCH }}"
49+
50+
- name: Sync k8s production canary
51+
uses: newrelic/fargate-runner-action@main
52+
with:
53+
aws_region: us-east-2
54+
container_make_target: "TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=production test/k8s-canaries/sync"
55+
ecs_cluster_name: caos_super_agent_releases
56+
task_definition_name: super_agent-releases
57+
cloud_watch_logs_group_name: /ecs/test-prerelease-super_agent-releases
58+
cloud_watch_logs_stream_name: ecs/test-super_agent-releases
59+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
60+
repo_name: "newrelic/newrelic-super-agent"
61+
git_clone_url: "ssh://git@github.com/newrelic/newrelic-super-agent.git"
62+
ref: "${{ env.GIT_BRANCH }}"

test/k8s-canaries/Makefile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
TERRAFORM_DIR := ./terraform
22
HELM_DIR := ./helm
3+
AWS_REGION := us-east-2
34
.DEFAULT_GOAL := all
45

5-
# Generate a random key to add to the helm deployment annotation
6+
# Generate the linux timestamp for helm deployment annotation
67
# This way, whenever there is a helm upgrade the pod will be recreated and its image pulled, even if the tag didn't change
7-
DEPLOYMENT_KEY := $(shell openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c 16)
8+
DEPLOYMENT_KEY := $(shell date +%s)
89

910
.PHONY: all
1011
all:
1112
@echo "No default target"
1213

14+
.PHONY: test/k8s-canaries/plan
15+
test/k8s-canaries/sync:
16+
ifndef CANARY_DIR
17+
@echo "CANARY_DIR variable must be provided to know which canary to plan"
18+
exit 1
19+
endif
20+
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) init && \
21+
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) plan
22+
1323
.PHONY: test/k8s-canaries/sync
1424
test/k8s-canaries/sync:
1525
ifndef CANARY_DIR
@@ -19,18 +29,27 @@ endif
1929
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) init && \
2030
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) apply -auto-approve
2131

32+
33+
.PHONY: test/k8s-canaries/aws-kubeconfig
34+
test/k8s-canaries/aws-kubeconfig:
35+
ifndef CLUSTER_NAME
36+
@echo "CLUSTER_NAME variable must be provided for test/k8s-canaries/aws-eks"
37+
exit 1
38+
endif
39+
@aws eks update-kubeconfig --region=$(AWS_REGION) --name $(CLUSTER_NAME)
40+
2241
.PHONY: test/k8s-canaries/helm
23-
test/k8s-canaries/helm:
42+
test/k8s-canaries/helm: test/k8s-canaries/aws-kubeconfig
2443
ifndef NR_LICENSE_KEY
25-
@echo "NR_LICENSE_KEY variable must be provided for k8s-canaries/helm"
44+
@echo "NR_LICENSE_KEY variable must be provided for test/k8s-canaries/helm"
2645
exit 1
2746
endif
2847
ifndef CLUSTER_NAME
29-
@echo "CLUSTER_NAME variable must be provided for k8s-canaries/helm"
48+
@echo "CLUSTER_NAME variable must be provided for test/k8s-canaries/helm"
3049
exit 1
3150
endif
3251
ifndef IMAGE_TAG
33-
@echo "IMAGE_TAG variable must be provided for k8s-canaries/helm"
52+
@echo "IMAGE_TAG variable must be provided for test/k8s-canaries/helm"
3453
exit 1
3554
endif
3655
@helm repo add newrelic https://helm-charts.newrelic.com

0 commit comments

Comments
 (0)