Skip to content

Commit e48c3a2

Browse files
authored
Merge pull request #4 from shafinhasnat/main
Driver version v0.0.4
2 parents 193b080 + eb1c013 commit e48c3a2

511 files changed

Lines changed: 133115 additions & 465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,26 @@
1-
# syntax=docker/dockerfile:1.4
2-
31
FROM golang:1.24 as build
4-
5-
ENV TZ=UTC
6-
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
7-
82
WORKDIR /build
9-
10-
RUN go install github.com/go-task/task/v3/cmd/task@latest
11-
RUN go install github.com/goreleaser/goreleaser@latest
12-
13-
# Install dependencies
14-
COPY --link go.mod go.sum ./
15-
3+
COPY go.mod go.sum ./
164
RUN go mod tidy
17-
18-
# Build binary
19-
COPY --link Taskfile.yaml .goreleaser.yaml ./
20-
COPY --link main.go ./
21-
COPY --link pkg ./pkg
22-
# For goreleaser, TODO: remove
23-
COPY --link .git ./.git
24-
25-
RUN task build
26-
5+
COPY . .
6+
RUN go mod tidy && go mod download
7+
ARG VERSION
8+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
9+
go build \
10+
-ldflags "-s -w \
11+
-X main.name=csi-hyperstack \
12+
-X main.version=${VERSION} \
13+
-X k8s.io/csi-hyperstack/pkg/driver.DriverName=hyperstack.csi.nexgencloud.com \
14+
-X k8s.io/csi-hyperstack/pkg/driver.DriverVersion=${VERSION}" \
15+
-o /csi-hyperstack
2716

2817
FROM alpine:3.20 as runtime
29-
30-
RUN apk add --no-cache --update \
31-
ca-certificates \
32-
bash \
33-
vim \
34-
curl
35-
36-
RUN curl -o /usr/local/bin/gosu \
37-
-fsSL "https://github.com/tianon/gosu/releases/download/1.12/gosu-amd64" \
38-
&& chmod +x /usr/local/bin/gosu
39-
40-
RUN curl -fsSL "https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz" -o grpcurl_1.7.0_linux_x86_64.tar.gz \
41-
&& tar -xvf grpcurl_1.7.0_linux_x86_64.tar.gz \
42-
&& chmod +x grpcurl
43-
RUN apk add e2fsprogs
44-
ENV HOME="/app"
45-
ENV PATH="/app:$PATH"
46-
WORKDIR "${HOME}"
47-
48-
ENV ELEVATED_USER "false"
49-
ENV GROUP_ID 1000
50-
ENV GROUP_NAME app
51-
ENV USER_ID 1000
52-
ENV USER_NAME app
53-
RUN addgroup -g "${GROUP_ID}" "${GROUP_NAME}" \
54-
&& adduser -u "${USER_ID}" -G "${GROUP_NAME}" -h "${HOME}" -D "${USER_NAME}"
55-
56-
COPY --link build/entrypoint.sh entrypoint.sh
57-
RUN chmod +x entrypoint.sh
58-
59-
COPY --link --from=build /build/dist/csi-hyperstack .
18+
RUN apk add --no-cache --update e2fsprogs
19+
RUN wget "https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz" \
20+
&& tar -xvf grpcurl_1.7.0_linux_x86_64.tar.gz -C /usr/local/bin grpcurl \
21+
&& chmod +x /usr/local/bin/grpcurl \
22+
&& rm -rf grpcurl_1.7.0_linux_x86_64.tar.gz
23+
COPY --from=build /csi-hyperstack .
6024
RUN chmod +x csi-hyperstack
61-
62-
ENV LOCAL_HEALTH_PORT "8080"
63-
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 \
64-
CMD curl -f "http://localhost:${LOCAL_HEALTH_PORT}/health" || exit 1
6525
RUN mkdir -p /csi
66-
# ENTRYPOINT ["entrypoint.sh"]
67-
# CMD ["csi-hyperstack", "start", "--endpoint", "unix:///csi/csi.sock", "--hyperstack-cluster-id", "''", "--hyperstack-node-id", "''", "--service-controller-enabled", "--service-node-enabled"]
26+
ENTRYPOINT ["/csi-hyperstack"]

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
IMAGE ?= ghcr.io/nexgencloud/csi-hyperstack/csi
2+
VERSION :=
3+
TAG ?= $(VERSION)
4+
5+
ifeq ($(VERSION),)
6+
$(error VERSION is not set. Usage: make <target> VERSION=<version> [TAG=<tag>])
7+
endif
8+
9+
.PHONY: docker-build
10+
docker-build:
11+
docker build -t $(IMAGE):$(TAG) --build-arg VERSION=$(VERSION) .
12+
13+
.PHONY: docker-push
14+
docker-push: docker-build
15+
docker push $(IMAGE):$(TAG)
16+
17+
.PHONY: docker-build-push
18+
docker-build-push:
19+
docker build -t $(IMAGE):$(TAG) --build-arg VERSION=$(VERSION) . --push

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ Before you begin, ensure you have the following tools installed:
1010
* A Hyperstack Kubernetes cluster
1111

