зеркало из https://github.com/Azure/orkestra.git
Merge branch 'main' into more-create-tests
This commit is contained in:
Коммит
0cc6d7796c
|
@ -27,6 +27,7 @@ jobs:
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{raw}}
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
latest
|
latest
|
||||||
|
@ -43,4 +44,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
|
|
@ -45,7 +45,10 @@ spec:
|
||||||
{{- if .Values.cleanup.enabled }}
|
{{- if .Values.cleanup.enabled }}
|
||||||
- --cleanup-downloaded-charts
|
- --cleanup-downloaded-charts
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- --debug={{ .Values.debug.level }}
|
{{ if .Values.debug.enabled }}
|
||||||
|
- --debug
|
||||||
|
{{- end }}
|
||||||
|
- --log-level={{ .Values.logLevel | default 0 }}
|
||||||
env:
|
env:
|
||||||
- name: WORKFLOW_NAMESPACE
|
- name: WORKFLOW_NAMESPACE
|
||||||
value: {{ .Release.Namespace }}
|
value: {{ .Release.Namespace }}
|
||||||
|
|
|
@ -47,7 +47,9 @@ cleanup:
|
||||||
|
|
||||||
# set to dev mode until MVP
|
# set to dev mode until MVP
|
||||||
debug:
|
debug:
|
||||||
level: 5
|
enabled: true
|
||||||
|
|
||||||
|
logLevel: 5
|
||||||
|
|
||||||
|
|
||||||
# Dependency overlay values
|
# Dependency overlay values
|
||||||
|
|
|
@ -99,30 +99,41 @@ func (r *ApplicationGroupReconciler) reconcileApplications(l logr.Logger, appGro
|
||||||
}
|
}
|
||||||
|
|
||||||
if appCh.Dependencies() != nil {
|
if appCh.Dependencies() != nil {
|
||||||
for _, sc := range appCh.Dependencies() {
|
// take account of all embedded subcharts found in the application chart
|
||||||
cs := v1alpha1.ChartStatus{
|
embeddedSubcharts := make(map[string]bool)
|
||||||
Version: sc.Metadata.Version,
|
for _, d := range appCh.Dependencies() {
|
||||||
}
|
embeddedSubcharts[d.Name()] = true
|
||||||
appGroup.Status.Applications[i].Subcharts[sc.Name()] = cs
|
}
|
||||||
|
|
||||||
|
// Remove all explicit subchart entries from tracking map
|
||||||
|
for _, d := range appGroup.Spec.Applications[i].Spec.Subcharts {
|
||||||
|
delete(embeddedSubcharts, d.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the remaining set of dependencies that are not explicitly declared and
|
||||||
|
// add them to the groups application spec's subcharts list
|
||||||
|
for name := range embeddedSubcharts {
|
||||||
|
appGroup.Spec.Applications[i].Spec.Subcharts = append(appGroup.Spec.Applications[i].Spec.Subcharts, v1alpha1.DAG{Name: name})
|
||||||
}
|
}
|
||||||
|
|
||||||
stagingRepoName := r.StagingRepoName
|
stagingRepoName := r.StagingRepoName
|
||||||
// If Dependencies - extract subchart and push each to staging registry
|
// Package and push all application subcharts staging registry
|
||||||
// if isDependenciesEmbedded(appCh) {
|
|
||||||
for _, sc := range appCh.Dependencies() {
|
for _, sc := range appCh.Dependencies() {
|
||||||
cs := v1alpha1.ChartStatus{
|
chartStatus := v1alpha1.ChartStatus{
|
||||||
Version: sc.Metadata.Version,
|
Version: sc.Metadata.Version,
|
||||||
|
Staged: false,
|
||||||
|
Error: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy sc
|
// copy the subchart
|
||||||
scc := &chart.Chart{}
|
scc := &chart.Chart{}
|
||||||
_ = copier.Copy(scc, sc)
|
_ = copier.Copy(scc, sc)
|
||||||
|
|
||||||
if err := scc.Validate(); err != nil {
|
if err := scc.Validate(); err != nil {
|
||||||
ll.Error(err, "failed to validate application subchart for staging registry")
|
ll.Error(err, "failed to validate application subchart for staging registry")
|
||||||
err = fmt.Errorf("failed to validate application subchart for staging registry : %w", err)
|
err = fmt.Errorf("failed to validate application subchart for staging registry : %w", err)
|
||||||
cs.Error = err.Error()
|
chartStatus.Error = err.Error()
|
||||||
appGroup.Status.Applications[i].Subcharts[sc.Name()] = cs
|
appGroup.Status.Applications[i].Subcharts[sc.Name()] = chartStatus
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +152,8 @@ func (r *ApplicationGroupReconciler) reconcileApplications(l logr.Logger, appGro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ll.Error(err, "failed to save subchart package as tgz")
|
ll.Error(err, "failed to save subchart package as tgz")
|
||||||
err = fmt.Errorf("failed to save subchart package as tgz at location %s : %w", path, err)
|
err = fmt.Errorf("failed to save subchart package as tgz at location %s : %w", path, err)
|
||||||
cs.Error = err.Error()
|
chartStatus.Error = err.Error()
|
||||||
appGroup.Status.Applications[i].Subcharts[sc.Name()] = cs
|
appGroup.Status.Applications[i].Subcharts[sc.Name()] = chartStatus
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,16 +161,14 @@ func (r *ApplicationGroupReconciler) reconcileApplications(l logr.Logger, appGro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ll.Error(err, "failed to push application subchart to staging registry")
|
ll.Error(err, "failed to push application subchart to staging registry")
|
||||||
err = fmt.Errorf("failed to push application subchart to staging registry : %w", err)
|
err = fmt.Errorf("failed to push application subchart to staging registry : %w", err)
|
||||||
cs.Error = err.Error()
|
chartStatus.Error = err.Error()
|
||||||
appGroup.Status.Applications[i].Subcharts[sc.Name()] = cs
|
appGroup.Status.Applications[i].Subcharts[sc.Name()] = chartStatus
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.Staged = true
|
chartStatus.Staged = true
|
||||||
cs.Version = sc.Metadata.Version
|
|
||||||
cs.Error = ""
|
|
||||||
|
|
||||||
appGroup.Status.Applications[i].Subcharts[sc.Name()] = cs
|
appGroup.Status.Applications[i].Subcharts[sc.Name()] = chartStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,15 @@ import (
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// The set of executor actions which can be performed on a helmrelease object
|
||||||
|
Install ExecutorAction = "install"
|
||||||
|
Delete ExecutorAction = "delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExecutorAction defines the set of executor actions which can be performed on a helmrelease object
|
||||||
|
type ExecutorAction string
|
||||||
|
|
||||||
type argo struct {
|
type argo struct {
|
||||||
scheme *runtime.Scheme
|
scheme *runtime.Scheme
|
||||||
cli client.Client
|
cli client.Client
|
||||||
|
@ -288,7 +297,7 @@ func (a *argo) generateReverseWorkflow(ctx context.Context, l logr.Logger, nodes
|
||||||
Parameters: []v1alpha12.Parameter{
|
Parameters: []v1alpha12.Parameter{
|
||||||
{
|
{
|
||||||
Name: HelmReleaseArg,
|
Name: HelmReleaseArg,
|
||||||
Value: utils.ToStrPtr(utils.HrToYaml(hr)),
|
Value: utils.ToStrPtr(base64.StdEncoding.EncodeToString([]byte(utils.HrToYaml(hr)))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -306,7 +315,7 @@ func (a *argo) generateReverseWorkflow(ctx context.Context, l logr.Logger, nodes
|
||||||
|
|
||||||
updateWorkflowTemplates(a.rwf, entry)
|
updateWorkflowTemplates(a.rwf, entry)
|
||||||
|
|
||||||
updateWorkflowTemplates(a.rwf, defaultReverseExecutor())
|
updateWorkflowTemplates(a.rwf, defaultExecutor(HelmReleaseReverseExecutorName, Delete))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -344,7 +353,7 @@ func (a *argo) generateAppGroupTpls(ctx context.Context, g *v1alpha1.Application
|
||||||
|
|
||||||
// TODO: Add the executor template
|
// TODO: Add the executor template
|
||||||
// This should eventually be configurable
|
// This should eventually be configurable
|
||||||
updateWorkflowTemplates(a.wf, defaultExecutor())
|
updateWorkflowTemplates(a.wf, defaultExecutor(HelmReleaseExecutorName, Install))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -598,10 +607,10 @@ func updateWorkflowTemplates(wf *v1alpha12.Workflow, tpls ...v1alpha12.Template)
|
||||||
wf.Spec.Templates = append(wf.Spec.Templates, tpls...)
|
wf.Spec.Templates = append(wf.Spec.Templates, tpls...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultExecutor() v1alpha12.Template {
|
func defaultExecutor(tplName string, action ExecutorAction) v1alpha12.Template {
|
||||||
executorArgs := []string{"--spec", "{{inputs.parameters.helmrelease}}", "--timeout", "{{inputs.parameters.timeout}}", "--interval", "10s"}
|
executorArgs := []string{"--spec", "{{inputs.parameters.helmrelease}}", "--action", string(action), "--timeout", "{{inputs.parameters.timeout}}", "--interval", "10s"}
|
||||||
return v1alpha12.Template{
|
return v1alpha12.Template{
|
||||||
Name: HelmReleaseExecutorName,
|
Name: tplName,
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
ServiceAccountName: workflowServiceAccountName(),
|
||||||
Inputs: v1alpha12.Inputs{
|
Inputs: v1alpha12.Inputs{
|
||||||
Parameters: []v1alpha12.Parameter{
|
Parameters: []v1alpha12.Parameter{
|
||||||
|
@ -626,28 +635,6 @@ func defaultExecutor() v1alpha12.Template {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultReverseExecutor() v1alpha12.Template {
|
|
||||||
return v1alpha12.Template{
|
|
||||||
Name: HelmReleaseReverseExecutorName,
|
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
|
||||||
Inputs: v1alpha12.Inputs{
|
|
||||||
Parameters: []v1alpha12.Parameter{
|
|
||||||
{
|
|
||||||
Name: "helmrelease",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Executor: &v1alpha12.ExecutorConfig{
|
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
|
||||||
},
|
|
||||||
Resource: &v1alpha12.ResourceTemplate{
|
|
||||||
// SetOwnerReference: true,
|
|
||||||
Action: "delete",
|
|
||||||
Manifest: "{{inputs.parameters.helmrelease}}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateSubchartHelmRelease(a v1alpha1.Application, appName, scName, version, repo, targetNS string, isStaged bool) (*fluxhelmv2beta1.HelmRelease, error) {
|
func generateSubchartHelmRelease(a v1alpha1.Application, appName, scName, version, repo, targetNS string, isStaged bool) (*fluxhelmv2beta1.HelmRelease, error) {
|
||||||
hr := &fluxhelmv2beta1.HelmRelease{
|
hr := &fluxhelmv2beta1.HelmRelease{
|
||||||
TypeMeta: v1.TypeMeta{
|
TypeMeta: v1.TypeMeta{
|
||||||
|
|
|
@ -15,7 +15,7 @@ const (
|
||||||
|
|
||||||
ExecutorName = "executor"
|
ExecutorName = "executor"
|
||||||
ExecutorImage = "azureorkestra/executor"
|
ExecutorImage = "azureorkestra/executor"
|
||||||
ExecutorImageTag = "v0.2.0"
|
ExecutorImageTag = "v0.3.0"
|
||||||
|
|
||||||
ChartMuseumName = "chartmuseum"
|
ChartMuseumName = "chartmuseum"
|
||||||
)
|
)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче