Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #154 from oracle/mp/fileStorageNew
Browse files Browse the repository at this point in the history
Dynamic Dedicated FSS
  • Loading branch information
MadalinaPatrichi authored Aug 15, 2018
2 parents 0643f4a + 8fa9e37 commit 00cc911
Show file tree
Hide file tree
Showing 40 changed files with 1,876 additions and 803 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ env.sh
*.log
test/system/venv/
test/system/run-test-image.yaml*
test/system/templates/*.yaml
*.pyc
.vscode/launch.json
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM iad.ocir.io/oracle/oci-volume-provisioner-system-test:1.0.0
FROM iad.ocir.io/oracle/oci-volume-provisioner-system-test:1.0.2

COPY dist /dist
COPY manifests /manifests
Expand Down
2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ignored = ["k8s.io/client-go/pkg/api/v1"]

[[override]]
name = "github.com/docker/distribution"
revision = "f0cc927784781fa395c06317c58dea2841ece3a9" # Lock in to version 2.6.3 when it is released
revision = "f0cc927784781fa395c06317c58dea2841ece3a9" # Lock in to version 2.6.3 when it is released

[[override]]
name = "k8s.io/api"
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ test:
build: ${DIR}/${BIN}
sed 's#@VERSION@#${VERSION}#g; s#@IMAGE@#${IMAGE}#g' \
manifests/oci-volume-provisioner.yaml > $(DIR)/oci-volume-provisioner.yaml
sed 's#@VERSION@#${VERSION}#g; s#@IMAGE@#${IMAGE}#g' \
manifests/oci-volume-provisioner-fss.yaml > $(DIR)/oci-volume-provisioner-fss.yaml
cp manifests/storage-class.yaml $(DIR)/storage-class.yaml
cp manifests/storage-class-ext3.yaml $(DIR)/storage-class-ext3.yaml
cp manifests/oci-volume-provisioner-rbac.yaml $(DIR)/oci-volume-provisioner-rbac.yaml
Expand Down
22 changes: 15 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ import (
"github.com/oracle/oci-volume-provisioner/pkg/provisioner/core"
"github.com/oracle/oci-volume-provisioner/pkg/signals"

"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

"k8s.io/apimachinery/pkg/api/resource"
)

const (
resyncPeriod = 15 * time.Second
minResyncPeriod = 12 * time.Hour
provisionerName = "oracle.com/oci"
exponentialBackOffOnError = false
failedRetryThreshold = 5
leasePeriod = controller.DefaultLeaseDuration
Expand All @@ -56,7 +54,7 @@ func informerResyncPeriod(minResyncPeriod time.Duration) func() time.Duration {

func main() {
syscall.Umask(0)

rand.Seed(time.Now().Unix())
kubeconfig := flag.String("kubeconfig", "", "Path to Kubeconfig file with authorization and master location information.")
volumeRoundingEnabled := flag.Bool("rounding-enabled", true, "When enabled volumes will be rounded up if less than 'minVolumeSizeMB'")
minVolumeSize := flag.String("min-volume-size", "50Gi", "The minimum size for a block volume. By default OCI only supports block volumes > 50GB")
Expand Down Expand Up @@ -92,6 +90,14 @@ func main() {
glog.Fatal("env variable NODE_NAME must be set so that this provisioner can identify itself")
}

// Decides what type of provider to deploy, either block or fss
provisionerType := os.Getenv("PROVISIONER_TYPE")
if provisionerType == "" {
provisionerType = core.ProvisionerNameBlock
}

glog.Infof("Starting volume provisioner in %s mode", provisionerType)

sharedInformerFactory := informers.NewSharedInformerFactory(clientset, informerResyncPeriod(minResyncPeriod)())

volumeSizeLowerBound, err := resource.ParseQuantity(*minVolumeSize)
Expand All @@ -101,13 +107,15 @@ func main() {

// Create the provisioner: it implements the Provisioner interface expected by
// the controller
ociProvisioner := core.NewOCIProvisioner(clientset, sharedInformerFactory.Core().V1().Nodes(), nodeName, *volumeRoundingEnabled, volumeSizeLowerBound)

ociProvisioner, err := core.NewOCIProvisioner(clientset, sharedInformerFactory.Core().V1().Nodes(), provisionerType, nodeName, *volumeRoundingEnabled, volumeSizeLowerBound)
if err != nil {
glog.Fatalf("Cannot create volume provisioner %v", err)
}
// Start the provision controller which will dynamically provision oci
// PVs
pc := controller.NewProvisionController(
clientset,
provisionerName,
provisionerType,
ociProvisioner,
serverVersion.GitVersion,
controller.ResyncPeriod(resyncPeriod),
Expand Down
11 changes: 0 additions & 11 deletions examples/example-claim-ffsw.template

This file was deleted.

14 changes: 14 additions & 0 deletions examples/example-claim-fss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: demooci
spec:
storageClassName: "oci-fss"
selector:
matchLabels:
failure-domain.beta.kubernetes.io/zone: "PHX-AD-1"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
18 changes: 18 additions & 0 deletions examples/example-pod-fss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: Pod
apiVersion: v1
metadata:
name: ocidemo-fss
spec:
volumes:
- name: nginx
persistentVolumeClaim:
claimName: fss-pvc
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage
3 changes: 1 addition & 2 deletions hack/check-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ set -o nounset
set -o pipefail

TARGETS=$(for d in "$@"; do echo ./$d/...; done)

echo -n "Checking golint: "
ERRS=$(golint ${TARGETS} 2>&1 || true)
ERRS=$(golint ${TARGETS} 2>&1 | grep -v mock_interfaces.go || true)
if [ -n "${ERRS}" ]; then
echo "FAIL"
echo "${ERRS}"
Expand Down
31 changes: 31 additions & 0 deletions manifests/oci-volume-provisioner-fss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: oci-volume-provisioner-fss
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
app: oci-volume-provisioner
spec:
serviceAccountName: oci-volume-provisioner
containers:
- name: oci-volume-provisioner
image: @IMAGE@:@VERSION@
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: PROVISIONER_TYPE
value: oracle.com/oci-fss
volumeMounts:
- name: config
mountPath: /etc/oci/
readOnly: true
volumes:
- name: config
secret:
secretName: oci-volume-provisioner
2 changes: 2 additions & 0 deletions manifests/oci-volume-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: PROVISIONER_TYPE
value: oracle.com/oci
volumeMounts:
- name: config
mountPath: /etc/oci/
Expand Down
69 changes: 55 additions & 14 deletions pkg/oci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,26 @@ import (
"time"

"github.com/golang/glog"
"github.com/pkg/errors"

"github.com/oracle/oci-go-sdk/common"
"github.com/oracle/oci-go-sdk/common/auth"
"github.com/oracle/oci-go-sdk/core"
"github.com/oracle/oci-go-sdk/filestorage"
"github.com/oracle/oci-go-sdk/identity"
"github.com/pkg/errors"

"github.com/oracle/oci-volume-provisioner/pkg/oci/instancemeta"
)

// ProvisionerClient wraps the OCI sub-clients required for volume provisioning.
type provisionerClient struct {
cfg *Config
blockStorage *core.BlockstorageClient
identity *identity.IdentityClient
context context.Context
timeout time.Duration
metadata *instancemeta.InstanceMetadata
cfg *Config
blockStorage *core.BlockstorageClient
identity *identity.IdentityClient
fileStorage *filestorage.FileStorageClient
virtualNetwork *core.VirtualNetworkClient
context context.Context
timeout time.Duration
metadata *instancemeta.InstanceMetadata
}

// BlockStorage specifies the subset of the OCI core API utilised by the provisioner.
Expand All @@ -59,10 +62,28 @@ type Identity interface {
ListAvailabilityDomains(ctx context.Context, request identity.ListAvailabilityDomainsRequest) (response identity.ListAvailabilityDomainsResponse, err error)
}

// FSS specifies the subset of the OCI core API utilised by the provisioner.
type FSS interface {
CreateFileSystem(ctx context.Context, request filestorage.CreateFileSystemRequest) (response filestorage.CreateFileSystemResponse, err error)
DeleteFileSystem(ctx context.Context, request filestorage.DeleteFileSystemRequest) (response filestorage.DeleteFileSystemResponse, err error)
CreateMountTarget(ctx context.Context, request filestorage.CreateMountTargetRequest) (response filestorage.CreateMountTargetResponse, err error)
CreateExport(ctx context.Context, request filestorage.CreateExportRequest) (response filestorage.CreateExportResponse, err error)
DeleteExport(ctx context.Context, request filestorage.DeleteExportRequest) (response filestorage.DeleteExportResponse, err error)
GetMountTarget(ctx context.Context, request filestorage.GetMountTargetRequest) (response filestorage.GetMountTargetResponse, err error)
ListMountTargets(ctx context.Context, request filestorage.ListMountTargetsRequest) (response filestorage.ListMountTargetsResponse, err error)
}

//VCN specifies the subset of the OCI core API utilised by the provisioner.
type VCN interface {
GetPrivateIp(ctx context.Context, request core.GetPrivateIpRequest) (response core.GetPrivateIpResponse, err error)
}

// ProvisionerClient is passed to all sub clients to provision a volume
type ProvisionerClient interface {
BlockStorage() BlockStorage
Identity() Identity
FSS() FSS
VCN() VCN
Context() context.Context
Timeout() time.Duration
CompartmentOCID() string
Expand All @@ -77,6 +98,14 @@ func (p *provisionerClient) Identity() Identity {
return p.identity
}

func (p *provisionerClient) FSS() FSS {
return p.fileStorage
}

func (p *provisionerClient) VCN() VCN {
return p.virtualNetwork
}

func (p *provisionerClient) Context() context.Context {
return p.context
}
Expand Down Expand Up @@ -119,6 +148,16 @@ func FromConfig(cfg *Config) (ProvisionerClient, error) {
return nil, err
}

fileStorage, err := filestorage.NewFileStorageClientWithConfigurationProvider(config)
if err != nil {
return nil, err
}

virtualNetwork, err := core.NewVirtualNetworkClientWithConfigurationProvider(config)
if err != nil {
return nil, err
}

identity, err := identity.NewIdentityClientWithConfigurationProvider(config)
if err != nil {
return nil, err
Expand All @@ -134,12 +173,14 @@ func FromConfig(cfg *Config) (ProvisionerClient, error) {
}

return &provisionerClient{
cfg: cfg,
blockStorage: &blockStorage,
identity: &identity,
timeout: 3 * time.Minute,
context: context.Background(),
metadata: metadata,
cfg: cfg,
blockStorage: &blockStorage,
identity: &identity,
fileStorage: &fileStorage,
virtualNetwork: &virtualNetwork,
timeout: 3 * time.Minute,
context: context.Background(),
metadata: metadata,
}, nil
}

Expand Down
Loading

0 comments on commit 00cc911

Please sign in to comment.