From a0b20b4448d4b5402e87b6fbb0399675fbba75d5 Mon Sep 17 00:00:00 2001 From: Michael Henriksen Date: Fri, 21 Sep 2018 14:49:33 -0400 Subject: [PATCH 1/6] upload documentation --- doc/upload.md | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 doc/upload.md diff --git a/doc/upload.md b/doc/upload.md new file mode 100644 index 0000000000..4f279b53ea --- /dev/null +++ b/doc/upload.md @@ -0,0 +1,153 @@ +# CDI Upload User Guide +The purpose of this document is to show how to upload a VM disk image on your local system to a PersistentVolumeClaim in Kubernetes. + +## Prerequesites +You have a Kubernetes cluster up and running with CDI installed and at least one PersistentVolume is available. + +Commands/manifests below will be run from the root of the CDI repo against a Minikube cluster. + +If you are using Minikube with the `storage-provisioner` addon enabled. You can create a PersistentVolume like so: + +```bash +cat < Date: Fri, 21 Sep 2018 15:52:25 -0400 Subject: [PATCH 2/6] jq command not required to extract token from UploadTokenRequest --- doc/upload.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/upload.md b/doc/upload.md index 4f279b53ea..9cb816186c 100644 --- a/doc/upload.md +++ b/doc/upload.md @@ -53,7 +53,7 @@ EOF Annotating a PVC with `cdi.kubevirt.io/storage.upload.target` marks the PVC as a target for CDI Upload. Take a look at at `manifests/example/upload-pvc.yaml` for an example. -``` +```yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -78,7 +78,7 @@ kubectl apply -f manifests/example/upload-pvc.yaml Before sending data to the Upload Proxy, and Upload Token must be requested. The CDI API Server validatees that the user has permissions to `post` to `uploadtokenrequest` resources. Take a look at at `manifests/example/upload-token.yaml` for an example. -``` +```yaml apiVersion: upload.cdi.kubevirt.io/v1alpha1 kind: UploadTokenRequest metadata: @@ -106,9 +106,9 @@ status: ``` Save the `token` field of the response status. It will be used to authorize our CDI Upload request. Tokens are good for 5 minutes. -If you have [jq](https://github.com/stedolan/jq) installed, you can capture the token in an environment variable by doing something like this: +You can capture the token in an environment variable by doing this: ```bash -TOKEN=`kubectl apply -f manifests/example/upload-token.yaml -o json | jq -r '.status.token'` +TOKEN=$(kubectl apply -f manifests/example/upload-token.yaml -o="jsonpath={.status.token}") ``` ## Upload an Image From 3af10bd239bca3a6465b61d4d77cec133f3a246e Mon Sep 17 00:00:00 2001 From: Michael Henriksen Date: Mon, 24 Sep 2018 12:52:38 -0400 Subject: [PATCH 3/6] add minishift route and upload command example --- doc/upload.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/upload.md b/doc/upload.md index 9cb816186c..84f0b2053c 100644 --- a/doc/upload.md +++ b/doc/upload.md @@ -27,7 +27,7 @@ EOF ## Expose cdi-uploadproxy service In order to upload data to your cluster, the cdi-uploadproxy service must be accessible from outside the cluster. In a production environment, the probably involves setting up a Ingress or a LoadBalancer Service. -For Minikube, you can exexute the following which will create a NodePort service accessible from your host: +### Minikube ```bash cat < Date: Tue, 25 Sep 2018 09:50:49 -0400 Subject: [PATCH 4/6] fix typo --- doc/upload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/upload.md b/doc/upload.md index 84f0b2053c..782df11a8a 100644 --- a/doc/upload.md +++ b/doc/upload.md @@ -25,7 +25,7 @@ EOF ``` ## Expose cdi-uploadproxy service -In order to upload data to your cluster, the cdi-uploadproxy service must be accessible from outside the cluster. In a production environment, the probably involves setting up a Ingress or a LoadBalancer Service. +In order to upload data to your cluster, the cdi-uploadproxy service must be accessible from outside the cluster. In a production environment, this probably involves setting up a Ingress or a LoadBalancer Service. ### Minikube From 903186b22e6f4bc759ff548fbada87e642c8936c Mon Sep 17 00:00:00 2001 From: Michael Henriksen Date: Tue, 25 Sep 2018 11:22:53 -0400 Subject: [PATCH 5/6] remove host from route because it's confusing --- doc/upload.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/upload.md b/doc/upload.md index 782df11a8a..a04b987423 100644 --- a/doc/upload.md +++ b/doc/upload.md @@ -52,14 +52,13 @@ EOF ### Minishift ```bash -cat < Date: Thu, 27 Sep 2018 08:57:48 -0400 Subject: [PATCH 6/6] use nip.io for minishift --- doc/upload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/upload.md b/doc/upload.md index a04b987423..1322fc6cf9 100644 --- a/doc/upload.md +++ b/doc/upload.md @@ -142,7 +142,7 @@ curl -v --insecure -H "Authorization: Bearer $TOKEN" --data-binary @tests/images ### Minishift ```bash -curl -v --insecure --resolve cdi-uploadproxy:443:$(minishift ip) -H "Authorization: Bearer $TOKEN" --data-binary @tests/images/cirros-qcow2.img https://cdi-uploadproxy/v1alpha1/upload +curl -v --insecure -H "Authorization: Bearer $TOKEN" --data-binary @tests/images/cirros-qcow2.img https://cdi-uploadproxy-kube-system.$(minishift ip).nip.io/v1alpha1/upload ``` Assuming you did not get an error, the PVC `upload-test` should now contain a bootable VM image.