Skip to content

Commit

Permalink
Csi snapshotter provider changes (#182)
Browse files Browse the repository at this point in the history
Signed-off-by: sushanthakumar <[email protected]>
  • Loading branch information
sushanthakumar authored Jul 14, 2023
1 parent 3e776d0 commit 9a0df02
Show file tree
Hide file tree
Showing 12 changed files with 729 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ readonly KAHU_STATIC_BINARIES=(
meta-service
volume-service
openebs-zfs
csi-snapshotter
nfs-provider
)

Expand All @@ -41,6 +42,7 @@ golang::targets() {
cmd/volume-service
providers/nfs/nfs-provider
cmd/openebs-zfs
cmd/csi-snapshotter
)
echo "${targets[@]}"
}
Expand Down
1 change: 1 addition & 0 deletions build/lib/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ build::get_docker_wrapped_binaries() {
meta-service
volume-service
openebs-zfs
csi-snapshotter
nfs-provider
)

Expand Down
34 changes: 34 additions & 0 deletions cmd/csi-snapshotter/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright 2023 The SODA Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"math/rand"
"os"
"time"

"github.com/soda-cdm/kahu/providers/csi-snapshotter/server"
)

func main() {
rand.Seed(time.Now().UnixNano())

command := server.NewCSISnapshotterProviderCommand()
if err := command.Execute(); err != nil {
os.Exit(1)
}
}
3 changes: 3 additions & 0 deletions controllers/backup/resourcecollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ func (ctrl *controller) getEnvValueForContainers(containers []v1.Container, name
for _, container := range containers {
if container.Env != nil {
for _, envVar := range container.Env {
if envVar.ValueFrom == nil {
continue
}

if envVar.ValueFrom.ConfigMapKeyRef != nil {
configName := envVar.ValueFrom.ConfigMapKeyRef.Name
Expand Down
2 changes: 1 addition & 1 deletion controllers/snapshot/csi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (s *snapshoter) checkCSISnapshotStatus(csiSnapshot *kahuapi.ResourceReferen
return false, err
}

if snapshot.Status.ReadyToUse == nil {
if snapshot.Status == nil || snapshot.Status.ReadyToUse == nil {
return false, fmt.Errorf("CSI snapshot (%s) status not updated", snapshot.Name)
}

Expand Down
4 changes: 3 additions & 1 deletion controllers/volumebackup/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const (
)

var volBackupSupport = map[string]string{
"zfs.csi.openebs.io": "zfs.backup.openebs.io",
"zfs.csi.openebs.io": "zfs.backup.openebs.io",
"linstor.csi.linbit.com": "snapshotter.backup.csi.io",
"cephfs.csi.ceph.com": "snapshotter.backup.csi.io",
}

type controller struct {
Expand Down
100 changes: 100 additions & 0 deletions deploy/volumeprovider/csi-snapshot-provider-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright 2023 The SODA Authors.
# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This mounts the lvm volume claim into /mnt and continuously
# overwrites /mnt/index.html with the time and hostname of the pod.

apiVersion: apps/v1
kind: Deployment
metadata:
name: kahu-csi-snapshotter-provider
namespace: kahu
spec:
replicas: 1
selector:
matchLabels:
app: csi-snapshotter-provider
template:
metadata:
labels:
app: csi-snapshotter-provider
spec:
serviceAccountName: kahu-csi-snapshotter-provider
containers:
- image: sodacdm/kahu-csi-snapshotter-provider:v1.0.0
imagePullPolicy: IfNotPresent
name: csi-snapshotter-driver
command: ["/usr/local/bin/csi-snapshotter"]
volumeMounts:
- name: socket
mountPath: "/tmp"
- image: sodacdm/kahu-volume-service:v1.0.0
imagePullPolicy: IfNotPresent
name: volume-service
command: ["/usr/local/bin/volume-service"]
env:
- name: NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.labels['app']
- name: NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
volumeMounts:
# name must match the volume name below
- name: socket
mountPath: "/tmp"
volumes:
- name: socket
emptyDir: {}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kahu-csi-snapshotter-provider
namespace: kahu
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
provisioner: kahu
name: kahu-csi-snapshotter-provider-clusterrole-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kahu-csi-snapshotter-provider-clusterrole
subjects:
- kind: ServiceAccount
name: kahu-csi-snapshotter-provider
namespace: kahu
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
provisioner: kahu
name: kahu-csi-snapshotter-provider-clusterrole
rules:
- apiGroups: ["kahu.io"]
resources: ["providers", "providers/status"]
verbs: ["create", "delete", "watch", "update", "patch", "get", "watch", "list"]
- apiGroups: [ "*" ]
resources: ["*"]
verbs: ["create", "delete", "watch", "update", "patch", "get", "watch", "list"]
---
Loading

0 comments on commit 9a0df02

Please sign in to comment.