Skip to content

Commit

Permalink
Remove user provided liveness and readiness config (#129)
Browse files Browse the repository at this point in the history
This PR removes user provided configuration for liveness and
readiness probes, since most of these fields are expected to be
constant and are known to us, we should not require users to
provide these. Instead, we simply use all known values and create
the probes - we only expect initialDelay and probe period from
users. If these fields are not provided, we do not create the
probe.

Additionally, this PR also adds steps on how to create local PV
before creating a MinIOInstance.

Fixes #124
  • Loading branch information
nitisht authored May 26, 2020
1 parent c4a6a1b commit 35ff9a9
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 31 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ issues:
exclude:
- should have a package comment
- error strings should not be capitalized or end with punctuation or a newline
exclude-rules:
# Exclude linters from running on auto-generated files.
- path: pkg/client
linters:
- golint
- deadcode

service:
golangci-lint-version: 1.20.0 # use the fixed version to not introduce new linters unexpectedly
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MinIO-Operator brings native MinIO, [MCS](https://github.com/minio/mcs), [KES](h

- Kubernetes version v1.17.0 and above for compatibility. MinIO Operator uses `k8s/client-go` v0.18.0.
- `kubectl` configured to refer to a Kubernetes cluster.
- Create the required PVs as [explained here](https://github.com/minio/minio-operator/blob/master/docs/creating-pv-manually.md).

### Create Operator and related resources

Expand All @@ -30,7 +31,7 @@ kubectl apply -f https://raw.githubusercontent.com/minio/minio-operator/master/m

This will create all relevant resources required for the Operator to work.

You could install the MinIO Operator a custom namespace by customizing the `minio-operator.yaml` file or using [kustomize](https://github.com/kubernetes-sigs/kustomize)
You could install the MinIO Operator a custom namespace by customizing the `minio-operator.yaml` file or using [kustomize](https://github.com/kubernetes-sigs/kustomize)

```bash
kustomize build | kubectl apply -f -
Expand Down
48 changes: 48 additions & 0 deletions docs/creating-pv-manually.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Creating PersistentVolumes

[![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
[![Docker Pulls](https://img.shields.io/docker/pulls/minio/k8s-operator.svg?maxAge=604800)](https://hub.docker.com/r/minio/k8s-operator)

We recommend using [`local` Persistent Volumes](https://kubernetes.io/docs/concepts/storage/volumes/#local) as the backing storage for MinIO StatefulSets. MinIO
creates a distributed, resilient, failure tolerant storage system on `local` PVs. There is no explicit dependency on external distributed file systems or CSI vendors.

This document explains how to create `local` PVs. Once you create these PVs, MinIOInstance PVCs should automatically bind to these PVs.

## Getting Started

A `local` volume represents a mounted local storage device such as a disk, partition or directory.

Currently, `local` volumes can only be used as a statically created PersistentVolume. Dynamic provisioning is not supported yet. Compared to `hostPath` volumes, `local` volumes can be used in a durable and portable manner without manually scheduling Pods to nodes, as the system is aware of the volume’s node constraints by looking at the node affinity on the PersistentVolume.

Total number of `local` PVs required for a MinIOInstance is equal to Total Servers (across all zones) x Total Volumes Per Server. For example, if you have 4 zones, with 4 servers per zone and each server has 4 volumes, then total PVs required is 64. Since each server has 4 volumes, you'll need to create 4 `local` PVs, on all 16 Servers.

## Sample PV

This is a sample PV configuration. Note that `storageClassName` and `capacity` specified here should match the `storageClassName` and `capacity` specified in MinIOInstance `volumeClaimTemplate` for the PV and PVC to bind. Additionally, please change `capacity`, `path`, and `nodeAffinity` as per your specific requirements.

```yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: minio-pv
spec:
capacity:
storage: 1Ti
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: ""
local:
path: /mnt/disks/ssd1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- example-node
```
After configuring the PV details, use `kubectl` to create the requisite number of PVs.
6 changes: 0 additions & 6 deletions examples/minioinstance-kes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ spec:
## 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: 60
## Readiness probe detects situations when MinIO server instance
Expand All @@ -161,9 +158,6 @@ spec:
## Readiness check will only work if PodManagementPolicy is set to "Parallel".
## Disable this check if you're setting PodManagementPolicy to "OrderedReady".
readiness:
httpGet:
path: /minio/health/ready
port: 9000
initialDelaySeconds: 120
periodSeconds: 60
## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be
Expand Down
6 changes: 0 additions & 6 deletions examples/minioinstance-mcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ spec:
## 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: 60
## Readiness probe detects situations when MinIO server instance
Expand All @@ -149,9 +146,6 @@ spec:
## Readiness check will only work if PodManagementPolicy is set to "Parallel".
## Disable this check if you're setting PodManagementPolicy to "OrderedReady".
readiness:
httpGet:
path: /minio/health/ready
port: 9000
initialDelaySeconds: 120
periodSeconds: 60
## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be
Expand Down
6 changes: 0 additions & 6 deletions examples/minioinstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ spec:
## 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: 60
## Readiness probe detects situations when MinIO server instance
Expand All @@ -123,9 +120,6 @@ spec:
## Readiness check will only work if PodManagementPolicy is set to "Parallel".
## Disable this check if you're setting PodManagementPolicy to "OrderedReady".
readiness:
httpGet:
path: /minio/health/ready
port: 9000
initialDelaySeconds: 120
periodSeconds: 60
## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/operator.min.io/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ const DefaultVolumesPerServer = 1
// DefaultZoneName specifies the default zone name
const DefaultZoneName = "zone-0"

// ReadinessPath specifies the endpoint for readiness check
const ReadinessPath = "/minio/health/ready"

// ReadinessInitialDelay specifies the initial delay in calling the readiness endpoint
const ReadinessInitialDelay = 120

// ReadinessPeriod specifies the interval in calling the readiness endpoint
const ReadinessPeriod = 60

// LivenessPath specifies the endpoint for liveness check
const LivenessPath = "/minio/health/live"

// LivenessInitialDelay specifies the initial delay in calling the liveness endpoint
const LivenessInitialDelay = 120

// LivenessPeriod specifies the interval in calling the liveness endpoint
const LivenessPeriod = 60

// MC Mirror Related Constants

// DefaultMCImage specifies the default mc Docker hub image
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/operator.min.io/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ func (mi *MinIOInstance) EnsureDefaults() *MinIOInstance {
}
}

if mi.Spec.Readiness != nil {
if mi.Spec.Readiness.InitialDelaySeconds == 0 {
mi.Spec.Readiness.InitialDelaySeconds = ReadinessInitialDelay
}
if mi.Spec.Readiness.PeriodSeconds == 0 {
mi.Spec.Readiness.PeriodSeconds = ReadinessPeriod
}
}

if mi.Spec.Liveness != nil {
if mi.Spec.Liveness.InitialDelaySeconds == 0 {
mi.Spec.Liveness.InitialDelaySeconds = LivenessInitialDelay
}
if mi.Spec.Liveness.PeriodSeconds == 0 {
mi.Spec.Liveness.PeriodSeconds = LivenessPeriod
}
}

if mi.HasMCSEnabled() {
if mi.Spec.MCS.Image == "" {
mi.Spec.MCS.Image = DefaultMCSImage
Expand Down
16 changes: 14 additions & 2 deletions pkg/apis/operator.min.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ type MinIOInstanceSpec struct {
Subpath string `json:"subPath,omitempty"`
// Liveness Probe for container liveness. Container will be restarted if the probe fails.
// +optional
Liveness *corev1.Probe `json:"liveness,omitempty"`
Liveness *Liveness `json:"liveness,omitempty"`
// Readiness Probe for container readiness. Container will be removed from service endpoints if the probe fails.
// +optional
Readiness *corev1.Probe `json:"readiness,omitempty"`
Readiness *Readiness `json:"readiness,omitempty"`
// RequestAutoCert allows user to enable Kubernetes based TLS cert generation and signing as explained here:
// https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
// +optional
Expand Down Expand Up @@ -157,6 +157,18 @@ type Zone struct {
Servers int32 `json:"servers"`
}

// Liveness specifies the spec for liveness probe
type Liveness struct {
InitialDelaySeconds int32 `json:"initialDelaySeconds"`
PeriodSeconds int32 `json:"periodSeconds"`
}

// Readiness specifies the spec for liveness probe
type Readiness struct {
InitialDelaySeconds int32 `json:"initialDelaySeconds"`
PeriodSeconds int32 `json:"periodSeconds"`
}

// MCSConfig defines the credentials for mcs
type MCSConfig struct {
// Replicas defines number of pods for KES StatefulSet.
Expand Down
40 changes: 36 additions & 4 deletions pkg/apis/operator.min.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 39 additions & 5 deletions pkg/resources/statefulsets/minio-statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
)

// Returns the MinIO environment variables set in configuration.
Expand Down Expand Up @@ -149,6 +150,43 @@ func volumeMounts(mi *miniov1.MinIOInstance) []corev1.VolumeMount {
return mounts
}

func probes(mi *miniov1.MinIOInstance) (readiness, liveness *corev1.Probe) {
scheme := corev1.URIScheme(strings.ToUpper(miniov1.Scheme))
port := intstr.IntOrString{
IntVal: int32(miniov1.MinIOPort),
}

if mi.Spec.Readiness != nil {
readiness = &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: miniov1.ReadinessPath,
Port: port,
Scheme: scheme,
},
},
InitialDelaySeconds: mi.Spec.Readiness.InitialDelaySeconds,
PeriodSeconds: mi.Spec.Readiness.PeriodSeconds,
}
}

if mi.Spec.Liveness != nil {
liveness = &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: miniov1.LivenessPath,
Port: port,
Scheme: scheme,
},
},
InitialDelaySeconds: mi.Spec.Liveness.InitialDelaySeconds,
PeriodSeconds: mi.Spec.Liveness.PeriodSeconds,
}
}

return readiness, liveness
}

// Builds the MinIO container for a MinIOInstance.
func minioServerContainer(mi *miniov1.MinIOInstance, serviceName string) corev1.Container {
args := []string{"server"}
Expand All @@ -164,11 +202,7 @@ func minioServerContainer(mi *miniov1.MinIOInstance, serviceName string) corev1.
}
}

readyProbe := mi.Spec.Readiness
readyProbe.HTTPGet.Scheme = corev1.URIScheme(strings.ToUpper(miniov1.Scheme))

liveProbe := mi.Spec.Liveness
liveProbe.HTTPGet.Scheme = corev1.URIScheme(strings.ToUpper(miniov1.Scheme))
readyProbe, liveProbe := probes(mi)

return corev1.Container{
Name: miniov1.MinIOServerName,
Expand Down

0 comments on commit 35ff9a9

Please sign in to comment.