Skip to content

Commit

Permalink
Fixes for #41 (#42)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mattsson <[email protected]>
  • Loading branch information
datamattsson authored May 8, 2023
1 parent 4b92f91 commit 3ff5d9a
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 22 deletions.
15 changes: 7 additions & 8 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ These procedures assumes a running Kubernetes cluster [supported by the HPE CSI
- TrueNAS 12.0 or later
- TrueNAS SCALE 22.02 or later
- FreeNAS 11.2-U3 or later
- Kubernetes 1.23 or later
- Helm 3.6 or later (recommended, only needed if using Helm to install the CSP)

### TrueNAS Container Storage Provider Helm Chart
Expand All @@ -22,18 +21,18 @@ The HPE CSI Driver may be installed using either a Helm Chart, Operator or direc

**Note:** The [TrueNAS Container Storage Provider Helm Chart](https://artifacthub.io/packages/helm/truenas-csp/truenas-csp) has a dependency on the HPE CSI Driver for Kubernetes Helm Chart and makes it a lot easier to manage configuration during runtime. Consider using Helm to deploy the CSP over the YAML manifests.

Install HPE CSI Driver using manifests:
Install HPE CSI Driver using manifests (assumes latest supported Kubernetes version of the CSI driver):

```
kubectl create ns hpe-storage
kubectl create -f https://raw.githubusercontent.com/hpe-storage/co-deployments/master/yaml/csi-driver/v2.3.0/hpe-linux-config.yaml
kubectl create -f https://raw.githubusercontent.com/hpe-storage/co-deployments/master/yaml/csi-driver/v2.3.0/hpe-csi-k8s-1.26.yaml
```

Install the TrueNAS CSP using manifests:

```
kubectl create ns hpe-storage
kubectl create -f https://raw.githubusercontent.com/hpe-storage/truenas-csp/master/K8s/v2.3.0/truenas-csp.yaml
kubectl create -f https://raw.githubusercontent.com/hpe-storage/truenas-csp/master/K8s/v2.3.10/truenas-csp.yaml
```

**Note:** Replace `hpe-csi-k8s-<version>.yaml` with your version of Kubernetes. Also change the version of the HPE CSI Driver manifests where applicable. Using mismatching versions of the TrueNAS CSP and the HPE CSI Driver will most likely **NOT** work.
Expand All @@ -52,7 +51,7 @@ metadata:
stringData:
serviceName: truenas-csp-svc
servicePort: "8080"
username: hpe-csi (username is a no-op)
username: hpe-csi (username is a no-op when using API key)
password: API key or root password of TrueNAS/FreeNAS appliance
backend: Management IP address of TrueNAS/FreeNAS appliance
```
Expand All @@ -66,15 +65,15 @@ The TrueNAS/FreeNAS appliance require an iSCSI portal to be configured manually
![](https://hpe-storage.github.io/truenas-csp/assets/portal.png)

- Description: `hpe-csi`
- IP Address: List of IPs used for iSCSI (do NOT use 0.0.0.0)
- IP Address: List of IPs used for iSCSI (do **NOT** use 0.0.0.0)

The Target Global Configuration needs to be updated with this Base Name:
The Target Global Configuration needs to have an explicit Base Name:

![](https://hpe-storage.github.io/truenas-csp/assets/global-target.png)

- Base Name: `iqn.2011-08.org.truenas.ctl` or `iqn.2005-10.org.freenas.ctl`

**Hint:** If TrueNAS/FreeNAS is not giving you the option to select nothing but 0.0.0.0 in the portal configuration is because you're using DHCP. Only statically assigned addresses can be used in the picker.
**Hint:** If TrueNAS/FreeNAS is not giving you the option to select nothing but 0.0.0.0 in the portal configuration is because DHCP is being used. Only statically assigned addresses can be used in the picker.

Also make sure the iSCSI service is started and enabled at boot on TrueNAS/FreeNAS.

Expand Down
25 changes: 25 additions & 0 deletions K8s/v2.3.10/hpe-storageclass-nfs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "false"
name: hpe-standard-nfs
provisioner: csi.hpe.com
parameters:
csi.storage.k8s.io/controller-expand-secret-name: truenas-secret
csi.storage.k8s.io/controller-expand-secret-namespace: hpe-storage
csi.storage.k8s.io/controller-publish-secret-name: truenas-secret
csi.storage.k8s.io/controller-publish-secret-namespace: hpe-storage
csi.storage.k8s.io/node-publish-secret-name: truenas-secret
csi.storage.k8s.io/node-publish-secret-namespace: hpe-storage
csi.storage.k8s.io/node-stage-secret-name: truenas-secret
csi.storage.k8s.io/node-stage-secret-namespace: hpe-storage
csi.storage.k8s.io/provisioner-secret-name: truenas-secret
csi.storage.k8s.io/provisioner-secret-namespace: hpe-storage
csi.storage.k8s.io/fstype: xfs
nfsResources: "true"
allowOverrides: sparse,compression,deduplication,volblocksize,sync,description
root: zwimming/csi-volumes
reclaimPolicy: Delete
allowVolumeExpansion: true
24 changes: 24 additions & 0 deletions K8s/v2.3.10/hpe-storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "true"
name: hpe-standard
provisioner: csi.hpe.com
parameters:
csi.storage.k8s.io/controller-expand-secret-name: truenas-secret
csi.storage.k8s.io/controller-expand-secret-namespace: hpe-storage
csi.storage.k8s.io/controller-publish-secret-name: truenas-secret
csi.storage.k8s.io/controller-publish-secret-namespace: hpe-storage
csi.storage.k8s.io/node-publish-secret-name: truenas-secret
csi.storage.k8s.io/node-publish-secret-namespace: hpe-storage
csi.storage.k8s.io/node-stage-secret-name: truenas-secret
csi.storage.k8s.io/node-stage-secret-namespace: hpe-storage
csi.storage.k8s.io/provisioner-secret-name: truenas-secret
csi.storage.k8s.io/provisioner-secret-namespace: hpe-storage
csi.storage.k8s.io/fstype: xfs
allowOverrides: sparse,compression,deduplication,volblocksize,sync,description
root: zwimming/csi-volumes
reclaimPolicy: Delete
allowVolumeExpansion: true
38 changes: 38 additions & 0 deletions K8s/v2.3.10/truenas-csp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
kind: Service
apiVersion: v1
metadata:
name: truenas-csp-svc
namespace: hpe-storage
labels:
app: truenas-csp-svc
spec:
ports:
- port: 8080
protocol: TCP
selector:
app: truenas-csp

---
kind: Deployment
apiVersion: apps/v1
metadata:
name: truenas-csp
namespace: hpe-storage
spec:
selector:
matchLabels:
app: truenas-csp
replicas: 1
template:
metadata:
labels:
app: truenas-csp
spec:
priorityClassName: system-cluster-critical
containers:
- name: truenas-csp
image: quay.io/datamattsson/truenas-csp:v2.3.10
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
12 changes: 12 additions & 0 deletions K8s/v2.3.10/truenas-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: v1
kind: Secret
metadata:
name: truenas-secret
namespace: hpe-storage
stringData:
serviceName: truenas-csp-svc
servicePort: "8080"
username: hpe-csi (username is a no-op)
password: API key or root password of TrueNAS/FreeNAS appliance
backend: Management IP address of TrueNAS/FreeNAS appliance
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Topology is currently not supported by the HPE CSI Driver.

Releases will track the upstream versioning of the HPE CSI Driver for Kubernetes and potential bugfixes in the TrueNAS CSP will be pushed to the same image tag matching the HPE CSI Driver version.

* [TrueNAS CSP v2.3.10](https://github.com/hpe-storage/truenas-csp/releases/tag/v2.3.10) for HPE CSI Driver v2.3.0
* [TrueNAS CSP v2.3.0](https://github.com/hpe-storage/truenas-csp/releases/tag/v2.3.0) for HPE CSI Driver v2.3.0
* [TrueNAS CSP v2.2.0](https://github.com/hpe-storage/truenas-csp/releases/tag/v2.2.0) for HPE CSI Driver v2.2.0
* [TrueNAS CSP v2.1.1](https://github.com/hpe-storage/truenas-csp/releases/tag/v2.1.1) for HPE CSI Driver v2.1.1
Expand All @@ -37,6 +38,10 @@ Releases will track the upstream versioning of the HPE CSI Driver for Kubernetes
* [TrueNAS CORE CSP v1.4.0](https://github.com/hpe-storage/truenas-csp/releases/tag/v1.4.0) for HPE CSI Driver v1.4.0
* [TrueNAS CORE CSP v1.3.0](https://github.com/hpe-storage/truenas-csp/releases/tag/v1.3.0) for HPE CSI Driver v1.3.0

# Version schemes

The TrueNAS CSP will track an official release of the HPE CSI Driver for Kubernetes, i.e v2.2.0 and there will be a subsequent release of the TrueNAS CSP v2.2.0. If a patch release of the CSP is needed, the patch position will be incremented by 10. I.e v2.2.10. The last digit will represent the patch version of the CSI driver. The [Helm chart](https://artifacthub.io/packages/helm/truenas-csp/truenas-csp) is it's own deliverable and has its own semantic versioning.

# Install

See [INSTALL](INSTALL.md).
Expand Down
35 changes: 34 additions & 1 deletion docs/index.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
apiVersion: v1
entries:
truenas-csp:
- annotations:
artifacthub.io/license: MIT
artifacthub.io/links: |
- name: HPE CSI Driver for Kubernetes
url: https://scod.hpedev.io
- name: Install
url: https://github.com/hpe-storage/truenas-csp/blob/master/INSTALL.md
artifacthub.io/prerelease: "false"
apiVersion: v2
appVersion: 2.3.10
created: "2023-05-07T18:50:16.384944624-07:00"
dependencies:
- name: hpe-csi-driver
repository: https://hpe-storage.github.io/co-deployments
version: 2.3.0
description: TrueNAS Container Storage Provider Helm chart for Kubernetes
digest: ff1b4d617477b6f55d3debd3820b69b7280acd721ad686b736025f30266df380
home: https://github.com/hpe-storage/truenas-csp
icon: https://hpe-storage.github.io/truenas-csp/assets/icon.svg
keywords:
- HPE
- Storage
- CSI
maintainers:
- email: [email protected]
name: Michael Mattsson
name: truenas-csp
sources:
- https://github.com/hpe-storage/truenas-csp
type: application
urls:
- truenas-csp-1.1.4.tgz
version: 1.1.4
- annotations:
artifacthub.io/license: MIT
artifacthub.io/links: |
Expand Down Expand Up @@ -166,4 +199,4 @@ entries:
urls:
- truenas-csp-1.0.0.tgz
version: 1.0.0
generated: "2023-05-04T22:52:19.983893272-07:00"
generated: "2023-05-07T18:50:16.383697211-07:00"
Binary file added docs/truenas-csp-1.1.4.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions helm/charts/truenas-csp/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ annotations:
- name: Install
url: https://github.com/hpe-storage/truenas-csp/blob/master/INSTALL.md
artifacthub.io/prerelease: "false"
version: "1.1.3"
appVersion: "2.3.0"
version: "1.1.4"
appVersion: "2.3.10"
maintainers:
- name: Michael Mattsson
email: [email protected]
Expand Down
3 changes: 1 addition & 2 deletions helm/charts/truenas-csp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ This Chart provide means to install the dependent [HPE CSI Driver for Kubernetes

## Prerequisites

- Fulfill all requirements of the [HPE CSI Driver for Kubernetes Helm chart](https://artifacthub.io/packages/helm/hpe-storage/hpe-csi-driver/2.3.0) v2.3.0
- TrueNAS 12.0 or later
- TrueNAS SCALE 22.02 or later
- FreeNAS 11.2-U3 or later

This chart is lock stepped with [HPE CSI Driver for Kubernetes Helm chart](https://artifacthub.io/packages/helm/hpe-storage/hpe-csi-driver) application versions. Other requirements and prerequisites may be found on that chart.
This chart is lock stepped with [HPE CSI Driver for Kubernetes Helm chart](https://artifacthub.io/packages/helm/hpe-storage/hpe-csi-driver) application versions. Other requirements and prerequisites such as supported host OS and Kubernetes versions may be found on that chart.

**IMPORTANT:** Do **NOT** install this chart if the HPE CSI Driver for Kubernetes is already installed!

Expand Down
2 changes: 1 addition & 1 deletion helm/charts/truenas-csp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ image:
repository: quay.io/datamattsson/truenas-csp
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2.3.0"
tag: "v2.3.10"

imagePullSecrets: []
nameOverride: ""
Expand Down
15 changes: 12 additions & 3 deletions truenascsp/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def ping(self, req):
self.logger.debug(' headers: %s', headers)

def ipaddrs_to_networks(self, ipaddrs):
interfaces = self.fetch('interface')
interfaces = self.fetch('interface', returnBy=list)

networks = []

Expand Down Expand Up @@ -255,11 +255,20 @@ def fetch(self, resource, **kwargs):

if len(results) == 1:
self.logger.debug('API fetch caught 1 item')
return results[0]

if kwargs.get('returnBy') == list:
return results
else:
return results[0]

if len(results) > 1:
self.logger.debug('API fetch caught %d items', len(results))
return results

if kwargs.get('returnBy') == dict:
self.logger.debug('Returning first row in result set')
return results[0]
else:
return results

return None

Expand Down
7 changes: 2 additions & 5 deletions truenascsp/truenascsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def on_put(self, req, resp, volume_id):

# grab host
initiator = api.fetch(
'iscsi/initiator', field='comment', value=content.get('host_uuid'))
'iscsi/initiator', field='comment', value=content.get('host_uuid'), returnBy=dict)

# grab portal IPs
portal = api.fetch('iscsi/portal', field='comment',
Expand Down Expand Up @@ -440,10 +440,7 @@ def on_post(self, req, resp):
req_backend['auth_network'] = api.cidrs_to_hosts(content.get('networks'))

initiator = api.fetch(
'iscsi/initiator', field='comment', value=content.get('uuid'))

# rare condition (race during initial creation)
initiator = initiator[0] if isinstance(initiator, list) else initiator
'iscsi/initiator', field='comment', value=content.get('uuid'), returnBy=dict)

if initiator:
api.put(
Expand Down

0 comments on commit 3ff5d9a

Please sign in to comment.