zfssa-5-canary: replace the dependabot branch with one that compiles and works

This commit is contained in:
Paul Monday 2021-09-10 10:33:04 -06:00
parent 8cf929d6b6
commit f865daa43f
13 changed files with 1494 additions and 63 deletions

View File

@ -5,18 +5,18 @@ as a backend for block storage (iSCSI volumes) and file storage (NFS).
| CSI Plugin Version | Supported CSI Versions | Supported Kubernetes Versions | Persistence | Supported Access Modes | Dynamic Provisioning | Raw Block Support |
| --- | --- | --- | --- | --- | --- | --- |
| v1.0.0 | v1.0+ | v1.17.X+ | Persistent | Read/Write Once (for Block), ReadWriteMany (for File) | Yes | Yes |
| v1.1.0 | v1.0+ | v1.20.X+ | Persistent | Read/Write Once (for Block), ReadWriteMany (for File) | Yes | Yes |
## Requirements
* Kubernetes v1.17 or above.
* A Container runtime implementing the Kubernetes Container Runtime Interface. This plugin was tested with CRI-O v1.17.
* Kubernetes v1.20 or above (Oracle Linux Cloud Native Environment 1.3)
* A Container runtime implementing the Kubernetes Container Runtime Interface (ex. CRI-O)
* An Oracle ZFS Storage Appliance running Appliance Kit Version 8.8 or above. This plugin may work with previous
versions but it is not tested with them. It is possible to use this
driver with the [Oracle ZFS Storage Simulator](https://www.oracle.com/downloads/server-storage/sun-unified-storage-sun-simulator-downloads.html)
* Access to both a management path and a data path for the target Oracle
ZFS Storage Appiance (or simulator). The management and data path
can be the same address.
ZFS Storage Appiance (or simulator). The management and data path
can be the same address.
* A suitable container image build environment (podman or docker are accounted
for in the makefile)

View File

@ -1 +1 @@
1.0.0
1.1.0

View File

@ -0,0 +1,4 @@
apiVersion: v1
name: zfssa-csi
version: 1.1.0
description: Deploys Oracle ZFS Storage Appliance CSI Plugin.

View File

@ -0,0 +1,9 @@
apiVersion: v1
stringData:
zfssa.yaml: |
username: {{ .Values.zfssaInformation.username }}
password: {{ .Values.zfssaInformation.password }}
kind: Secret
metadata:
name: oracle.zfssa.csi.node
namespace: {{ .Values.deployment.namespace }}

View File

@ -0,0 +1,8 @@
apiVersion: v1
data:
zfssa.crt: {{ .Values.zfssaInformation.cert }}
kind: Secret
metadata:
name: oracle.zfssa.csi.node.certs
type: Opaque

View File

@ -0,0 +1,84 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: zfssa-csi
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: zfssa-csi-role
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments/status"]
verbs: ["patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["patch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch", "delete", "get"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csinodeinfos"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch", "create", "update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [ "snapshot.storage.k8s.io" ]
resources: [ "volumesnapshotcontents/status" ]
verbs: [ "update" ]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csidrivers"]
verbs: ["create", "delete"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "create", "update"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: zfssa-csi-role-binding
subjects:
- kind: ServiceAccount
name: zfssa-csi
namespace: {{ .Values.deployment.namespace }}
roleRef:
kind: ClusterRole
name: zfssa-csi-role
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,139 @@
# Service defined here, plus serviceName below in StatefulSet,
# are needed only because of condition explained in
# https://github.com/kubernetes/kubernetes/issues/69608
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: zfssa-csi-driver
namespace: {{ .Values.deployment.namespace }}
spec:
attachRequired: true
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: zfssa-csi-nodeplugin
namespace: {{ .Values.deployment.namespace }}
spec:
selector:
matchLabels:
app: zfssa-csi-nodeplugin
template:
metadata:
labels:
app: zfssa-csi-nodeplugin
spec:
serviceAccount: zfssa-csi
hostNetwork: true
containers:
- name: node-driver-registrar
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiNodeDriverRegistrar.name }}:{{ .Values.images.csiNodeDriverRegistrar.tag }}
args:
- --v=5
- --csi-address=/plugin/csi.sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/com.oracle.zfssabs/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
privileged: true
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
- name: registration-dir
mountPath: /registration
- name: zfssabs
image: {{ .Values.image.zfssaBase }}{{ .Values.images.zfssaCsiDriver.name }}:{{ .Values.images.zfssaCsiDriver.tag }}
args:
- "--drivername=zfssa-csi-driver.oracle.com"
- "--v=5"
- "--endpoint=$(CSI_ENDPOINT)"
- "--nodeid=$(NODE_NAME)"
env:
- name: CSI_ENDPOINT
value: unix://plugin/csi.sock
- name: LOG_LEVEL
value: "5"
- name: ZFSSA_TARGET
value: {{ .Values.zfssaInformation.target }}
- name: ZFSSA_INSECURE
value: "False"
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
privileged: true
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
- name: mountpoint-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
- name: plugins-dir
mountPath: /var/lib/kubelet/plugins
mountPropagation: Bidirectional
- name: dev-dir
mountPath: /dev
- name: zfssa-credentials
mountPath: "/mnt/zfssa"
readOnly: true
- name: certs
mountPath: "/mnt/certs"
readOnly: true
volumes:
- name: socket-dir
hostPath:
path: {{ .Values.paths.pluginDir.hostPath }}
type: DirectoryOrCreate
- name: mountpoint-dir
hostPath:
path: /var/lib/kubelet/pods
type: DirectoryOrCreate
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
type: Directory
- name: plugins-dir
hostPath:
path: /var/lib/kubelet/plugins
type: Directory
- name: dev-dir
hostPath:
path: /dev
type: Directory
- name: zfssa-credentials
secret:
secretName: oracle.zfssa.csi.node
items:
- key: zfssa.yaml
path: zfssa.yaml
- name: certs
secret:
secretName: oracle.zfssa.csi.node.certs
items:
- key: zfssa.crt
path: zfssa.crt

View File

@ -0,0 +1,90 @@
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: zfssa-csi-provisioner
namespace: {{ .Values.deployment.namespace }}
spec:
serviceName: "zfssa-csi-provisioner"
replicas: 1
selector:
matchLabels:
app: zfssa-csi-provisioner
template:
metadata:
labels:
app: zfssa-csi-provisioner
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- zfssa-csi-nodeplugin
topologyKey: kubernetes.io/hostname
serviceAccountName: zfssa-csi
containers:
- name: zfssa-csi-snapshotter
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiSnapshotter.name }}:{{ .Values.images.csiSnapshotter.tag }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election=false"
env:
- name: ADDRESS
value: /plugin/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-resizer
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiResizer.name }}:{{ .Values.images.csiResizer.tag }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election"
env:
- name: ADDRESS
value: /plugin/csi.sock
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-provisioner
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiProvisioner.name }}:{{ .Values.images.csiProvisioner.tag }}
args:
- -v=5
- --csi-address=/plugin/csi.sock
- --timeout=30s
- --feature-gates=Topology=true
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
privileged: true
volumeMounts:
- name: socket-dir
mountPath: /plugin
- name: zfssa-csi-attacher
image: {{ .Values.image.sidecarBase }}{{ .Values.images.csiAttacher.name }}:{{ .Values.images.csiAttacher.tag }}
args:
- --v=5
- --csi-address=/plugin/csi.sock
# securityContext:
# This is necessary only for systems with SELinux, where
# non-privileged sidecar containers cannot access unix domain socket
# created by privileged CSI driver container.
# privileged: true
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: {{ .Values.paths.pluginDir.mountPath }}
volumes:
- name: socket-dir
hostPath:
path: {{ .Values.paths.pluginDir.hostPath }}
type: DirectoryOrCreate

