Skip to content

Commit 4bcf93d

Browse files
Add new steps to the workflows to update the helm release on the canaries and tf, a new rbac is added to the clusters (#1027)
1 parent f26c197 commit 4bcf93d

File tree

17 files changed

+415
-30
lines changed

17 files changed

+415
-30
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
id-token: write
21+
contents: read
22+
23+
jobs:
24+
infra:
25+
name: Prepare infra
26+
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Configure AWS Credentials
31+
uses: aws-actions/configure-aws-credentials@v4
32+
with:
33+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
34+
aws-region: us-east-2
35+
36+
- name: Set branch name
37+
run: |
38+
# Short name for current branch. For PRs, use target branch (base ref)
39+
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
40+
# Is the ref a tag? If so, remove refs/tags/ prefix
41+
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
42+
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
43+
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Upgrade helm release
49+
uses: newrelic/fargate-runner-action@main
50+
with:
51+
aws_region: us-east-2
52+
container_make_target: "IMAGE_TAG=${{ inputs.image-tag }} CLUSTER_NAME=${{ inputs.cluster_name }} HELM_DIR=test/k8s-canaries/helm test/k8s-canaries/helm-upgrade"
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: ${{ github.repository }}
59+
git_clone_url: "ssh://git@github.com/${{ github.repository }}.git"
60+
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.AWS_ROLE_ARN }}
9292
AWS_VPC_SUBNET: ${{ secrets.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.AWS_ROLE_ARN }}
102+
AWS_VPC_SUBNET: ${{ secrets.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.AWS_ROLE_ARN }}
132132
# AWS_VPC_SUBNET: ${{ secrets.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.AWS_ROLE_ARN }}
142+
AWS_VPC_SUBNET: ${{ secrets.AWS_VPC_SUBNET }}
143+
134144
get_previous_tag:
135145
runs-on: ubuntu-latest
136146
outputs:
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: terraform apply 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/terraform-apply"
41+
ecs_cluster_name: agent_control
42+
task_definition_name: agent_control
43+
cloud_watch_logs_group_name: /ecs/test-prerelease-agent_control
44+
cloud_watch_logs_stream_name: ecs/test-agent_control
45+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
46+
repo_name: ${{ github.repository }}
47+
git_clone_url: "ssh://git@github.com/${{ github.repository }}.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/terraform-apply"
55+
ecs_cluster_name: agent_control
56+
task_definition_name: agent_control
57+
cloud_watch_logs_group_name: /ecs/test-prerelease-agent_control
58+
cloud_watch_logs_stream_name: ecs/test-agent_control
59+
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
60+
repo_name: ${{ github.repository }}
61+
git_clone_url: "ssh://git@github.com/${{ github.repository }}.git"
62+
ref: "${{ env.GIT_BRANCH }}"
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/terraform-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: ${{ github.repository }}
45+
git_clone_url: "ssh://git@github.com/${{ github.repository }}.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/terraform-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: ${{ github.repository }}
59+
git_clone_url: "ssh://git@github.com/${{ github.repository }}.git"
60+
ref: "${{ env.GIT_BRANCH }}"

test/k8s-canaries/Makefile

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

56
# Generate a random key to add to the helm deployment annotation
@@ -10,27 +11,45 @@ DEPLOYMENT_KEY := $(shell openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c 1
1011
all:
1112
@echo "No default target"
1213

13-
.PHONY: test/k8s-canaries/sync
14-
test/k8s-canaries/sync:
14+
.PHONY: test/k8s-canaries/terraform-plan
15+
test/k8s-canaries/terraform-plan:
1516
ifndef CANARY_DIR
16-
@echo "CANARY_DIR variable must be provided to know which canary to sync"
17+
@echo "CANARY_DIR variable must be provided to know which canary to terraform-plan"
18+
exit 1
19+
endif
20+
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) init && \
21+
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) plan
22+
23+
.PHONY: test/k8s-canaries/terraform-apply
24+
test/k8s-canaries/terraform-apply:
25+
ifndef CANARY_DIR
26+
@echo "CANARY_DIR variable must be provided to know which canary to terraform-apply"
1727
exit 1
1828
endif
1929
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) init && \
2030
terraform -chdir=$(TERRAFORM_DIR)/$(CANARY_DIR) apply -auto-approve
2131

