Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 46dfc80

Browse files
authored
Merge pull request #10 from scality/feature/COSI-11-deploy-cosi-resources-in-CI
COSI-11 deploy cosi resources in ci
2 parents 792beac + 737a340 commit 46dfc80

17 files changed

+199
-185
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Define log file for debugging
5+
LOG_FILE=".github/e2e_tests/artifacts/logs/kind_cluster_logs/cosi_deployment/setup_debug.log"
6+
mkdir -p "$(dirname "$LOG_FILE")" # Ensure the log directory exists
7+
8+
# Error handling function
9+
error_handler() {
10+
echo "An error occurred during the COSI setup. Check the log file for details." | tee -a "$LOG_FILE"
11+
echo "Failed command: $BASH_COMMAND" | tee -a "$LOG_FILE"
12+
exit 1
13+
}
14+
15+
# Trap errors and call the error handler
16+
trap 'error_handler' ERR
17+
18+
# Log command execution to the log file for debugging
19+
log_and_run() {
20+
echo "Running: $*" | tee -a "$LOG_FILE"
21+
"$@" | tee -a "$LOG_FILE"
22+
}
23+
24+
# Step 1: Install COSI CRDs
25+
log_and_run echo "Installing COSI CRDs..."
26+
log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-api
27+
log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-controller
28+
29+
# Step 2: Verify COSI Controller Pod Status
30+
log_and_run echo "Verifying COSI Controller Pod status..."
31+
log_and_run kubectl wait --namespace default --for=condition=ready pod -l app.kubernetes.io/name=container-object-storage-interface-controller --timeout=10s
32+
log_and_run kubectl get pods --namespace default
33+
34+
# Step 3: Build COSI driver Docker image
35+
log_and_run echo "Building COSI driver image..."
36+
log_and_run docker build -t ghcr.io/scality/cosi:latest .
37+
38+
# Step 4: Load COSI driver image into KIND cluster
39+
log_and_run echo "Loading COSI driver image into KIND cluster..."
40+
log_and_run kind load docker-image ghcr.io/scality/cosi:latest --name object-storage-cluster
41+
42+
# Step 5: Run COSI driver
43+
log_and_run echo "Applying COSI driver manifests..."
44+
log_and_run kubectl apply -k .
45+
46+
# Step 6: Verify COSI driver Pod Status
47+
log_and_run echo "Verifying COSI driver Pod status..."
48+
log_and_run kubectl wait --namespace scality-object-storage --for=condition=ready pod --selector=app.kubernetes.io/name=scality-cosi-driver --timeout=20s
49+
log_and_run kubectl get pods -n scality-object-storage
50+
51+
log_and_run echo "COSI setup completed successfully."

.github/workflows/ci-e2e-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ jobs:
3737
with:
3838
detached: true
3939

40+
41+
- name: Setup COSI Controller, CRDs and Driver
42+
run: |
43+
pwd
44+
chmod +x .github/scripts/setup_cosi_resources.sh
45+
.github/scripts/setup_cosi_resources.sh
46+
4047
- name: Capture Kubernetes Logs in artifacts directory
4148
run: |
4249
chmod +x .github/scripts/capture_k8s_logs.sh

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
APP_NAME = scality-cosi-driver
22
BIN_DIR = ./bin
33

4+
# 'go env' vars aren't always available in make environments, so get defaults for needed ones
5+
GOARCH ?= $(shell go env GOARCH)
6+
IMAGE_NAME ?= ghcr.io/scality/cosi:latest
7+
48
.PHONY: all build test clean
59

610
all: test build
711

812
build:
913
@echo "Building $(APP_NAME)..."
10-
go build -o $(BIN_DIR)/$(APP_NAME) ./cmd/$(APP_NAME)
14+
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o $(BIN_DIR)/$(APP_NAME) ./cmd/$(APP_NAME)
1115

1216
test:
1317
@echo "Running Ginkgo tests..."
@@ -17,3 +21,7 @@ test:
1721
clean:
1822
@echo "Cleaning up..."
1923
rm -rf $(BIN_DIR)
24+
25+
container:
26+
@echo "Building container image..."
27+
docker build -t $(IMAGE_NAME) .

kustomization.yaml

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,5 @@
1-
---
21
apiVersion: kustomize.config.k8s.io/v1beta1
32
kind: Kustomization
4-
namespace: scality-cosi-driver
5-
6-
commonAnnotations:
7-
cosi.storage.k8s.io/authors: "Kubernetes Authors"
8-
cosi.storage.k8s.io/license: "Apache V2"
9-
cosi.storage.k8s.io/support: "https://github.com/kubernetes-sigs/container-object-storage-api"
10-
11-
commonLabels:
12-
app.kubernetes.io/part-of: container-object-storage-interface
13-
app.kubernetes.io/component: driver-scality
14-
app.kubernetes.io/version: main
15-
app.kubernetes.io/name: cosi-driver-scality
16-
17-
configMapGenerator:
18-
- name: cosi-driver-scality-config
19-
env: resources/cosi-driver-scality.properties
20-
generatorOptions:
21-
disableNameSuffixHash: true
22-
labels:
23-
generated-by: "kustomize"
243

