Skip to content

Commit caccff4

Browse files
hakuna-matatahHarish Kuna
andauthored
Security fixes ; KIT tekton tasks and flux integration; KIT Tekton Pipeline periodics (#45)
* security vulnerabilities fix; Kit tekton tasks; pipeline periodics; Co-authored-by: Harish Kuna <[email protected]>
1 parent cf39cb1 commit caccff4

File tree

11 files changed

+2929
-3385
lines changed

11 files changed

+2929
-3385
lines changed

testbed/addons/awslb/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AWSLoadBalancerController extends cdk.Construct {
2323
managedPolicyArn: `arn:aws:iam::aws:policy/AdministratorAccess`
2424
});
2525

26-
const manifest = props.cluster.addManifest('awsLbcCrdManifest', ...yaml.loadAll(request.default('GET', 'https://raw.githubusercontent.com/aws/eks-charts/master/stable/aws-load-balancer-controller/crds/crds.yaml').getBody().toString()));
26+
const manifest = props.cluster.addManifest('awsLbcCrdManifest', ...yaml.loadAll(request.default('GET', 'https://raw.githubusercontent.com/aws/eks-charts/master/stable/aws-load-balancer-controller/crds/crds.yaml').getBody().toString()) as [Record<string,unknown>]);
2727

2828
const chart = props.cluster.addHelmChart('AWSLBCHelmChart', {
2929
chart: 'aws-load-balancer-controller',

testbed/addons/flux/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class Flux extends cdk.Construct {
2020

2121
const fluxManifest = props.cluster.addManifest(
2222
'flux', ...yaml.loadAll(request.default(
23-
"GET", "https://github.com/fluxcd/flux2/releases/download/v0.15.0/install.yaml").getBody().toString()));
23+
"GET", "https://github.com/fluxcd/flux2/releases/download/v0.15.0/install.yaml").getBody().toString()) as [Record<string,unknown>]);
2424

