Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi/k8s: add host module for doing k8 lookups #71

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.atc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine AS builder
FROM golang:1.24-alpine AS builder

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.yokecd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine
FROM golang:1.24-alpine

WORKDIR /cmp

Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ tasks:

kube:
cmds:
- GOOS=wasip1 GOARCH=wasm go build -o kube.wasm ./cmd/examples/kube
- GOOS=wasip1 GOARCH=wasm go build -o basic.wasm ./examples/basic

pg:
cmds:
- GOOS=wasip1 GOARCH=wasm go build -o pg.wasm ./cmd/examples/pg
- GOOS=wasip1 GOARCH=wasm go build -o pg.wasm ./examples/embeddedfs

redis:
cmds:
- GOOS=wasip1 GOARCH=wasm go build -o redis.wasm ./cmd/examples/redis
- GOOS=wasip1 GOARCH=wasm go build -o redis.wasm ./examples/redis
37 changes: 33 additions & 4 deletions cmd/atc-installer/installer/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/yokecd/yoke/pkg/apis/airway/v1alpha1"
"github.com/yokecd/yoke/pkg/flight"
"github.com/yokecd/yoke/pkg/flight/wasi/k8s"
"github.com/yokecd/yoke/pkg/openapi"
)

Expand All @@ -34,6 +35,7 @@ type Config struct {
Port int `json:"port"`
ServiceAccountName string `json:"serviceAccountName"`
ImagePullPolicy corev1.PullPolicy `json:"ImagePullPolicy"`
GenerateTLS bool `json:"generateTLS"`
}

var (
Expand Down Expand Up @@ -140,7 +142,34 @@ func Run(cfg Config) error {
},
}

tls, err := NewTLS(svc)
const (
keyRootCA = "ca.crt"
keyServerCert = "server.crt"
keyServerKey = "server.key"
)

tls, err := func() (*TLS, error) {
if cfg.GenerateTLS {
return NewTLS(svc)
}
secret, err := k8s.Lookup[corev1.Secret](k8s.ResourceIdentifier{
Name: flight.Release() + "-tls",
Namespace: flight.Namespace(),
Kind: "Secret",
ApiVersion: "v1",
})
if err != nil && !k8s.IsErrNotFound(err) {
return nil, fmt.Errorf("failed to lookup tls secret: %v", err)
}
if secret != nil {
return &TLS{
RootCA: secret.Data[keyRootCA],
ServerCert: secret.Data[keyServerCert],
ServerKey: secret.Data[keyServerKey],
}, nil
}
return NewTLS(svc)
}()
if err != nil {
return err
}
Expand All @@ -155,9 +184,9 @@ func Run(cfg Config) error {
Namespace: flight.Namespace(),
},
Data: map[string][]byte{
"ca.crt": tls.RootCA,
"server.crt": tls.ServerCert,
"server.key": tls.ServerKey,
keyRootCA: tls.RootCA,
keyServerCert: tls.ServerCert,
keyServerKey: tls.ServerKey,
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/atc/internal/testing/Dockerfile.wasmcache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine AS builder
FROM golang:1.24-alpine AS builder

WORKDIR /app

Expand Down
6 changes: 2 additions & 4 deletions cmd/atc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,14 @@ func TestAirTrafficController(t *testing.T) {
"failed to detect new Backend version",
)

// ALthough we create a v1 version we will be able to fetch it as a v2 version.
// Although we create a v1 version we will be able to fetch it as a v2 version.
require.NoError(
t,
commander.Takeoff(ctx, yoke.TakeoffParams{
Release: "c4ts",
Flight: yoke.FlightParams{
Input: testutils.JsonReader(backendv1.Backend{
ObjectMeta: metav1.ObjectMeta{
Name: "c4ts",
},
ObjectMeta: metav1.ObjectMeta{Name: "c4ts"},
Spec: backendv1.BackendSpec{
Image: "yokecd/c4ts:test",
Replicas: 1,
Expand Down
Loading