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

Commit 24d18a0

Browse files
Harvey Lowndesowainlewis
authored andcommitted
Support flex volume driver configuration via secret (#113)
1 parent f3a9aad commit 24d18a0

File tree

4 files changed

+77
-14
lines changed

4 files changed

+77
-14
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ installed on every node in your Kubernetes cluster.
1616

1717
### Kubernetes DaemonSet Installer
1818

19-
The recommended way to install the driver is through the daemonset installer mechanism.
19+
The recommended way to install the driver is through the daemonset installer mechanism. This will create two daemonsets, one specifically for master nodes, allowing configuration via a Kubernetes Secret, and one for worker nodes.
2020

2121
```
2222
kubectl apply -f https://github.com/oracle/oci-flexvolume-driver/releases/download/${flexvolume_driver_version}/oci-flexvolume-driver.yaml
2323
```
2424

25-
You'll need to add the config file as per below.
25+
You'll still need to add the config file manually or as a kubernetes secret.
2626

2727
### Manually
2828

@@ -62,6 +62,18 @@ auth:
6262
If `"region"` and/or `"compartment"` are not specified in the config file
6363
they will be retrieved from the hosts [OCI metadata service][4].
6464
65+
### Submit configuration as a Kubernetes secret
66+
67+
The configuration file above can be submitted as a Kubernetes Secret onto the master nodes.
68+
69+
```
70+
kubectl create secret generic oci-flexvolume-driver \
71+
-n kube-system \
72+
--from-file=config.yaml=config.yaml
73+
```
74+
75+
Once the Secret is set and the daemonsets deployed, the configuration file will be placed onto the master nodes.
76+
6577
##### Using instance principals
6678

6779
To authenticate using [instance principals][9] the following policies must first be

deploy.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@ driver_dir="/flexmnt/$VENDOR${VENDOR:+"~"}${DRIVER}"
2424

2525
LOG_FILE="$driver_dir/oci_flexvolume_driver.log"
2626

27+
config_file_name="config.yaml"
28+
config_tmp_dir="/tmp"
29+
30+
CONFIG_FILE="$config_tmp_dir/$config_file_name"
31+
2732
if [ ! -d "$driver_dir" ]; then
2833
mkdir "$driver_dir"
2934
fi
3035

3136
cp "/$DRIVER" "$driver_dir/.$DRIVER"
3237
mv -f "$driver_dir/.$DRIVER" "$driver_dir/$DRIVER"
3338

39+
if [ -f "$CONFIG_FILE" ]; then
40+
cp "$CONFIG_FILE" "$driver_dir/$config_file_name"
41+
fi
42+
3443
while : ; do
3544
touch $LOG_FILE
3645
tail -f $LOG_FILE

manifests/oci-flexvolume-driver.yaml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
11
apiVersion: extensions/v1beta1
22
kind: DaemonSet
33
metadata:
4-
name: oci-flexvolume-driver
4+
name: oci-flexvolume-driver-master
55
namespace: kube-system
66
spec:
77
template:
88
metadata:
9-
name: oci-flexvolume-driver
9+
name: oci-flexvolume-driver-master
1010
labels:
1111
app: oci-flexvolume-driver
1212
spec:
13+
nodeSelector:
14+
node-role.kubernetes.io/master: "true"
1315
tolerations:
14-
- key: node-role.kubernetes.io/master
15-
effect: NoSchedule
16+
- key: node.cloudprovider.kubernetes.io/uninitialized
17+
value: "true"
18+
effect: NoSchedule
19+
- key: node-role.kubernetes.io/master
20+
operator: Exists
21+
effect: NoSchedule
1622
containers:
1723
- image: iad.ocir.io/__DOCKER_REGISTRY_USERNAME__/oci-flexvolume-driver:__VERSION__
24+
imagePullPolicy: Always
25+
name: oci-flexvolume-driver
26+
securityContext:
27+
privileged: true
28+
volumeMounts:
29+
- mountPath: /flexmnt
30+
name: flexvolume-mount
31+
- mountPath: /tmp
32+
name: config
33+
readOnly: true
34+
volumes:
35+
- name: flexvolume-mount
36+
hostPath:
37+
path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/
38+
type: DirectoryOrCreate
39+
- name: config
40+
secret:
41+
secretName: oci-flexvolume-driver
42+
---
43+
apiVersion: extensions/v1beta1
44+
kind: DaemonSet
45+
metadata:
46+
name: oci-flexvolume-driver-worker
47+
namespace: kube-system
48+
spec:
49+
template:
50+
metadata:
51+
name: oci-flexvolume-driver-worker
52+
labels:
53+
app: oci-flexvolume-driver
54+
spec:
55+
containers:
56+
- image: iad.ocir.io/__DOCKER_REGISTRY_USERNAME__/oci-flexvolume-driver:__VERSION__
57+
imagePullPolicy: Always
1858
name: oci-flexvolume-driver
1959
securityContext:
2060
privileged: true

test/system/runner.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
MAX_NUM_LOCKFILE_RETRIES = 100
4141
CI_LOCKFILE_PREFIX = "CI"
4242
LOCAL_LOCKFILE_PREFIX = "LOCAL"
43-
DAEMONSET_NAME = "oci-flexvolume-driver"
43+
WORKER_DAEMONSET_NAME = "oci-flexvolume-driver-worker"
44+
MASTER_DAEMONSET_NAME = "oci-flexvolume-driver-master"
4445
CI_APPLICATION_NAME = "oci-flexvolume-driver"
4546
CI_BASE_URL = "https://app.wercker.com/api/v3"
4647
CI_PIPELINE_NAME = "system-test"
@@ -355,29 +356,30 @@ def _create_replication_controller_yaml(using_oci, volume_name, test_id):
355356
volume_name, test_id)
356357

357358

358-
def _is_driver_running():
359-
stdout = _kubectl("-n kube-system get daemonset " + DAEMONSET_NAME + " -o json", log_stdout=False)
359+
def _is_driver_running(name):
360+
stdout = _kubectl("-n kube-system get daemonset " + name + " -o json", log_stdout=False)
360361
jsn = json.loads(stdout)
361362
desired = int(jsn["status"]["desiredNumberScheduled"])
362363
ready = int(jsn["status"]["numberReady"])
363-
_log(" - daemonset " + DAEMONSET_NAME + ": desired: " + str(desired) + ", ready: " + str(ready))
364+
_log(" - daemonset " + name + ": desired: " + str(desired) + ", ready: " + str(ready))
364365
return desired == ready
365366

366367

367-
def _wait_for_driver():
368+
def _wait_for_driver(name):
368369
num_polls = 0
369-
while not _is_driver_running():
370+
while not _is_driver_running(name):
370371
time.sleep(1)
371372
num_polls += 1
372373
if num_polls == TIMEOUT:
373-
_log("Error: Daemonset: " + DAEMONSET_NAME + " " + "failed to achieve running status: ")
374+
_log("Error: Daemonset: " + name + " " + "failed to achieve running status: ")
374375
_finish_with_exit_code(1)
375376

376377

377378
def _install_driver():
378379
_kubectl("delete -f ../../dist/oci-flexvolume-driver.yaml", exit_on_error=False, display_errors=False)
379380
_kubectl("apply -f ../../dist/oci-flexvolume-driver.yaml")
380-
_wait_for_driver()
381+
_wait_for_driver(WORKER_DAEMONSET_NAME)
382+
_wait_for_driver(MASTER_DAEMONSET_NAME)
381383

382384

383385
def _get_pod_infos(test_id):

0 commit comments

Comments
 (0)