2525
props.repositories.forEach(function (value, index) {
2626
// Bootstrap manifests

testbed/addons/kit/construct.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ export class Kit extends cdk.Construct {
7575

7676
// Install kit
7777
const chart = props.cluster.addHelmChart('kit', {
78-
chart: 'kit',
79-
release: 'kit',
80-
version: 'v0.0.1',
78+
chart: 'kit-operator',
79+
release: 'kit-operator',
8180
repository: 'https://github.com/awslabs/kubernetes-iteration-toolkit/tree/main/operator/charts/kit-operator',
8281
namespace: namespace,
8382
createNamespace: false,

testbed/package-lock.json

Lines changed: 2696 additions & 3370 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testbed/package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@
1010
"cdk": "cdk"
1111
},
1212
"devDependencies": {
13-
"@aws-cdk/assert": "1.108.1",
14-
"@types/jest": "^26.0.10",
15-
"@types/js-yaml": "^4.0.1",
13+
"@aws-cdk/assert": "^1.127.0",
14+
"@types/jest": "^26.0.24",
15+
"@types/js-yaml": "^4.0.3",
1616
"@types/node": "10.17.27",
17-
"aws-cdk": "1.108.1",
18-
"jest": "^26.4.2",
17+
"aws-cdk": "^1.127.0",
18+
"jest": "^27.2.5",
1919
"ts-jest": "^26.2.0",
2020
"ts-node": "^9.0.0",
2121
"typescript": "~3.9.7"
2222
},
2323
"dependencies": {
24-
"@aws-cdk/aws-ec2": "1.108.1",
25-
"@aws-cdk/aws-eks": "1.108.1",
26-
"@aws-cdk/aws-iam": "1.108.1",
27-
"@aws-cdk/core": "1.108.1",
28-
"@types/js-yaml": "^4.0.1",
24+
"@aws-cdk/aws-ec2": "1.127.0",
25+
"@aws-cdk/aws-eks": "1.127.0",
26+
"@aws-cdk/aws-iam": "1.127.0",
27+
"@aws-cdk/core": "1.127.0",
2928
"js-yaml": "^4.0.1",
3029
"sync-request": "6.1.0"
3130
}

tests/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ resources:
66
- tasks/setup/eksctl/default.yaml
77
- tasks/teardown/eksctl.yaml
88
- pipelines/eks/upstream-load.yaml
9+
- tasks/setup/kit-cluster/default.yaml
10+
- tasks/teardown/kit.yaml
11+
- pipelines/kit/upstream-load.yaml
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Pipeline
4+
metadata:
5+
name: kitloadtest
6+
spec:
7+
workspaces:
8+
- name: config
9+
- name: source
10+
- name: results
11+
params:
12+
- name: cluster-name
13+
description: The name of the kit cluster you want to spin.
14+
- name: host-cluster-region
15+
default: "us-west-2"
16+
description: The region where the Host EKS cluster is in.
17+
- name: guest-cluster-region
18+
default: "us-west-2"
19+
description: The region where the kit cluster is created.
20+
- name: control-plane-spec
21+
description: url to the controlplane spec.
22+
- name: dataplane-spec
23+
description: url to the dataplane spec.
24+
- name: giturl
25+
description: "git url to clone the package"
26+
default: https://github.com/kubernetes/perf-tests.git
27+
- name: pods-per-node
28+
description: "pod density"
29+
default: "10"
30+
- name: nodes-per-namespace
31+
description: "nodes per namespace to get created for load test "
32+
default: "100"
33+
- name: cl2-load-test-throughput
34+
description: "throughput used for mutate operations"
35+
default: "15"
36+
- name: results-bucket
37+
description: "Results bucket with path of s3 to upload results"
38+
- name: desired-nodes
39+
description: The desired number of nodes in the cluster which we define in DataPlane spec.
40+
tasks:
41+
- name: create-kit-cluster
42+
taskRef:
43+
name: kit-cluster-create
44+
params:
45+
- name: cluster-name
46+
value: '$(params.cluster-name)'
47+
- name: host-cluster-region
48+
value: '$(params.host-cluster-region)'
49+
- name: guest-cluster-region
50+
value: '$(params.guest-cluster-region)'
51+
- name: control-plane-spec
52+
value: '$(params.control-plane-spec)'
53+
- name: dataplane-spec
54+
value: '$(params.dataplane-spec)'
55+
workspaces:
56+
- name: config
57+
workspace: config
58+
- name: generate
59+
runAfter: [create-kit-cluster]
60+
taskRef:
61+
name: load
62+
params:
63+
- name: giturl
64+
value: '$(params.giturl)'
65+
- name: pods-per-node
66+
value: '$(params.pods-per-node)'
67+
- name: nodes-per-namespace
68+
value: '$(params.nodes-per-namespace)'
69+
- name: cl2-load-test-throughput
70+
value: '$(params.cl2-load-test-throughput)'
71+
- name: results-bucket
72+
value: '$(params.results-bucket)'
73+
- name: nodes
74+
value: '$(params.desired-nodes)'
75+
workspaces:
76+
- name: source
77+
workspace: source
78+
- name: config
79+
workspace: config
80+
- name: results
81+
workspace: results
82+
- name: teardown
83+
runAfter: [generate]
84+
taskRef:
85+
name: kit-cluster-teardown
86+
params:
87+
- name: cluster-name
88+
value: '$(params.cluster-name)'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: kit-cluster-create
6+
spec:
7+
description: |
8+
Create a KIT cluster.
9+
This Task can be used to create an KIT cluster in an AWS account and write a kubeconfig to a desired location that
10+
can be used by other tasks (in a context with kubectl) to make requests to the cluster.
11+
params:
12+
- name: cluster-name
13+
description: The name of the KIT cluster you want to spin.
14+
- name: host-cluster-region
15+
default: "us-west-2"
16+
description: The region where the Host EKS cluster is in.
17+
- name: guest-cluster-region
18+
default: "us-west-2"
19+
description: The region where the kit cluster is created.
20+
- name: control-plane-spec
21+
description: url to the controlplane spec.
22+
- name: dataplane-spec
23+
description: url to the dataplane spec.
24+
workspaces:
25+
- name: config
26+
description: |
27+
A workspace into which a kubeconfig file called `kubeconfig` for Guest(kit-type) cluster will be written that will contain the information required to access the cluster.
28+
steps:
29+
- name: write-kubeconfig
30+
image: amazon/aws-cli
31+
script: |
32+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
33+
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
34+
kubectl version
35+
aws eks update-kubeconfig --name testbed --region $(params.host-cluster-region)
36+
kubectl config current-context
37+
#Provision a control plane for the guest cluster
38+
kubectl create -f $(params.control-plane-spec)
39+
#Provision a dataplane plane for the guest cluster
40+
kubectl create -f $(params.dataplane-spec)
41+
#Get the admin KUBECONFIG for the guest cluster from the substrate cluster
42+
kubectl get secret $(params.cluster-name)-kube-admin-config -ojsonpath='{.data.config}' | base64 -d > $(workspaces.config.path)/kubeconfig
43+
#Deploy CNI plugin to the guest cluster for the nodes to be ready.
44+
#Todo: CNI installation only works for `us-west-2`, yet to decide how to tackle other regions.
45+
kubectl --kubeconfig=$(workspaces.config.path)/kubeconfig apply -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/master/config/v1.9/aws-k8s-cni.yaml
46+
sleep 300

tests/tasks/teardown/kit.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: kit-cluster-teardown
6+
spec:
7+
description: |
8+
Teardown an KIT cluster.
9+
This Task can be used to teardown an KIT cluster in an AWS account.
10+
params:
11+
- name: cluster-name
12+
description: The name of the EKS cluster which will be teared down.
13+
steps:
14+
- name: delete-cluster
15+
image: amazon/aws-cli
16+
script: |
17+
kubectl version
18+
aws eks update-kubeconfig --name testbed --region $(params.host-cluster-region)
19+
kubectl config current-context
20+
#delete kit controlplane spec and dataplane spec crds
21+
kubectl delete ControlPlane --name $(params.cluster-name)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: batch/v1beta1
3+
kind: CronJob
4+
metadata:
5+
name: kit-small-upstream-load
6+
spec:
7+
schedule: "0 8 * * *"
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
containers:
13+
- name: curl
14+
image: curlimages/curl
15+
args: ["curl", "-X", "POST", "--data", "{}", "el-kit-small-upstream-load.default.svc.cluster.local:8080"]
16+
restartPolicy: Never
17+
---
18+
apiVersion: triggers.tekton.dev/v1alpha1
19+
kind: TriggerBinding
20+
metadata:
21+
name: kit-small-upstream-load
22+
---
23+
apiVersion: triggers.tekton.dev/v1alpha1
24+
kind: EventListener
25+
metadata:
26+
name: kit-small-upstream-load
27+
spec:
28+
serviceAccountName: tekton-triggers
29+
triggers:
30+
- name: cron
31+
bindings:
32+
- ref: kit-small-upstream-load
33+
template:
34+
ref: kit-small-upstream-load
35+
---
36+
apiVersion: triggers.tekton.dev/v1alpha1
37+
kind: TriggerTemplate
38+
metadata:
39+
name: kit-small-upstream-load
40+
spec:
41+
resourcetemplates:
42+
- apiVersion: tekton.dev/v1beta1
43+
kind: PipelineRun
44+
metadata:
45+
generateName: kit-small-upstream-load-
46+
spec:
47+
pipelineRef:
48+
name: loadtest
49+
serviceAccountName: test-executor
50+
workspaces:
51+
- name: source
52+
emptyDir: {}
53+
- name: config
54+
emptyDir: {}
55+
- name: results
56+
emptyDir: {}
57+
params:
58+
- name: cluster-name
59+
value: "kit-small"
60+
- name: results-bucket
61+
value: "kit-scalability-dev/$(date +'%Y/%m/%d/%HH/%mm)/$(context.pipelineRun.uid)"

0 commit comments

Comments
 (0)