Skip to content

Commit

Permalink
introduce MinIO Job CRD (#1883)
Browse files Browse the repository at this point in the history
Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
  • Loading branch information
pjuarezd committed Jan 19, 2024
1 parent 1fb15e7 commit ed454ec
Show file tree
Hide file tree
Showing 35 changed files with 2,383 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ regen-crd:
@${GOPATH}/bin/controller-gen crd:maxDescLen=0,generateEmbeddedObjectMeta=true paths="./..." output:crd:artifacts:config=$(KUSTOMIZE_CRDS)
@sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/minio.min.io_tenants.yaml > $(HELM_TEMPLATES)/minio.min.io_tenants.yaml
@sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/sts.min.io_policybindings.yaml > $(HELM_TEMPLATES)/sts.min.io_policybindings.yaml
@sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/job.min.io_miniojobs.yaml > $(HELM_TEMPLATES)/job.min.io_jobs.yaml

regen-crd-docs:
@echo "Installing crd-ref-docs" && GO111MODULE=on go install -v github.com/elastic/crd-ref-docs@latest
@${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/minio.min.io/v2 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/tenant_crd.adoc --templates-dir=docs/templates/asciidoctor/
@${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/sts.min.io/v1alpha1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/policybinding_crd.adoc --templates-dir=docs/templates/asciidoctor/
@${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/job.min.io/v1alpha1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/job_crd.adoc --templates-dir=docs/templates/asciidoctor/

plugin: regen-crd
@echo "Building 'kubectl-minio' binary"
Expand Down
162 changes: 162 additions & 0 deletions docs/job_crd.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Generated documentation. Please do not edit.
:anchor_prefix: k8s-api

[id="{p}-api-reference"]
== API Reference

:minio-image: https://hub.docker.com/r/minio/minio/tags[minio/minio:RELEASE.2023-11-15T20-43-25Z]
:kes-image: https://hub.docker.com/r/minio/kes/tags[minio/kes:2023-11-10T10-44-28Z]


[id="{anchor_prefix}-job-min-io-v1alpha1"]
=== job.min.io/v1alpha1

Package v1alpha1 - The following parameters are specific to the `job.min.io/v1alpha1` MinIOJob CRD API.

MinIOJob is an automated InfrastructureAsCode integrated with Minio Operator STS to configure MinIO Tenants.



[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-commandspec"]
==== CommandSpec

CommandSpec (`spec`) defines the configuration of a MinioClient Command.

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojobspec[$$MinIOJobSpec$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`op`* __string__
|*Required* +
Operation is the MinioClient Action

|*`name`* __string__
|Name is the Command Name, optional, required if want to reference it with `DependsOn`

|*`args`* __object (keys:string, values:string)__
|Args Arguments to pass to the action

|*`dependsOn`* __string array__
|DependsOn List of named `command` in this MinioJob that have to be scheduled and executed before this command runs

|===


[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-commandstatus"]
==== CommandStatus

CommandStatus Status of MinioJob command execution

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojobstatus[$$MinIOJobStatus$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`name`* __string__
|

|*`result`* __string__
|*Required* +

|*`message`* __string__
|

|===


[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojob"]
==== MinIOJob

MinIOJob is a top-level type. A client is created for it

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojoblist[$$MinIOJobList$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#objectmeta-v1-meta[$$ObjectMeta$$]__
|Refer to Kubernetes API documentation for fields of `metadata`.


|*`spec`* __xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojobspec[$$MinIOJobSpec$$]__
|*Required* +
The root field for the MinIOJob object.

|===




[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojobspec"]
==== MinIOJobSpec

MinIOJobSpec (`spec`) defines the configuration of a MinIOJob object. +

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojob[$$MinIOJob$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`serviceAccountName`* __string__
|*Required* +
Service Account name for the jobs to run

|*`tenant`* __xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-tenantref[$$TenantRef$$]__
|*Required* +
TenantRef Reference for minio Tenant to eun the jobs against

|*`execution`* __Execution__
|Execution order of the jobs, either `parallel` or `sequential`. Defaults to `parallel` if not provided.

|*`failureStrategy`* __FailureStrategy__
|FailureStrategy is the forward plan in case of the failure of one or more MinioJob pods Either `stopOnFailure` or `continueOnFailure`, defaults to `continueOnFailure`.

|*`commands`* __xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-commandspec[$$CommandSpec$$] array__
|*Required* +
Commands List of MinioClient commands

|===




[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-tenantref"]
==== TenantRef

TenantRef Is the reference to the target tenant of the jobs

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-job-min-io-v1alpha1-miniojobspec[$$MinIOJobSpec$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`name`* __string__
|*Required* +

|*`namespace`* __string__
|*Required* +

|===


112 changes: 112 additions & 0 deletions helm/operator/templates/job.min.io_jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: miniojobs.job.min.io
spec:
group: job.min.io
names:
kind: MinIOJob
listKind: MinIOJobList
plural: miniojobs
shortNames:
- miniojob
singular: miniojob
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.tenant.name
name: Tenant
type: string
- jsonPath: .spec.status.phase
name: Phase
type: string
name: v1alpha1
schema:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
commands:
items:
properties:
args:
additionalProperties:
type: string
type: object
dependsOn:
items:
type: string
type: array
name:
type: string
op:
type: string
required:
- op
type: object
type: array
execution:
default: parallel
enum:
- parallel
- sequential
type: string
failureStrategy:
default: continueOnFailure
enum:
- continueOnFailure
- stopOnFailure
type: string
serviceAccountName:
type: string
tenant:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
required:
- commands
- serviceAccountName
- tenant
type: object
status:
properties:
commands:
items:
properties:
message:
type: string
name:
type: string
result:
type: string
required:
- result
type: object
type: array
phase:
type: string
required:
- commands
- phase
type: object
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 1 addition & 1 deletion k8s/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ chmod +x ${CODEGEN_PKG}/generate-internal-groups.sh
cd ${SCRIPT_ROOT}
${CODEGEN_PKG}/generate-groups.sh "all" \
$ROOT_PKG/pkg/client $ROOT_PKG/pkg/apis \
"minio.min.io:v2 sts.min.io:v1alpha1" \
"minio.min.io:v2 sts.min.io:v1alpha1 job.min.io:v1alpha1" \
--output-base "${TEMP_DIR}" \
--go-header-file "k8s/boilerplate.go.txt"

Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/job.min.io/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2022, MinIO, Inc.
//
// This code is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License, version 3,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License, version 3,
// along with this program. If not, see <http://www.gnu.org/licenses/>

package operator

// MinIOJob group name.
const (
GroupName = "job.min.io"
)
23 changes: 23 additions & 0 deletions pkg/apis/job.min.io/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2023, MinIO, Inc.
//
// This code is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License, version 3,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License, version 3,
// along with this program. If not, see <http://www.gnu.org/licenses/>

// +k8s:deepcopy-gen=package,register
// go:generate controller-gen crd:trivialVersions=true paths=. output:dir=.

// Package v1alpha1 - The following parameters are specific to the `job.min.io/v1alpha1` MinIOJob CRD API.
//
// MinIOJob is an automated InfrastructureAsCode integrated with Minio Operator STS to configure MinIO Tenants.
// +groupName=job.min.io
// +versionName=v1alpha1
package v1alpha1

0 comments on commit ed454ec

Please sign in to comment.