Skip to content

Commit

Permalink
Move custom tekton resources to flux (TraceMachina#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmondal authored Nov 2, 2024
1 parent 8a3869c commit f877ab0
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 144 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/lre.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ jobs:
kubectl apply -k . &&
rm kustomization.yaml'
- name: Wait for Tekton resources
run: >
nix develop --impure --command
bash -c "flux reconcile kustomization -n default \
--timeout=15m \
nativelink-tekton-resources"
- name: Wait for Tekton pipelines
run: >
nix develop --impure --command
Expand Down
19 changes: 19 additions & 0 deletions kubernetes/components/operator/flux-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,22 @@ spec:
name: nativelink-image-tags
dependsOn:
- name: nativelink-configmaps
- name: nativelink-tekton-resources
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: nativelink-tekton-resources
namespace: default
spec:
interval: 2m
path: "./kubernetes/components/tekton-resources"
prune: true
force: true
retryInterval: 20s
targetNamespace: default
wait: true
sourceRef:
kind: GitRepository
name: nativelink
namespace: default
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- cosign-verify.yaml
- nix2container-copyto.yaml
- nix2container-image-info.yaml
- rebuild-nativelink.yaml
- skopeo-copy.yaml
- cosign-verify.yaml
- skopeo-check-hashlocked-url.yaml
- nix2container-image-info.yaml
- skopeo-copy.yaml
- trigger.yaml
- update-image-tags.yaml
- capacitor.yaml
# - nativelink-gateways.yaml # Gateways are handled in Pulumi via the
# NativeLinkGateways resource.
File renamed without changes.
40 changes: 40 additions & 0 deletions native-cli/components/capacitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package components

import (
_ "embed"
"fmt"

"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/yaml"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

type Capacitor struct {
Dependencies []pulumi.Resource
}

// These are vendored yaml files which we don't port to Pulumi so that we can
// potentially adjust/reuse them in more generic contexts. We embed them in the
// executable to keep the cli portable.
//
//go:embed embedded/capacitor.yaml
var capacitorYaml string

// Install sets up the Capacitor dashboard.
func (component *Capacitor) Install(
ctx *pulumi.Context,
name string,
) ([]pulumi.Resource, error) {
capacitor, err := yaml.NewConfigGroup(
ctx,
name,
&yaml.ConfigGroupArgs{
YAML: []string{capacitorYaml},
},
pulumi.DependsOn(component.Dependencies),
)
if err != nil {
return nil, fmt.Errorf("%w: %w", errPulumi, err)
}

return []pulumi.Resource{capacitor}, nil
}
109 changes: 0 additions & 109 deletions native-cli/components/rebuild-nativelink.go

This file was deleted.

4 changes: 2 additions & 2 deletions native-cli/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
}:
buildGoModule {
pname = "native-cli";
version = "0.4.0";
version = "0.5.3";
src = ./.;
vendorHash = "sha256-ASmQhGHplG4ayeezhhM4R01pZLBLjYcqEuKVVxNADX0=";
vendorHash = "sha256-F6nEK/KylCcNvBscXnNYDSwOHiKLpSlCWv19GistNpI=";
buildInputs = [makeWrapper];
ldflags = ["-s -w"];
installPhase = ''
Expand Down
41 changes: 14 additions & 27 deletions native-cli/programs/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,23 @@ func ProgramForLocalCluster(ctx *pulumi.Context) error {
os.Exit(1)
}

localSources, err := components.AddComponent(
components.Check(components.AddComponent(
ctx,
"local-sources",
&components.LocalPVAndPVC{
Size: "50Mi",
HostPath: "/mnt",
},
)
if err != nil {
log.Println(err)
os.Exit(1)
}
))

nixStore, err := components.AddComponent(
components.Check(components.AddComponent(
ctx,
"nix-store",
&components.LocalPVAndPVC{
Size: "10Gi",
HostPath: "/nix",
},
)
if err != nil {
log.Println(err)
os.Exit(1)
}
))

flux, err := components.AddComponent(
ctx,
Expand All @@ -68,6 +60,16 @@ func ProgramForLocalCluster(ctx *pulumi.Context) error {
os.Exit(1)
}

components.Check(components.AddComponent(
ctx,
"capacitor",
&components.Capacitor{
Dependencies: slices.Concat(
flux,
),
},
))

tektonPipelines, err := components.AddComponent(
ctx,
"tekton-pipelines",
Expand Down Expand Up @@ -106,21 +108,6 @@ func ProgramForLocalCluster(ctx *pulumi.Context) error {
},
))

components.Check(components.AddComponent(
ctx,
"rebuild-nativelink",
&components.RebuildNativeLink{
Dependencies: slices.Concat(
cilium,
tektonPipelines,
tektonTriggers,
localSources,
nixStore,
flux,
),
},
))

nativeLinkGateways, err := components.AddComponent(
ctx,
"nativelink-gatways",
Expand Down

0 comments on commit f877ab0

Please sign in to comment.