22-
.PHONY: test/k8s-canaries/helm
23-
test/k8s-canaries/helm:
32+
33+
.PHONY: test/k8s-canaries/update-kubeconfig-from-aws
34+
test/k8s-canaries/update-kubeconfig-from-aws:
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+
41+
.PHONY: test/k8s-canaries/helm-upgrade
42+
test/k8s-canaries/helm-upgrade: test/k8s-canaries/update-kubeconfig-from-aws
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-upgrade"
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-upgrade"
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-upgrade"
3453
exit 1
3554
endif
3655
@helm repo add newrelic https://helm-charts.newrelic.com
@@ -40,3 +59,4 @@ endif
4059
--set global.cluster=$(CLUSTER_NAME) \
4160
--set agent-control-deployment.image.tag=$(IMAGE_TAG) \
4261
--set agent-control-deployment.podAnnotations.deploymentKey="${DEPLOYMENT_KEY}"
62+

test/k8s-canaries/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The default terraform dir for where the terraform modules are taken from is:
2222
`TERRAFORM_DIR := ./terraform`
2323

2424
```bash
25-
$ make CANARY_DIR=staging test/k8s-canaries/sync
25+
$ make CANARY_DIR=staging test/k8s-canaries/terraform-apply
2626
```
2727

2828
If this target is called from the root of this repository, the TERRAFORM_DIR should be overwritten to point to the relative path:
2929
```bash
30-
$ make TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=staging test/k8s-canaries/sync
30+
$ make TERRAFORM_DIR=test/k8s-canaries/terraform CANARY_DIR=staging test/k8s-canaries/terraform-apply
3131
```
3232

3333
### Helm Upgrade for nightlies and prereleases
@@ -39,10 +39,10 @@ The default helm dir where there is the default values file to apply is:
3939
`HELM_DIR := ./helm`
4040

4141
```bash
42-
$ make NR_LICENSE_KEY=xxx CLUSTER_NAME=my-cluster IMAGE_TAG=nightly test/k8s-canaries/helm
42+
$ make NR_LICENSE_KEY=xxx CLUSTER_NAME=my-cluster IMAGE_TAG=nightly test/k8s-canaries/helm-upgrade
4343
```
4444

4545
If this target is called from the root of this repository, the HELM_DIR should be overwritten to point to the relative path:
4646
```bash
47-
$ make HELM_DIR=test/k8s-canaries/helm NR_LICENSE_KEY=xxx CLUSTER_NAME=my-cluster IMAGE_TAG=nightly test/k8s-canaries/helm
47+
$ make HELM_DIR=test/k8s-canaries/helm NR_LICENSE_KEY=xxx CLUSTER_NAME=my-cluster IMAGE_TAG=nightly test/k8s-canaries/helm-upgrade
4848
```

test/k8s-canaries/terraform/modules/eks_cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ resource "aws_eks_node_group" "eks-nodegroup" {
107107

108108
launch_template {
109109
id = aws_launch_template.eks_node.id
110-
version = "$Latest"
110+
version = "1"
111111
}
112112

113113
ami_type = var.nodes_ami_type
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
output "ekscluster" {
1+
output "cluster" {
22
value = {
3-
aws_eks_cluster = {
4-
ekscluster = {
5-
name = aws_eks_cluster.ekscluster.name
6-
endpoint = aws_eks_cluster.ekscluster.endpoint
7-
}
8-
}
3+
name = aws_eks_cluster.ekscluster.name
4+
endpoint = aws_eks_cluster.ekscluster.endpoint
95
}
106
}

0 commit comments

Comments
 (0)