diff --git a/Makefile b/Makefile index ba5dd64e..d55cec4c 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ test-python-sdk: ./hack/python-sdk/test-sdk.sh .PHONY: verify -verify: vet fmt-verify ci-lint manifests generate toc-verify +verify: vet fmt-verify ci-lint manifests generate toc-verify generate-apiref git --no-pager diff --exit-code config api client-go @@ -294,4 +294,14 @@ golangci-lint: ## Download golangci-lint locally if necessary. GOTESTSUM = $(shell pwd)/bin/gotestsum .PHONY: gotestsum gotestsum: ## Download gotestsum locally if necessary. - @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install gotest.tools/gotestsum@v1.8.2 \ No newline at end of file + @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install gotest.tools/gotestsum@v1.8.2 + + +.PHONY: generate-apiref +generate-apiref: genref + cd $(PROJECT_DIR)/hack/genref/ && $(GENREF) -o $(PROJECT_DIR)/site/content/en/docs/reference + +GENREF = $(PROJECT_DIR)/bin/genref +.PHONY: genref +genref: ## Download genref locally if necessary. + @GOBIN=$(PROJECT_DIR)/bin $(GO_CMD) install github.com/kubernetes-sigs/reference-docs/genref@v0.28.0 \ No newline at end of file diff --git a/hack/genref/config.yaml b/hack/genref/config.yaml new file mode 100644 index 00000000..be3b7ef5 --- /dev/null +++ b/hack/genref/config.yaml @@ -0,0 +1,20 @@ +# more details can be found https://github.com/kubernetes-sigs/reference-docs/tree/master/genref +hiddenMemberFields: + - "TypeMeta" + - "ObjectMeta" + +apis: + - name: jobset + title: JobSet API + package: sigs.k8s.io/jobset + path: api/jobset/v1alpha2 + +externalPackages: + - match: ^k8s\.io/(api|apimachinery/pkg/apis)/ + target: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#{{- lower .TypeIdentifier -}}-{{- arrIndex .PackageSegments -1 -}}-{{- arrIndex .PackageSegments -2 -}} + - match: ^k8s\.io/apimachinery/pkg/api/resource\.Quantity$ + target: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity + - match: ^k8s.io/component-base/config/v1alpha1. + target: https://pkg.go.dev/k8s.io/component-base/config/v1alpha1#{{- .TypeIdentifier -}} + - match: ^time\.Duration$ + target: https://pkg.go.dev/time#Duration diff --git a/hack/genref/markdown/members.tpl b/hack/genref/markdown/members.tpl new file mode 100644 index 00000000..b9702186 --- /dev/null +++ b/hack/genref/markdown/members.tpl @@ -0,0 +1,34 @@ +{{ define "members" }} + {{/* . is a apiType */}} + {{- range .GetMembers -}} + {{/* . is a apiMember */}} + {{- if not .Hidden }} +{{ .FieldName }} + {{- if not .IsOptional }} [Required]{{- end -}} +
+{{/* Link for type reference */}} + {{- with .GetType -}} + {{- if .Link -}} +{{ .DisplayName }} + {{- else -}} +{{ .DisplayName }} + {{- end -}} + {{- end }} + + + {{- if .IsInline -}} +(Members of {{ .FieldName }} are embedded into this type.) + {{- end }} + {{ if .GetComment -}} + {{ .GetComment }} + {{- else -}} + No description provided. + {{- end }} + {{- if and (eq (.GetType.Name.Name) "ObjectMeta") -}} +Refer to the Kubernetes API documentation for the fields of the metadata field. + {{- end -}} + + + {{- end }} + {{- end }} +{{ end }} diff --git a/hack/genref/markdown/pkg.tpl b/hack/genref/markdown/pkg.tpl new file mode 100644 index 00000000..fea0397b --- /dev/null +++ b/hack/genref/markdown/pkg.tpl @@ -0,0 +1,46 @@ +{{ define "packages" -}} + +{{- range $idx, $val := .packages -}} +{{/* Special handling for config */}} + {{- if .IsMain -}} +--- +title: {{ .Title }} +content_type: tool-reference +package: {{ .DisplayName }} +auto_generated: true +description: Generated API reference documentation for {{ .DisplayName }}. +--- +{{ .GetComment -}} + {{- end -}} +{{- end }} + +## Resource Types + +{{ range .packages -}} + {{ $isConfig := (eq .GroupName "") }} + {{- range .VisibleTypes -}} + {{- if or .IsExported (and $isConfig (eq .DisplayName "Configuration")) }} +- [{{ .DisplayName }}]({{ .Link }}) + {{- end -}} + {{- end -}} +{{- end -}} + +{{ range .packages }} + {{ if ne .GroupName "" -}} + {{/* For package with a group name, list all type definitions in it. */}} + {{- range .VisibleTypes }} + {{- if or .Referenced .IsExported -}} +{{ template "type" . }} + {{- end -}} + {{ end }} + {{ else }} + {{/* For package w/o group name, list only types referenced. */}} + {{ $isConfig := (eq .GroupName "") }} + {{- range .VisibleTypes -}} + {{- if or .Referenced $isConfig -}} +{{ template "type" . }} + {{- end -}} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/hack/genref/markdown/type.tpl b/hack/genref/markdown/type.tpl new file mode 100644 index 00000000..e8e72358 --- /dev/null +++ b/hack/genref/markdown/type.tpl @@ -0,0 +1,37 @@ +{{ define "type" }} + +## `{{ .Name.Name }}` {#{{ .Anchor }}} + +{{ if eq .Kind "Alias" -}} +(Alias of `{{ .Underlying }}`) +{{ end }} + +{{- with .References }} +**Appears in:** +{{ range . }} +{{ if or .Referenced .IsExported -}} +- [{{ .DisplayName }}]({{ .Link }}) +{{ end -}} +{{- end -}} +{{- end }} + +{{ if .GetComment -}} +{{ .GetComment }} +{{ end }} +{{ if .GetMembers -}} + + + + {{/* . is a apiType */}} + {{- if .IsExported -}} +{{/* Add apiVersion and kind rows if deemed necessary */}} + + + {{ end -}} + +{{/* The actual list of members is in the following template */}} +{{- template "members" . -}} + +
FieldDescription
apiVersion
string
{{- .APIGroup -}}
kind
string
{{- .Name.Name -}}
+{{- end -}} +{{- end -}} diff --git a/site/content/en/docs/reference/jobset.v1alpha2.md b/site/content/en/docs/reference/jobset.v1alpha2.md new file mode 100644 index 00000000..17a53a0f --- /dev/null +++ b/site/content/en/docs/reference/jobset.v1alpha2.md @@ -0,0 +1,535 @@ +--- +title: JobSet API +content_type: tool-reference +package: jobset.x-k8s.io/v1alpha2 +auto_generated: true +description: Generated API reference documentation for jobset.x-k8s.io/v1alpha2. +--- + + +## Resource Types + + +- [JobSet](#jobset-x-k8s-io-v1alpha2-JobSet) + + +## `JobSet` {#jobset-x-k8s-io-v1alpha2-JobSet} + + +**Appears in:** + + + +

