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

Commit 00cc911

Browse files
Merge pull request #154 from oracle/mp/fileStorageNew
Dynamic Dedicated FSS
2 parents 0643f4a + 8fa9e37 commit 00cc911

40 files changed

+1876
-803
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ env.sh
55
*.log
66
test/system/venv/
77
test/system/run-test-image.yaml*
8+
test/system/templates/*.yaml
9+
*.pyc
10+
.vscode/launch.json

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM iad.ocir.io/oracle/oci-volume-provisioner-system-test:1.0.0
1+
FROM iad.ocir.io/oracle/oci-volume-provisioner-system-test:1.0.2
22

33
COPY dist /dist
44
COPY manifests /manifests

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ignored = ["k8s.io/client-go/pkg/api/v1"]
4848

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

5353
[[override]]
5454
name = "k8s.io/api"

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ test:
5959
build: ${DIR}/${BIN}
6060
sed 's#@VERSION@#${VERSION}#g; s#@IMAGE@#${IMAGE}#g' \
6161
manifests/oci-volume-provisioner.yaml > $(DIR)/oci-volume-provisioner.yaml
62+
sed 's#@VERSION@#${VERSION}#g; s#@IMAGE@#${IMAGE}#g' \
63+
manifests/oci-volume-provisioner-fss.yaml > $(DIR)/oci-volume-provisioner-fss.yaml
6264
cp manifests/storage-class.yaml $(DIR)/storage-class.yaml
6365
cp manifests/storage-class-ext3.yaml $(DIR)/storage-class-ext3.yaml
6466
cp manifests/oci-volume-provisioner-rbac.yaml $(DIR)/oci-volume-provisioner-rbac.yaml

cmd/main.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@ import (
2626
"github.com/oracle/oci-volume-provisioner/pkg/provisioner/core"
2727
"github.com/oracle/oci-volume-provisioner/pkg/signals"
2828

29+
"k8s.io/apimachinery/pkg/api/resource"
2930
"k8s.io/client-go/informers"
3031
"k8s.io/client-go/kubernetes"
3132
"k8s.io/client-go/tools/clientcmd"
32-
33-
"k8s.io/apimachinery/pkg/api/resource"
3433
)
3534

3635
const (
3736
resyncPeriod = 15 * time.Second
3837
minResyncPeriod = 12 * time.Hour
39-
provisionerName = "oracle.com/oci"
4038
exponentialBackOffOnError = false
4139
failedRetryThreshold = 5
4240
leasePeriod = controller.DefaultLeaseDuration
@@ -56,7 +54,7 @@ func informerResyncPeriod(minResyncPeriod time.Duration) func() time.Duration {
5654

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

93+
// Decides what type of provider to deploy, either block or fss
94+
provisionerType := os.Getenv("PROVISIONER_TYPE")
95+
if provisionerType == "" {
96+
provisionerType = core.ProvisionerNameBlock
97+
}
98+
99+
glog.Infof("Starting volume provisioner in %s mode", provisionerType)
100+
95101
sharedInformerFactory := informers.NewSharedInformerFactory(clientset, informerResyncPeriod(minResyncPeriod)())
96102

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

102108
// Create the provisioner: it implements the Provisioner interface expected by
103109
// the controller
104-
ociProvisioner := core.NewOCIProvisioner(clientset, sharedInformerFactory.Core().V1().Nodes(), nodeName, *volumeRoundingEnabled, volumeSizeLowerBound)
105-
110+
ociProvisioner, err := core.NewOCIProvisioner(clientset, sharedInformerFactory.Core().V1().Nodes(), provisionerType, nodeName, *volumeRoundingEnabled, volumeSizeLowerBound)
111+
if err != nil {
112+
glog.Fatalf("Cannot create volume provisioner %v", err)
113+
}
106114
// Start the provision controller which will dynamically provision oci
107115
// PVs
108116
pc := controller.NewProvisionController(
109117
clientset,
110-
provisionerName,
118+
provisionerType,
111119
ociProvisioner,
112120
serverVersion.GitVersion,
113121
controller.ResyncPeriod(resyncPeriod),

examples/example-claim-ffsw.template

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/example-claim-fss.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
kind: PersistentVolumeClaim
2+
apiVersion: v1
3+
metadata:
4+
name: demooci
5+
spec:
6+
storageClassName: "oci-fss"
7+
selector:
8+
matchLabels:
9+
failure-domain.beta.kubernetes.io/zone: "PHX-AD-1"
10+
accessModes:
11+
- ReadWriteOnce
12+
resources:
13+
requests:
14+
storage: 50Gi

examples/example-pod-fss.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
kind: Pod
2+
apiVersion: v1
3+
metadata:
4+
name: ocidemo-fss
5+
spec:
6+
volumes:
7+
- name: nginx
8+
persistentVolumeClaim:
9+
claimName: fss-pvc
10+
containers:
11+
- name: task-pv-container
12+
image: nginx
13+
ports:
14+
- containerPort: 80
15+
name: "http-server"
16+
volumeMounts:
17+
- mountPath: "/usr/share/nginx/html"
18+
name: task-pv-storage

hack/check-golint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ set -o nounset
2121
set -o pipefail
2222

2323
TARGETS=$(for d in "$@"; do echo ./$d/...; done)
24-
2524
echo -n "Checking golint: "
26-
ERRS=$(golint ${TARGETS} 2>&1 || true)
25+
ERRS=$(golint ${TARGETS} 2>&1 | grep -v mock_interfaces.go || true)
2726
if [ -n "${ERRS}" ]; then
2827
echo "FAIL"
2928
echo "${ERRS}"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: oci-volume-provisioner-fss
5+
namespace: kube-system
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: oci-volume-provisioner
12+
spec:
13+
serviceAccountName: oci-volume-provisioner
14+
containers:
15+
- name: oci-volume-provisioner
16+
image: @IMAGE@:@VERSION@
17+
env:
18+
- name: NODE_NAME
19+
valueFrom:
20+
fieldRef:
21+
fieldPath: spec.nodeName
22+
- name: PROVISIONER_TYPE
23+
value: oracle.com/oci-fss
24+
volumeMounts:
25+
- name: config
26+
mountPath: /etc/oci/
27+
readOnly: true
28+
volumes:
29+
- name: config
30+
secret:
31+
secretName: oci-volume-provisioner

manifests/oci-volume-provisioner.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ spec:
1919
valueFrom:
2020
fieldRef:
2121
fieldPath: spec.nodeName
22+
- name: PROVISIONER_TYPE
23+
value: oracle.com/oci
2224
volumeMounts:
2325
- name: config
2426
mountPath: /etc/oci/

pkg/oci/client/client.go

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,26 @@ import (
2828
"time"
2929

3030
"github.com/golang/glog"
31-
"github.com/pkg/errors"
32-
3331
"github.com/oracle/oci-go-sdk/common"
3432
"github.com/oracle/oci-go-sdk/common/auth"
3533
"github.com/oracle/oci-go-sdk/core"
34+
"github.com/oracle/oci-go-sdk/filestorage"
3635
"github.com/oracle/oci-go-sdk/identity"
36+
"github.com/pkg/errors"
37+
3738
"github.com/oracle/oci-volume-provisioner/pkg/oci/instancemeta"
3839
)
3940

4041
// ProvisionerClient wraps the OCI sub-clients required for volume provisioning.
4142
type provisionerClient struct {
42-
cfg *Config
43-
blockStorage *core.BlockstorageClient
44-
identity *identity.IdentityClient
45-
context context.Context
46-
timeout time.Duration
47-
metadata *instancemeta.InstanceMetadata
43+
cfg *Config
44+
blockStorage *core.BlockstorageClient
45+
identity *identity.IdentityClient
46+
fileStorage *filestorage.FileStorageClient
47+
virtualNetwork *core.VirtualNetworkClient
48+
context context.Context
49+
timeout time.Duration
50+
metadata *instancemeta.InstanceMetadata
4851
}
4952

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

65+
// FSS specifies the subset of the OCI core API utilised by the provisioner.
66+
type FSS interface {
67+
CreateFileSystem(ctx context.Context, request filestorage.CreateFileSystemRequest) (response filestorage.CreateFileSystemResponse, err error)
68+
DeleteFileSystem(ctx context.Context, request filestorage.DeleteFileSystemRequest) (response filestorage.DeleteFileSystemResponse, err error)
69+
CreateMountTarget(ctx context.Context, request filestorage.CreateMountTargetRequest) (response filestorage.CreateMountTargetResponse, err error)
70+
CreateExport(ctx context.Context, request filestorage.CreateExportRequest) (response filestorage.CreateExportResponse, err error)
71+
DeleteExport(ctx context.Context, request filestorage.DeleteExportRequest) (response filestorage.DeleteExportResponse, err error)
72+
GetMountTarget(ctx context.Context, request filestorage.GetMountTargetRequest) (response filestorage.GetMountTargetResponse, err error)
73+
ListMountTargets(ctx context.Context, request filestorage.ListMountTargetsRequest) (response filestorage.ListMountTargetsResponse, err error)
74+
}
75+
76+
//VCN specifies the subset of the OCI core API utilised by the provisioner.
77+
type VCN interface {
78+
GetPrivateIp(ctx context.Context, request core.GetPrivateIpRequest) (response core.GetPrivateIpResponse, err error)
79+
}
80+
6281
// ProvisionerClient is passed to all sub clients to provision a volume
6382
type ProvisionerClient interface {
6483
BlockStorage() BlockStorage
6584
Identity() Identity
85+
FSS() FSS
86+
VCN() VCN
6687
Context() context.Context
6788
Timeout() time.Duration
6889
CompartmentOCID() string
@@ -77,6 +98,14 @@ func (p *provisionerClient) Identity() Identity {
7798
return p.identity
7899
}
79100

101+
func (p *provisionerClient) FSS() FSS {
102+
return p.fileStorage
103+
}
104+
105+
func (p *provisionerClient) VCN() VCN {
106+
return p.virtualNetwork
107+
}
108+
80109
func (p *provisionerClient) Context() context.Context {
81110
return p.context
82111
}
@@ -119,6 +148,16 @@ func FromConfig(cfg *Config) (ProvisionerClient, error) {
119148
return nil, err
120149
}
121150

151+
fileStorage, err := filestorage.NewFileStorageClientWithConfigurationProvider(config)
152+
if err != nil {
153+
return nil, err
154+
}
155+
156+
virtualNetwork, err := core.NewVirtualNetworkClientWithConfigurationProvider(config)
157+
if err != nil {
158+
return nil, err
159+
}
160+
122161
identity, err := identity.NewIdentityClientWithConfigurationProvider(config)
123162
if err != nil {
124163
return nil, err
@@ -134,12 +173,14 @@ func FromConfig(cfg *Config) (ProvisionerClient, error) {
134173
}
135174

136175
return &provisionerClient{
137-
cfg: cfg,
138-
blockStorage: &blockStorage,
139-
identity: &identity,
140-
timeout: 3 * time.Minute,
141-
context: context.Background(),
142-
metadata: metadata,
176+
cfg: cfg,
177+
blockStorage: &blockStorage,
178+
identity: &identity,
179+
fileStorage: &fileStorage,
180+
virtualNetwork: &virtualNetwork,
181+
timeout: 3 * time.Minute,
182+
context: context.Background(),
183+
metadata: metadata,
143184
}, nil
144185
}
145186

0 commit comments

Comments
 (0)