Skip to content

Commit

Permalink
Merge pull request #65 from Huweicai/master
Browse files Browse the repository at this point in the history
Feat: support kuberntes higher versions
  • Loading branch information
heymingwei authored Sep 6, 2022
2 parents df3943c + 6256c78 commit 5a0394e
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 502 deletions.
15 changes: 12 additions & 3 deletions build/build_cfs_csi_driver.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/sh

RootPath=$(cd $(dirname $0) ; pwd)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${RootPath}/bin/cfs-csi-driver ../cmd && echo "build cfs-csi-driver success"

RootPath=$(
cd $(dirname $0)
pwd
)
echo ${RootPath}

CommitID=$(git rev-parse --short=8 HEAD)
Branch=$(git symbolic-ref --short -q HEAD)
BuildTime=$(date +%Y-%m-%dT%H:%M)

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-gcflags=-trimpath=$(pwd) -asmflags=-trimpath=$(pwd) \
-ldflags="-s -w -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime} -X main.Branch=${Branch} " \
-o ${RootPath}/bin/cfs-csi-driver ../cmd && echo "build cfs-csi-driver success"
11 changes: 10 additions & 1 deletion cmd/cubefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
Expand All @@ -34,12 +35,20 @@ var (
conf cubefs.Config
)

// injected while compile
var (
CommitID = ""
BuildTime = ""
Branch = ""
)

func init() {
_ = flag.Set("logtostderr", "true")
}

func main() {
_ = flag.CommandLine.Parse([]string{})
fmt.Printf("System build info: BuildTime: [%s], Branch [%s], CommitID [%s]\n", BuildTime, Branch, CommitID)

cmd := &cobra.Command{
Use: "cfs-csi-driver --endpoint=<endpoint> --nodeid=<nodeid> --drivername=<drivername> --version=<version>",
Short: "CSI based CFS driver",
Expand Down
8 changes: 4 additions & 4 deletions deploy/csi-controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ spec:
app: cfs-csi-controller
spec:
serviceAccount: cfs-csi-service-account
serviceAccountName: cfs-csi-service-account
nodeSelector:
cubefs-csi-controller: enabled
containers:
- name: csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v1.6.0
image: k8s.gcr.io/sig-storage/csi-provisioner:v2.2.2
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
args:
- --provisioner=csi.cubefs.com
- --csi-address=$(ADDRESS)
env:
- name: TZ
Expand All @@ -41,7 +41,7 @@ spec:
- mountPath: /csi
name: socket-dir
- name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v2.0.0
image: k8s.gcr.io/sig-storage/csi-attacher:v3.4.0
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
Expand All @@ -60,7 +60,7 @@ spec:
- mountPath: /csi
name: socket-dir
- name: csi-resizer
image: quay.io/k8scsi/csi-resizer:v0.5.0
image: k8s.gcr.io/sig-storage/csi-resizer:v1.3.0
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
Expand Down
3 changes: 2 additions & 1 deletion deploy/csi-node-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ spec:
app: cfs-csi-node
spec:
serviceAccount: cfs-csi-service-account
serviceAccountName: cfs-csi-service-account
nodeSelector:
cubefs-csi-node: enabled
containers:
- name: csi-node-driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.3.0
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
Expand Down
6 changes: 6 additions & 0 deletions deploy/csi-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ rules:
- apiGroups: [ "storage.k8s.io" ]
resources: [ "storageclasses" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "csinodes" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "volumeattachments" ]
verbs: [ "get", "list", "watch", "create", "update", "delete", "patch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "volumeattachments/status" ]
verbs: [ "patch" ]
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
1 change: 0 additions & 1 deletion deploy/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: cfs-sc
namespace: default
provisioner: csi.cubefs.com
allowVolumeExpansion: true
reclaimPolicy: Delete
Expand Down
58 changes: 44 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
module github.com/cubefs/cubefs-csi

go 1.13
go 1.18

require (
github.com/container-storage-interface/spec v1.1.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/container-storage-interface/spec v1.5.0
github.com/golang/glog v1.0.0
github.com/kubernetes-csi/csi-lib-utils v0.7.0
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20211209124913-491a49abca63
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
google.golang.org/grpc v1.29.1
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.1-beta.0
k8s.io/client-go v0.17.0
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
k8s.io/api v0.22.12
k8s.io/apimachinery v0.22.12
k8s.io/client-go v0.22.12
k8s.io/utils v0.0.0-20211116205334-6203023598ed
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.5 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.9.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace (
k8s.io/api => github.com/kubernetes/api v0.16.4
k8s.io/apimachinery => github.com/kubernetes/apimachinery v0.16.4 // indirect
k8s.io/client-go => github.com/kubernetes/client-go v0.16.4
k8s.io/api => k8s.io/api v0.22.12
k8s.io/apimachinery => k8s.io/apimachinery v0.22.12 // indirect
k8s.io/client-go => k8s.io/client-go v0.22.12
)
Loading

0 comments on commit 5a0394e

Please sign in to comment.