From 6d121b49b5520622b2ea7a84b4e06a573591c286 Mon Sep 17 00:00:00 2001 From: Nitish Date: Mon, 13 Feb 2017 23:11:21 +0530 Subject: [PATCH 01/11] Add Minio example --- examples/storage/minio/README.md | 61 +++++++++++++++++++ .../minio/minio-standalone-deployment.yaml | 39 ++++++++++++ .../storage/minio/minio-standalone-pvc.yaml | 17 ++++++ .../minio/minio-standalone-service.yaml | 12 ++++ 4 files changed, 129 insertions(+) create mode 100644 examples/storage/minio/README.md create mode 100644 examples/storage/minio/minio-standalone-deployment.yaml create mode 100644 examples/storage/minio/minio-standalone-pvc.yaml create mode 100644 examples/storage/minio/minio-standalone-service.yaml diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md new file mode 100644 index 00000000000..7b50d140ad3 --- /dev/null +++ b/examples/storage/minio/README.md @@ -0,0 +1,61 @@ +# Cloud Native Deployment of Minio using Kubernetes + +## Table of Contents + + - [Prerequisites](#prerequisites) + - [Minio Docker](#minio-docker) + - [Get Started](#get-started) + + Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. + + The following document describes the process to deploy [Minio](https://minio.io/) on Kubernetes. Minio is a _cloud native_ application, meaning + Minio understands that it is running within a cluster manager, and uses this cluster management infrastructure for allocation of compute and storage + resources. + + This example uses some of the core components of Kubernetes: + + - [_Pods_](https://kubernetes.io/docs/user-guide/pods/) + - [_Services_](https://kubernetes.io/docs/user-guide/services/) + - [_Deployments_](https://kubernetes.io/docs/user-guide/deployments/) + - [_Persistent Volume Claims_](https://kubernetes.io/docs/user-guide/persistent-volumes/#persistentvolumeclaims) + + ## Prerequisites + + This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, + and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) + command line tool somewhere in your path. Please see the + [getting started guides](../../../docs/getting-started-guides/) + for installation instructions for your platform. + + ## Minio Docker + + The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. + + ## Get Started + + But before creating the deployment, you need to create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. Create a PersistentVolumeClaim by downloading the file [minio-standalone-pvc.yaml] (minio-standalone-pvc.yaml?raw=true) and running + + ```sh + kubectl create -f minio-standalone-pvc.yaml + ``` + + A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. Create the Minio Deployment by downloading the file [minio-standalone-deployment.yaml] (minio-standalone-deployment.yaml?raw=true) and running + + ```sh + kubectl create -f minio-standalone-deployment.yaml + ``` + + Now that you have a Minio deployment running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. + + In this example, we expose the Minio Deployment by creating a LoadBalancer service. Download the file [minio-standalone-service.yaml] (minio-standalone-service.yaml?raw=true) and running + + ```sh + kubectl create -f minio-standalone-service.yaml + ``` + + Once you are done, cleanup the cluster using + ```sh + kubectl delete deployment minio-deployment \ + && kubectl delete pvc minio-pv-claim \ + && kubectl delete svc minio-service + ``` diff --git a/examples/storage/minio/minio-standalone-deployment.yaml b/examples/storage/minio/minio-standalone-deployment.yaml new file mode 100644 index 00000000000..6d234e2f276 --- /dev/null +++ b/examples/storage/minio/minio-standalone-deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + # This name uniquely identifies the Deployment + name: minio-deployment +spec: + strategy: + type: Recreate + template: + metadata: + labels: + # Label is used as selector in the service. + app: minio-server + spec: + # Refer to the PVC created earlier + volumes: + - name: storage + persistentVolumeClaim: + # Name of the PVC created earlier + claimName: minio-pv-claim + containers: + - name: minio + # Pulls the default Minio image from Docker Hub + image: minio/minio + command: ["minio"] + args: ["server", "/storage"] + env: + # Minio access key and secret key + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + ports: + - containerPort: 9000 + hostPort: 9000 + # Mount the volume into the pod + volumeMounts: + - name: storage # must match the volume name, above + mountPath: "/storage" diff --git a/examples/storage/minio/minio-standalone-pvc.yaml b/examples/storage/minio/minio-standalone-pvc.yaml new file mode 100644 index 00000000000..edd05215a9e --- /dev/null +++ b/examples/storage/minio/minio-standalone-pvc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + # This name uniquely identifies the PVC. Will be used in deployment below. + name: minio-pv-claim + annotations: + volume.alpha.kubernetes.io/storage-class: anything + labels: + app: minio-storage-claim +spec: + # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes + accessModes: + - ReadWriteOnce + resources: + # This is the request for storage. Should be available in the cluster. + requests: + storage: 10Gi diff --git a/examples/storage/minio/minio-standalone-service.yaml b/examples/storage/minio/minio-standalone-service.yaml new file mode 100644 index 00000000000..4d4ad7a562a --- /dev/null +++ b/examples/storage/minio/minio-standalone-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + type: LoadBalancer + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio-server From dd20e14ceb3c030938f582c0bc9c8ea80937e2fc Mon Sep 17 00:00:00 2001 From: Nitish Date: Mon, 13 Feb 2017 23:19:29 +0530 Subject: [PATCH 02/11] Updated read --- examples/storage/minio/README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index 7b50d140ad3..f6ffbe2002b 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -1,18 +1,20 @@ -# Cloud Native Deployment of Minio using Kubernetes + # Cloud Native Deployment of Minio using Kubernetes -## Table of Contents + ## Table of Contents + - [Introduction](#introduction) - [Prerequisites](#prerequisites) - - [Minio Docker](#minio-docker) - [Get Started](#get-started) + ## Introduction + Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. The following document describes the process to deploy [Minio](https://minio.io/) on Kubernetes. Minio is a _cloud native_ application, meaning Minio understands that it is running within a cluster manager, and uses this cluster management infrastructure for allocation of compute and storage resources. - This example uses some of the core components of Kubernetes: + The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. This example uses some of the core components of Kubernetes: - [_Pods_](https://kubernetes.io/docs/user-guide/pods/) - [_Services_](https://kubernetes.io/docs/user-guide/services/) @@ -27,10 +29,6 @@ [getting started guides](../../../docs/getting-started-guides/) for installation instructions for your platform. - ## Minio Docker - - The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. - ## Get Started But before creating the deployment, you need to create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. Create a PersistentVolumeClaim by downloading the file [minio-standalone-pvc.yaml] (minio-standalone-pvc.yaml?raw=true) and running From 9ee4b63bd7f7ca9215f63b4be0e3d960b297e6ae Mon Sep 17 00:00:00 2001 From: Nitish Date: Mon, 13 Feb 2017 23:20:43 +0530 Subject: [PATCH 03/11] Updated Readme --- examples/storage/minio/README.md | 83 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index f6ffbe2002b..f45890fb2cb 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -1,59 +1,58 @@ - # Cloud Native Deployment of Minio using Kubernetes +# Cloud Native Deployment of Minio using Kubernetes - ## Table of Contents +## Table of Contents - - [Introduction](#introduction) - - [Prerequisites](#prerequisites) - - [Get Started](#get-started) +- [Introduction](#introduction) +- [Prerequisites](#prerequisites) +- [Get Started](#get-started) - ## Introduction +## Introduction +Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. - Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. +The following document describes the process to deploy [Minio](https://minio.io/) on Kubernetes. Minio is a _cloud native_ application, meaning +Minio understands that it is running within a cluster manager, and uses this cluster management infrastructure for allocation of compute and storage +resources. - The following document describes the process to deploy [Minio](https://minio.io/) on Kubernetes. Minio is a _cloud native_ application, meaning - Minio understands that it is running within a cluster manager, and uses this cluster management infrastructure for allocation of compute and storage - resources. +The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. This example uses some of the core components of Kubernetes: - The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. This example uses some of the core components of Kubernetes: +- [_Pods_](https://kubernetes.io/docs/user-guide/pods/) +- [_Services_](https://kubernetes.io/docs/user-guide/services/) +- [_Deployments_](https://kubernetes.io/docs/user-guide/deployments/) +- [_Persistent Volume Claims_](https://kubernetes.io/docs/user-guide/persistent-volumes/#persistentvolumeclaims) - - [_Pods_](https://kubernetes.io/docs/user-guide/pods/) - - [_Services_](https://kubernetes.io/docs/user-guide/services/) - - [_Deployments_](https://kubernetes.io/docs/user-guide/deployments/) - - [_Persistent Volume Claims_](https://kubernetes.io/docs/user-guide/persistent-volumes/#persistentvolumeclaims) +## Prerequisites - ## Prerequisites +This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, +and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) +command line tool somewhere in your path. Please see the +[getting started guides](../../../docs/getting-started-guides/) +for installation instructions for your platform. - This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, - and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) - command line tool somewhere in your path. Please see the - [getting started guides](../../../docs/getting-started-guides/) - for installation instructions for your platform. +## Get Started - ## Get Started +But before creating the deployment, you need to create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. Create a PersistentVolumeClaim by downloading the file [minio-standalone-pvc.yaml] (minio-standalone-pvc.yaml?raw=true) and running - But before creating the deployment, you need to create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. Create a PersistentVolumeClaim by downloading the file [minio-standalone-pvc.yaml] (minio-standalone-pvc.yaml?raw=true) and running +```sh +kubectl create -f minio-standalone-pvc.yaml +``` - ```sh - kubectl create -f minio-standalone-pvc.yaml - ``` +A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. Create the Minio Deployment by downloading the file [minio-standalone-deployment.yaml] (minio-standalone-deployment.yaml?raw=true) and running - A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. Create the Minio Deployment by downloading the file [minio-standalone-deployment.yaml] (minio-standalone-deployment.yaml?raw=true) and running +```sh +kubectl create -f minio-standalone-deployment.yaml +``` - ```sh - kubectl create -f minio-standalone-deployment.yaml - ``` +Now that you have a Minio deployment running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. - Now that you have a Minio deployment running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. +In this example, we expose the Minio Deployment by creating a LoadBalancer service. Download the file [minio-standalone-service.yaml] (minio-standalone-service.yaml?raw=true) and running - In this example, we expose the Minio Deployment by creating a LoadBalancer service. Download the file [minio-standalone-service.yaml] (minio-standalone-service.yaml?raw=true) and running +```sh +kubectl create -f minio-standalone-service.yaml +``` - ```sh - kubectl create -f minio-standalone-service.yaml - ``` - - Once you are done, cleanup the cluster using - ```sh - kubectl delete deployment minio-deployment \ - && kubectl delete pvc minio-pv-claim \ - && kubectl delete svc minio-service - ``` +Once you are done, cleanup the cluster using +```sh +kubectl delete deployment minio-deployment \ +&& kubectl delete pvc minio-pv-claim \ +&& kubectl delete svc minio-service +``` From 0a580596ab3a5127882916c6a73c8033d77e77ec Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 14 Feb 2017 14:19:21 +0530 Subject: [PATCH 04/11] Added detailed steps --- examples/storage/minio/README.md | 162 ++++++++++++++++++++++++++++--- 1 file changed, 150 insertions(+), 12 deletions(-) diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index f45890fb2cb..c784453a555 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -4,16 +4,18 @@ - [Introduction](#introduction) - [Prerequisites](#prerequisites) -- [Get Started](#get-started) +- [Quickstart](#quickstart) +- [Step 1: Create Persistent Volume Claim](#step1-create-persistent-volume-claim) +- [Step 2: Create Deployment](#step2-create-deployment) +- [Step 3: Create LoadBalancer Service](#step3-create-loadbalancer-service) +- [Step 4: Resource cleanup](#step4-resource-cleanup) ## Introduction -Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. +Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. Minio is _cloud native_, meaning Minio understands that it is running within a cluster manager, and uses the cluster management infrastructure for allocation of compute and storage resources. -The following document describes the process to deploy [Minio](https://minio.io/) on Kubernetes. Minio is a _cloud native_ application, meaning -Minio understands that it is running within a cluster manager, and uses this cluster management infrastructure for allocation of compute and storage -resources. +The following document describes the process to deploy standalone [Minio](https://minio.io/) server on Kubernetes. The deployment uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. -The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. This example uses some of the core components of Kubernetes: +This example uses some of the core components of Kubernetes: - [_Pods_](https://kubernetes.io/docs/user-guide/pods/) - [_Services_](https://kubernetes.io/docs/user-guide/services/) @@ -22,34 +24,170 @@ The pods use the [official Minio Docker image](https://hub.docker.com/r/minio/mi ## Prerequisites -This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, -and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) +This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) command line tool somewhere in your path. Please see the [getting started guides](../../../docs/getting-started-guides/) for installation instructions for your platform. -## Get Started +## Quickstart -But before creating the deployment, you need to create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. Create a PersistentVolumeClaim by downloading the file [minio-standalone-pvc.yaml] (minio-standalone-pvc.yaml?raw=true) and running +Run the below commands to get started quickly + +```sh +kubectl create -f examples/storage/minio/minio-standalone-pvc.yaml +kubectl create -f examples/storage/minio/minio-standalone-deployment.yaml +kubectl create -f examples/storage/minio/minio-standalone-service.yaml +``` + +## Step 1: Create Persistent Volume Claim + +Minio needs persistent storage to store objects. If there is no +persistent storage, the data stored in Minio instance will be stored in the container file system and will be wiped off as soon as the container restarts. + +Create a persistent volume claim (PVC) to request storage for the Minio instance. Kubernetes looks out for PVs matching the PVC request in the cluster and binds it to the PVC automatically. + +This is the PVC description. + +```sh +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + # This name uniquely identifies the PVC. Will be used in deployment below. + name: minio-pv-claim + annotations: + volume.alpha.kubernetes.io/storage-class: anything + labels: + app: minio-storage-claim +spec: + # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes + accessModes: + - ReadWriteOnce + resources: + # This is the request for storage. Should be available in the cluster. + requests: + storage: 10Gi +``` +[Download example] (minio-standalone-pvc.yaml?raw=true) + +Create the PersistentVolumeClaim ```sh kubectl create -f minio-standalone-pvc.yaml ``` +The response should be like this: -A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. Create the Minio Deployment by downloading the file [minio-standalone-deployment.yaml] (minio-standalone-deployment.yaml?raw=true) and running +```sh +persistentvolumeclaim "minio-pv-claim" created +``` + +# Step 2: Create Minio Deployment + +A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. + +This is the deployment description. + +```sh +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + # This name uniquely identifies the Deployment + name: minio-deployment +spec: + strategy: + type: Recreate + template: + metadata: + labels: + # Label is used as selector in the service. + app: minio-server + spec: + # Refer to the PVC created earlier + volumes: + - name: storage + persistentVolumeClaim: + # Name of the PVC created earlier + claimName: minio-pv-claim + containers: + - name: minio + # Pulls the default Minio image from Docker Hub + image: minio/minio + command: ["minio"] + args: ["server", "/storage"] + env: + # Minio access key and secret key + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + ports: + - containerPort: 9000 + hostPort: 9000 + # Mount the volume into the pod + volumeMounts: + - name: storage # must match the volume name, above + mountPath: "/storage" +``` + +[Download example] (minio-standalone-deployment.yaml?raw=true) + +Create the Deployment ```sh kubectl create -f minio-standalone-deployment.yaml ``` +The response should be like this + +```sh +deployment "minio-deployment" created +``` + +# Step 3: Create Minio Service + Now that you have a Minio deployment running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. -In this example, we expose the Minio Deployment by creating a LoadBalancer service. Download the file [minio-standalone-service.yaml] (minio-standalone-service.yaml?raw=true) and running +In this example, we expose the Minio Deployment by creating a LoadBalancer service. This is the service description. + +```sh +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + type: LoadBalancer + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio-server +``` + +[Download example] (minio-standalone-service.yaml?raw=true) ```sh kubectl create -f minio-standalone-service.yaml ``` +The response should be like this + +```sh +service "minio-service" created +``` +To check if the service was created successfully, run the command + +```sh +kubectl get svc minio-service +``` + +You should get a response like this +```sh +NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE +minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m +``` + +# Step 4: Resource cleanup + Once you are done, cleanup the cluster using ```sh kubectl delete deployment minio-deployment \ From cf356188026c98b821d18fba3a706ad2181ef5d7 Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 14 Feb 2017 14:22:11 +0530 Subject: [PATCH 05/11] Fix links --- examples/storage/minio/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index c784453a555..e54c64adaa1 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -5,10 +5,10 @@ - [Introduction](#introduction) - [Prerequisites](#prerequisites) - [Quickstart](#quickstart) -- [Step 1: Create Persistent Volume Claim](#step1-create-persistent-volume-claim) -- [Step 2: Create Deployment](#step2-create-deployment) -- [Step 3: Create LoadBalancer Service](#step3-create-loadbalancer-service) -- [Step 4: Resource cleanup](#step4-resource-cleanup) +- [Step 1: Create Persistent Volume Claim](#step-1-create-persistent-volume-claim) +- [Step 2: Create Deployment](#step-2-create-deployment) +- [Step 3: Create LoadBalancer Service](#step-3-create-loadbalancer-service) +- [Step 4: Resource cleanup](#step-4-resource-cleanup) ## Introduction Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. Minio is _cloud native_, meaning Minio understands that it is running within a cluster manager, and uses the cluster management infrastructure for allocation of compute and storage resources. From ee59ecb9ff604dc10edd7eff093fc38209ada569 Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 14 Feb 2017 14:24:36 +0530 Subject: [PATCH 06/11] Fix links --- examples/storage/minio/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index e54c64adaa1..802c0ca90d6 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -6,8 +6,8 @@ - [Prerequisites](#prerequisites) - [Quickstart](#quickstart) - [Step 1: Create Persistent Volume Claim](#step-1-create-persistent-volume-claim) -- [Step 2: Create Deployment](#step-2-create-deployment) -- [Step 3: Create LoadBalancer Service](#step-3-create-loadbalancer-service) +- [Step 2: Create Deployment](#step-2-create-minio-deployment) +- [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) - [Step 4: Resource cleanup](#step-4-resource-cleanup) ## Introduction From 6dae1a7580f540cc6965d84bdc3bc461e5e7a08b Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 14 Feb 2017 15:11:42 +0530 Subject: [PATCH 07/11] Add distributed Minio example --- examples/storage/minio-distributed/README.md | 195 ++++++++++++++++++ .../minio-distributed-headless-service.yaml | 13 ++ .../minio-distributed-service.yaml | 14 ++ .../minio-distributed-statefulset.yaml | 44 ++++ 4 files changed, 266 insertions(+) create mode 100644 examples/storage/minio-distributed/README.md create mode 100644 examples/storage/minio-distributed/minio-distributed-headless-service.yaml create mode 100644 examples/storage/minio-distributed/minio-distributed-service.yaml create mode 100644 examples/storage/minio-distributed/minio-distributed-statefulset.yaml diff --git a/examples/storage/minio-distributed/README.md b/examples/storage/minio-distributed/README.md new file mode 100644 index 00000000000..0ae411d76b7 --- /dev/null +++ b/examples/storage/minio-distributed/README.md @@ -0,0 +1,195 @@ +# Cloud Native Deployment of Distributed Minio using Kubernetes + +## Table of Contents + +- [Introduction](#introduction) +- [Prerequisites](#prerequisites) +- [Quickstart](#quickstart) +- [Step 1: Create Minio Headless Service](#step-1-create-minio-headless-service) +- [Step 2: Create Minio Statefulset](#step-2-create-minio-statefulset) +- [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) +- [Step 4: Resource cleanup](#step-4-resource-cleanup) + +## Introduction +Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. Minio is _cloud native_, meaning Minio understands that it +is running within a cluster manager, and uses the cluster management infrastructure for allocation of compute and storage resources. + +The following document describes the process to deploy [distributed Minio](https://docs.minio.io/docs/distributed-minio-quickstart-guide) server on Kubernetes. +This example uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. + +This example uses some of the core components of Kubernetes: + +- [_Pods_](https://kubernetes.io/docs/user-guide/pods/) +- [_Services_](https://kubernetes.io/docs/user-guide/services/) +- [_Statefulsets_](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/) + +## Prerequisites + +This example assumes that you have a Kubernetes version >=1.5 cluster installed and running, and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) +command line tool somewhere in your path. Please see the +[getting started guides](../../../docs/getting-started-guides/) +for installation instructions for your platform. + +## Quickstart + +Run the below commands to get started quickly + +```sh +kubectl create -f examples/storage/minio/minio-distributed-headless-service.yaml +kubectl create -f examples/storage/minio/minio-distributed-statefulset.yaml +kubectl create -f examples/storage/minio/minio-distributed-service.yaml +``` + +## Step 1: Create Minio Headless Service + +Headless Service controls the domain within which we create StatefulSets. The domain managed by this Service takes the form: `$(service name).$(namespace).svc.cluster.local` (where “cluster.local” is the cluster domain), and the pods in this domain take the form: `$(pod-name-{i}).$(service name).$(namespace).svc.cluster.local`. This is required to get a DNS resolvable URL for each of the pods created within the Statefulset. + +This is the Headless service description. + +```sh +apiVersion: v1 +kind: Service +metadata: + name: minio + labels: + app: minio +spec: + clusterIP: None + ports: + - port: 9000 + name: minio + selector: + app: minio +``` +[Download example] (minio-distributed-headless-service.yaml?raw=true) + +Create the Headless Service + +```sh +kubectl create -f minio-distributed-headless-service.yaml +``` +The response should be like this: + +```sh +service "minio" created +``` + +# Step 2: Create Minio Statefulset + +A StatefulSet provides a deterministic name and a unique identity to each pod, making it easy to deploy stateful distributed applications. To launch distributed Minio you need to pass drive locations as parameters to the minio server command. Then, you’ll need to run the same command on all the participating pods. StatefulSets offer a perfect way to handle this requirement. + +This is the Statefulset description. + +```sh +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: minio +spec: + serviceName: "minio" + replicas: 4 + template: + metadata: + annotations: + pod.alpha.kubernetes.io/initialized: "true" + labels: + app: minio + spec: + containers: + - name: minio + env: + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + image: minio/minio + command: ["minio"] + args: ["server", "http://minio-0.minio.default.svc.cluster.local/data", "http://minio-1.minio.default.svc.cluster.local/data", "http://minio-2.minio.default.svc.cluster.local/data", "http://minio-3.minio.default.svc.cluster.local/data"] + ports: + - containerPort: 9000 + hostPort: 9000 + # These volume mounts are persistent. Each pod in the PetSet + # gets a volume mounted based on this field. + volumeMounts: + - name: data + mountPath: /data + # These are converted to volume claims by the controller + # and mounted at the paths mentioned above. + volumeClaimTemplates: + - metadata: + name: data + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 10Gi +``` + +[Download example] (minio-distributed-statefulset.yaml?raw=true) + +Create the Statefulset + +```sh +kubectl create -f minio-distributed-statefulset.yaml +``` + +The response should be like this + +```sh +statefulset "minio" created +``` + +# Step 3: Create Minio Service + +Now that you have a Minio statefulset running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. + +In this example, we expose the Minio Deployment by creating a LoadBalancer service. This is the service description. + +```sh +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + type: LoadBalancer + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio-server +``` + +[Download example] (minio-distributed-service.yaml?raw=true) + +```sh +kubectl create -f minio-distributed-service.yaml +``` + +The response should be like this + +```sh +service "minio-service" created +``` +To check if the service was created successfully, run the command + +```sh +kubectl get svc minio-service +``` + +You should get a response like this +```sh +NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE +minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m +``` + +# Step 4: Resource cleanup + +Once you are done, cleanup the cluster using +```sh +kubectl delete statefulset minio \ +&& kubectl delete svc minio \ +&& kubectl delete svc minio-service +``` diff --git a/examples/storage/minio-distributed/minio-distributed-headless-service.yaml b/examples/storage/minio-distributed/minio-distributed-headless-service.yaml new file mode 100644 index 00000000000..a822d76ebaf --- /dev/null +++ b/examples/storage/minio-distributed/minio-distributed-headless-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: minio + labels: + app: minio +spec: + clusterIP: None + ports: + - port: 9000 + name: minio + selector: + app: minio diff --git a/examples/storage/minio-distributed/minio-distributed-service.yaml b/examples/storage/minio-distributed/minio-distributed-service.yaml new file mode 100644 index 00000000000..1428732a60d --- /dev/null +++ b/examples/storage/minio-distributed/minio-distributed-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: minio-service + labels: + app: minio +spec: + ports: + - port: 9000 + targetPort: 9000 + protocol: "TCP" + name: minio + selector: + app: minio diff --git a/examples/storage/minio-distributed/minio-distributed-statefulset.yaml b/examples/storage/minio-distributed/minio-distributed-statefulset.yaml new file mode 100644 index 00000000000..779ec935f8d --- /dev/null +++ b/examples/storage/minio-distributed/minio-distributed-statefulset.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: minio +spec: + serviceName: "minio" + replicas: 4 + template: + metadata: + annotations: + pod.alpha.kubernetes.io/initialized: "true" + labels: + app: minio + spec: + containers: + - name: minio + env: + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + image: minio/minio + command: ["minio"] + args: ["server", "http://minio-0.minio.default.svc.cluster.local/data", "http://minio-1.minio.default.svc.cluster.local/data", "http://minio-2.minio.default.svc.cluster.local/data", "http://minio-3.minio.default.svc.cluster.local/data"] + ports: + - containerPort: 9000 + hostPort: 9000 + # These volume mounts are persistent. Each pod in the PetSet + # gets a volume mounted based on this field. + volumeMounts: + - name: data + mountPath: /data + # These are converted to volume claims by the controller + # and mounted at the paths mentioned above. + volumeClaimTemplates: + - metadata: + name: data + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 10Gi From 1391c647bb45ae0fd5ca8c39035831367c8308d3 Mon Sep 17 00:00:00 2001 From: Nitish Date: Wed, 15 Feb 2017 11:59:40 +0530 Subject: [PATCH 08/11] Added absolute URLs for config yaml files --- examples/storage/minio-distributed/README.md | 6 +++--- examples/storage/minio/README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/storage/minio-distributed/README.md b/examples/storage/minio-distributed/README.md index 0ae411d76b7..a54c5c4ac08 100644 --- a/examples/storage/minio-distributed/README.md +++ b/examples/storage/minio-distributed/README.md @@ -35,9 +35,9 @@ for installation instructions for your platform. Run the below commands to get started quickly ```sh -kubectl create -f examples/storage/minio/minio-distributed-headless-service.yaml -kubectl create -f examples/storage/minio/minio-distributed-statefulset.yaml -kubectl create -f examples/storage/minio/minio-distributed-service.yaml +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-headless-service.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-statefulset.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-service.yaml?raw=true ``` ## Step 1: Create Minio Headless Service diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index 802c0ca90d6..7889b3893c4 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -34,9 +34,9 @@ for installation instructions for your platform. Run the below commands to get started quickly ```sh -kubectl create -f examples/storage/minio/minio-standalone-pvc.yaml -kubectl create -f examples/storage/minio/minio-standalone-deployment.yaml -kubectl create -f examples/storage/minio/minio-standalone-service.yaml +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-pvc.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-deployment.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-service.yaml?raw=true ``` ## Step 1: Create Persistent Volume Claim From 32707fb318ae0f65b295eaaf8eceb21055b5c83a Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 20 Feb 2017 20:12:51 +0530 Subject: [PATCH 09/11] Updated the service type --- .../storage/minio-distributed/minio-distributed-service.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/storage/minio-distributed/minio-distributed-service.yaml b/examples/storage/minio-distributed/minio-distributed-service.yaml index 1428732a60d..d1a24d6f669 100644 --- a/examples/storage/minio-distributed/minio-distributed-service.yaml +++ b/examples/storage/minio-distributed/minio-distributed-service.yaml @@ -5,6 +5,7 @@ metadata: labels: app: minio spec: + type: LoadBalancer ports: - port: 9000 targetPort: 9000 From 26e274e3c9f87b8c21868a35c2997a7ae27a3e48 Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 7 Mar 2017 22:44:03 +0530 Subject: [PATCH 10/11] Updated as per review comments. --- examples/storage/minio-distributed/README.md | 56 +++++++------------ .../minio-distributed-service.yaml | 5 +- .../minio-distributed-statefulset.yaml | 15 +++-- examples/storage/minio/README.md | 44 +++++---------- .../minio/minio-standalone-deployment.yaml | 9 ++- .../minio/minio-standalone-service.yaml | 2 +- 6 files changed, 53 insertions(+), 78 deletions(-) diff --git a/examples/storage/minio-distributed/README.md b/examples/storage/minio-distributed/README.md index a54c5c4ac08..b54e87b7e06 100644 --- a/examples/storage/minio-distributed/README.md +++ b/examples/storage/minio-distributed/README.md @@ -42,7 +42,7 @@ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/ ## Step 1: Create Minio Headless Service -Headless Service controls the domain within which we create StatefulSets. The domain managed by this Service takes the form: `$(service name).$(namespace).svc.cluster.local` (where “cluster.local” is the cluster domain), and the pods in this domain take the form: `$(pod-name-{i}).$(service name).$(namespace).svc.cluster.local`. This is required to get a DNS resolvable URL for each of the pods created within the Statefulset. +Headless Service controls the domain within which StatefulSets are created. The domain managed by this Service takes the form: `$(service name).$(namespace).svc.cluster.local` (where “cluster.local” is the cluster domain), and the pods in this domain take the form: `$(pod-name-{i}).$(service name).$(namespace).svc.cluster.local`. This is required to get a DNS resolvable URL for each of the pods created within the Statefulset. This is the Headless service description. @@ -61,16 +61,11 @@ spec: selector: app: minio ``` -[Download example] (minio-distributed-headless-service.yaml?raw=true) Create the Headless Service ```sh -kubectl create -f minio-distributed-headless-service.yaml -``` -The response should be like this: - -```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-headless-service.yaml?raw=true service "minio" created ``` @@ -86,7 +81,7 @@ kind: StatefulSet metadata: name: minio spec: - serviceName: "minio" + serviceName: minio replicas: 4 template: metadata: @@ -103,8 +98,14 @@ spec: - name: MINIO_SECRET_KEY value: "minio123" image: minio/minio - command: ["minio"] - args: ["server", "http://minio-0.minio.default.svc.cluster.local/data", "http://minio-1.minio.default.svc.cluster.local/data", "http://minio-2.minio.default.svc.cluster.local/data", "http://minio-3.minio.default.svc.cluster.local/data"] + command: + - minio + args: + - server + - http://minio-0.minio.default.svc.cluster.local/data + - http://minio-1.minio.default.svc.cluster.local/data + - http://minio-2.minio.default.svc.cluster.local/data + - http://minio-3.minio.default.svc.cluster.local/data ports: - containerPort: 9000 hostPort: 9000 @@ -121,23 +122,17 @@ spec: annotations: volume.alpha.kubernetes.io/storage-class: anything spec: - accessModes: [ "ReadWriteOnce" ] + accessModes: + - ReadWriteOnce resources: requests: storage: 10Gi ``` -[Download example] (minio-distributed-statefulset.yaml?raw=true) - Create the Statefulset ```sh -kubectl create -f minio-distributed-statefulset.yaml -``` - -The response should be like this - -```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-statefulset.yaml?raw=true statefulset "minio" created ``` @@ -159,35 +154,26 @@ spec: targetPort: 9000 protocol: TCP selector: - app: minio-server + app: minio ``` - -[Download example] (minio-distributed-service.yaml?raw=true) - -```sh -kubectl create -f minio-distributed-service.yaml -``` - -The response should be like this +Create the Minio service ```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-service.yaml?raw=true service "minio-service" created ``` -To check if the service was created successfully, run the command + +The `LoadBalancer` service takes couple of minutes to launch. To check if the service was created successfully, run the command ```sh -kubectl get svc minio-service -``` - -You should get a response like this -```sh +$ kubectl get svc minio-service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m ``` # Step 4: Resource cleanup -Once you are done, cleanup the cluster using +You can cleanup the cluster using ```sh kubectl delete statefulset minio \ && kubectl delete svc minio \ diff --git a/examples/storage/minio-distributed/minio-distributed-service.yaml b/examples/storage/minio-distributed/minio-distributed-service.yaml index d1a24d6f669..60514a8636b 100644 --- a/examples/storage/minio-distributed/minio-distributed-service.yaml +++ b/examples/storage/minio-distributed/minio-distributed-service.yaml @@ -2,14 +2,11 @@ apiVersion: v1 kind: Service metadata: name: minio-service - labels: - app: minio spec: type: LoadBalancer ports: - port: 9000 targetPort: 9000 - protocol: "TCP" - name: minio + protocol: TCP selector: app: minio diff --git a/examples/storage/minio-distributed/minio-distributed-statefulset.yaml b/examples/storage/minio-distributed/minio-distributed-statefulset.yaml index 779ec935f8d..0d3f3adcf8c 100644 --- a/examples/storage/minio-distributed/minio-distributed-statefulset.yaml +++ b/examples/storage/minio-distributed/minio-distributed-statefulset.yaml @@ -3,7 +3,7 @@ kind: StatefulSet metadata: name: minio spec: - serviceName: "minio" + serviceName: minio replicas: 4 template: metadata: @@ -20,8 +20,14 @@ spec: - name: MINIO_SECRET_KEY value: "minio123" image: minio/minio - command: ["minio"] - args: ["server", "http://minio-0.minio.default.svc.cluster.local/data", "http://minio-1.minio.default.svc.cluster.local/data", "http://minio-2.minio.default.svc.cluster.local/data", "http://minio-3.minio.default.svc.cluster.local/data"] + command: + - minio + args: + - server + - http://minio-0.minio.default.svc.cluster.local/data + - http://minio-1.minio.default.svc.cluster.local/data + - http://minio-2.minio.default.svc.cluster.local/data + - http://minio-3.minio.default.svc.cluster.local/data ports: - containerPort: 9000 hostPort: 9000 @@ -38,7 +44,8 @@ spec: annotations: volume.alpha.kubernetes.io/storage-class: anything spec: - accessModes: [ "ReadWriteOnce" ] + accessModes: + - ReadWriteOnce resources: requests: storage: 10Gi diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index 7889b3893c4..f4be0163a09 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -67,16 +67,11 @@ spec: requests: storage: 10Gi ``` -[Download example] (minio-standalone-pvc.yaml?raw=true) Create the PersistentVolumeClaim ```sh -kubectl create -f minio-standalone-pvc.yaml -``` -The response should be like this: - -```sh +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-pvc.yaml?raw=true persistentvolumeclaim "minio-pv-claim" created ``` @@ -99,7 +94,7 @@ spec: metadata: labels: # Label is used as selector in the service. - app: minio-server + app: minio spec: # Refer to the PVC created earlier volumes: @@ -111,8 +106,11 @@ spec: - name: minio # Pulls the default Minio image from Docker Hub image: minio/minio - command: ["minio"] - args: ["server", "/storage"] + command: + - minio + args: + - server + - /storage env: # Minio access key and secret key - name: MINIO_ACCESS_KEY @@ -128,17 +126,10 @@ spec: mountPath: "/storage" ``` -[Download example] (minio-standalone-deployment.yaml?raw=true) - Create the Deployment ```sh -kubectl create -f minio-standalone-deployment.yaml -``` - -The response should be like this - -```sh +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-deployment.yaml?raw=true deployment "minio-deployment" created ``` @@ -160,28 +151,19 @@ spec: targetPort: 9000 protocol: TCP selector: - app: minio-server + app: minio ``` - -[Download example] (minio-standalone-service.yaml?raw=true) - -```sh -kubectl create -f minio-standalone-service.yaml -``` - -The response should be like this +Create the Minio service ```sh +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-service.yaml?raw=true service "minio-service" created ``` -To check if the service was created successfully, run the command + +The `LoadBalancer` service takes couple of minutes to launch. To check if the service was created successfully, run the command ```sh kubectl get svc minio-service -``` - -You should get a response like this -```sh NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m ``` diff --git a/examples/storage/minio/minio-standalone-deployment.yaml b/examples/storage/minio/minio-standalone-deployment.yaml index 6d234e2f276..1ec25a5ebf8 100644 --- a/examples/storage/minio/minio-standalone-deployment.yaml +++ b/examples/storage/minio/minio-standalone-deployment.yaml @@ -10,7 +10,7 @@ spec: metadata: labels: # Label is used as selector in the service. - app: minio-server + app: minio spec: # Refer to the PVC created earlier volumes: @@ -22,8 +22,11 @@ spec: - name: minio # Pulls the default Minio image from Docker Hub image: minio/minio - command: ["minio"] - args: ["server", "/storage"] + command: + - minio + args: + - server + - /storage env: # Minio access key and secret key - name: MINIO_ACCESS_KEY diff --git a/examples/storage/minio/minio-standalone-service.yaml b/examples/storage/minio/minio-standalone-service.yaml index 4d4ad7a562a..60514a8636b 100644 --- a/examples/storage/minio/minio-standalone-service.yaml +++ b/examples/storage/minio/minio-standalone-service.yaml @@ -9,4 +9,4 @@ spec: targetPort: 9000 protocol: TCP selector: - app: minio-server + app: minio From d0641307803cea1fcc776c4d4e57e17b2ee533e5 Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 14 Mar 2017 21:33:48 +0530 Subject: [PATCH 11/11] Merged Minio standalone and distributed in one doc --- examples/storage/minio-distributed/README.md | 181 ---------------- examples/storage/minio/README.md | 205 ++++++++++++++++-- .../minio-distributed-headless-service.yaml | 0 .../minio-distributed-service.yaml | 0 .../minio-distributed-statefulset.yaml | 0 5 files changed, 186 insertions(+), 200 deletions(-) delete mode 100644 examples/storage/minio-distributed/README.md rename examples/storage/{minio-distributed => minio}/minio-distributed-headless-service.yaml (100%) rename examples/storage/{minio-distributed => minio}/minio-distributed-service.yaml (100%) rename examples/storage/{minio-distributed => minio}/minio-distributed-statefulset.yaml (100%) diff --git a/examples/storage/minio-distributed/README.md b/examples/storage/minio-distributed/README.md deleted file mode 100644 index b54e87b7e06..00000000000 --- a/examples/storage/minio-distributed/README.md +++ /dev/null @@ -1,181 +0,0 @@ -# Cloud Native Deployment of Distributed Minio using Kubernetes - -## Table of Contents - -- [Introduction](#introduction) -- [Prerequisites](#prerequisites) -- [Quickstart](#quickstart) -- [Step 1: Create Minio Headless Service](#step-1-create-minio-headless-service) -- [Step 2: Create Minio Statefulset](#step-2-create-minio-statefulset) -- [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) -- [Step 4: Resource cleanup](#step-4-resource-cleanup) - -## Introduction -Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. Minio is _cloud native_, meaning Minio understands that it -is running within a cluster manager, and uses the cluster management infrastructure for allocation of compute and storage resources. - -The following document describes the process to deploy [distributed Minio](https://docs.minio.io/docs/distributed-minio-quickstart-guide) server on Kubernetes. -This example uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. - -This example uses some of the core components of Kubernetes: - -- [_Pods_](https://kubernetes.io/docs/user-guide/pods/) -- [_Services_](https://kubernetes.io/docs/user-guide/services/) -- [_Statefulsets_](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/) - -## Prerequisites - -This example assumes that you have a Kubernetes version >=1.5 cluster installed and running, and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) -command line tool somewhere in your path. Please see the -[getting started guides](../../../docs/getting-started-guides/) -for installation instructions for your platform. - -## Quickstart - -Run the below commands to get started quickly - -```sh -kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-headless-service.yaml?raw=true -kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-statefulset.yaml?raw=true -kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-service.yaml?raw=true -``` - -## Step 1: Create Minio Headless Service - -Headless Service controls the domain within which StatefulSets are created. The domain managed by this Service takes the form: `$(service name).$(namespace).svc.cluster.local` (where “cluster.local” is the cluster domain), and the pods in this domain take the form: `$(pod-name-{i}).$(service name).$(namespace).svc.cluster.local`. This is required to get a DNS resolvable URL for each of the pods created within the Statefulset. - -This is the Headless service description. - -```sh -apiVersion: v1 -kind: Service -metadata: - name: minio - labels: - app: minio -spec: - clusterIP: None - ports: - - port: 9000 - name: minio - selector: - app: minio -``` - -Create the Headless Service - -```sh -$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-headless-service.yaml?raw=true -service "minio" created -``` - -# Step 2: Create Minio Statefulset - -A StatefulSet provides a deterministic name and a unique identity to each pod, making it easy to deploy stateful distributed applications. To launch distributed Minio you need to pass drive locations as parameters to the minio server command. Then, you’ll need to run the same command on all the participating pods. StatefulSets offer a perfect way to handle this requirement. - -This is the Statefulset description. - -```sh -apiVersion: apps/v1beta1 -kind: StatefulSet -metadata: - name: minio -spec: - serviceName: minio - replicas: 4 - template: - metadata: - annotations: - pod.alpha.kubernetes.io/initialized: "true" - labels: - app: minio - spec: - containers: - - name: minio - env: - - name: MINIO_ACCESS_KEY - value: "minio" - - name: MINIO_SECRET_KEY - value: "minio123" - image: minio/minio - command: - - minio - args: - - server - - http://minio-0.minio.default.svc.cluster.local/data - - http://minio-1.minio.default.svc.cluster.local/data - - http://minio-2.minio.default.svc.cluster.local/data - - http://minio-3.minio.default.svc.cluster.local/data - ports: - - containerPort: 9000 - hostPort: 9000 - # These volume mounts are persistent. Each pod in the PetSet - # gets a volume mounted based on this field. - volumeMounts: - - name: data - mountPath: /data - # These are converted to volume claims by the controller - # and mounted at the paths mentioned above. - volumeClaimTemplates: - - metadata: - name: data - annotations: - volume.alpha.kubernetes.io/storage-class: anything - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi -``` - -Create the Statefulset - -```sh -$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-statefulset.yaml?raw=true -statefulset "minio" created -``` - -# Step 3: Create Minio Service - -Now that you have a Minio statefulset running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. - -In this example, we expose the Minio Deployment by creating a LoadBalancer service. This is the service description. - -```sh -apiVersion: v1 -kind: Service -metadata: - name: minio-service -spec: - type: LoadBalancer - ports: - - port: 9000 - targetPort: 9000 - protocol: TCP - selector: - app: minio -``` -Create the Minio service - -```sh -$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio-distributed/minio-distributed-service.yaml?raw=true -service "minio-service" created -``` - -The `LoadBalancer` service takes couple of minutes to launch. To check if the service was created successfully, run the command - -```sh -$ kubectl get svc minio-service -NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE -minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m -``` - -# Step 4: Resource cleanup - -You can cleanup the cluster using -```sh -kubectl delete statefulset minio \ -&& kubectl delete svc minio \ -&& kubectl delete svc minio-service -``` diff --git a/examples/storage/minio/README.md b/examples/storage/minio/README.md index f4be0163a09..2538801714c 100644 --- a/examples/storage/minio/README.md +++ b/examples/storage/minio/README.md @@ -4,32 +4,39 @@ - [Introduction](#introduction) - [Prerequisites](#prerequisites) -- [Quickstart](#quickstart) -- [Step 1: Create Persistent Volume Claim](#step-1-create-persistent-volume-claim) -- [Step 2: Create Deployment](#step-2-create-minio-deployment) -- [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) -- [Step 4: Resource cleanup](#step-4-resource-cleanup) +- [Minio Standalone Server Deployment](#minio-standalone-server-deployment) + - [Standalone Quickstart](#standalone-quickstart) + - [Step 1: Create Persistent Volume Claim](#step-1-create-persistent-volume-claim) + - [Step 2: Create Deployment](#step-2-create-minio-deployment) + - [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) + - [Step 4: Resource cleanup](#step-4-resource-cleanup) +- [Minio Distributed Server Deployment](#minio-distributed-server-deployment) + - [Distributed Quickstart](#distributed-quickstart) + - [Step 1: Create Minio Headless Service](#step-1-create-minio-headless-service) + - [Step 2: Create Minio Statefulset](#step-2-create-minio-statefulset) + - [Step 3: Create LoadBalancer Service](#step-3-create-minio-service) + - [Step 4: Resource cleanup](#step-4-resource-cleanup) ## Introduction Minio is an AWS S3 compatible, object storage server built for cloud applications and devops. Minio is _cloud native_, meaning Minio understands that it is running within a cluster manager, and uses the cluster management infrastructure for allocation of compute and storage resources. -The following document describes the process to deploy standalone [Minio](https://minio.io/) server on Kubernetes. The deployment uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. +## Prerequisites -This example uses some of the core components of Kubernetes: +This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, and that you have installed the [`kubectl`](https://kubernetes.io/docs/user-guide/prereqs/) command line tool in your path. Please see the +[getting started guides](https://kubernetes.io/docs/getting-started-guides/) for installation instructions for your platform. + +## Minio Standalone Server Deployment + +The following section describes the process to deploy standalone [Minio](https://minio.io/) server on Kubernetes. The deployment uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. + +This section uses following core components of Kubernetes: - [_Pods_](https://kubernetes.io/docs/user-guide/pods/) - [_Services_](https://kubernetes.io/docs/user-guide/services/) - [_Deployments_](https://kubernetes.io/docs/user-guide/deployments/) - [_Persistent Volume Claims_](https://kubernetes.io/docs/user-guide/persistent-volumes/#persistentvolumeclaims) -## Prerequisites - -This example assumes that you have a Kubernetes version >=1.4 cluster installed and running, and that you have installed the [`kubectl`](../../../docs/user-guide/kubectl/kubectl.md) -command line tool somewhere in your path. Please see the -[getting started guides](../../../docs/getting-started-guides/) -for installation instructions for your platform. - -## Quickstart +### Standalone Quickstart Run the below commands to get started quickly @@ -39,7 +46,7 @@ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-standalone-service.yaml?raw=true ``` -## Step 1: Create Persistent Volume Claim +### Step 1: Create Persistent Volume Claim Minio needs persistent storage to store objects. If there is no persistent storage, the data stored in Minio instance will be stored in the container file system and will be wiped off as soon as the container restarts. @@ -75,7 +82,7 @@ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/ persistentvolumeclaim "minio-pv-claim" created ``` -# Step 2: Create Minio Deployment +### Step 2: Create Minio Deployment A deployment encapsulates replica sets and pods — so, if a pod goes down, replication controller makes sure another pod comes up automatically. This way you won’t need to bother about pod failures and will have a stable Minio service available. @@ -133,7 +140,7 @@ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/ deployment "minio-deployment" created ``` -# Step 3: Create Minio Service +### Step 3: Create Minio Service Now that you have a Minio deployment running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. @@ -168,7 +175,7 @@ NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m ``` -# Step 4: Resource cleanup +### Step 4: Resource cleanup Once you are done, cleanup the cluster using ```sh @@ -176,3 +183,163 @@ kubectl delete deployment minio-deployment \ && kubectl delete pvc minio-pv-claim \ && kubectl delete svc minio-service ``` + +## Minio Distributed Server Deployment + +The following document describes the process to deploy [distributed Minio](https://docs.minio.io/docs/distributed-minio-quickstart-guide) server on Kubernetes. This example uses the [official Minio Docker image](https://hub.docker.com/r/minio/minio/~/dockerfile/) from Docker Hub. + +This example uses following core components of Kubernetes: + +- [_Pods_](https://kubernetes.io/docs/user-guide/pods/) +- [_Services_](https://kubernetes.io/docs/user-guide/services/) +- [_Statefulsets_](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/) + +### Distributed Quickstart + +Run the below commands to get started quickly + +```sh +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-headless-service.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-statefulset.yaml?raw=true +kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-service.yaml?raw=true +``` + +### Step 1: Create Minio Headless Service + +Headless Service controls the domain within which StatefulSets are created. The domain managed by this Service takes the form: `$(service name).$(namespace).svc.cluster.local` (where “cluster.local” is the cluster domain), and the pods in this domain take the form: `$(pod-name-{i}).$(service name).$(namespace).svc.cluster.local`. This is required to get a DNS resolvable URL for each of the pods created within the Statefulset. + +This is the Headless service description. + +```sh +apiVersion: v1 +kind: Service +metadata: + name: minio + labels: + app: minio +spec: + clusterIP: None + ports: + - port: 9000 + name: minio + selector: + app: minio +``` + +Create the Headless Service + +```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-headless-service.yaml?raw=true +service "minio" created +``` + +### Step 2: Create Minio Statefulset + +A StatefulSet provides a deterministic name and a unique identity to each pod, making it easy to deploy stateful distributed applications. To launch distributed Minio you need to pass drive locations as parameters to the minio server command. Then, you’ll need to run the same command on all the participating pods. StatefulSets offer a perfect way to handle this requirement. + +This is the Statefulset description. + +```sh +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: minio +spec: + serviceName: minio + replicas: 4 + template: + metadata: + annotations: + pod.alpha.kubernetes.io/initialized: "true" + labels: + app: minio + spec: + containers: + - name: minio + env: + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + image: minio/minio + command: + - minio + args: + - server + - http://minio-0.minio.default.svc.cluster.local/data + - http://minio-1.minio.default.svc.cluster.local/data + - http://minio-2.minio.default.svc.cluster.local/data + - http://minio-3.minio.default.svc.cluster.local/data + ports: + - containerPort: 9000 + hostPort: 9000 + # These volume mounts are persistent. Each pod in the PetSet + # gets a volume mounted based on this field. + volumeMounts: + - name: data + mountPath: /data + # These are converted to volume claims by the controller + # and mounted at the paths mentioned above. + volumeClaimTemplates: + - metadata: + name: data + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi +``` + +Create the Statefulset + +```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-statefulset.yaml?raw=true +statefulset "minio" created +``` + +### Step 3: Create Minio Service + +Now that you have a Minio statefulset running, you may either want to access it internally (within the cluster) or expose it as a Service onto an external (outside of your cluster, maybe public internet) IP address, depending on your use case. You can achieve this using Services. There are 3 major service types — default type is ClusterIP, which exposes a service to connection from inside the cluster. NodePort and LoadBalancer are two types that expose services to external traffic. + +In this example, we expose the Minio Deployment by creating a LoadBalancer service. This is the service description. + +```sh +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + type: LoadBalancer + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio +``` +Create the Minio service + +```sh +$ kubectl create -f https://github.com/kubernetes/kubernetes/blob/master/examples/storage/minio/minio-distributed-service.yaml?raw=true +service "minio-service" created +``` + +The `LoadBalancer` service takes couple of minutes to launch. To check if the service was created successfully, run the command + +```sh +$ kubectl get svc minio-service +NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE +minio-service 10.55.248.23 104.199.249.165 9000:31852/TCP 1m +``` + +### Step 4: Resource cleanup + +You can cleanup the cluster using +```sh +kubectl delete statefulset minio \ +&& kubectl delete svc minio \ +&& kubectl delete svc minio-service +``` diff --git a/examples/storage/minio-distributed/minio-distributed-headless-service.yaml b/examples/storage/minio/minio-distributed-headless-service.yaml similarity index 100% rename from examples/storage/minio-distributed/minio-distributed-headless-service.yaml rename to examples/storage/minio/minio-distributed-headless-service.yaml diff --git a/examples/storage/minio-distributed/minio-distributed-service.yaml b/examples/storage/minio/minio-distributed-service.yaml similarity index 100% rename from examples/storage/minio-distributed/minio-distributed-service.yaml rename to examples/storage/minio/minio-distributed-service.yaml diff --git a/examples/storage/minio-distributed/minio-distributed-statefulset.yaml b/examples/storage/minio/minio-distributed-statefulset.yaml similarity index 100% rename from examples/storage/minio-distributed/minio-distributed-statefulset.yaml rename to examples/storage/minio/minio-distributed-statefulset.yaml