diff --git a/Dockerfile b/Dockerfile index 7bc49a1fe6..3194af0192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,5 +16,5 @@ COPY ./examples/flex-debug.sh /opt/csi-provisioner/ COPY ./_output/csi-provisioner /opt/csi-provisioner/ -ENTRYPOINT ["/opt/csi-flex/flex-provision"] +ENTRYPOINT ["/opt/csi-provisioner/csi-provisioner"] diff --git a/Makefile b/Makefile index d58cb6ff48..4f97f353c2 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +IMAGE = k8scsi/csi-provision + VERSION := TAG := $(shell git describe --abbrev=0 --tags HEAD 2>/dev/null) COMMIT := $(shell git rev-parse HEAD) @@ -42,9 +44,13 @@ deps: .PHONY: deps quick-container: - docker build -t kube-csi-provision:latest . + docker build -t $(IMAGE):$(VERSION) . .PHONY: quick-container +push-container: + docker push $(IMAGE):$(VERSION) +.PHONY: push-container + provisioner: mkdir -p _output go build -i -o _output/csi-provisioner ./cmd/csi-provisioner/ diff --git a/cmd/csi-provisioner/csi-provisioner.go b/cmd/csi-provisioner/csi-provisioner.go index 9fd55bde38..d1aa64ec33 100644 --- a/cmd/csi-provisioner/csi-provisioner.go +++ b/cmd/csi-provisioner/csi-provisioner.go @@ -35,10 +35,10 @@ import ( ) var ( - provisioner = flag.String("provisioner", "k8s.io/default", "Name of the provisioner. The provisioner will only provision volumes for claims that request a StorageClass with a provisioner field set equal to this name.") + provisioner = flag.String("provisioner", "k8s.io/flex", "Name of the provisioner. The provisioner will only provision volumes for claims that request a StorageClass with a provisioner field set equal to this name.") master = flag.String("master", "", "Master URL to build a client config from. Either this or kubeconfig needs to be set if the provisioner is being run out of cluster.") kubeconfig = flag.String("kubeconfig", "/var/run/kubernetes/admin.kubeconfig", "Absolute path to the kubeconfig file. Either this or master needs to be set if the provisioner is being run out of cluster.") - csiEndpoint = flag.String("csiendpoint", "/tmp/csi.sock", "The gRPC endpoint for Target CSI Volume") + csiEndpoint = flag.String("csi-address", "/tmp/csi.sock", "The gRPC endpoint for Target CSI Volume") connectionTimeout = flag.Duration("connection-timeout", 10*time.Second, "Timeout for waiting for CSI driver socket.") provisionController *controller.ProvisionController diff --git a/deploy/kubernetes/statefulset.yaml b/deploy/kubernetes/statefulset.yaml new file mode 100644 index 0000000000..1ca21f3433 --- /dev/null +++ b/deploy/kubernetes/statefulset.yaml @@ -0,0 +1,93 @@ +# This YAML file contains all API objects that are necessary to run external +# CSI provisioner. +# +# In production, this needs to be in separate files, e.g. service account and +# role and role binding needs to be created once, while stateful set may +# require some tuning. +# +# In addition, mock CSI driver is hardcoded as the CSI driver. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-provisioner + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-provisioner-runner +rules: + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "update"] + +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-provisioner-role +subjects: + - kind: ServiceAccount + name: csi-provisioner + namespace: default +roleRef: + kind: ClusterRole + name: external-provisioner-runner + apiGroup: rbac.authorization.k8s.io + +--- +kind: Service +apiVersion: v1 +metadata: + name: csi-provisioner + labels: + app: csi-provisioner +spec: + selector: + app: csi-provisioner + ports: + - name: dummy + port: 12345 + +--- +kind: StatefulSet +apiVersion: apps/v1beta1 +metadata: + name: csi-provisioner +spec: + serviceName: "csi-provisioner" + replicas: 1 + template: + metadata: + labels: + app: csi-provisioner + spec: + serviceAccount: csi-provisioner + containers: + - name: csi-provisioner + image: docker.io/k8scsi/csi-provisioner + args: + - "--provisioner=csi-flex" + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/mock.socket + imagePullPolicy: "IfNotPresent" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + + - name: mock-driver + image: docker.io/k8scsi/mock-plugin + env: + - name: CSI_ENDPOINT + value: /var/lib/csi/sockets/pluginproxy/mock.socket + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + + volumes: + - name: socket-dir + emptyDir: +