JobSet is the Schema for the jobsets API

+ + + + + + + + + + + + + + + + + +
FieldDescription
apiVersion
string
jobset.x-k8s.io/v1alpha2
kind
string
JobSet
spec [Required]
+JobSetSpec +
+ No description provided.
status [Required]
+JobSetStatus +
+ No description provided.
+ +## `FailurePolicy` {#jobset-x-k8s-io-v1alpha2-FailurePolicy} + + +**Appears in:** + +- [JobSetSpec](#jobset-x-k8s-io-v1alpha2-JobSetSpec) + + + + + + + + + + + + + + + +
FieldDescription
maxRestarts [Required]
+int32 +
+

MaxRestarts defines the limit on the number of JobSet restarts. +A restart is achieved by recreating all active child jobs.

+
rules [Required]
+[]FailurePolicyRule +
+

List of failure policy rules for this JobSet. +For a given Job failure, the rules will be evaluated in order, +and only the first matching rule will be executed. +If no matching rule is found, the RestartJobSet action is applied.

+
+ +## `FailurePolicyAction` {#jobset-x-k8s-io-v1alpha2-FailurePolicyAction} + +(Alias of `string`) + +**Appears in:** + +- [FailurePolicyRule](#jobset-x-k8s-io-v1alpha2-FailurePolicyRule) + + +

