From: enyinna1234 Date: Wed, 9 Oct 2019 17:18:22 +0000 (-0700) Subject: Adds unit tests and K8s artifacts X-Git-Tag: v0.4.0~65 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=149466f046765ee3851a155be749ec0e27f35b30;p=icn.git Adds unit tests and K8s artifacts This adds unit tests, a Kubernetes Service, and Deployment to create objects that enable the RESTful API as a Kubenetes service, and adds end to end testing. Change-Id: I0439ff51931ac0abe7c5bff8b7d75e8ced19a06f Signed-off-by: Enyinna Ochulor Signed-off-by: Chen, Tingjie --- diff --git a/Makefile b/Makefile index 9260307..950ba51 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ BPA_OPERATOR:=$(CURDIR)/cmd/bpa-operator/ KUD_PATH:=$(CURDIR)/deploy/kud SDWAN_VERIFIER_PATH:=$(CURDIR)/sdwan/test BPA_E2E_SETUP:=https://raw.githubusercontent.com/onap/multicloud-k8s/master/kud/hosting_providers/vagrant/setup.sh +BPA_REST_API:=$(CURDIR)/cmd/bpa-restapi-agent + help: @echo " Targets:" @@ -57,6 +59,12 @@ bpa_op_verifier: bpa_op_install bpa_op_e2e bpa_op_all: bm_all bpa_op_install +bpa_rest_api_install: + pushd $(BPA_REST_API) && make deploy && popd + +bpa_rest_api_verifier: + pushd $(BPA_REST_API) && make e2e_test && popd + bashate: bashate -i E006,E003,E002,E010,E011,E042,E043 `find . -type f -not -path './cmd/bpa-operator/vendor/*' -name *.sh` @@ -66,7 +74,8 @@ prerequisite: verify_all: prerequisite \ metal3_prerequisite \ kud_bm_deploy_mini \ - metal3_vm + metal3_vm \ + bpa_rest_api_verifier verifier: verify_all diff --git a/cmd/bpa-restapi-agent/Makefile b/cmd/bpa-restapi-agent/Makefile index 2e70365..6b41947 100644 --- a/cmd/bpa-restapi-agent/Makefile +++ b/cmd/bpa-restapi-agent/Makefile @@ -1,32 +1,22 @@ - -# # The name of the executable (default is current directory name) -# TARGET := $(shell echo $${PWD\#\#*/}) -# .DEFAULT_GOAL: $(TARGET) -# -# # These will be provided to the target -# VERSION := 1.0.0 -# BUILD := `git rev-parse HEAD` -# -# # Use linker flags to provide version/build settings to the target -# LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)" -# -# # go source files, ignore vendor directory -# SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*") -# -# .PHONY: all build -# -# all: build -# -# $(TARGET): $(SRC) -# @go build $(LDFLAGS) -o $(TARGET) -# -# build: $(TARGET) -# @true - .PHONY: build -build: +build: untar go build -mod=vendor -o build/_output/bin/bpa-restapi-agent main.go -docker: +docker: docker build -t akraino.org/icn/bpa-restapi-agent:latest . -f build/Dockerfile + +untar: + tar -xzvf vendor.tar.gz + +deploy: docker + ./bpa_api_install.sh + +test: go_install + go test ./... -v + +go_install: + install_go.sh + +e2e_test: deploy + ./e2e_test.sh diff --git a/cmd/bpa-restapi-agent/bpa_api_cluster_role.yml b/cmd/bpa-restapi-agent/bpa_api_cluster_role.yml new file mode 100644 index 0000000..e8171ec --- /dev/null +++ b/cmd/bpa-restapi-agent/bpa_api_cluster_role.yml @@ -0,0 +1,8 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: do-all +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] diff --git a/cmd/bpa-restapi-agent/bpa_api_cluster_role_binding.yml b/cmd/bpa-restapi-agent/bpa_api_cluster_role_binding.yml new file mode 100644 index 0000000..eb9649d --- /dev/null +++ b/cmd/bpa-restapi-agent/bpa_api_cluster_role_binding.yml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: do-all-global +subjects: +- kind: ServiceAccount + name: bpa-restapi-agent + namespace: default +roleRef: + kind: ClusterRole + name: do-all + apiGroup: rbac.authorization.k8s.io diff --git a/cmd/bpa-restapi-agent/bpa_api_install.sh b/cmd/bpa-restapi-agent/bpa_api_install.sh new file mode 100755 index 0000000..843727a --- /dev/null +++ b/cmd/bpa-restapi-agent/bpa_api_install.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +ICN_DIR=$(dirname "$(dirname "$PWD")") + +kubectl apply -f create-service-account.yml + +kubectl apply -f bpa_api_cluster_role.yml + +kubectl apply -f bpa_api_cluster_role_binding.yml + +pushd $ICN_DIR/deploy/kud-plugin-addons/minio + +./install.sh + +popd + +kubectl apply -f service.yml diff --git a/cmd/bpa-restapi-agent/create-service-account.yml b/cmd/bpa-restapi-agent/create-service-account.yml new file mode 100644 index 0000000..3764bb9 --- /dev/null +++ b/cmd/bpa-restapi-agent/create-service-account.yml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: bpa-restapi-agent diff --git a/cmd/bpa-restapi-agent/e2e_test.sh b/cmd/bpa-restapi-agent/e2e_test.sh new file mode 100755 index 0000000..09c4582 --- /dev/null +++ b/cmd/bpa-restapi-agent/e2e_test.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +ICN_DIR=$(dirname "$(dirname "$PWD")") + +source "$ICN_DIR/env/lib/common.sh" + +#create sample image +if true ; then + cat <<- EOF > /tmp/sample_image + This is a dummy file for testing. +EOF +fi + +IMAGE_SIZE=$(ls -al /tmp/sample_image | awk '{print $5}') + +if true ; then + cat <<- EOF > /tmp/sample.json + { + "owner": "alpha", + "cluster_name": "beta", + "type": "container", + "image_name": "qwerty123", + "image_length": $IMAGE_SIZE, + "image_offset": 0, + "upload_complete": false, + "description": { + "image_records": [ + { + "image_record_name": "iuysdi1234", + "repo": "icn", + "tag": "2" + } + ] + } + } +EOF +fi + +curr_status="" + +while [[ $curr_status != "Running" ]]; do + + new_status=$(kubectl get pods | grep bpa-api-deployment | awk '{print $3}') + if [[ $new_status != $curr_status ]]; then + echo "$(date +%H:%M:%S) - BPA-RESTful-API Pod status: $new_status" + curr_status=$new_status + if [[ $new_status == "Running" ]]; then + break + fi + fi + if [[ $new_status == "Err"* ]]; then + exit 1 + fi + sleep 10 +done + + +#Get CLusterIP +IP=$(kubectl get services | grep bpa-api-service | awk '{print $3}') + +call_api -i -F "metadata= /dev/null; then + sudo apt-get -yq install golang-go +fi diff --git a/cmd/bpa-restapi-agent/internal/app/image.go b/cmd/bpa-restapi-agent/internal/app/image.go index 28cda77..2c117a3 100644 --- a/cmd/bpa-restapi-agent/internal/app/image.go +++ b/cmd/bpa-restapi-agent/internal/app/image.go @@ -1,25 +1,25 @@ package app import ( + "bpa-restapi-agent/internal/db" "encoding/json" "os" "os/user" "path" - "bpa-restapi-agent/internal/db" pkgerrors "github.com/pkg/errors" ) // Image contains the parameters needed for Image information type Image struct { - Owner string `json:"owner"` - ClusterName string `json:"cluster_name"` - Type string `json:"type"` - ImageName string `json:"image_name"` - ImageOffset *int `json:"image_offset"` - ImageLength int `json:"image_length"` - UploadComplete *bool `json:"upload_complete"` - Description ImageRecordList `json:"description"` + Owner string `json:"owner"` + ClusterName string `json:"cluster_name"` + Type string `json:"type"` + ImageName string `json:"image_name"` + ImageOffset *int `json:"image_offset"` + ImageLength int `json:"image_length"` + UploadComplete *bool `json:"upload_complete"` + Description ImageRecordList `json:"description"` } type ImageRecordList struct { @@ -28,9 +28,7 @@ type ImageRecordList struct { // ImageKey is the key structure that is used in the database type ImageKey struct { - // Owner string `json:"owner"` - // ClusterName string `json:"cluster_name"` - ImageName string `json:"image_name"` + ImageName string `json:"image_name"` } // We will use json marshalling to convert to string to @@ -54,32 +52,56 @@ type ImageManager interface { GetDirPath(imageName string) (string, string, error) } +// Interface to aid unit test by mocking third party packages +type Utility interface { + GetCurrentUser() (*user.User, error) + DBCreate(storeName string, key ImageKey, meta string, c Image) error + DBRead(storeName string, key ImageKey, meta string) ([]byte, error) + DBUnmarshal(value []byte) (Image, error) + OSMakeDir(dirpath string, perm int) error + OSCreateFile(filePath string) error + GetPath(user *user.User, imageName string, storeName string) (string, string) + DBDelete(storeName string, key ImageKey, meta string) error + OSRemove(filePath string) error + DBUpdate(storeName string, key ImageKey, tagMeta string, c Image) error +} + // ImageClient implements the ImageManager // It will also be used to maintain some localized state type ImageClient struct { + util Utility storeName string tagMeta string } +type DBService struct { +} + // To Do - Fix repetition in // NewImageClient returns an instance of the ImageClient // which implements the ImageManager func NewBinaryImageClient() *ImageClient { + service := DBService{} return &ImageClient{ + util: service, storeName: "binary_images", tagMeta: "metadata", } } func NewContainerImageClient() *ImageClient { + service := DBService{} return &ImageClient{ + util: service, storeName: "container_images", tagMeta: "metadata", } } func NewOSImageClient() *ImageClient { + service := DBService{} return &ImageClient{ + util: service, storeName: "os_images", tagMeta: "metadata", } @@ -87,11 +109,8 @@ func NewOSImageClient() *ImageClient { // Create an entry for the Image resource in the database` func (v *ImageClient) Create(c Image) (Image, error) { - //Construct composite key consisting of name key := ImageKey{ - // Owner: c.Owner, - // ClusterName: c.ClusterName, ImageName: c.ImageName, } @@ -101,12 +120,12 @@ func (v *ImageClient) Create(c Image) (Image, error) { return Image{}, pkgerrors.New("Image already exists") } - err = db.DBconn.Create(v.storeName, key, v.tagMeta, c) + err = v.util.DBCreate(v.storeName, key, v.tagMeta, c) if err != nil { return Image{}, pkgerrors.Wrap(err, "Creating DB Entry") } - err = v.CreateFile(v.storeName, c) + err = v.CreateFile(c) if err != nil { return Image{}, pkgerrors.Wrap(err, "Creating File in FS") } @@ -114,28 +133,53 @@ func (v *ImageClient) Create(c Image) (Image, error) { return c, nil } +func (d DBService) DBCreate(storeName string, key ImageKey, meta string, c Image) error { + + //Construct composite key consisting of name + err := db.DBconn.Create(storeName, key, meta, c) + if err != nil { + return pkgerrors.Wrap(err, "Creating DB Entry") + } + + return nil +} + // Create file -func (v *ImageClient) CreateFile(dirName string, c Image) error { +func (v *ImageClient) CreateFile(c Image) error { filePath, dirPath, err := v.GetDirPath(c.ImageName) if err != nil { return pkgerrors.Wrap(err, "Get file path") } - err = os.MkdirAll(dirPath, 0744) - if err != nil { + err = v.util.OSMakeDir(dirPath, 0744) + if err != nil { return pkgerrors.Wrap(err, "Make image directory") - } - file1, err := os.Create(filePath) + } + err = v.util.OSCreateFile(filePath) if err != nil { return pkgerrors.Wrap(err, "Create image file") } - defer file1.Close() - + return nil +} - return nil +func (d DBService) OSMakeDir(dirPath string, perm int) error { + err := os.MkdirAll(dirPath, 0744) + if err != nil { + return pkgerrors.Wrap(err, "Make image directory") + } + return nil } +func (d DBService) OSCreateFile(filePath string) error { + file1, err := os.Create(filePath) + if err != nil { + return pkgerrors.Wrap(err, "Create image file") + } + defer file1.Close() + + return nil +} // Get returns Image for corresponding to name func (v *ImageClient) Get(imageName string) (Image, error) { @@ -147,15 +191,14 @@ func (v *ImageClient) Get(imageName string) (Image, error) { ImageName: imageName, } - value, err := db.DBconn.Read(v.storeName, key, v.tagMeta) + value, err := v.util.DBRead(v.storeName, key, v.tagMeta) if err != nil { return Image{}, pkgerrors.Wrap(err, "Get Image") } //value is a byte array if value != nil { - c := Image{} - err = db.DBconn.Unmarshal(value, &c) + c, err := v.util.DBUnmarshal(value) if err != nil { return Image{}, pkgerrors.Wrap(err, "Unmarshaling Value") } @@ -165,6 +208,25 @@ func (v *ImageClient) Get(imageName string) (Image, error) { return Image{}, pkgerrors.New("Error getting Connection") } +func (d DBService) DBRead(storeName string, key ImageKey, meta string) ([]byte, error) { + value, err := db.DBconn.Read(storeName, key, meta) + if err != nil { + return []byte{}, pkgerrors.Wrap(err, "Get Image") + } + + return value, nil +} + +func (d DBService) DBUnmarshal(value []byte) (Image, error) { + c := Image{} + err := db.DBconn.Unmarshal(value, &c) + if err != nil { + return Image{}, pkgerrors.Wrap(err, "Unmarshaling Value") + } + + return c, nil +} + func (v *ImageClient) GetImageRecordByName(imgName string, imageRecordName string) (map[string]string, error) { @@ -183,13 +245,8 @@ func (v *ImageClient) GetImageRecordByName(imgName string, } func (v *ImageClient) GetDirPath(imageName string) (string, string, error) { - u, err := user.Current() - if err != nil { - return "", "", pkgerrors.Wrap(err, "Current user") - } - home := u.HomeDir - dirPath := path.Join(home, "images", v.storeName) - filePath := path.Join(dirPath, imageName) + u, err := v.util.GetCurrentUser() + filePath, dirPath := v.util.GetPath(u, imageName, v.storeName) return filePath, dirPath, err } @@ -203,20 +260,33 @@ func (v *ImageClient) Delete(imageName string) error { // ClusterName: clusterName, ImageName: imageName, } - err := db.DBconn.Delete(v.storeName, key, v.tagMeta) - if err != nil { - return pkgerrors.Wrap(err, "Delete Image") - } + err := v.util.DBDelete(v.storeName, key, v.tagMeta) //Delete image from FS filePath, _, err := v.GetDirPath(imageName) if err != nil { return pkgerrors.Wrap(err, "Get file path") } - err = os.Remove(filePath) + err = v.util.OSRemove(filePath) + + return nil +} + +func (d DBService) OSRemove(filePath string) error { + err := os.Remove(filePath) if err != nil { return pkgerrors.Wrap(err, "Delete image file") } + + return nil +} + +func (d DBService) DBDelete(storeName string, key ImageKey, tagMeta string) error { + err := db.DBconn.Delete(storeName, key, tagMeta) + if err != nil { + return pkgerrors.Wrap(err, "Delete Image") + } + return nil } @@ -233,10 +303,34 @@ func (v *ImageClient) Update(imageName string, c Image) (Image, error) { return Image{}, pkgerrors.New("Update Error - Image doesn't exist") } - err = db.DBconn.Update(v.storeName, key, v.tagMeta, c) + err = v.util.DBUpdate(v.storeName, key, v.tagMeta, c) + + return c, nil +} + +func (d DBService) DBUpdate(storeName string, key ImageKey, tagMeta string, c Image) error { + err := db.DBconn.Update(storeName, key, tagMeta, c) if err != nil { - return Image{}, pkgerrors.Wrap(err, "Updating DB Entry") + return pkgerrors.Wrap(err, "Updating DB Entry") } - return c, nil + return nil +} + +// Define GetCurrentUser +func (d DBService) GetCurrentUser() (*user.User, error) { + u, err := user.Current() + if err != nil { + return nil, pkgerrors.Wrap(err, "Current user") + } + + return u, nil +} + +func (d DBService) GetPath(user *user.User, imageName string, storeName string) (string, string) { + home := user.HomeDir + dirPath := path.Join(home, "images", storeName) + filePath := path.Join(dirPath, imageName) + + return filePath, dirPath } diff --git a/cmd/bpa-restapi-agent/internal/app/image_test.go b/cmd/bpa-restapi-agent/internal/app/image_test.go new file mode 100644 index 0000000..f90a5b3 --- /dev/null +++ b/cmd/bpa-restapi-agent/internal/app/image_test.go @@ -0,0 +1,164 @@ +package app + +import ( + "fmt" + "os/user" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/pkg/errors" + +) + +type mockValues struct { + mock.Mock +} + +func (m *mockValues) GetCurrentUser() (*user.User, error) { + fmt.Println("Mocked Get User") + args := m.Called() + + return args.Get(0).(*user.User), args.Error(1) +} + +func TestGetDirPath(t *testing.T) { + fakeUser := user.User{} + u := &fakeUser + + myMocks := new(mockValues) + + myMocks.On("GetCurrentUser").Return(&fakeUser, nil) + myMocks.On("GetPath", u, "", "test_image").Return("", "") + + imageClient := ImageClient{myMocks, "test_image", "test_meta"} + _, dir, err := imageClient.GetDirPath("") + if err != nil { + t.Errorf("Path was incorrect, got: %q, want: %q.", dir, "some_path") + } +} + +func (m *mockValues) DBCreate(name string, key ImageKey, meta string, c Image) error{ + fmt.Println("Mocked Create image in Mongo") + args := m.Called(name, key, meta, c) + + return args.Error(0) +} + +func (m *mockValues) DBRead(name string, key ImageKey, meta string) ([]byte, error) { + fmt.Println("Mocked Mongo DB Read Operations") + args := m.Called(name, key, meta) + + return args.Get(0).([]byte), args.Error(1) +} + +func (m *mockValues) DBUnmarshal(value []byte, c Image) error { + fmt.Println("Mocked Mongo DB Unmarshal Operation") + args := m.Called(value, c) + + return args.Error(0) +} + +func (m *mockValues) GetPath(u *user.User, imageName string, storeName string) (string, string) { + args := m.Called(u, "", "test_image") + + return args.String(0), args.String(1) +} + +func (m *mockValues) OSMakeDir(dirPath string, perm int) error { + fmt.Println("Mocked OS Create Directory Operation") + args := m.Called(dirPath, perm) + + return args.Error(0) +} + +func (m *mockValues) OSCreateFile(filePath string) error { + fmt.Println("Mocked Create File Operation") + args := m.Called(filePath) + + return args.Error(0) +} + +func (m *mockValues) DBDelete(name string, key ImageKey, meta string) error { + fmt.Println("Mocked Mongo DB Delete") + args := m.Called(name, key, meta) + + return args.Error(0) + +} + +func (m *mockValues) OSRemove(filePath string) error { + fmt.Println("Mocked OS File Remove") + args := m.Called(filePath) + + return args.Error(0) +} + +func (m *mockValues) DBUpdate(s string, k ImageKey, t string, c Image) error { + fmt.Println("Mocked Mongo DB Update") + args := m.Called(s, k, t, c) + + return args.Error(0) +} + +func TestCreate(t *testing.T) { + image := Image{} + arr_data := []byte{} + key := ImageKey{} + myMocks := new(mockValues) + // just to get an error value + err1 := errors.New("math: square root of negative number") + + fakeUser := user.User{} + u := &fakeUser + + myMocks.On("DBCreate", "test_image", key, "test_meta", image).Return(nil) + myMocks.On("DBRead", "test_image", key, "test_meta").Return(arr_data, err1) + myMocks.On("DBUnmarshal", arr_data, image).Return(nil) + myMocks.On("GetCurrentUser").Return(&fakeUser, nil) + myMocks.On("GetPath", u, "", "test_image").Return("", "") + myMocks.On("OSMakeDir", "", 0744).Return(nil) + myMocks.On("OSCreateFile", "").Return(nil) + + imageClient := ImageClient{myMocks, "test_image", "test_meta"} + _, err := imageClient.Create(image) + if err != nil { + t.Errorf("Some error occured!") + } +} + +func TestDelete(t *testing.T) { + key := ImageKey{} + fakeUser := user.User{} + u := &fakeUser + + myMocks := new(mockValues) + + myMocks.On("DBDelete", "test_image", key, "test_meta").Return(nil) + myMocks.On("GetCurrentUser").Return(&fakeUser, nil) + myMocks.On("GetPath", u, "", "test_image").Return("", "") + myMocks.On("OSRemove", "").Return(nil) + + imageClient := ImageClient{myMocks, "test_image", "test_meta"} + err := imageClient.Delete("") + if err != nil { + t.Errorf("Some error occured!") + } + +} + +func TestUpdate(t *testing.T) { + image := Image{} + key := ImageKey{} + arr_data := []byte{} + + myMocks := new(mockValues) + + myMocks.On("DBRead", "test_image", key, "test_meta").Return(arr_data, nil) + myMocks.On("DBUnmarshal", arr_data, image).Return(nil) + myMocks.On("DBUpdate", "test_image", key, "test_meta", image).Return(nil) + imageClient := ImageClient{myMocks, "test_image", "test_meta"} + _, err := imageClient.Update("", image) + if err != nil { + t.Errorf("Some error occured!") + } +} diff --git a/cmd/bpa-restapi-agent/sample.json b/cmd/bpa-restapi-agent/sample.json deleted file mode 100644 index 97c2125..0000000 --- a/cmd/bpa-restapi-agent/sample.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "owner": "alpha", - "cluster_name": "beta", - "type": "container", - "image_name": "asdf246", - "image_length": 21579557, - "image_offset": 0, - "upload_complete": false, - "description": { - "image_records": [ - { - "image_record_name": "iuysdi1234", - "repo": "java", - "tag": "8" - } - ] - } -} diff --git a/cmd/bpa-restapi-agent/service.yml b/cmd/bpa-restapi-agent/service.yml new file mode 100644 index 0000000..db3163b --- /dev/null +++ b/cmd/bpa-restapi-agent/service.yml @@ -0,0 +1,64 @@ +apiVersion: v1 +kind: Service +metadata: + name: bpa-api-service +spec: + selector: + app: bpa-api1 + ports: + - port: 9015 + targetPort: 9015 + protocol: TCP + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: bpa-api-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: bpa-api1 + strategy: + type: Recreate + template: + metadata: + labels: + app: bpa-api1 + spec: + serviceAccount: bpa-restapi-agent + # Refer to the PVC created earlier + volumes: + - name: storage + persistentVolumeClaim: + # Name of the PVC created earlier + claimName: minio-local-claim + containers: + - name: bpa-api1 + image: akraino.org/icn/bpa-restapi-agent:latest + imagePullPolicy: IfNotPresent + ports: + - containerPort: 9015 + - name: mongo + image: mongo + ports: + - containerPort: 27017 + - name: minio + # Pulls the default Minio image from Docker Hub + image: minio/minio:latest + args: + - server + - /storage + env: + # Minio access key and secret key + - name: MINIO_ACCESS_KEY + value: "ICN-ACCESSKEYID" + - name: MINIO_SECRET_KEY + value: "ICN-SECRETACCESSKEY" + ports: + - containerPort: 9000 + # Mount the volume into the pod + volumeMounts: + - name: storage # must match the volume name, above + mountPath: "/storage" diff --git a/cmd/bpa-restapi-agent/vendor.tar.gz b/cmd/bpa-restapi-agent/vendor.tar.gz new file mode 100644 index 0000000..74490a2 Binary files /dev/null and b/cmd/bpa-restapi-agent/vendor.tar.gz differ diff --git a/deploy/kud-plugin-addons/minio/install.sh b/deploy/kud-plugin-addons/minio/install.sh index f1a61ea..b81d8b1 100755 --- a/deploy/kud-plugin-addons/minio/install.sh +++ b/deploy/kud-plugin-addons/minio/install.sh @@ -1,21 +1,23 @@ #!/bin/bash +ICN_DIR=$(dirname "$(dirname "$(dirname "$PWD")")") + # Make sure 64GB+ free space. echo "s"|sudo -S mkdir /mnt/minio -# Create local-storage persistent volume first since not support dynamic provisioning. -kubectl create -f local-pv.yaml +# Create local-sc persistent volume first since not support dynamic provisioning. +kubectl apply -f $ICN_DIR/deploy/kud-plugin-addons/minio/local-pv.yaml -# Create storage class for local-storage -kubectl create -f local-sc.yaml +# Create storage class for local-sc +kubectl apply -f $ICN_DIR/deploy/kud-plugin-addons/minio/local-sc.yaml # Create persistent volume claim for minio server -kubectl create -f local-pvc.yaml +kubectl apply -f $ICN_DIR/deploy/kud-plugin-addons/minio/local-pvc.yaml # Create deployment of MinIO server -kubectl create -f minio-deployment.yaml +kubectl apply -f $ICN_DIR/deploy/kud-plugin-addons/minio/minio-deployment.yaml # Create service for MinIO -kubectl create -f minio-service.yaml +# kubectl create -f minio-service.yaml diff --git a/deploy/kud-plugin-addons/minio/local-pv.yaml b/deploy/kud-plugin-addons/minio/local-pv.yaml index d273a0f..448622a 100644 --- a/deploy/kud-plugin-addons/minio/local-pv.yaml +++ b/deploy/kud-plugin-addons/minio/local-pv.yaml @@ -9,7 +9,7 @@ spec: accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Delete - storageClassName: local-storage + storageClassName: local-sc local: path: /mnt/minio nodeAffinity: diff --git a/deploy/kud-plugin-addons/minio/local-pvc.yaml b/deploy/kud-plugin-addons/minio/local-pvc.yaml index 923dd61..8fb630f 100644 --- a/deploy/kud-plugin-addons/minio/local-pvc.yaml +++ b/deploy/kud-plugin-addons/minio/local-pvc.yaml @@ -8,5 +8,5 @@ spec: resources: requests: storage: 64Gi - storageClassName: local-storage + storageClassName: local-sc diff --git a/deploy/kud-plugin-addons/minio/local-sc.yaml b/deploy/kud-plugin-addons/minio/local-sc.yaml index b442e77..65bc293 100644 --- a/deploy/kud-plugin-addons/minio/local-sc.yaml +++ b/deploy/kud-plugin-addons/minio/local-sc.yaml @@ -1,7 +1,7 @@ kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: local-storage + name: local-sc provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer