Skip to content

Commit

Permalink
Merge pull request #83 from IBM/develop
Browse files Browse the repository at this point in the history
Merge develop branch (version 0.9.0) to master branch
  • Loading branch information
shay-berman authored Sep 24, 2019
2 parents 8bfd3aa + 715fa39 commit d466dc7
Show file tree
Hide file tree
Showing 108 changed files with 18,534 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore .cache folder
.cache
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.pyc
.idea
.coverage
.project
.pydevproject
/.metadata/
/bin/
node/mocks
32 changes: 32 additions & 0 deletions Dockerfile-cleanup-volumes
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright IBM Corporation 2019.
#
# 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.

FROM centos:7
RUN yum --enablerepo=extras -y install epel-release && yum -y install python36-pip

COPY scripts/ci/cleanup_volumes.py /scripts/cleanup_volumes.py
RUN pip3 install pyxcli
RUN pip3 install munch

RUN groupadd -g 9999 appuser && \
useradd -r -u 9999 -g appuser appuser
RUN chown -R appuser:appuser /scripts
USER appuser

WORKDIR /scripts
ENV PYTHONPATH=/scripts

ENTRYPOINT ["/scripts/cleanup_volumes.py"]


45 changes: 45 additions & 0 deletions Dockerfile-csi-controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright IBM Corporation 2019.
#
# 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.

FROM registry.access.redhat.com/ubi8/python-36:1
MAINTAINER IBM Storage

###Required Labels
LABEL name="IBM block storage CSI driver controller" \
vendor="IBM" \
version="0.9.0" \
release="b62" \
summary="The controller component of the IBM block storage CSI driver" \
description="The IBM block storage CSI driver enables container orchestrators, such as Kubernetes and OpenShift, to manage the life-cycle of persistent storage." \
io.k8s.display-name="IBM block storage CSI driver controller" \
io.k8s.description="The IBM block storage CSI driver enables container orchestrators, such as Kubernetes and OpenShift, to manage the life-cycle of persistent storage." \
io.openshift.tags=ibm,csi,ibm-block-csi-driver,ibm-block-csi-node

COPY controller/requirements.txt /driver/controller/
RUN pip3 install --upgrade pip==19.1.1
RUN pip3 install -r /driver/controller/requirements.txt

COPY ./common /driver/common
COPY ./controller /driver/controller
COPY ./LICENSE /licenses/
COPY ./NOTICES /licenses/

WORKDIR /driver
ENV PYTHONPATH=/driver

# Note: UBI runs with app-user by default.

ENTRYPOINT ["/driver/controller/scripts/entrypoint.sh"]


40 changes: 40 additions & 0 deletions Dockerfile-csi-controller.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright IBM Corporation 2019.
#
# 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.

# Description:
# This Dockerfile.test is for running the csi controller unit testing inside a container.
# Its similar to the Dockerfile but with additional requirements-tests.txt and CMD to run nosetests.

FROM centos:7
#TODO : move to UBI like FROM registry.access.redhat.com/ubi7/python-27:2.7
RUN yum --enablerepo=extras -y install epel-release && yum -y install python36-pip

COPY controller/requirements.txt /driver/controller/
RUN pip3 install --upgrade pip==19.1.1
RUN pip3 install -r /driver/controller/requirements.txt

# Requires to run unit testing
COPY controller/requirements-tests.txt /driver/controller/
RUN pip3 install -r /driver/controller/requirements-tests.txt

COPY ./common /driver/common
COPY ./controller /driver/controller
RUN groupadd -g 9999 appuser && \
useradd -r -u 9999 -g appuser appuser
RUN chown -R appuser:appuser /driver
USER appuser
WORKDIR /driver

ENTRYPOINT ["/driver/controller/scripts/entrypoint-test.sh"]

69 changes: 69 additions & 0 deletions Dockerfile-csi-node
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright IBM Corporation 2019.
#
# 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.

# Build stage
FROM golang:1.12.6 as builder

WORKDIR /go/src/github.com/ibm/ibm-block-csi-driver
ENV GO111MODULE=on

# Populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN make ibm-block-csi-driver

# Final stage
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.0
MAINTAINER IBM Storage

LABEL name="IBM block storage CSI driver node" \
vendor="IBM" \
version="0.9.0" \
release="b62" \
summary="The node component of the IBM block storage CSI driver" \
description="The IBM block storage CSI driver enables container orchestrators, such as Kubernetes and OpenShift, to manage the life-cycle of persistent storage." \
io.k8s.display-name="IBM block storage CSI driver node" \
io.k8s.description="The IBM block storage CSI driver enables container orchestrators, such as Kubernetes and OpenShift, to manage the life-cycle of persistent storage." \
io.openshift.tags=ibm,csi,ibm-block-csi-driver,ibm-block-csi-node

WORKDIR /root
COPY --from=builder /go/src/github.com/ibm/ibm-block-csi-driver/common/config.yaml .
COPY --from=builder /go/src/github.com/ibm/ibm-block-csi-driver/bin/ibm-block-csi-node-driver .
COPY ./LICENSE /licenses/
COPY ./NOTICES /licenses/

RUN mkdir /chroot
ADD chroot-host-wrapper.sh /chroot
RUN chmod 777 /chroot/chroot-host-wrapper.sh
RUN ln -s /chroot/chroot-host-wrapper.sh /chroot/blkid \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/blockdev \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/iscsiadm \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/lsblk \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/lsscsi \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/mkfs.ext3 \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/mkfs.ext4 \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/mkfs.xfs \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/fsck \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/mount \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/multipath \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/multipathd \
&& ln -s /chroot/chroot-host-wrapper.sh /chroot/umount

ENV PATH="/chroot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"


ENTRYPOINT ["/root/ibm-block-csi-node-driver"]
30 changes: 30 additions & 0 deletions Dockerfile-csi-node.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright IBM Corporation 2019.
#
# 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.

# Build stage
FROM golang:1.12.6 as builder

WORKDIR /go/src/github.com/ibm/ibm-block-csi-driver
ENV GO111MODULE=on

# Populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN go get github.com/tebeka/go2xunit # when GO111MODULE=on the module will not become executable, so get it here to run it as binary.
RUN go get github.com/golang/mock/gomock
RUN go install github.com/golang/mock/mockgen

COPY . .
ENTRYPOINT ["make", "test-xunit"]
36 changes: 36 additions & 0 deletions Dockerfile-csi-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright IBM Corporation 2019.
#
# 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.

FROM golang:1.11

RUN git clone https://github.com/kubernetes-csi/csi-test /usr/local/go/src/github.com/kubernetes-csi/csi-test
RUN make -C /usr/local/go/src/github.com/kubernetes-csi/csi-test

COPY ./scripts/csi_test /usr/local/go/src/github.com/kubernetes-csi/csi-test/ibm-driver

RUN groupadd -g 9999 appuser && \
useradd -r -u 9999 -g appuser appuser
RUN chown -R appuser:appuser /usr/local/go/src/github.com/kubernetes-csi/csi-test

USER appuser
WORKDIR /usr/local/go/src/github.com/kubernetes-csi/csi-test

ENV JUNIT_OUTPUT="/tmp/test_results/out_client.xml"
ENV SECRET_FILE="/usr/local/go/src/github.com/kubernetes-csi/csi-test/ibm-driver/csi_secrets"
ENV PARAM_FILE="/usr/local/go/src/github.com/kubernetes-csi/csi-test/ibm-driver/csi_params"
ENV ENDPOINT="/tmp/k8s_dir/nodecsi"
ENV ENDPOINT_CONTROLLER="/tmp/k8s_dir/f"
ENV TESTS_TO_RUN_FILE="/usr/local/go/src/github.com/kubernetes-csi/csi-test/ibm-driver/csi_tests_to_run"

ENTRYPOINT ["/usr/local/go/src/github.com/kubernetes-csi/csi-test/ibm-driver/entrypoint-csi-tests.sh"]
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Copyright 2019 IBM Corp.
#
# 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.
#

# Note: this Makefile currently applicable responsible for CSI compile, test and build image. Later will should add csi-controller to the makefile party.

PKG=github.com/ibm/ibm-block-csi-driver
IMAGE=ibmcom/ibm-block-csi-driver
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS?="-X ${PKG}/node/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/node/pkg/driver.buildDate=${BUILD_DATE} -s -w"
GO111MODULE=on
DRIVER_CONFIG_YML=$(shell pwd)/common/config.yaml

.EXPORT_ALL_VARIABLES:

.PHONY: ibm-block-csi-driver
ibm-block-csi-driver:
mkdir -p bin
CGO_ENABLED=0 GOOS=linux go build -ldflags ${LDFLAGS} -o bin/ibm-block-csi-node-driver ./node/cmd

.PHONY: test
test:
if [ -d ./node/mocks ]; then rm -rf ./node/mocks; fi
go generate ./...
go test -v -race ./node/...

.PHONY: test-xunit
test-xunit:
mkdir -p ./build/reports
if [ -d ./node/mocks ]; then rm -rf ./node/mocks; fi
go generate ./...
go test -v -race ./node/... | go2xunit -output build/reports/csi-node-unitests.xml
go test -v -race ./node/... # run again so the makefile will fail in case tests failing

.PHONY: test-xunit-in-container
test-xunit-in-container:
# Run make test-xunit inside csi node container for testing (to avoid go and other testing utils on your laptop).
docker build -f Dockerfile-csi-node.test -t csi-node-unitests .
docker run --rm -t -v $(CURDIR)/build/reports/:/go/src/github.com/ibm/ibm-block-csi-driver/build/reports/ csi-node-unitests


.PHONY: gofmt
gofmt:
gofmt -w ./node

.PHONY: csi-build-images-and-push-artifactory
csi-build-images-and-push-artifactory:
./scripts/ci/build_push_images.sh

.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'

Loading

0 comments on commit d466dc7

Please sign in to comment.