FailurePolicyAction defines the action the JobSet controller will take for +a given FailurePolicyRule.

+ + + + +## `FailurePolicyRule` {#jobset-x-k8s-io-v1alpha2-FailurePolicyRule} + + +**Appears in:** + +- [FailurePolicy](#jobset-x-k8s-io-v1alpha2-FailurePolicy) + + +

FailurePolicyRule defines a FailurePolicyAction to be executed if a child job +fails due to a reason listed in OnJobFailureReasons.

+ + + + + + + + + + + + + + + + + + + + +
FieldDescription
name [Required]
+string +
+

The name of the failure policy rule. +The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. +The name must match the regular expression "^A-Za-z?$".

+
action [Required]
+FailurePolicyAction +
+

The action to take if the rule is matched.

+
onJobFailureReasons [Required]
+[]string +
+

The requirement on the job failure reasons. The requirement +is satisfied if at least one reason matches the list. +The rules are evaluated in order, and the first matching +rule is executed. +An empty list applies the rule to any job failure reason.

+
targetReplicatedJobs
+[]string +
+

TargetReplicatedJobs are the names of the replicated jobs the operator applies to. +An empty list will apply to all replicatedJobs.

+
+ +## `JobSetSpec` {#jobset-x-k8s-io-v1alpha2-JobSetSpec} + + +**Appears in:** + +- [JobSet](#jobset-x-k8s-io-v1alpha2-JobSet) + + +

JobSetSpec defines the desired state of JobSet

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
replicatedJobs [Required]
+[]ReplicatedJob +
+

ReplicatedJobs is the group of jobs that will form the set.

+
network
+Network +
+

Network defines the networking options for the jobset.

+
successPolicy [Required]
+SuccessPolicy +
+

SuccessPolicy configures when to declare the JobSet as +succeeded. +The JobSet is always declared succeeded if all jobs in the set +finished with status complete.

+
failurePolicy [Required]
+FailurePolicy +
+

FailurePolicy, if set, configures when to declare the JobSet as +failed. +The JobSet is always declared failed if any job in the set +finished with status failed.

+
startupPolicy [Required]
+StartupPolicy +
+

StartupPolicy, if set, configures in what order jobs must be started

+
suspend [Required]
+bool +
+

Suspend suspends all running child Jobs when set to true.

+
managedBy
+string +
+

ManagedBy is used to indicate the controller or entity that manages a JobSet. +The built-in JobSet controller reconciles JobSets which don't have this +field at all or the field value is the reserved string +jobset.sigs.k8s.io/jobset-controller, but skips reconciling JobSets +with a custom value for this field.

+

The value must be a valid domain-prefixed path (e.g. acme.io/foo) - +all characters before the first "/" must be a valid subdomain as defined +by RFC 1123. All characters trailing the first "/" must be valid HTTP Path +characters as defined by RFC 3986. The value cannot exceed 63 characters. +The field is immutable.

+
ttlSecondsAfterFinished
+int32 +
+

TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished +execution (either Complete or Failed). If this field is set, +TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be +automatically deleted. When the JobSet is being deleted, its lifecycle +guarantees (e.g. finalizers) will be honored. If this field is unset, +the JobSet won't be automatically deleted. If this field is set to zero, +the JobSet becomes eligible to be deleted immediately after it finishes.

+
+ +## `JobSetStatus` {#jobset-x-k8s-io-v1alpha2-JobSetStatus} + + +**Appears in:** + +- [JobSet](#jobset-x-k8s-io-v1alpha2-JobSet) + + +

JobSetStatus defines the observed state of JobSet

+ + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
conditions
+[]k8s.io/apimachinery/pkg/apis/meta/v1.Condition +
+ No description provided.
restarts [Required]
+int32 +
+

Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy).

+
restartsCountTowardsMax [Required]
+int32 +
+

RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts.

+
terminalState [Required]
+string +
+

TerminalState the state of the JobSet when it finishes execution. +It can be either Complete or Failed. Otherwise, it is empty by default.

+
replicatedJobsStatus
+[]ReplicatedJobStatus +
+

ReplicatedJobsStatus track the number of JobsReady for each replicatedJob.

