Skip to content

Commit 9cfcfdb

Browse files
Updates Tasks to use kubeconfig from workspace. (#354)
This commit updates task to use kubeconfig from workspaces to make load and addon related task generic. Signed-off-by: Ashish Ranjan <[email protected]>
1 parent a8b7d70 commit 9cfcfdb

File tree

15 files changed

+128
-86
lines changed

15 files changed

+128
-86
lines changed

tests/pipelines/eks/awscli-cl2-load-with-addons.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ spec:
8282
taskRef:
8383
kind: Task
8484
name: awscli-eks-cluster-create-with-vpc-stack
85+
workspaces:
86+
- name: config
87+
workspace: config
8588
- name: create-mng-monitoring-nodes
8689
params:
8790
- name: cluster-name
@@ -105,17 +108,21 @@ spec:
105108
taskRef:
106109
kind: Task
107110
name: awscli-eks-nodegroup-create
111+
workspaces:
112+
- name: config
113+
workspace: config
108114
- name: install-fluentbit-addon
109115
params:
110116
- name: cluster-name
111117
value: $(params.cluster-name)
112-
- name: endpoint
113-
value: $(params.endpoint)
114118
runAfter:
115119
- create-mng-monitoring-nodes
116120
taskRef:
117121
kind: Task
118122
name: eks-addon-fluentbit
123+
workspaces:
124+
- name: config
125+
workspace: config
119126
- name: create-mng-nodes
120127
params:
121128
- name: cluster-name
@@ -131,17 +138,21 @@ spec:
131138
taskRef:
132139
kind: Task
133140
name: awscli-eks-nodegroup-create
141+
workspaces:
142+
- name: config
143+
workspace: config
134144
- name: create-cw-agent-addon
135145
params:
136146
- name: cluster-name
137147
value: $(params.cluster-name)
138-
- name: endpoint
139-
value: $(params.endpoint)
140148
runAfter:
141149
- create-mng-nodes
142150
taskRef:
143151
kind: Task
144152
name: eks-addon-cwagent
153+
workspaces:
154+
- name: config
155+
workspace: config
145156
- name: generate
146157
params:
147158
- name: cluster-name
@@ -158,8 +169,6 @@ spec:
158169
value: $(params.desired-nodes)
159170
- name: amp-workspace-id
160171
value: '$(params.amp-workspace-id)'
161-
- name: endpoint
162-
value: $(params.endpoint)
163172
runAfter:
164173
- create-cw-agent-addon
165174
taskRef:
@@ -170,6 +179,8 @@ spec:
170179
workspace: source
171180
- name: results
172181
workspace: results
182+
- name: config
183+
workspace: config
173184
finally:
174185
- name: teardown
175186
params:
@@ -190,4 +201,5 @@ spec:
190201
name: awscli-eks-cluster-teardown
191202
workspaces:
192203
- name: source
193-
- name: results
204+
- name: results
205+
- name: config

tests/pipelines/eks/awscli-eks-cl2-load.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ spec:
8585
taskRef:
8686
kind: Task
8787
name: awscli-eks-cluster-create-with-vpc-stack
88+
workspaces:
89+
- name: config
90+
workspace: config
8891
- name: create-mng-monitoring-nodes
8992
params:
9093
- name: cluster-name
@@ -108,17 +111,21 @@ spec:
108111
taskRef:
109112
kind: Task
110113
name: awscli-eks-nodegroup-create
114+
workspaces:
115+
- name: config
116+
workspace: config
111117
- name: install-fluentbit-addon
112118
params:
113119
- name: cluster-name
114120
value: $(params.cluster-name)
115-
- name: endpoint
116-
value: $(params.endpoint)
117121
runAfter:
118122
- create-mng-monitoring-nodes
119123
taskRef:
120124
kind: Task
121125
name: eks-addon-fluentbit
126+
workspaces:
127+
- name: config
128+
workspace: config
122129
- name: create-mng-nodes
123130
params:
124131
- name: cluster-name
@@ -134,6 +141,9 @@ spec:
134141
taskRef:
135142
kind: Task
136143
name: awscli-eks-nodegroup-create
144+
workspaces:
145+
- name: config
146+
workspace: config
137147
- name: generate
138148
params:
139149
- name: pods-per-node
@@ -148,8 +158,6 @@ spec:
148158
value: $(params.desired-nodes)
149159
- name: cluster-name
150160
value: $(params.cluster-name)
151-
- name: endpoint
152-
value: $(params.endpoint)
153161
- name: amp-workspace-id
154162
value: '$(params.amp-workspace-id)'
155163
runAfter:
@@ -161,7 +169,9 @@ spec:
161169
- name: source
162170
workspace: source
163171
- name: results
164-
workspace: results
172+
workspace: results
173+
- name: config
174+
workspace: config
165175
- name: cw-metrics
166176
params:
167177
- name: dimensions
@@ -195,4 +205,5 @@ spec:
195205
name: awscli-eks-cluster-teardown
196206
workspaces:
197207
- name: source
198-
- name: results
208+
- name: results
209+
- name: config

tests/tasks/addons/cwagent.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ spec:
1313
- name: region
1414
default: "us-west-2"
1515
description: The region where the cluster is in.
16-
- name: endpoint
17-
default: ""
16+
workspaces:
17+
- name: config
18+
mountPath: /config/
19+
stepTemplate:
20+
env:
21+
- name: KUBECONFIG
22+
value: /config/kubeconfig
1823
steps:
1924
- name: create-cw-agent
20-
image: alpine/k8s:1.22.6
25+
image: alpine/k8s:1.23.7
2126
script: |
22-
echo "Approving KCM requests"
23-
kubectl certificate approve $(kubectl get csr | grep "Pending" | awk '{print $1}') 2>/dev/null || true
24-
ENDPOINT_FLAG=""
25-
if [ -n "$(params.endpoint)" ]; then
26-
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
27-
fi
28-
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
27+
2928
#kubectl commands are purely for knowing state of cluster before kicking off the test.
3029
kubectl version
3130
kubectl config current-context

tests/tasks/addons/fluentbit.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ spec:
1313
- name: region
1414
default: "us-west-2"
1515
description: The region where the cluster is in.
16-
- name: endpoint
17-
default: ""
16+
workspaces:
17+
- name: config
18+
mountPath: /config/
19+
stepTemplate:
20+
env:
21+
- name: KUBECONFIG
22+
value: /config/kubeconfig
1823
steps:
1924
- name: create-fluentbit-addon
20-
image: alpine/k8s:1.22.6
25+
image: alpine/k8s:1.23.7
2126
script: |
22-
echo "Approving KCM requests"
23-
kubectl certificate approve $(kubectl get csr | grep "Pending" | awk '{print $1}') 2>/dev/null || true
24-
ENDPOINT_FLAG=""
25-
if [ -n "$(params.endpoint)" ]; then
26-
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
27-
fi
28-
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
2927
#kubectl commands are purely for knowing state of cluster before kicking off the test.
3028
kubectl version
3129
kubectl config current-context

tests/tasks/generators/clusterloader/load.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ spec:
3030
- name: region
3131
default: "us-west-2"
3232
description: The region where the cluster is in.
33-
- name: endpoint
34-
default: ""
35-
description: "aws eks enpoint to create clusters against"
3633
- name: cluster-name
3734
description: The name of the EKS cluster you want to spin.
3835
- name: amp-workspace-id
@@ -47,6 +44,12 @@ spec:
4744
- name: source
4845
mountPath: /src/k8s.io/
4946
- name: results
47+
- name: config
48+
mountPath: /config/
49+
stepTemplate:
50+
env:
51+
- name: KUBECONFIG
52+
value: /config/kubeconfig
5053
steps:
5154
- name: git-clone
5255
image: alpine/git
@@ -127,21 +130,16 @@ spec:
127130
cd $(workspaces.source.path)/perf-tests/clusterloader2/
128131
GOPROXY=direct GOOS=linux CGO_ENABLED=0 go build -v -o ./clusterloader ./cmd
129132
- name: run-loadtest
130-
image: alpine/k8s:1.22.6
133+
image: alpine/k8s:1.23.7
131134
onError: continue
132135
script: |
133136
#!/bin/bash
134-
ENDPOINT_FLAG=""
135-
if [ -n "$(params.endpoint)" ]; then
136-
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
137-
fi
138137
if [ -n "$(params.amp-workspace-id)" ]; then
139138
CL2_PROMETHEUS_FLAGS="--enable-prometheus-server=true --prometheus-pvc-storage-class gp2 --prometheus-manifest-path=$(workspaces.source.path)/perf-tests/clusterloader2/pkg/prometheus/manifests/"
140139
fi
141-
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
142140
cat $(workspaces.source.path)/perf-tests/clusterloader2/testing/load/config.yaml
143141
cd $(workspaces.source.path)/perf-tests/clusterloader2/
144-
ENABLE_EXEC_SERVICE=false ./clusterloader --kubeconfig=/root/.kube/config --testconfig=$(workspaces.source.path)/perf-tests/clusterloader2/testing/load/config.yaml --testoverrides=$(workspaces.source.path)/overrides.yaml --nodes=$(params.nodes) --provider=eks --report-dir=$(workspaces.results.path) --alsologtostderr --v=2 $CL2_PROMETHEUS_FLAGS
142+
ENABLE_EXEC_SERVICE=false ./clusterloader --kubeconfig=$KUBECONFIG --testconfig=$(workspaces.source.path)/perf-tests/clusterloader2/testing/load/config.yaml --testoverrides=$(workspaces.source.path)/overrides.yaml --nodes=$(params.nodes) --provider=eks --report-dir=$(workspaces.results.path) --alsologtostderr --v=2 $CL2_PROMETHEUS_FLAGS
145143
exit_code=$?
146144
if [ $exit_code -eq 0 ]; then
147145
echo "1" | tee $(results.datapoint.path)

tests/tasks/notifications/slack.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ spec:
1515
description: The message you want to post.
1616
steps:
1717
- name: send-notification
18-
image: alpine/k8s:1.22.6
18+
image: alpine/k8s:1.23.7
1919
script: |
20-
echo "Approving KCM requests"
21-
kubectl certificate approve $(kubectl get csr | grep "Pending" | awk '{print $1}') 2>/dev/null || true
2220
if [ -n "$(params.slack-hook)" ]; then
2321
curl -H "Content-type: application/json" --data '{"Message": "$(params.slack-message)"}' -X POST $(params.slack-hook)
2422
fi

tests/tasks/setup/eks/awscli-cp-with-vpc.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ spec:
2727
- name: aws-ebs-csi-driver-version
2828
default: release-1.13
2929
description: The release version for aws ebs csi driver.
30+
workspaces:
31+
- name: config
32+
mountPath: /config/
33+
stepTemplate:
34+
env:
35+
- name: KUBECONFIG
36+
value: /config/kubeconfig
3037
steps:
3138
- name: create-eks
32-
image: alpine/k8s:1.23.13
39+
image: alpine/k8s:1.23.7
3340
script: |
34-
echo "Approving KCM requests"
35-
kubectl certificate approve $(kubectl get csr | grep "Pending" | awk '{print $1}') 2>/dev/null || true
3641
ENDPOINT_FLAG=""
3742
if [ -n "$(params.endpoint)" ]; then
3843
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
@@ -53,7 +58,17 @@ spec:
5358
aws eks create-cluster --name $(params.cluster-name) --region $(params.region) --kubernetes-version $(params.kubernetes-version) --role-arn $SERVICE_ROLE_ARN --resources-vpc-config subnetIds=$subnets,securityGroupIds=$sg $ENDPOINT_FLAG
5459
fi
5560
aws eks $ENDPOINT_FLAG --region $(params.region) wait cluster-active --name $(params.cluster-name)
61+
- name: write-kubeconfig
62+
image: alpine/k8s:1.23.7
63+
script: |
64+
ENDPOINT_FLAG=""
65+
if [ -n "$(params.endpoint)" ]; then
66+
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
67+
fi
5668
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
69+
- name: install-addons-and-validate
70+
image: alpine/k8s:1.23.7
71+
script: |
5772
# enable PD on the cluster
5873
kubectl api-versions
5974
kubectl api-resources

tests/tasks/setup/eks/awscli-cp.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ spec:
2525
description: servicerole name to be used for eks cluster to perform operations in customer account to setup cluster
2626
workspaces:
2727
- name: config
28-
description: |
29-
A workspace into which a kubeconfig file called `kubeconfig` will be written that will contain the information required to access the cluster. The `kubeconfig` will expect to use [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator/) to authenticate, so in order for it to be used it must be run in a container which contains both `kubectl` and `aws-iam-authenticator`.
28+
mountPath: /config/
29+
stepTemplate:
30+
env:
31+
- name: KUBECONFIG
32+
value: /config/kubeconfig
3033
steps:
31-
- name: write-kubeconfig
32-
image: alpine/k8s:1.23.13
34+
- name: create-cluster
35+
image: alpine/k8s:1.23.7
3336
script: |
34-
echo "Approving KCM requests"
35-
kubectl certificate approve $(kubectl get csr | grep "Pending" | awk '{print $1}') 2>/dev/null || true
3637
ENDPOINT_FLAG=""
3738
if [ -n "$(params.endpoint)" ]; then
3839
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
@@ -51,8 +52,16 @@ spec:
5152
if [ "$CREATED_CLUSTER" == "" ]; then
5253
aws eks create-cluster --name $(params.cluster-name) --region $(params.region) --kubernetes-version $(params.kubernetes-version) --role-arn $SERVICE_ROLE_ARN --resources-vpc-config subnetIds=$subnets,securityGroupIds=$sg $ENDPOINT_FLAG
5354
fi
54-
aws eks $ENDPOINT_FLAG --region $(params.region) wait cluster-active --name $(params.cluster-name)
55-
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
56-
cp /root/.kube/config $(workspaces.config.path)/kubeconfig
55+
- name: write-kubeconfig
56+
image: alpine/k8s:1.23.7
57+
script: |
58+
ENDPOINT_FLAG=""
59+
if [ -n "$(params.endpoint)" ]; then
60+
ENDPOINT_FLAG="--endpoint $(params.endpoint)"
61+
fi
62+
aws eks $ENDPOINT_FLAG update-kubeconfig --name $(params.cluster-name) --region $(params.region)
63+
- name: update-cni-config
64+
image: alpine/k8s:1.23.7
65+
script: |
5766
# enable PD on the cluster
5867
kubectl set env daemonset/aws-node -n kube-system ENABLE_PREFIX_DELEGATION=true

0 commit comments

Comments
 (0)