1212
### CLI Dependencies (installed via Go)
13-
14-
* [GoReleaser](https://goreleaser.com/) – Manages Go builds.
15-
16-
```bash
17-
go install github.com/goreleaser/goreleaser@latest
18-
```
19-
2013
* (Optional) [gRPCurl](https://github.com/fullstorydev/grpcurl) – Useful for debugging gRPC calls.
2114

2215
```bash
@@ -47,7 +40,7 @@ You can invoke a specific RPC method for a given operation using `grpcurl`.
4740
To build the project:
4841

4942
```bash
50-
task build
43+
make build VERSION=<VERSION>
5144
```
5245

5346
## Usage
@@ -60,16 +53,6 @@ For more information about the features of the Hyperstack API, visit
6053
the [Hyperstack Documentation](https://infrahub-doc.nexgencloud.com/docs/features/).
6154

6255
Relevant docs:
63-
64-
- [Simple guide](https://arslan.io/2018/06/21/how-to-write-a-container-storage-interface-csi-plugin/)
6556
- [Kubernetes CSI Developer Documentation](https://kubernetes-csi.github.io/docs/introduction.html):
66-
official documentation on CSI plugin development
67-
- [CSI Volume Plugins in Kubernetes Design Doc](https://github.com/kubernetes/design-proposals-archive/blob/main/storage/container-storage-interface.md):
68-
initial CSI proposal
69-
70-
Examples (reference for development):
71-
72-
- [Openstack cinder driver](https://github.com/kubernetes/cloud-provider-openstack/blob/master/pkg/csi/cinder/driver.go)
73-
- [Azure file](https://github.com/kubernetes-sigs/azurefile-csi-driver/blob/master/pkg/azurefile/azurefile.go)
74-
- [Synology](https://github.com/SynologyOpenSource/synology-csi/blob/main/main.go)
75-
- [Deployment example](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/deploy/kubernetes-1.27/hostpath/csi-hostpath-plugin.yaml)
57+
- [CSI Specification](https://github.com/container-storage-interface/spec/blob/master/spec.md)
58+
- [Openstack cinder driver](https://github.com/kubernetes/cloud-provider-openstack/blob/master/pkg/csi/cinder/driver.go)

Taskfile.yaml

Lines changed: 0 additions & 109 deletions
This file was deleted.

charts/csi-hyperstack/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name: csi-hyperstack
33
description: |
44
HELM chart for Hyperstack CSI drvier deployment
55
type: application
6-
version: 0.0.2
7-
appVersion: 0.0.1
6+
version: 0.0.6
7+
appVersion: v0.0.4

charts/csi-hyperstack/templates/daemonset-node.yaml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,47 @@ spec:
2222
hostNetwork: true
2323
containers:
2424
- name: csi-hyperstack-node
25-
image: {{ .Values.components.csiHyperstack.image }}:{{ .Values.components.csiHyperstack.tag }}
25+
image: {{ .Values.components.csiHyperstack.image }}:{{ .Values.components.csiHyperstack.tag | default .Chart.AppVersion }}
2626
imagePullPolicy: {{ .Values.components.csiHyperstack.imagePullPolicy}}
2727
securityContext:
2828
privileged: true
2929
runAsUser: 0
3030
runAsGroup: 0
31-
command: ["csi-hyperstack"]
31+
# command: ["csi-hyperstack"]
3232
args:
3333
- "start"
3434
- "--endpoint=unix:///csi/csi.sock"
35-
- "--hyperstack-api-address={{ .Values.hyperstack.apiKey }}"
36-
- "--hyperstack-api-key={{ .Values.hyperstack.apiAddress }}"
37-
- "--service-node-enabled"
35+
- "--hyperstack-api-address={{ .Values.hyperstack.apiAddress }}"
36+
- "--hyperstack-api-key={{ .Values.hyperstack.apiKey }}"
37+
- "--service-node-enabled=true"
38+
livenessProbe:
39+
exec:
40+
command:
41+
- /bin/sh
42+
- -c
43+
- |
44+
grpcurl -plaintext -unix /csi/csi.sock csi.v1.Identity.GetPluginInfo >/dev/null 2>&1 \
45+
&& grpcurl -plaintext -unix /csi/csi.sock csi.v1.Node.NodeGetInfo >/dev/null 2>&1
46+
# initialDelaySeconds: 20
47+
# periodSeconds: 10
48+
readinessProbe:
49+
exec:
50+
command:
51+
- /bin/sh
52+
- -c
53+
- |
54+
grpcurl -plaintext -unix /csi/csi.sock csi.v1.Identity.GetPluginInfo >/dev/null 2>&1 \
55+
&& grpcurl -plaintext -unix /csi/csi.sock csi.v1.Node.NodeGetInfo >/dev/null 2>&1
56+
# initialDelaySeconds: 20
57+
# periodSeconds: 10
58+
# timeoutSeconds: 5
59+
# failureThreshold: 3
60+
# successThreshold: 1
3861
env:
62+
- name: DRIVER_NAME
63+
value: "hyperstack.csi.nexgencloud.com"
64+
- name: DRIVER_VERSION
65+
value: "v1.0.0"
3966
- name: KUBE_NODE_NAME
4067
valueFrom:
4168
fieldRef:
@@ -57,6 +84,12 @@ spec:
5784
- --v=5
5885
- --csi-address=/csi/csi.sock
5986
- --kubelet-registration-path=/var/lib/kubelet/plugins/hyperstack.csi.nexgencloud.com/csi.sock
87+
livenessProbe:
88+
exec:
89+
command:
90+
- /csi-node-driver-registrar
91+
- --kubelet-registration-path=/var/lib/kubelet/plugins/hyperstack.csi.nexgencloud.com/csi.sock
92+
- --mode=kubelet-registration-probe
6093
securityContext:
6194
privileged: true
6295
env:
@@ -70,6 +103,13 @@ spec:
70103
name: socket-dir
71104
- mountPath: /registration
72105
name: registration-dir
106+
- name: liveness-probe
107+
image: {{ .Values.components.livenessProbe.image }}
108+
args:
109+
- --csi-address=/csi/csi.sock
110+
volumeMounts:
111+
- mountPath: /csi
112+
name: socket-dir
73113
volumes:
74114
- name: socket-dir
75115
hostPath:

0 commit comments

Comments
 (0)