View File

@ -0,0 +1,42 @@
# Global docker image setting
image:
sidecarBase: k8s.gcr.io/sig-storage/
zfssaBase: iad.ocir.io/zs/store/csi/
pullPolicy: Always
# Define all the images that will be used during helm chart deployment
images:
csiNodeDriverRegistrar:
name: csi-node-driver-registrar
tag: "v2.0.0"
zfssaCsiDriver:
name: zfssa-csi-driver
tag: "v1.1.0"
csiProvisioner:
name: csi-provisioner
tag: "v2.0.5"
csiAttacher:
name: csi-attacher
tag: "v3.0.2"
csiResizer:
name: csi-resizer
tag: "v1.1.0"
csiSnapshotter:
name: csi-snapshotter
tag: "v3.0.3"
paths:
pluginDir:
hostPath: "/var/lib/kubelet/plugins/com.oracle.zfssabs"
mountPath: "/plugin"
deployment:
namespace: default
# ZFSSA-specific information
# It is desirable to provision a normal login user with required authorizations.
zfssaInformation:
username: text-string
password: text-string
target: text-string
cert: cert-base64-encoded

103
go.mod
View File

@ -2,52 +2,71 @@ module github.com/oracle/zfssa-csi-driver
go 1.13
require (
github.com/container-storage-interface/spec v1.2.0
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.4.0
github.com/kubernetes-csi/csi-lib-iscsi v0.0.0-20190415173011-c545557492f4
github.com/kubernetes-csi/csi-lib-utils v0.6.1
github.com/onsi/gomega v1.9.0 // indirect
github.com/prometheus/client_golang v1.2.1 // indirect
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
google.golang.org/grpc v1.23.1
gopkg.in/yaml.v2 v2.2.8
k8s.io/apimachinery v0.17.11
k8s.io/client-go v0.18.2
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.17.5
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
)
replace (
k8s.io/api => k8s.io/api v0.17.5
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.17.5
k8s.io/apimachinery => k8s.io/apimachinery v0.17.6-beta.0
k8s.io/apiserver => k8s.io/apiserver v0.17.5
k8s.io/cli-runtime => k8s.io/cli-runtime v0.17.5
k8s.io/client-go => k8s.io/client-go v0.17.5
k8s.io/cloud-provider => k8s.io/cloud-provider v0.17.5
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.17.5
k8s.io/code-generator => k8s.io/code-generator v0.17.6-beta.0
k8s.io/component-base => k8s.io/component-base v0.17.5
k8s.io/cri-api => k8s.io/cri-api v0.17.13-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.17.5
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.17.5
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.17.5
k8s.io/kube-proxy => k8s.io/kube-proxy v0.17.5
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.17.5
k8s.io/kubelet => k8s.io/kubelet v0.17.5
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.17.5
k8s.io/metrics => k8s.io/metrics v0.17.5
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.17.5
k8s.io/api => k8s.io/api v0.20.10
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.20.10
k8s.io/apimachinery => k8s.io/apimachinery v0.20.11-rc.0
k8s.io/apiserver => k8s.io/apiserver v0.20.10
k8s.io/cli-runtime => k8s.io/cli-runtime v0.20.10
k8s.io/client-go => k8s.io/client-go v0.20.10
k8s.io/cloud-provider => k8s.io/cloud-provider v0.20.10
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.20.10
k8s.io/code-generator => k8s.io/code-generator v0.20.11-rc.0
k8s.io/component-base => k8s.io/component-base v0.20.10
k8s.io/cri-api => k8s.io/cri-api v0.20.11-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.20.10
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.20.10
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.20.10
k8s.io/kube-proxy => k8s.io/kube-proxy v0.20.10
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.20.10
k8s.io/kubelet => k8s.io/kubelet v0.20.10
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.20.10
k8s.io/metrics => k8s.io/metrics v0.20.10
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.20.10
)
replace k8s.io/kubectl => k8s.io/kubectl v0.17.5
replace k8s.io/kubectl => k8s.io/kubectl v0.20.10
replace k8s.io/node-api => k8s.io/node-api v0.17.5
replace k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.17.5
replace k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.20.10
replace k8s.io/sample-controller => k8s.io/sample-controller v0.17.5
replace k8s.io/sample-controller => k8s.io/sample-controller v0.20.10
require (
github.com/container-storage-interface/spec v1.5.0
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kubernetes-csi/csi-lib-iscsi v0.0.0-20210519140452-fd47a25d3e16
github.com/kubernetes-csi/csi-lib-utils v0.10.0
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/net v0.0.0-20210908191846-a5e095526f91
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.40.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.22.1 // indirect
k8s.io/apimachinery v0.22.1
k8s.io/apiserver v0.22.1 // indirect
k8s.io/client-go v0.22.1
k8s.io/component-base v0.22.1 // indirect
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
k8s.io/kubernetes v1.20.10
k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e
)
replace k8s.io/component-helpers => k8s.io/component-helpers v0.20.10
replace k8s.io/controller-manager => k8s.io/controller-manager v0.20.10
replace k8s.io/mount-utils => k8s.io/mount-utils v0.20.11-rc.0
replace k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.22.1

