9
9
10
10
# Args:
11
11
# GCE_PD_SA_DIR: Directory the service account key has been saved in (generated by setup-project.sh)
12
- # GCE_PD_DRIVER_VERSION: The version of the GCE PD CSI Driver to deploy. Can be one of {stable, dev}
12
+ # GCE_PD_DRIVER_VERSION: The kustomize overlay (located in
13
+ # deploy/kubernetes/overlays) to deploy. Can be one of {stable, dev}
13
14
14
15
set -o nounset
15
16
set -o errexit
17
+ set -x
16
18
19
+ readonly NAMESPACE=" ${GCE_PD_DRIVER_NAMESPACE:- default} "
20
+ readonly DEPLOY_VERSION=" ${GCE_PD_DRIVER_VERSION:- stable} "
17
21
readonly PKGDIR=" ${GOPATH} /src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver"
18
22
source " ${PKGDIR} /deploy/common.sh"
19
23
20
- ensure_var GCE_PD_SA_DIR
21
- ensure_var GCE_PD_DRIVER_VERSION
24
+ print_usage ()
25
+ {
26
+ echo " deploy-driver.sh [--skip-sa-check]\n"
27
+ echo " \t--skip-sa-check: don't check the service account for required roles"
28
+ echo
29
+ }
22
30
23
- readonly KUBEDEPLOY=" ${PKGDIR} /deploy/kubernetes/${GCE_PD_DRIVER_VERSION} "
31
+ skip_sa_check=
32
+ while [ ! -z " ${1-} " ]; do
33
+ case $1 in
34
+ --skip-sa-check ) shift
35
+ skip_sa_check=true
36
+ ;;
37
+ -h | --help ) print_usage
38
+ exit 1
39
+ ;;
40
+ * ) print_usage
41
+ exit 1
42
+ ;;
43
+ esac
44
+ done
45
+
46
+ ensure_var GCE_PD_SA_DIR
24
47
25
48
function check_service_account()
26
49
{
@@ -47,11 +70,15 @@ function check_service_account()
47
70
fi
48
71
}
49
72
50
- check_service_account
73
+ ensure_kustomize
74
+
75
+ if [ " $skip_sa_check " != true ]; then
76
+ check_service_account
77
+ fi
51
78
52
- if ! kubectl get secret cloud-sa;
79
+ if ! kubectl get secret cloud-sa -n ${NAMESPACE} ;
53
80
then
54
- kubectl create secret generic cloud-sa --from-file=" ${GCE_PD_SA_DIR} /cloud-sa.json"
81
+ kubectl create secret generic cloud-sa --from-file=" ${GCE_PD_SA_DIR} /cloud-sa.json" -n ${NAMESPACE}
55
82
fi
56
83
57
84
# GKE Required Setup
60
87
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $( gcloud config get-value account)
61
88
fi
62
89
63
- kubectl apply -f " ${KUBEDEPLOY} /setup-cluster .yaml"
64
- kubectl apply -f " ${KUBEDEPLOY} /node.yaml "
65
- kubectl apply -f " ${KUBEDEPLOY} /controller.yaml "
90
+ readonly tmp_spec=/tmp/gcp-compute-persistent-disk-csi-driver-specs-generated .yaml
91
+ ${KUSTOMIZE_PATH} build ${PKGDIR} /deploy/kubernetes/overlays/ ${DEPLOY_VERSION} | tee $tmp_spec
92
+ kubectl apply -f $tmp_spec
0 commit comments