Skip to content

Commit 8571e47

Browse files
committed
e2e: cluster object store
1 parent 8bfe6dc commit 8571e47

File tree

8 files changed

+296
-0
lines changed

8 files changed

+296
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: capi-controller-manager
5+
namespace: capi-system
6+
status:
7+
availableReplicas: 1
8+
---
9+
apiVersion: apps/v1
10+
kind: Deployment
11+
metadata:
12+
name: capl-controller-manager
13+
namespace: capl-system
14+
status:
15+
availableReplicas: 1
16+
---
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
metadata:
20+
name: capi-kubeadm-bootstrap-controller-manager
21+
namespace: kubeadm-bootstrap-system
22+
status:
23+
availableReplicas: 1
24+
---
25+
apiVersion: apps/v1
26+
kind: Deployment
27+
metadata:
28+
name: capi-kubeadm-control-plane-controller-manager
29+
namespace: kubeadm-control-plane-system
30+
status:
31+
availableReplicas: 1
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
3+
kind: LinodeObjectStorageKey
4+
metadata:
5+
name: ($key)
6+
spec:
7+
keyGeneration: 0
8+
status:
9+
ready: true
10+
lastKeyGeneration: 0
11+
---
12+
apiVersion: v1
13+
kind: Secret
14+
metadata:
15+
name: ($key_secret)
16+
data:
17+
(bucket_name != null): true
18+
(s3_endpoint != null): true
19+
(access_key != null): true
20+
(secret_key != null): true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
3+
kind: LinodeMachine
4+
metadata:
5+
labels:
6+
cluster.x-k8s.io/cluster-name: ($cluster)
7+
spec:
8+
region: us-sea
9+
type: g6-nanode-1
10+
status:
11+
ready: true
12+
instanceState: running
13+
---
14+
apiVersion: cluster.x-k8s.io/v1beta1
15+
kind: Machine
16+
metadata:
17+
labels:
18+
cluster.x-k8s.io/cluster-name: ($cluster)
19+
spec:
20+
clusterName: ($cluster)
21+
status:
22+
bootstrapReady: true
23+
infrastructureReady: true
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
name: cluster-object-store
6+
# Label to trigger the test on every PR
7+
labels:
8+
all:
9+
linodemachine:
10+
spec:
11+
bindings:
12+
# A short identifier for the E2E test run
13+
- name: run
14+
value: (join('-', ['e2e', 'cluster-obj-store', env('GIT_REF')]))
15+
- name: cluster
16+
# Format the cluster name
17+
value: (trim((truncate(($run), `29`)), '-'))
18+
- name: key
19+
# Format the key name into a valid Kubernetes object name
20+
# TODO: This is over-truncated to account for the Kubernetes access key Secret
21+
value: (trim((truncate((join('-', [($cluster), 'object-store'])), `52`)), '-'))
22+
- name: key_secret
23+
value: (join('-', [($key), 'obj-key']))
24+
template: true
25+
steps:
26+
- name: Check if CAPI provider resources exist
27+
try:
28+
- assert:
29+
file: assert-capi-resources.yaml
30+
- name: Create bucket
31+
try:
32+
- script:
33+
env:
34+
- name: URI
35+
value: object-storage/buckets
36+
- name: BUCKET_LABEL
37+
value: ($key)
38+
content: |
39+
set -e
40+
41+
curl -s \
42+
-X POST \
43+
-H "Authorization: Bearer $LINODE_TOKEN" \
44+
-H "Content-Type: application/json" \
45+
-d "{\"label\":\"$BUCKET_LABEL\",\"region\":\"us-sea\"}" \
46+
"https://api.linode.com/v4/$URI"
47+
check:
48+
($error): ~
49+
- name: Create LinodeObjectStorageKey
50+
try:
51+
- apply:
52+
file: create-linodeobjectstoragekey.yaml
53+
- assert:
54+
file: assert-key-and-secret.yaml
55+
catch:
56+
- describe:
57+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
58+
kind: LinodeObjectStorageKey
59+
- describe:
60+
apiVersion: v1
61+
kind: Secret
62+
- name: Create Cluster resource
63+
try:
64+
- apply:
65+
file: create-cluster.yaml
66+
catch:
67+
- describe:
68+
apiVersion: cluster.x-k8s.io/v1beta1
69+
kind: Cluster
70+
- name: Generate dummy thicc cloud-config data
71+
try:
72+
- script:
73+
env:
74+
- name: NAMESPACE
75+
value: ($namespace)
76+
content: |
77+
set -e
78+
79+
tr -dc A-Za-z0-9 < /dev/urandom | head -c 100kB > chonk.txt
80+
kubectl -n $NAMESPACE create secret generic chonk-secret --from-file=chonk.txt
81+
check:
82+
($error): ~
83+
- name: Create LinodeMachine resource
84+
try:
85+
- apply:
86+
file: create-linodemachine.yaml
87+
- assert:
88+
file: assert-linodemachine.yaml
89+
catch:
90+
- describe:
91+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
92+
kind: LinodeMachineTemplate
93+
- describe:
94+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
95+
kind: KubeadmControlPlane
96+
- name: Delete Cluster resource
97+
try:
98+
- delete:
99+
ref:
100+
apiVersion: cluster.x-k8s.io/v1beta1
101+
kind: Cluster
102+
name: ($cluster)
103+
- error:
104+
file: check-linodemachine-deletion.yaml
105+
- name: Delete LinodeObjectStorageKey
106+
try:
107+
- script:
108+
env:
109+
- name: URI
110+
value: object-storage/keys
111+
- name: OBJ_KEY
112+
value: ($key)
113+
content: |
114+
set -e
115+
116+
export KEY_ID=$(kubectl -n $NAMESPACE get lobjkey $OBJ_KEY -ojson | jq '.status.accessKeyRef')
117+
118+
curl -s \
119+
-X DELETE \
120+
-H "Authorization: Bearer $LINODE_TOKEN" \
121+
"https://api.linode.com/v4/$URI/$KEY_ID"
122+
check:
123+
($error): ~
124+
- name: Delete bucket
125+
try:
126+
- script:
127+
env:
128+
- name: URI
129+
value: object-storage/buckets/us-sea
130+
- name: BUCKET_LABEL
131+
value: ($key)
132+
content: |
133+
set -e
134+
135+
curl -s \
136+
-X DELETE \
137+
-H "Authorization: Bearer $LINODE_TOKEN" \
138+
"https://api.linode.com/v4/$URI/$BUCKET_LABEL"
139+
check:
140+
($error): ~
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
2+
kind: LinodeMachine
3+
metadata:
4+
labels:
5+
cluster.x-k8s.io/cluster-name: ($cluster)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: ($cluster)
6+
spec:
7+
controlPlaneRef:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
9+
kind: KubeadmControlPlane
10+
name: ($cluster)
11+
infrastructureRef:
12+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
13+
kind: LinodeCluster
14+
name: ($cluster)
15+
---
16+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
17+
kind: LinodeCluster
18+
metadata:
19+
name: ($cluster)
20+
spec:
21+
region: us-sea
22+
objectStore:
23+
credentialsRef:
24+
name: ($key_secret)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
3+
kind: KubeadmControlPlane
4+
metadata:
5+
name: ($cluster)
6+
spec:
7+
kubeadmConfigSpec:
8+
files:
9+
- path: /chonk.txt
10+
contentFrom:
11+
secret:
12+
key: chonk.txt
13+
name: chonk-secret
14+
clusterConfiguration:
15+
apiServer:
16+
extraArgs:
17+
cloud-provider: external
18+
controllerManager:
19+
extraArgs:
20+
cloud-provider: external
21+
machineTemplate:
22+
infrastructureRef:
23+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
24+
kind: LinodeMachineTemplate
25+
name: ($cluster)
26+
replicas: 1
27+
version: 1.29.1
28+
---
29+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
30+
kind: LinodeMachineTemplate
31+
metadata:
32+
name: ($cluster)
33+
spec:
34+
template:
35+
spec:
36+
region: us-sea
37+
type: g6-nanode-1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
2+
kind: LinodeObjectStorageKey
3+
metadata:
4+
name: ($key)
5+
spec:
6+
bucketAccess:
7+
- bucketName: ($key)
8+
permissions: read_write
9+
region: us-sea
10+
generatedSecret:
11+
name: ($key_secret)
12+
format:
13+
bucket_name: '{{ .BucketName }}'
14+
s3_endpoint: '{{ .S3Endpoint }}'
15+
access_key: '{{ .AccessKey }}'
16+
secret_key: '{{ .SecretKey }}'

0 commit comments

Comments
 (0)