API spec changes to support configuring workflow executors (#380)

* API spec changes to support configuring workflow executors

Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>

* Update api-docs

Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>

* Address review comments and generate CRD manifests

Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>

* Add multi-executor example

Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>

* Update appgroup_types.go

* Update appgroup_types.go

Co-authored-by: Jonathan Innis <jonathan.innis.ji@gmail.com>
This commit is contained in:
Nitish Malhotra 2021-09-03 15:46:01 -07:00 коммит произвёл GitHub
Родитель b7b480a7e6
Коммит e22ff10fdb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 395 добавлений и 10 удалений

Просмотреть файл

@ -71,6 +71,49 @@ type ApplicationSpec struct {
// Subcharts provides the dependency order among the subcharts of the application
// +optional
Subcharts []DAG `json:"subcharts,omitempty"`
// Workflow provides an option to specify one or more workflow executors to run
// as a DAG
// +optional
Workflow []Executor `json:"workflow,omitempty"`
}
// ExecutorType can either refer to a native executor (helmrelease and/or keptn) or
// be a custom executor defined by the end-user
type ExecutorType string
const (
// HelmReleaseExecutor type is a "deployment" executor native to Orkestra that is responsible for
// deploying the application through the `HelmRelease` custom resource for the fluxcd helm-controller
HelmReleaseExecutor ExecutorType = "helmrelease"
// KeptnExecutor type is a "evaluation" executor native to Orkestra that is respnsible for running
// evaluations tests and quality gates based rollouts and promotions.
// Important : A testing executor may not be used as a standalone executor and must always
// be executed after a deployment executor (i.e. must depend on a deployment executor) .
KeptnExecutor ExecutorType = "keptn"
// CustomExecutor lets the user specify their own executor template to be used either as a deployment
// executor, a testing executor or for any other action to be taken on behalf of the application node.
CustomExecutor ExecutorType = "custom"
)
type Executor struct {
// DAG contains the dependency information
// +required
DAG `json:",inline"`
// Type specifies the executor type to be run
// +kubebuilder:validation:Enum=helmrelease;keptn;custom
// +required
Type ExecutorType `json:"type,omitempty"`
// Image allows the end user to specify the docker image name and tag
// to be executed by the workflow node
// +optional
Image string `json:"image,omitempty"`
// Params hold executor specific properties
// +optional
Params *apiextensionsv1.JSON `json:"params,omitempty"`
}
type Release struct {

Просмотреть файл

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// Copyright (c) Microsoft Corporation.
@ -10,8 +11,8 @@ package v1alpha1
import (
"github.com/fluxcd/helm-controller/api/v2beta1"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@ -103,7 +104,7 @@ func (in *ApplicationGroupSpec) DeepCopyInto(out *ApplicationGroupSpec) {
}
if in.Interval != nil {
in, out := &in.Interval, &out.Interval
*out = new(v1.Duration)
*out = new(metav1.Duration)
**out = **in
}
}
@ -130,7 +131,7 @@ func (in *ApplicationGroupStatus) DeepCopyInto(out *ApplicationGroupStatus) {
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]v1.Condition, len(*in))
*out = make([]metav1.Condition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@ -167,6 +168,13 @@ func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Workflow != nil {
in, out := &in.Workflow, &out.Workflow
*out = make([]Executor, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec.
@ -227,7 +235,7 @@ func (in *ChartStatus) DeepCopyInto(out *ChartStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]v1.Condition, len(*in))
*out = make([]metav1.Condition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@ -264,18 +272,39 @@ func (in *DAG) DeepCopy() *DAG {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Executor) DeepCopyInto(out *Executor) {
*out = *in
in.DAG.DeepCopyInto(&out.DAG)
if in.Params != nil {
in, out := &in.Params, &out.Params
*out = new(v1.JSON)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Executor.
func (in *Executor) DeepCopy() *Executor {
if in == nil {
return nil
}
out := new(Executor)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Release) DeepCopyInto(out *Release) {
*out = *in
out.Interval = in.Interval
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
*out = new(v1.Duration)
*out = new(metav1.Duration)
**out = **in
}
if in.Values != nil {
in, out := &in.Values, &out.Values
*out = new(apiextensionsv1.JSON)
*out = new(v1.JSON)
(*in).DeepCopyInto(*out)
}
if in.Install != nil {

Просмотреть файл

@ -112,6 +112,13 @@ spec:
install:
description: Install holds the configuration for Helm install actions for this HelmRelease.
properties:
crds:
description: "CRDs upgrade CRDs from the Helm Chart's crds directory according to the CRD upgrade policy provided here. Valid values are `Skip`, `Create` or `CreateReplace`. Default is `Create` and if omitted CRDs are installed but not updated. \n Skip: do neither install nor replace (update) any CRDs. \n Create: new CRDs are created, existing CRDs are neither updated nor deleted. \n CreateReplace: new CRDs are created, existing CRDs are updated (replaced) but not deleted. \n By default, CRDs are applied (installed) during Helm install action. With this option users can opt-in to CRD replace existing CRDs on Helm install actions, which is not (yet) natively supported by Helm. https://helm.sh/docs/chart_best_practices/custom_resource_definitions."
enum:
- Skip
- Create
- CreateReplace
type: string
createNamespace:
description: CreateNamespace tells the Helm install action to create the HelmReleaseSpec.TargetNamespace if it does not exist yet. On uninstall, the namespace will not be garbage collected.
type: boolean
@ -124,6 +131,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm install has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm install has been performed.
type: boolean
remediation:
description: Remediation holds the remediation configuration for when the Helm install action for the HelmRelease fails. The default is to not perform any action.
properties:
@ -141,7 +151,7 @@ spec:
description: Replace tells the Helm install action to re-use the 'ReleaseName', but only if that name is a deleted release which remains in the history.
type: boolean
skipCRDs:
description: SkipCRDs tells the Helm install action to not install any CRDs. By default, CRDs are installed if not already present.
description: "SkipCRDs tells the Helm install action to not install any CRDs. By default, CRDs are installed if not already present. \n Deprecated use CRD policy (`crds`) attribute with value `Skip` instead."
type: boolean
timeout:
description: Timeout is the time to wait for any individual Kubernetes operation (like Jobs for hooks) during the performance of a Helm install action. Defaults to 'HelmReleaseSpec.Timeout'.
@ -163,6 +173,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm rollback has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm rollback has been performed.
type: boolean
force:
description: Force forces resource updates through a replacement strategy.
type: boolean
@ -200,6 +213,13 @@ spec:
cleanupOnFail:
description: CleanupOnFail allows deletion of new resources created during the Helm upgrade action when it fails.
type: boolean
crds:
description: "CRDs upgrade CRDs from the Helm Chart's crds directory according to the CRD upgrade policy provided here. Valid values are `Skip`, `Create` or `CreateReplace`. Default is `Skip` and if omitted CRDs are neither installed nor upgraded. \n Skip: do neither install nor replace (update) any CRDs. \n Create: new CRDs are created, existing CRDs are neither updated nor deleted. \n CreateReplace: new CRDs are created, existing CRDs are updated (replaced) but not deleted. \n By default, CRDs are not applied during Helm upgrade action. With this option users can opt-in to CRD upgrade, which is not (yet) natively supported by Helm. https://helm.sh/docs/chart_best_practices/custom_resource_definitions."
enum:
- Skip
- Create
- CreateReplace
type: string
disableHooks:
description: DisableHooks prevents hooks from running during the Helm upgrade action.
type: boolean
@ -209,6 +229,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm upgrade has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm upgrade has been performed.
type: boolean
force:
description: Force forces resource updates through a replacement strategy.
type: boolean
@ -259,6 +282,35 @@ spec:
- name
type: object
type: array
workflow:
description: Workflow provides an option to specify one or more workflow executors to run as a DAG
items:
properties:
dependencies:
description: Dependencies on other applications by name
items:
type: string
type: array
image:
description: Image allows the end user to specify the docker image name and tag to be executed by the workflow node
type: string
name:
description: Name of the application
type: string
params:
description: Params hold executor specific properties
x-kubernetes-preserve-unknown-fields: true
type:
description: Type specifies the executor type to be run
enum:
- helmrelease
- keptn
- custom
type: string
required:
- name
type: object
type: array
required:
- chart
- release

Просмотреть файл

@ -112,6 +112,13 @@ spec:
install:
description: Install holds the configuration for Helm install actions for this HelmRelease.
properties:
crds:
description: "CRDs upgrade CRDs from the Helm Chart's crds directory according to the CRD upgrade policy provided here. Valid values are `Skip`, `Create` or `CreateReplace`. Default is `Create` and if omitted CRDs are installed but not updated. \n Skip: do neither install nor replace (update) any CRDs. \n Create: new CRDs are created, existing CRDs are neither updated nor deleted. \n CreateReplace: new CRDs are created, existing CRDs are updated (replaced) but not deleted. \n By default, CRDs are applied (installed) during Helm install action. With this option users can opt-in to CRD replace existing CRDs on Helm install actions, which is not (yet) natively supported by Helm. https://helm.sh/docs/chart_best_practices/custom_resource_definitions."
enum:
- Skip
- Create
- CreateReplace
type: string
createNamespace:
description: CreateNamespace tells the Helm install action to create the HelmReleaseSpec.TargetNamespace if it does not exist yet. On uninstall, the namespace will not be garbage collected.
type: boolean
@ -124,6 +131,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm install has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm install has been performed.
type: boolean
remediation:
description: Remediation holds the remediation configuration for when the Helm install action for the HelmRelease fails. The default is to not perform any action.
properties:
@ -141,7 +151,7 @@ spec:
description: Replace tells the Helm install action to re-use the 'ReleaseName', but only if that name is a deleted release which remains in the history.
type: boolean
skipCRDs:
description: SkipCRDs tells the Helm install action to not install any CRDs. By default, CRDs are installed if not already present.
description: "SkipCRDs tells the Helm install action to not install any CRDs. By default, CRDs are installed if not already present. \n Deprecated use CRD policy (`crds`) attribute with value `Skip` instead."
type: boolean
timeout:
description: Timeout is the time to wait for any individual Kubernetes operation (like Jobs for hooks) during the performance of a Helm install action. Defaults to 'HelmReleaseSpec.Timeout'.
@ -163,6 +173,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm rollback has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm rollback has been performed.
type: boolean
force:
description: Force forces resource updates through a replacement strategy.
type: boolean
@ -200,6 +213,13 @@ spec:
cleanupOnFail:
description: CleanupOnFail allows deletion of new resources created during the Helm upgrade action when it fails.
type: boolean
crds:
description: "CRDs upgrade CRDs from the Helm Chart's crds directory according to the CRD upgrade policy provided here. Valid values are `Skip`, `Create` or `CreateReplace`. Default is `Skip` and if omitted CRDs are neither installed nor upgraded. \n Skip: do neither install nor replace (update) any CRDs. \n Create: new CRDs are created, existing CRDs are neither updated nor deleted. \n CreateReplace: new CRDs are created, existing CRDs are updated (replaced) but not deleted. \n By default, CRDs are not applied during Helm upgrade action. With this option users can opt-in to CRD upgrade, which is not (yet) natively supported by Helm. https://helm.sh/docs/chart_best_practices/custom_resource_definitions."
enum:
- Skip
- Create
- CreateReplace
type: string
disableHooks:
description: DisableHooks prevents hooks from running during the Helm upgrade action.
type: boolean
@ -209,6 +229,9 @@ spec:
disableWait:
description: DisableWait disables the waiting for resources to be ready after a Helm upgrade has been performed.
type: boolean
disableWaitForJobs:
description: DisableWaitForJobs disables waiting for jobs to complete after a Helm upgrade has been performed.
type: boolean
force:
description: Force forces resource updates through a replacement strategy.
type: boolean
@ -259,6 +282,35 @@ spec:
- name
type: object
type: array
workflow:
description: Workflow provides an option to specify one or more workflow executors to run as a DAG
items:
properties:
dependencies:
description: Dependencies on other applications by name
items:
type: string
type: array
image:
description: Image allows the end user to specify the docker image name and tag to be executed by the workflow node
type: string
name:
description: Name of the application
type: string
params:
description: Params hold executor specific properties
x-kubernetes-preserve-unknown-fields: true
type:
description: Type specifies the executor type to be run
enum:
- helmrelease
- keptn
- custom
type: string
required:
- name
type: object
type: array
required:
- chart
- release

Просмотреть файл

@ -101,6 +101,21 @@ Release
<p>Subcharts provides the dependency order among the subcharts of the application</p>
</td>
</tr>
<tr>
<td>
<code>workflow</code><br>
<em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.Executor">
[]Executor
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Workflow provides an option to specify one or more workflow executors to run
as a DAG</p>
</td>
</tr>
</table>
</td>
</tr>
@ -376,6 +391,21 @@ Release
<p>Subcharts provides the dependency order among the subcharts of the application</p>
</td>
</tr>
<tr>
<td>
<code>workflow</code><br>
<em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.Executor">
[]Executor
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Workflow provides an option to specify one or more workflow executors to run
as a DAG</p>
</td>
</tr>
</tbody>
</table>
</div>
@ -591,7 +621,8 @@ staging helm repo</p>
<p>
(<em>Appears on:</em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.Application">Application</a>,
<a href="#orkestra.azure.microsoft.com/v1alpha1.ApplicationSpec">ApplicationSpec</a>)
<a href="#orkestra.azure.microsoft.com/v1alpha1.ApplicationSpec">ApplicationSpec</a>,
<a href="#orkestra.azure.microsoft.com/v1alpha1.Executor">Executor</a>)
</p>
<p>DAG contains the dependency information</p>
<div class="md-typeset__scrollwrap">
@ -631,6 +662,90 @@ string
</table>
</div>
</div>
<h3 id="orkestra.azure.microsoft.com/v1alpha1.Executor">Executor
</h3>
<p>
(<em>Appears on:</em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.ApplicationSpec">ApplicationSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>DAG</code><br>
<em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.DAG">
DAG
</a>
</em>
</td>
<td>
<p>
(Members of <code>DAG</code> are embedded into this type.)
</p>
<p>DAG contains the dependency information</p>
</td>
</tr>
<tr>
<td>
<code>type</code><br>
<em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.ExecutorType">
ExecutorType
</a>
</em>
</td>
<td>
<p>Type specifies the executor type to be run</p>
</td>
</tr>
<tr>
<td>
<code>image</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Image allows the end user to specify the docker image name and tag
to be executed by the workflow node</p>
</td>
</tr>
<tr>
<td>
<code>params</code><br>
<em>
<a href="https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1?tab=doc#JSON">
Kubernetes pkg/apis/apiextensions/v1.JSON
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Params hold executor specific properties</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="orkestra.azure.microsoft.com/v1alpha1.ExecutorType">ExecutorType
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em>
<a href="#orkestra.azure.microsoft.com/v1alpha1.Executor">Executor</a>)
</p>
<p>ExecutorType can either refer to a native executor (helmrelease and/or keptn) or
be a custom executor defined by the end-user</p>
<h3 id="orkestra.azure.microsoft.com/v1alpha1.Release">Release
</h3>
<p>

Просмотреть файл

@ -0,0 +1,47 @@
apiVersion: orkestra.azure.microsoft.com/v1alpha1
kind: ApplicationGroup
metadata:
name: bookinfo
spec:
applications:
- name: bookinfo
dependencies: [ambassador]
spec:
chart:
url: "https://nitishm.github.io/charts"
name: bookinfo
version: v1
release:
targetNamespace: bookinfo
values:
productpage:
replicaCount: 1
details:
replicaCount: 1
reviews:
replicaCount: 1
ratings:
replicaCount: 1
workflow:
- name: helmrelease
dependencies: []
# image: azureorkestra/executor:v0.4.2
type: helmrelease
params: nil
- name: keptn
dependencies: ["helmrelease"]
# image: azureorkestra/keptn-executor:v0.1.0
type: keptn
params:
configmapRef:
name: keptn-config
namespace: orkestra
- name: my-custom-executor
dependencies: ["helmrelease"]
image: azureorkestra/my-custom-executor:v0.1.0
params:
foo:
bar: value
baz: value

Просмотреть файл

@ -0,0 +1,47 @@
apiVersion: orkestra.azure.microsoft.com/v1alpha1
kind: ApplicationGroup
metadata:
name: bookinfo
spec:
applications:
- name: bookinfo
dependencies: [ambassador]
spec:
chart:
url: "https://nitishm.github.io/charts"
name: bookinfo
version: v1
release:
targetNamespace: bookinfo
values:
productpage:
replicaCount: 1
details:
replicaCount: 1
reviews:
replicaCount: 1
ratings:
replicaCount: 1
workflow:
- name: helmrelease
dependencies: []
# image: azureorkestra/executor:v0.4.2
type: helmrelease
params: nil
- name: keptn
dependencies: ["helmrelease"]
# image: azureorkestra/keptn-executor:v0.1.0
type: keptn
params:
configmapRef:
name: keptn-config
namespace: orkestra
- name: my-custom-executor
dependencies: ["helmrelease"]
image: azureorkestra/my-custom-executor:v0.1.0
params:
foo:
bar: value
baz: value