Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat: mirror workflow images
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcodelf authored and thxCode committed Nov 22, 2023
1 parent 974b157 commit 9ddbecf
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
13 changes: 13 additions & 0 deletions hack/mirror/full_image_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
docker.io/sealio/mirrored-node-exporter:v1.6.0
docker.io/sealio/mirrored-prometheus-config-reloader:v0.67.0
docker.io/sealio/mirrored-prometheus:v2.46.0
docker.io/sealio/mirrored-kube-state-metrics:v2.9.2
docker.io/sealio/mirrored-kubecost-cost-model:v1.105.2
docker.io/sealio/mirrored-workflow-controller:v3.5.0
docker.io/sealio/mirrored-argoexec:v3.5.0
docker.io/sealio/mirrored-argocli:v3.5.0
docker.io/sealio/terraform-deployer:v0.1.4
docker.io/sealio/walrus:v0.4.0
docker.io/sealio/casdoor:v1.344.0-seal.1
docker.io/sealio/curl-jq:v0.0.1
docker.io/postgres:14.8
3 changes: 3 additions & 0 deletions hack/mirror/mirror_image_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ quay.io/prometheus-operator/prometheus-config-reloader:v0.67.0 docker.io/sealio
quay.io/prometheus/prometheus:v2.46.0 docker.io/sealio/mirrored-prometheus:v2.46.0
registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.9.2 docker.io/sealio/mirrored-kube-state-metrics:v2.9.2
quay.io/kubecost1/kubecost-cost-model:1.105.2 docker.io/sealio/mirrored-kubecost-cost-model:v1.105.2
quay.io/argoproj/workflow-controller:v3.5.0 docker.io/sealio/mirrored-workflow-controller:v3.5.0
quay.io/argoproj/argoexec:v3.5.0 docker.io/sealio/mirrored-argoexec:v3.5.0
quay.io/argoproj/argocli:v3.5.0 docker.io/sealio/mirrored-argocli:v3.5.0
7 changes: 4 additions & 3 deletions pkg/server/init_workflow_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/seal-io/walrus/pkg/dao/model"
"github.com/seal-io/walrus/pkg/dao/types"
"github.com/seal-io/walrus/pkg/workflow/deployer"
"github.com/seal-io/walrus/utils/gopool"
Expand Down Expand Up @@ -39,7 +40,7 @@ func (r *Server) setupWorkflowRuntime(ctx context.Context, opts initOptions) err
}
}

applyWorkflowDeployment(ctx, opts.K8sConfig)
applyWorkflowDeployment(opts.ModelClient, opts.K8sConfig)

return nil
}
Expand Down Expand Up @@ -246,9 +247,9 @@ func applyWorkflowPermission(ctx context.Context, cli *kubernetes.Clientset) err
return nil
}

func applyWorkflowDeployment(_ context.Context, config *rest.Config) {
func applyWorkflowDeployment(mc model.ClientSet, config *rest.Config) {
gopool.Go(func() {
err := deployer.DeployArgoWorkflow(context.Background(), config)
err := deployer.DeployArgoWorkflow(context.Background(), mc, config)
if err != nil {
log.WithName("workflow").Errorf("failed to deploy argo workflow: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ var (
"WorkflowStepServiceImage",
editable,
// When the image is updated, sync the one in server Dockerfile.
// TODO replace with seal curl-jq image.
initializeFromEnv("badouralix/curl-jq"),
initializeFromEnv("sealio/curl-jq:v0.0.1"),
modifyWith(notBlank, containerImageReference),
)
)
Expand Down
42 changes: 37 additions & 5 deletions pkg/workflow/deployer/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/seal-io/walrus/pkg/dao/model"
"github.com/seal-io/walrus/pkg/dao/types"
"github.com/seal-io/walrus/pkg/k8s"
"github.com/seal-io/walrus/pkg/k8s/deploy"
"github.com/seal-io/walrus/pkg/settings"
)

const NameWorkflow = "walrus-workflow"

const (
imageServer = "sealio/mirrored-argocli"
imageController = "sealio/mirrored-workflow-controller"
imageExecutor = "sealio/mirrored-argoexec"
tag = "v3.5.0"
)

const (
defaultWorkflowChartURL = "https://github.com/argoproj/argo-helm/releases/download/" +
"argo-workflows-0.36.1/argo-workflows-0.36.1.tgz"
Expand All @@ -41,10 +50,30 @@ var defaultWorkflowChartPath = func() string {
return path.Join(cdir, defaultWorkflowChart)
}()

func workflow() *deploy.ChartApp {
func workflow(imageRegistry string) *deploy.ChartApp {
imageConfig := func(repo string) map[string]any {
cfg := map[string]any{
"registry": imageRegistry,
"tag": tag,
}

if repo != "" {
cfg["repository"] = repo
}

return cfg
}

values := map[string]any{
"server": map[string]any{
"image": imageConfig(imageServer),
},
"controller": map[string]any{
"name": "controller",
"name": "controller",
"image": imageConfig(imageController),
},
"executor": map[string]any{
"image": imageConfig(imageExecutor),
},
"fullnameOverride": NameWorkflow,
"crds": map[string]any{
Expand All @@ -61,8 +90,11 @@ func workflow() *deploy.ChartApp {
}
}

func DeployArgoWorkflow(ctx context.Context, config *rest.Config) error {
clientConfig := k8s.ToClientCmdApiConfig(config)
func DeployArgoWorkflow(ctx context.Context, mc model.ClientSet, config *rest.Config) error {
var (
imageRegistry = settings.ImageRegistry.ShouldValue(ctx, mc)
clientConfig = k8s.ToClientCmdApiConfig(config)
)

kubeCfg, err := clientcmd.Write(clientConfig)
if err != nil {
Expand All @@ -74,5 +106,5 @@ func DeployArgoWorkflow(ctx context.Context, config *rest.Config) error {
return err
}

return d.EnsureChart(workflow(), false)
return d.EnsureChart(workflow(imageRegistry), false)
}
4 changes: 4 additions & 0 deletions pkg/workflow/step/service_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"path"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -111,6 +112,9 @@ func (s *ServiceStepManager) GenerateTemplates(
stepExecution *model.WorkflowStepExecution,
) (main *wfv1.Template, subTemplates []*wfv1.Template, err error) {
deployerImage := settings.WorkflowStepServiceImage.ShouldValue(ctx, s.mc)
imageRegistry := settings.ImageRegistry.ShouldValue(ctx, s.mc)

deployerImage = path.Join(imageRegistry, deployerImage)

environment, ok := stepExecution.Attributes["environment"].(map[string]any)
if !ok {
Expand Down

0 comments on commit 9ddbecf

Please sign in to comment.