254
resources:
26-
- resources/ns.yaml
27-
- resources/sa.yaml
28-
- resources/rbac.yaml
29-
- resources/deployment.yaml
30-
31-
configurations:
32-
- resources/kustomizeconfig.yaml
33-
34-
vars:
35-
- name: IMAGE_ORG
36-
objref:
37-
name: cosi-driver-scality-config
38-
kind: ConfigMap
39-
apiVersion: v1
40-
fieldref:
41-
fieldpath: data.OBJECTSTORAGE_PROVISIONER_IMAGE_ORG
42-
- name: IMAGE_VERSION
43-
objref:
44-
name: cosi-driver-scality-config
45-
kind: ConfigMap
46-
apiVersion: v1
47-
fieldref:
48-
fieldpath: data.OBJECTSTORAGE_PROVISIONER_IMAGE_VERSION
49-
- name: SCALITY_IMAGE_ORG
50-
objref:
51-
name: cosi-driver-scality-config
52-
kind: ConfigMap
53-
apiVersion: v1
54-
fieldref:
55-
fieldpath: data.SCALITY_DRIVER_IMAGE_ORG
56-
- name: SCALITY_IMAGE_VERSION
57-
objref:
58-
name: cosi-driver-scality-config
59-
kind: ConfigMap
60-
apiVersion: v1
61-
fieldref:
62-
fieldpath: data.SCALITY_DRIVER_IMAGE_VERSION
5+
- kustomize/overlays

kustomize/base/deployment.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: scality-cosi-driver
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app.kubernetes.io/name: scality-cosi-driver
10+
template:
11+
metadata:
12+
labels:
13+
app.kubernetes.io/name: scality-cosi-driver
14+
app.kubernetes.io/part-of: container-object-storage-interface
15+
app.kubernetes.io/component: driver
16+
app.kubernetes.io/version: main
17+
app.kubernetes.io/managed-by: kustomize
18+
spec:
19+
serviceAccountName: scality-object-storage-provisioner
20+
containers:
21+
- name: scality-cosi-driver
22+
image: ghcr.io/scality/cosi:latest
23+
imagePullPolicy: IfNotPresent
24+
args:
25+
- "--driver-prefix=cosi"
26+
- "--v=$(COSI_DRIVER_LOG_LEVEL)"
27+
volumeMounts:
28+
- mountPath: /var/lib/cosi
29+
name: socket
30+
env:
31+
- name: POD_NAMESPACE
32+
valueFrom:
33+
fieldRef:
34+
fieldPath: metadata.namespace
35+
- name: objectstorage-provisioner-sidecar
36+
image: gcr.io/k8s-staging-sig-storage/objectstorage-sidecar:latest
37+
imagePullPolicy: IfNotPresent
38+
args:
39+
- "--v=$(OBJECTSTORAGE_PROVISIONER_SIDECAR_LOG_LEVEL)"
40+
volumeMounts:
41+
- mountPath: /var/lib/cosi
42+
name: socket
43+
volumes:
44+
- name: socket
45+
emptyDir: {}

kustomize/base/kustomization.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
namespace: scality-object-storage
5+
6+
resources:
7+
- namespace.yaml
8+
- serviceaccount.yaml
9+
- rbac.yaml
10+
- deployment.yaml

kustomize/base/namespace.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: scality-object-storage

kustomize/base/rbac.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: scality-object-storage-provisioner-role
5+
rules:
6+
- apiGroups: ["objectstorage.k8s.io"]
7+
resources: ["buckets", "bucketaccesses", "bucketclaims", "bucketaccessclasses", "buckets/status", "bucketaccesses/status", "bucketclaims/status", "bucketaccessclasses/status"]
8+
verbs: ["get", "list", "watch", "update", "create", "delete"]
9+
- apiGroups: ["coordination.k8s.io"]
10+
resources: ["leases"]
11+
verbs: ["get", "watch", "list", "delete", "update", "create"]
12+
- apiGroups: [""]
13+
resources: ["secrets", "events"]
14+
verbs: ["get", "delete", "update", "create"]
15+
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: scality-object-storage-provisioner-role-binding
21+
subjects:
22+
- kind: ServiceAccount
23+
name: scality-object-storage-provisioner
24+
namespace: default
25+
roleRef:
26+
kind: ClusterRole
27+
name: scality-object-storage-provisioner-role
28+
apiGroup: rbac.authorization.k8s.io

kustomize/base/serviceaccount.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: scality-object-storage-provisioner
5+
namespace: default
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
configMapGenerator:
5+
- name: scality-cosi-driver-properties
6+
env: scality-cosi-driver.properties
7+
generatorOptions:
8+
disableNameSuffixHash: true
9+
labels:
10+
generated-by: "kustomize"
11+
12+
resources:
13+
- ../base
14+
15+
commonLabels:
16+
app.kubernetes.io/version: main
17+
app.kubernetes.io/component: driver
18+
app.kubernetes.io/name: scality-cosi-driver
19+
app.kubernetes.io/part-of: container-object-storage-interface
20+
app.kubernetes.io/managed-by: kustomize
21+
22+
vars:
23+
- name: COSI_DRIVER_LOG_LEVEL
24+
objref:
25+
name: scality-cosi-driver-properties
26+
kind: ConfigMap
27+
apiVersion: v1
28+
fieldref:
29+
fieldpath: data.COSI_DRIVER_LOG_LEVEL
30+
31+
- name: OBJECTSTORAGE_PROVISIONER_SIDECAR_LOG_LEVEL
32+
objref:
33+
name: scality-cosi-driver-properties
34+
kind: ConfigMap
35+
apiVersion: v1
36+
fieldref:
37+
fieldpath: data.OBJECTSTORAGE_PROVISIONER_SIDECAR_LOG_LEVEL

0 commit comments

Comments
 (0)