Skip to content

Commit

Permalink
Merge pull request #1 from minio/master
Browse files Browse the repository at this point in the history
merge latest
  • Loading branch information
aaronmcohen authored Jul 26, 2019
2 parents 383fb8c + 816a619 commit 49faacf
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MinIO is a high performance distributed object storage server, designed for larg

### Prerequisites

- Kubernetes cluster 1.10.0+.
- Kubernetes API v1.15 and above.
- `kubectl` configured to refer to relevant Kubernetes cluster.

### Create Operator and related resources
Expand Down
96 changes: 96 additions & 0 deletions docs/minio-examples/minioinstance-with-external-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: ClusterIP
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
---
apiVersion: miniocontroller.min.io/v1beta1
kind: MinIOInstance
metadata:
name: minio
## If specified, MinIOInstance pods will be dispatched by specified scheduler.
## If not specified, the pod will be dispatched by default scheduler.
# scheduler:
# name: my-custom-scheduler
spec:
## Supply number of replicas, (should be an even number).
replicas: 4
## Add metadata to the pods created by the StatefulSet
metadata:
labels:
app: minio
annotations:
prometheus.io/path: /minio/prometheus/metrics
prometheus.io/port: "9000"
prometheus.io/scrape: "true"
## MinIO release version, (minio/minio image tag).
version: RELEASE.2019-07-10T00-34-56Z
## Secret with credentials to be used by MinIO instance.
credsSecret:
name: minio-creds-secret
## Add environment variables to be set in MinIO container (https://github.com/minio/minio/tree/master/docs/config)
env:
- name: MINIO_BROWSER
value: "on"
- name: MINIO_STORAGE_CLASS_RRS
value: "EC:2"
## Configure resource requests and limits for MinIO containers
resources:
requests:
memory: 256Mi
cpu: 250m
limits:
memory: 512Mi
cpu: 750m
## Liveness probe detects situations where MinIO server instance
## is not working properly and needs restart. Kubernetes automatically
## restarts the pods if liveness checks fail.
liveness:
httpGet:
path: /minio/health/live
port: 9000
initialDelaySeconds: 120
periodSeconds: 20
## Readiness probe detects situations when MinIO server instance
## is not ready to accept traffic. Kubernetes doesn't forward
## traffic to the pod while readiness checks fail.
## Recommended to be used only for standalone MinIO Instances.
# readiness:
# httpGet:
# path: /minio/health/ready
# port: 9000
# initialDelaySeconds: 120
# periodSeconds: 20
## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be
## eligible to run on a node, the node must have each of the
## indicated key-value pairs as labels.
## Read more here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
# nodeSelector:
# disktype: ssd
## Affinity settings for MinIO pods. Read more about affinity
## here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity.
# affinity:
## Secret with certificates to configure TLS for MinIO certs. Create secrets as explained
## here: https://github.com/minio/minio/tree/master/docs/tls/kubernetes#2-create-kubernetes-secret
# sslSecret:
# name: tls-ssl-minio
## Mountpath where PV will be mounted inside container(s). Defaults to "/export".
# mountPath: /export
## Subpath inside Mountpath where MinIO starts. Defaults to "".
# subPath: /data
volumeClaimTemplate:
metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
18 changes: 14 additions & 4 deletions docs/minio-examples/minioinstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@ metadata:
# scheduler:
# name: my-custom-scheduler
spec:
## Supply number of replicas, (should be an even number).
## Supply number of replicas.
## For standalone mode, supply 1. For distributed mode, supply 4 or more (should be even).
## Note that the operator does not support upgrading from standalone to distributed mode.
replicas: 4
## Add metadata to the pods created by the StatefulSet
metadata:
labels:
app: minio
annotations:
prometheus.io/path: /minio/prometheus/metrics
prometheus.io/port: "9000"
prometheus.io/scrape: "true"
## MinIO release version, (minio/minio image tag).
version: RELEASE.2019-06-19T18-24-42Z
version: RELEASE.2019-07-10T00-34-56Z
## Secret with credentials to be used by MinIO instance.
credsSecret:
name: minio-creds-secret
## Add environment variables to be set in MinIO container (https://github.com/minio/minio/tree/master/docs/config)
env:
- name: MINIO_BROWSER
value: "on"
- name: MINIO_STORAGE_CLASS_RRS
value: "EC:2"
# - name: MINIO_STORAGE_CLASS_RRS
# value: "EC:2"
## Configure resource requests and limits for MinIO containers
resources:
requests:
Expand Down
24 changes: 23 additions & 1 deletion docs/minio-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,32 @@ metadata:
spec:
group: miniocontroller.min.io
version: v1beta1
scope: Namespaced
names:
kind: MinIOInstance
singular: minioinstance
plural: minioinstances
scope: Namespaced
preserveUnknownFields: true
validation:
# openAPIV3Schema is the schema for validating custom objects.
# Refer https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#specifying-a-structural-schema
# for more details
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
replicas:
type: integer
minimum: 1
maximum: 32
version:
type: string
mountpath:
type: string
subpath:
type: string
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/miniocontroller/v1beta1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func (mi *MinIOInstance) HasCredsSecret() bool {
return mi.Spec.CredsSecret != nil
}