+
+ +## `Network` {#jobset-x-k8s-io-v1alpha2-Network} + + +**Appears in:** + +- [JobSetSpec](#jobset-x-k8s-io-v1alpha2-JobSetSpec) + + + + + + + + + + + + + + + + + + +
FieldDescription
enableDNSHostnames
+bool +
+

EnableDNSHostnames allows pods to be reached via their hostnames. +Pods will be reachable using the fully qualified pod hostname: +<jobSet.name>-<spec.replicatedJob.name>--.

+
subdomain
+string +
+

Subdomain is an explicit choice for a network subdomain name +When set, any replicated job in the set is added to this network. +Defaults to <jobSet.name> if not set.

+
publishNotReadyAddresses
+bool +
+

Indicates if DNS records of pods should be published before the pods are ready. +Defaults to True.

+
+ +## `Operator` {#jobset-x-k8s-io-v1alpha2-Operator} + +(Alias of `string`) + +**Appears in:** + +- [SuccessPolicy](#jobset-x-k8s-io-v1alpha2-SuccessPolicy) + + +

Operator defines the target of a SuccessPolicy or FailurePolicy.

+ + + + +## `ReplicatedJob` {#jobset-x-k8s-io-v1alpha2-ReplicatedJob} + + +**Appears in:** + +- [JobSetSpec](#jobset-x-k8s-io-v1alpha2-JobSetSpec) + + + + + + + + + + + + + + + + + + +
FieldDescription
name [Required]
+string +
+

Name is the name of the entry and will be used as a suffix +for the Job name.

+
template [Required]
+k8s.io/api/batch/v1.JobTemplateSpec +
+

Template defines the template of the Job that will be created.

+
replicas [Required]
+int32 +
+

Replicas is the number of jobs that will be created from this ReplicatedJob's template. +Jobs names will be in the format: <jobSet.name>-<spec.replicatedJob.name>-

+
+ +## `ReplicatedJobStatus` {#jobset-x-k8s-io-v1alpha2-ReplicatedJobStatus} + + +**Appears in:** + +- [JobSetStatus](#jobset-x-k8s-io-v1alpha2-JobSetStatus) + + +

ReplicatedJobStatus defines the observed ReplicatedJobs Readiness.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
name [Required]
+string +
+

Name of the ReplicatedJob.

+
ready [Required]
+int32 +
+

Ready is the number of child Jobs where the number of ready pods and completed pods +is greater than or equal to the total expected pod count for the Job (i.e., the minimum +of job.spec.parallelism and job.spec.completions).

+
succeeded [Required]
+int32 +
+

Succeeded is the number of successfully completed child Jobs.

+
failed [Required]
+int32 +
+

Failed is the number of failed child Jobs.

+
active [Required]
+int32 +
+

Active is the number of child Jobs with at least 1 pod in a running or pending state +which are not marked for deletion.

+
suspended [Required]
+int32 +
+

Suspended is the number of child Jobs which are in a suspended state.

+
+ +## `StartupPolicy` {#jobset-x-k8s-io-v1alpha2-StartupPolicy} + + +**Appears in:** + +- [JobSetSpec](#jobset-x-k8s-io-v1alpha2-JobSetSpec) + + + + + + + + + + + + +
FieldDescription
startupPolicyOrder [Required]
+StartupPolicyOptions +
+

StartupPolicyOrder determines the startup order of the ReplicatedJobs. +AnyOrder means to start replicated jobs in any order. +InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only +when all the jobs of the previous one are ready.

+
+ +## `StartupPolicyOptions` {#jobset-x-k8s-io-v1alpha2-StartupPolicyOptions} + +(Alias of `string`) + +**Appears in:** + +- [StartupPolicy](#jobset-x-k8s-io-v1alpha2-StartupPolicy) + + + + + +## `SuccessPolicy` {#jobset-x-k8s-io-v1alpha2-SuccessPolicy} + + +**Appears in:** + +- [JobSetSpec](#jobset-x-k8s-io-v1alpha2-JobSetSpec) + + + + + + + + + + + + + + + +
FieldDescription
operator [Required]
+Operator +
+

Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful

+
targetReplicatedJobs
+[]string +
+

TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. +A null or empty list will apply to all replicatedJobs.

+
+ \ No newline at end of file