Skip to content

Commit

Permalink
Merge pull request #70 from YeYoot/dev
Browse files Browse the repository at this point in the history
CSI V3.0.0
  • Loading branch information
YeYoot authored Jul 15, 2022
2 parents 3ee6acf + e0035a3 commit 2eb7131
Show file tree
Hide file tree
Showing 72 changed files with 5,333 additions and 951 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)
### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

[Releases](https://github.com/Huawei/eSDK_K8S_Plugin/releases)

## Changes since v2.2.16

**Enhancements**

- Support Helm
- Support ReadWriteOncePod
- Support NFS 4.0/4.1
- Support DPC
- Support Kubernets 1.24
- Support Red Hat CoreOS 4.10 x86_64
- Support Kylin V10 SP1/SP2 ARM
- Support OceanStor Dorado V6 6.1.5
- Support OceanStor V6 6.1.5
- Support OceanStor Pacific 8.1.3

## Changes since v2.2.15

**Enhancements**
Expand All @@ -13,4 +28,4 @@
- Support UltraPath 31.1.0/UltraPath-NVMe 31.1.RC8
- Support Kubernets 1.22/1.23
- Support Ubuntu 18.04/20.04
- Support Centos 7.9
- Support Centos 7.9
34 changes: 13 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ all:COMMON_1 DIFF COMMON_2
COMMON_1:
rm -rf ./${PACKAGE} ./${CLOUD_PACKAGE}
rm -rf ./src/vendor

mkdir -p ./${PACKAGE}/bin

DIFF:
Expand All @@ -28,26 +27,19 @@ ifeq (${PLATFORM}, ARM)
endif

COMMON_2:
mkdir -p ./${PACKAGE}/deploy/v1.18-v1.19
mkdir -p ./${PACKAGE}/deploy/v1.20-v1.23

cp -r ./deploy/huawei-csi-node.yaml ./deploy/huawei-csi-rbac.yaml ./deploy/huawei-csi-configmap ./${PACKAGE}/deploy/v1.18-v1.19
cp -r ./deploy/huawei-csi-node.yaml ./deploy/huawei-csi-rbac.yaml ./deploy/huawei-csi-configmap ./${PACKAGE}/deploy/v1.20-v1.23
cp ./deploy/huawei-csi-controller-snapshot-v1beta1.yaml ./${PACKAGE}/deploy/v1.18-v1.19/huawei-csi-controller.yaml
cp ./deploy/huawei-csi-snapshot-crd-v1beta1.yaml ./${PACKAGE}/deploy/v1.18-v1.19/huawei-csi-snapshot-crd.yaml
cp ./deploy/huawei-csi-controller-snapshot-v1.yaml ./${PACKAGE}/deploy/v1.20-v1.23/huawei-csi-controller.yaml
cp ./deploy/huawei-csi-snapshot-crd-v1.yaml ./${PACKAGE}/deploy/v1.20-v1.23/huawei-csi-snapshot-crd.yaml

mkdir -p ./${PACKAGE}/examples/v1.18-v1.19
mkdir -p ./${PACKAGE}/examples/v1.20-v1.23
cp ./examples/* ./${PACKAGE}/examples/v1.18-v1.19
cp ./examples/* ./${PACKAGE}/examples/v1.20-v1.23
rm -rf ./${PACKAGE}/examples/v1.18-v1.19/*-v1.yaml
rm -rf ./${PACKAGE}/examples/v1.20-v1.23/*-v1beta1.yaml
mv ./${PACKAGE}/examples/v1.18-v1.19/snapshot-v1beta1.yaml ./${PACKAGE}/examples/v1.18-v1.19/volume-snapshot.yaml
mv ./${PACKAGE}/examples/v1.18-v1.19/snapshotclass-v1beta1.yaml ./${PACKAGE}/examples/v1.18-v1.19/volume-snapshot-class.yaml
mv ./${PACKAGE}/examples/v1.20-v1.23/snapshot-v1.yaml ./${PACKAGE}/examples/v1.20-v1.23/volume-snapshot.yaml
mv ./${PACKAGE}/examples/v1.20-v1.23/snapshotclass-v1.yaml ./${PACKAGE}/examples/v1.20-v1.23/volume-snapshot-class.yaml
mkdir -p ./${PACKAGE}/deploy
cp -r ./deploy/huawei-csi-node.yaml ./deploy/huawei-csi-rbac.yaml ./deploy/huawei-csi-configmap ./${PACKAGE}/deploy
cp ./deploy/huawei-csi-controller-snapshot-v1.yaml ./${PACKAGE}/deploy/huawei-csi-controller.yaml
cp ./deploy/huawei-csi-snapshot-crd-v1.yaml ./${PACKAGE}/deploy/huawei-csi-snapshot-crd.yaml

mkdir -p ./${PACKAGE}/examples
cp ./examples/* ./${PACKAGE}/examples

mkdir -p ./${PACKAGE}/helm/esdk
cp -r ./helm/esdk/* ./${PACKAGE}/helm/esdk

mkdir -p ./${PACKAGE}/tools
cp -r ./tools/imageUpload/* ./${PACKAGE}/tools

zip -r ${PACKAGE}.zip ./${PACKAGE}
mv ${PACKAGE} ${CLOUD_PACKAGE}
Expand Down
97 changes: 10 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,24 @@

# Huawei Storage CSI Driver For Kubernetes
## Overview
## Description

Huawei Container Storage Interface (CSI) Driver is used to provision LUN, recycle LUN,
and provide a series of disaster recovery functions of storages for Kubernetes Containers.

## Compatibility Matrix
| Features |1.18|1.19|1.20|1.21|1.22|1.23|
|---|---|---|---|---|---|---|
|Create PVC|||||||
|Delete PVC|||||||
|Create POD|||||||
|Delete POD|||||||
|Offline Resize|||||||
|Online Resize|||||||
|Create Snapshot|||||||
|Delete Snapshot|||||||
|Restore|||||||
|Clone|||||||

More details [release doc](https://github.com/Huawei/eSDK_K8S_Plugin/blob/master/RELEASE.md)

## Compiling the Huawei CSI Driver
## Compiling
This section describes the environmental requirements and steps of compiling Huawei CSI Driver

### Compiler Environment
| System | Go Version |
|---|---|
|Linux| >=1.16|
|Linux| >=1.17|

### Compilation steps
Step 1. Download the package and **cd** into the package, the structure is as follows:

- docs
- en
- zh
- cli
- connector
- csi
- proto
- storage
- tools
- utils
- vendor
- deploy
- example
- Dockerfile
- go.mod
- go.sum
- Makefile
Step 1. Download the package and **cd** into the package

Step 2. Run following command to compile the Huawei CSI Driver

make -f Makefile RELEASE_VER=[2.3.4] VER=[2.2.16] PLATFORM=[X86|ARM]
make -f Makefile RELEASE_VER=[2.5.RC1] VER=[3.0.0] PLATFORM=[X86|ARM]

Step 3. After the compilation is finished, a bin directory will be created in the current
directory, the structure is as follows:
Expand All @@ -61,53 +28,9 @@ directory, the structure is as follows:
- secretGenerate
- secretUpdate

In addition, we also provide a way to directly download the installation package, click Release to obtain the
corresponding version of the plug-in package

## Deployment and Examples
### Create Dockerfile and Make Huawei CSI Image
Ensure the docker has been installed on the host and host can access the networks in
order to obtain some dependent software, then you can refer to the [documentation](
https://github.com/Huawei/eSDK_K8S_Plugin/tree/master/docs) and
create your own Dockerfile.

docker build -f Dockerfile -t huawei-csi:*.*.*

Export and import the image

docker save huawei-csi:*.*.* -o huawei-csi.tar

docker load -i huawei-csi.tar

### Deploy The huawei-csi-rbac
Fill in the appropriate mirror version in [huawei-csi-rbac.yaml](https://github.com/Huawei/eSDK_K8S_Plugin/blob/master/deploy/huawei-csi-rbac.yaml),
and then create the Huawei CSI Rbac.

kubectl create -f huawei-csi-rbac.yaml

### Deploy the huawei-csi-configmap
Fill in the appropriate mirror version in [huawei-csi-configmap.yaml](https://github.com/Huawei/eSDK_K8S_Plugin/blob/master/deploy/huawei-csi-configmap/huawei-csi-configmap-oceanstor-iscsi.yaml), and then create the Huawei CSI Configmap

kubectl create -f huawei-csi-configmap.yaml

### Input the user and password of the storage device
chmod +x secretGenerate
./secretGenerate

### Deploy the huawei-csi-controller
Fill in the appropriate mirror version in [huawei-csi-controller.yaml](https://github.com/Huawei/eSDK_K8S_Plugin/blob/master/deploy/huawei-csi-controller-snapshot-v1.yaml), and then create the Huawei CSI Controller service

kubectl create -f huawei-csi-controller.yaml

### Deploy the huawei-csi-node
Fill in the appropriate mirror version in [huawei-csi-node.yaml](https://github.com/Huawei/eSDK_K8S_Plugin/blob/master/deploy/huawei-csi-node.yaml),
and then create the Huawei CSI Node service

kubectl create -f huawei-csi-node.yaml

### Verify CSI Driver is running
In addition, we also provide a way to directly download the installation package,
click [Release](https://github.com/Huawei/eSDK_K8S_Plugin/releases) to obtain the corresponding version of the plug-in package

kubectl get pods -n kube-system
## Documentation

Also, we support our own logging service for the Huawei CSI Driver, the default directory is */var/log/huawei*.
When you encounter some driver issues, you can get some help from these logs.
For details, see the user guide in the docs directory.
13 changes: 6 additions & 7 deletions cli/client/yaml_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ package client
import "testing"

const csiSecret = "huawei-csi-secret"
const defaultNameSpace = "kube-system"
const defaultNameSpace = "huawei-csi"

const normalCaseExpected = `
apiVersion: v1
kind: Secret
metadata:
name: huawei-csi-secret
namespace: kube-system
namespace: huawei-csi
type: Opaque
stringData:
secret.json: |
{
"secrets": {
"stringDataKey1": stringDataVal1,
"stringDataKey2": stringDataVal2
"stringDataKey1": stringDataVal1
}
}
`
Expand All @@ -27,14 +26,14 @@ apiVersion: v1
kind: Secret
metadata:
name: huawei-csi-secret
namespace: kube-system
namespace: huawei-csi
type: Opaque
stringData:
secret.json: |
`

func TestGetSecretYAML(t *testing.T) {
stringData := map[string]string{"stringDataKey1": "stringDataVal1", "stringDataKey2": "stringDataVal2"}
stringData := map[string]string{"stringDataKey1": "stringDataVal1"}

cases := []struct {
CaseName string
Expand All @@ -49,7 +48,7 @@ func TestGetSecretYAML(t *testing.T) {
for _, c := range cases {
t.Run(c.CaseName, func(t *testing.T) {
if ans := GetSecretYAML(c.secretName, c.namespace, c.stringData); ans != c.Expected {
t.Errorf("Test GetSecretYAML failed.")
t.Errorf("Test GetSecretYAML failed.\nExpected:%s \nGet:%s", c.Expected, ans)
}
})
}
Expand Down
9 changes: 1 addition & 8 deletions cli/command/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@ const (

var (
client k8sClient.Interface
storageNamespace string
)

func Init() {
if len(os.Args) >= inputArgsLength {
storageNamespace = os.Args[1]
} else {
storageNamespace = HUAWEINamespace
}

initInstallerLogging()
processInstallationArguments()
installSecret()
Expand Down Expand Up @@ -67,7 +60,7 @@ func installSecret() {
}

func initClient() (k8sClient.Interface, error) {
client, err := k8sClient.NewCliClient(storageNamespace, 180*time.Second)
client, err := k8sClient.NewCliClient(*secretNamespace, 180*time.Second)
if err != nil {
return nil, fmt.Errorf("Could not new a Kubernetes client, err: %v", err)
}
Expand Down
14 changes: 10 additions & 4 deletions cli/command/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"net/url"
"os"
Expand All @@ -28,6 +29,7 @@ import (
"time"

k8sClient "huawei-csi-driver/cli/client"
"huawei-csi-driver/cli/config"
"huawei-csi-driver/utils/log"
"huawei-csi-driver/utils/pwd"

Expand Down Expand Up @@ -56,6 +58,10 @@ var (
backendNameSet = make(map[string]struct{})
)

var (
secretNamespace = flag.String("namespace", config.DefaultNameSpace, "Namespace for huawei-csi-secret")
)

type backendConfigStatus struct {
Storage string
Urls []string
Expand Down Expand Up @@ -83,7 +89,7 @@ func safeExit() {
return
}

newSecretYAML := k8sClient.GetSecretYAML(HUAWEICSISecret, storageNamespace, secretMap)
newSecretYAML := k8sClient.GetSecretYAML(HUAWEICSISecret, *secretNamespace, secretMap)
err = client.CreateObjectByYAML(newSecretYAML)
if err != nil {
fmt.Println(saveErr)
Expand Down Expand Up @@ -121,7 +127,7 @@ func checkBackendConnectivity(urlStr string) error {
}

addr := u.Host[:len(u.Host)-len(u.Port())-1]
sh := fmt.Sprintf("ping -c 3 -i 0.001 -w 1 %s", addr)
sh := fmt.Sprintf("ping -c 3 -i 0.2 -w 1 %s", addr)
cmd := exec.Command("/bin/bash", "-c", sh)
output, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -174,9 +180,9 @@ func getInputString(tips string, isVisible bool) (string, error) {

var sh string
if isVisible {
sh = "stty erase '^H' -isig -ixon && read str && echo $str"
sh = "stty erase '^H' -isig -ixon && read -r str && echo $str"
} else {
sh = "stty erase '^H' -isig -ixon && read -s pwd && echo $pwd"
sh = "stty erase '^H' -isig -ixon && read -sr pwd && echo $pwd"
}

cmd := exec.Command("/bin/bash", "-c", sh)
Expand Down
9 changes: 0 additions & 9 deletions cli/command/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,12 @@ package command

import (
"fmt"
"os"

"huawei-csi-driver/utils/log"
)

const inputArgsLength = 2

// Update is to update the secret info for CSI
func Update() {
if len(os.Args) >= inputArgsLength {
storageNamespace = os.Args[1]
} else {
storageNamespace = HUAWEINamespace
}

initInstallerLogging()
processInstallationArguments()
update()
Expand Down
7 changes: 4 additions & 3 deletions cli/config/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package config

const (
DefaultNameSpace = "huawei-csi"
OrchestratorName = "Huawei"
OrchestratorVersion = "2.2.16"
MinKubernetesCSIVersion = "v1.18.0"
MaxKubernetesCSIVersion = "v1.23.x"
OrchestratorVersion = "3.0.0"
MinKubernetesCSIVersion = "v1.21.0"
MaxKubernetesCSIVersion = "v1.24.x"
)
Loading

0 comments on commit 2eb7131

Please sign in to comment.