// HasMetadata returns true if the user has provided a object metadata
// for a MinIOInstance else false
func (mi *MinIOInstance) HasMetadata() bool {
return mi.Spec.Metadata != nil
}

// RequiresSSLSetup returns true is the user has provided a secret
// that contains CA cert, server cert and server key for group replication
// SSL support
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/miniocontroller/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type MinIOInstanceSpec struct {
Version string `json:"version"`
// Replicas defines the number of MinIO instances in a MinIOInstance resource
Replicas int32 `json:"replicas"`
// Metadata defines the object metadata passed to each pod that is a part of this MinIOInstance
Metadata *metav1.ObjectMeta `json:"metadata,omitempty"`
// If provided, use this secret as the credentials for MinIOInstance resource
// Otherwise MinIO server creates dynamic credentials printed on MinIO server startup banner
// +optional
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const MinIOVolumeSubPath = ""
const DefaultMinIOImagePath = "minio/minio"

// DefaultMinIOImageVersion specifies the latest released MinIO Docker hub image
const DefaultMinIOImageVersion = "RELEASE.2019-06-19T18-24-42Z"
const DefaultMinIOImageVersion = "RELEASE.2019-07-10T00-34-56Z"

// MinIOServerName specifies the default container name for MinIOInstance
const MinIOServerName = "minio"
Expand Down
44 changes: 36 additions & 8 deletions pkg/resources/statefulsets/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,31 @@ func minioEnvironmentVars(mi *miniov1beta1.MinIOInstance) []corev1.EnvVar {
return envVars
}

// Returns the MinIO pods metadata set in configuration.
// If a user specifies metadata in the spec we return that
// metadata.
func minioMetadata(mi *miniov1beta1.MinIOInstance) metav1.ObjectMeta {
meta := metav1.ObjectMeta{}
if mi.HasMetadata() {
meta = *mi.Spec.Metadata
}
// Initialize empty fields
if meta.Labels == nil {
meta.Labels = make(map[string]string)
}
if meta.Annotations == nil {
meta.Annotations = make(map[string]string)
}
// Add the additional label used by StatefulSet spec
podLabelKey, podLabelValue := minioPodLabels(mi)
meta.Labels[podLabelKey] = podLabelValue
return meta
}

func minioPodLabels(mi *miniov1beta1.MinIOInstance) (string, string) {
return constants.InstanceLabel, mi.Name
}

// Builds the volume mounts for MinIO container.
func volumeMounts(mi *miniov1beta1.MinIOInstance) []corev1.VolumeMount {
var mounts []corev1.VolumeMount
Expand Down Expand Up @@ -109,9 +134,14 @@ func minioServerContainer(mi *miniov1beta1.MinIOInstance, serviceName, imagePath
"server",
}

// append all the MinIOInstance replica URLs
for i := 0; i < replicas; i++ {
args = append(args, fmt.Sprintf("%s://%s-"+strconv.Itoa(i)+".%s.%s.svc.cluster.local%s", scheme, mi.Name, serviceName, mi.Namespace, minioPath))
if replicas == 1 {
// to run in standalone mode we must pass the path
args = append(args, constants.MinIOVolumeMountPath)
} else {
// append all the MinIOInstance replica URLs
for i := 0; i < replicas; i++ {
args = append(args, fmt.Sprintf("%s://%s-"+strconv.Itoa(i)+".%s.%s.svc.cluster.local%s", scheme, mi.Name, serviceName, mi.Namespace, minioPath))
}
}

return corev1.Container{
Expand Down Expand Up @@ -175,9 +205,9 @@ func NewForCluster(mi *miniov1beta1.MinIOInstance, serviceName, imagePath string
}

containers := []corev1.Container{minioServerContainer(mi, serviceName, imagePath)}

podLabelKey, podLabelValue := minioPodLabels(mi)
podLabels := map[string]string{
constants.InstanceLabel: mi.Name,
podLabelKey: podLabelValue,
}

ss := &appsv1.StatefulSet{
Expand All @@ -199,9 +229,7 @@ func NewForCluster(mi *miniov1beta1.MinIOInstance, serviceName, imagePath string
ServiceName: serviceName,
Replicas: &mi.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: podLabels,
},
ObjectMeta: minioMetadata(mi),
Spec: corev1.PodSpec{
Containers: containers,
Volumes: podVolumes,
Expand Down

0 comments on commit 49faacf

Please sign in to comment.