Skip to content

New kustomization for pd driver #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,6 @@ roleRef:
apiGroup: rbac.authorization.k8s.io

---
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: csi-gce-pd-node-psp
spec:
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
privileged: true
volumes:
- '*'
hostNetwork: true
allowedHostPaths:
- pathPrefix: "/var/lib/kubelet/plugins_registry/"
- pathPrefix: "/var/lib/kubelet"
- pathPrefix: "/var/lib/kubelet/plugins/pd.csi.storage.gke.io/"
- pathPrefix: "/dev"
- pathPrefix: "/etc/udev"
- pathPrefix: "/lib/udev"
- pathPrefix: "/run/udev"
- pathPrefix: "/sys"
---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -187,6 +160,18 @@ rules:
- csi-gce-pd-node-psp
---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-gce-pd-node-deploy-win
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- csi-gce-pd-node-psp-win
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -196,9 +181,35 @@ roleRef:
kind: ClusterRole
name: csi-gce-pd-node-deploy
subjects:
- kind: ServiceAccount
name: csi-gce-pd-node-sa
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: csi-gce-pd-node-win
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-gce-pd-node-deploy-win
subjects:
- kind: ServiceAccount
name: csi-gce-pd-node-sa

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: csi-gce-pd-controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-gce-pd-node-deploy
subjects:
- kind: ServiceAccount
name: csi-gce-pd-controller-sa

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -231,7 +242,6 @@ roleRef:
kind: ClusterRole
name: csi-gce-pd-snapshotter-role
apiGroup: rbac.authorization.k8s.io

---

kind: Role
Expand Down Expand Up @@ -262,3 +272,4 @@ roleRef:
kind: Role
name: csi-gce-pd-leaderelection-role
apiGroup: rbac.authorization.k8s.io

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
# this requirement when issue is resolved and before any exposure of
# metrics ports
hostNetwork: true
nodeSelector:
kubernetes.io/os: linux
serviceAccountName: csi-gce-pd-controller-sa
priorityClassName: csi-gce-pd-controller
containers:
Expand Down
7 changes: 7 additions & 0 deletions deploy/kubernetes/base/controller/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace:
gce-pd-csi-driver
resources:
- cluster_setup.yaml
- controller.yaml
10 changes: 5 additions & 5 deletions deploy/kubernetes/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
commonLabels:
k8s-app: gcp-compute-persistent-disk-csi-driver
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace:
gce-pd-csi-driver
resources:
- node.yaml
- controller.yaml
- setup-cluster.yaml
- controller
- node_linux
- node_windows
7 changes: 7 additions & 0 deletions deploy/kubernetes/base/node_linux/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace:
gce-pd-csi-driver
resources:
- node.yaml
- psp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ spec:
hostNetwork: true
priorityClassName: csi-gce-pd-node
serviceAccountName: csi-gce-pd-node-sa
nodeSelector:
kubernetes.io/os: linux
containers:
- name: csi-driver-registrar
image: gke.gcr.io/csi-node-driver-registrar
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
- "--kubelet-registration-path=/var/lib/kubelet/plugins/pd.csi.storage.gke.io/csi.sock"
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "rm -rf /registration/pd.csi.storage.gke.io /registration/pd.csi.storage.gke.io-reg.sock"]
env:
- name: KUBE_NODE_NAME
valueFrom:
Expand All @@ -41,14 +39,14 @@ spec:
- name: registration-dir
mountPath: /registration
- name: gce-pd-driver
securityContext:
privileged: true
# Don't change base image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
securityContext:
privileged: true
volumeMounts:
- name: kubelet-dir
mountPath: /var/lib/kubelet
Expand All @@ -67,8 +65,6 @@ spec:
mountPath: /run/udev
- name: sys
mountPath: /sys
nodeSelector:
kubernetes.io/os: linux
volumes:
- name: registration-dir
hostPath:
Expand Down
27 changes: 27 additions & 0 deletions deploy/kubernetes/base/node_linux/psp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: csi-gce-pd-node-psp
spec:
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
privileged: true
volumes:
- '*'
hostNetwork: true
allowedHostPaths:
- pathPrefix: "/var/lib/kubelet/plugins_registry/"
- pathPrefix: "/var/lib/kubelet"
- pathPrefix: "/var/lib/kubelet/plugins/pd.csi.storage.gke.io/"
- pathPrefix: "/dev"
- pathPrefix: "/etc/udev"
- pathPrefix: "/lib/udev"
- pathPrefix: "/run/udev"
- pathPrefix: "/sys"