1025
go.sum Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ package service
import (
"errors"
"fmt"
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
@ -39,13 +40,16 @@ func InitClusterInterface() error {
// Returns the node name based on the passed in node ID.
//
func GetNodeName(nodeID string) (string, error) {
nodeInfo, err := clientset.CoreV1().Nodes().Get(nodeID, metav1.GetOptions{
TypeMeta: metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
nodeInfo, err := clientset.CoreV1().Nodes().Get(
context.TODO(), nodeID,
metav1.GetOptions{
TypeMeta:
metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
if err != nil {
return "", err
@ -57,14 +61,16 @@ func GetNodeName(nodeID string) (string, error) {
// Returns the list of nodes in the form of a slice containing their name.
//
func GetNodeList() ([]string, error) {
nodeList, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
nodeList, err := clientset.CoreV1().Nodes().List(
context.TODO(),
metav1.ListOptions{
TypeMeta:
metav1.TypeMeta{
Kind: "",
APIVersion: "",
},
ResourceVersion: "1",
})
if err != nil {
return nil, err

View File

@ -168,6 +168,11 @@ func validateCreateVolumeReq(ctx context.Context, token *zfssarest.Token, req *c
return err
}
func (zd *ZFSSADriver) ControllerGetVolume(ctx context.Context, request *csi.ControllerGetVolumeRequest) (
*csi.ControllerGetVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "ControllerGetVolume is not implemented")
}
func (zd *ZFSSADriver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (
*csi.DeleteVolumeResponse, error) {