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

Commit

Permalink
Support flex volume driver configuration via secret
Browse files Browse the repository at this point in the history
  • Loading branch information
Harvey Lowndes committed May 10, 2018
1 parent 3e8a54b commit 1976ac4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
9 changes: 9 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ driver_dir="/flexmnt/$VENDOR${VENDOR:+"~"}${DRIVER}"

LOG_FILE="$driver_dir/oci_flexvolume_driver.log"

config_file_name="config.yaml"
config_tmp_dir="/tmp"

CONFIG_FILE="$config_tmp_dir/$config_file_name"

if [ ! -d "$driver_dir" ]; then
mkdir "$driver_dir"
fi

cp "/$DRIVER" "$driver_dir/.$DRIVER"
mv -f "$driver_dir/.$DRIVER" "$driver_dir/$DRIVER"

if [ -f "$CONFIG_FILE" ]; then
cp "$CONFIG_FILE" "$driver_dir/$config_file_name"
fi

while : ; do
touch $LOG_FILE
tail -f $LOG_FILE
Expand Down
48 changes: 44 additions & 4 deletions manifests/oci-flexvolume-driver.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,60 @@
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: oci-flexvolume-driver
name: oci-flexvolume-driver-master
namespace: kube-system
spec:
template:
metadata:
name: oci-flexvolume-driver
name: oci-flexvolume-driver-master
labels:
app: oci-flexvolume-driver
spec:
nodeSelector:
node-role.kubernetes.io/master: "true"
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
- key: node.cloudprovider.kubernetes.io/uninitialized
value: "true"
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- image: iad.ocir.io/__DOCKER_REGISTRY_USERNAME__/oci-flexvolume-driver:__VERSION__
imagePullPolicy: Always
name: oci-flexvolume-driver
securityContext:
privileged: true
volumeMounts:
- mountPath: /flexmnt
name: flexvolume-mount
- mountPath: /tmp
name: config
readOnly: true
volumes:
- name: flexvolume-mount
hostPath:
path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/
type: DirectoryOrCreate
- name: config
secret:
secretName: oci-flexvolume-driver
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: oci-flexvolume-driver-worker
namespace: kube-system
spec:
template:
metadata:
name: oci-flexvolume-driver-worker
labels:
app: oci-flexvolume-driver
spec:
containers:
- image: iad.ocir.io/__DOCKER_REGISTRY_USERNAME__/oci-flexvolume-driver:__VERSION__
imagePullPolicy: Always
name: oci-flexvolume-driver
securityContext:
privileged: true
Expand Down
18 changes: 10 additions & 8 deletions test/system/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
MAX_NUM_LOCKFILE_RETRIES = 100
CI_LOCKFILE_PREFIX = "CI"
LOCAL_LOCKFILE_PREFIX = "LOCAL"
DAEMONSET_NAME = "oci-flexvolume-driver"
WORKER_DAEMONSET_NAME = "oci-flexvolume-driver-worker"
MASTER_DAEMONSET_NAME = "oci-flexvolume-driver-master"
CI_APPLICATION_NAME = "oci-flexvolume-driver"
CI_BASE_URL = "https://app.wercker.com/api/v3"
CI_PIPELINE_NAME = "system-test"
Expand Down Expand Up @@ -355,29 +356,30 @@ def _create_replication_controller_yaml(using_oci, volume_name, test_id):
volume_name, test_id)


def _is_driver_running():
stdout = _kubectl("-n kube-system get daemonset " + DAEMONSET_NAME + " -o json", log_stdout=False)
def _is_driver_running(name):
stdout = _kubectl("-n kube-system get daemonset " + name + " -o json", log_stdout=False)
jsn = json.loads(stdout)
desired = int(jsn["status"]["desiredNumberScheduled"])
ready = int(jsn["status"]["numberReady"])
_log(" - daemonset " + DAEMONSET_NAME + ": desired: " + str(desired) + ", ready: " + str(ready))
_log(" - daemonset " + name + ": desired: " + str(desired) + ", ready: " + str(ready))
return desired == ready


def _wait_for_driver():
def _wait_for_driver(name):
num_polls = 0
while not _is_driver_running():
while not _is_driver_running(name):
time.sleep(1)
num_polls += 1
if num_polls == TIMEOUT:
_log("Error: Daemonset: " + DAEMONSET_NAME + " " + "failed to achieve running status: ")
_log("Error: Daemonset: " + name + " " + "failed to achieve running status: ")
_finish_with_exit_code(1)


def _install_driver():
_kubectl("delete -f ../../dist/oci-flexvolume-driver.yaml", exit_on_error=False, display_errors=False)
_kubectl("apply -f ../../dist/oci-flexvolume-driver.yaml")
_wait_for_driver()
_wait_for_driver(WORKER_DAEMONSET_NAME)
_wait_for_driver(MASTER_DAEMONSET_NAME)


def _get_pod_infos(test_id):
Expand Down

0 comments on commit 1976ac4

Please sign in to comment.