7 changes: 7 additions & 0 deletions deploy/kubernetes/base/node_windows/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace:
gce-pd-csi-driver
resources:
- node.yaml
- psp.yaml
85 changes: 85 additions & 0 deletions deploy/kubernetes/base/node_windows/node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#TODO(#40): Force DaemonSet to not run on master.
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-gce-pd-node-win
spec:
selector:
matchLabels:
app: gcp-compute-persistent-disk-csi-driver-win
template:
metadata:
labels:
app: gcp-compute-persistent-disk-csi-driver-win
spec:
# Host network must be used for interaction with Workload Identity in GKE
# since it replaces GCE Metadata Server with GKE Metadata Server. Remove
# this requirement when issue is resolved and before any exposure of
# metrics ports. But hostNetwork is not working for Windows, might be an issue
# when deploying on GKE Windows node.
# hostNetwork: true
priorityClassName: csi-gce-pd-node
serviceAccountName: csi-gce-pd-node-sa
nodeSelector:
kubernetes.io/os: windows
containers:
- name: csi-driver-registrar
image: gke.gcr.io/k8s-staging-csi/csi-node-driver-registrar-win
args:
- --v=5
- --csi-address=unix://C:\\csi\\csi.sock
- --kubelet-registration-path=C:\\var\\lib\\kubelet\\plugins\\pd.csi.storage.gke.io\\csi.sock
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: plugin-dir
mountPath: /csi
- name: registration-dir
mountPath: /registration
- name: gce-pd-driver
# Don't change base image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver-win
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
volumeMounts:
- name: kubelet-dir
mountPath: C:\var\lib\kubelet
mountPropagation: "None"
- name: plugin-dir
mountPath: C:\csi
- name: csi-proxy-disk-pipe
mountPath: \\.\pipe\csi-proxy-disk-v1alpha1
- name: csi-proxy-volume-pipe
mountPath: \\.\pipe\csi-proxy-volume-v1alpha1
- name: csi-proxy-filesystem-pipe
mountPath: \\.\pipe\csi-proxy-filesystem-v1alpha1
volumes:
- name: csi-proxy-disk-pipe
hostPath:
path: \\.\pipe\csi-proxy-disk-v1alpha1
type: ""
- name: csi-proxy-volume-pipe
hostPath:
path: \\.\pipe\csi-proxy-volume-v1alpha1
type: ""
- name: csi-proxy-filesystem-pipe
hostPath:
path: \\.\pipe\csi-proxy-filesystem-v1alpha1
type: ""
- name: registration-dir
hostPath:
path: \var\lib\kubelet\plugins_registry
type: Directory
- name: kubelet-dir
hostPath:
path: \var\lib\kubelet
type: Directory
- name: plugin-dir
hostPath:
path: \var\lib\kubelet\plugins\pd.csi.storage.gke.io
type: DirectoryOrCreate
24 changes: 24 additions & 0 deletions deploy/kubernetes/base/node_windows/psp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: csi-gce-pd-node-psp-win
spec:
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
seLinux:
rule: RunAsAny
volumes:
- '*'
hostNetwork: true
allowedHostPaths:
- pathPrefix: \var\lib\kubelet
- pathPrefix: \var\lib\kubelet\plugins_registry
- pathPrefix: \var\lib\kubelet\plugins\pd.csi.storage.gke.io
- pathPrefix: \\.\pipe\csi-proxy-disk-v1alpha1
- pathPrefix: \\.\pipe\csi-proxy-volume-v1alpha1
- pathPrefix: \\.\pipe\csi-proxy-filesystem-v1alpha1

1 change: 0 additions & 1 deletion deploy/kubernetes/deploy-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ ${KUBECTL} version
readonly tmp_spec=/tmp/gcp-compute-persistent-disk-csi-driver-specs-generated.yaml
${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | tee $tmp_spec
${KUBECTL} apply -v="${VERBOSITY}" -f $tmp_spec

18 changes: 18 additions & 0 deletions deploy/kubernetes/images/alpha/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-gcepd-driver-alpha-win
imageTag:
name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver-win
newName: gcr.io/jing-k8s-dev/gce-pd-windows-2019
newTag: "0.2.0"
---

apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-node-registrar-win
imageTag:
name: gke.gcr.io/k8s-staging-csi/csi-node-driver-registrar-win
newName: gcr.io/k8s-staging-csi/csi-node-driver-registrar
newTag: "amd64-windows-v20200428-v1.3.0-26-g510710d5"
5 changes: 5 additions & 0 deletions deploy/kubernetes/images/alpha/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace:
gce-pd-csi-driver
resources:
- ../stable/
- image.yaml
8 changes: 8 additions & 0 deletions deploy/kubernetes/images/dev/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: builtin
kind: ImageTagTransformer
metadata:
name: imagetag-gcepd-driver-dev
imageTag:
name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/dyzz-csi-staging/csi/gce-pd-driver
newTag: "latest"
5 changes: 5 additions & 0 deletions deploy/kubernetes/images/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace:
gce-pd-csi-driver
resources:
- ../alpha/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever need to change the tag for node-driver-registrar in the dev overlay, should it use the image name in base or alpha?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is only for dev, then change the image in the image.yaml file under /dev

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this dev/image.yaml, do we set imageTag.name to the one in base (gke.gcr.io/gcp-compute-persistent-disk-csi-driver-win) or alpha (gke.gcr.io/k8s-staging-csi/csi-node-driver-registrar-win)? And does the answer depend on other factors, like maybe the ordering of items in kustomization.yaml?

I'm not sure if we'll ever need to update node registrar tag name, so we can potentially defer this question until that happens.

Copy link
Contributor Author

@jingxu97 jingxu97 Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no image name gke.gcr.io/gcp-compute-persistent-disk-csi-driver-win (this is for windows) in base (stable).
Generally, the following can happen
in stable, change image name --> nameA
in alpha, change image name --> nameB
if alpha is also based on stable, I think the final image name will be nameA.
Or,
in stable, change image name --> nameA
in alpha, change image nameA --> nameB
if alpha is also based on stable, I think the final image name will be nameB.

This is using ImageTagTransformer. I also tested using both ImageTagTransformer and images section directly in kustomization.yaml. The latter (images section) seems taking the final effect.
There are so many ways to construct this, we just have to try it out.

- image.yaml
Loading