Skip to content

Commit

Permalink
refactor(domain-name): replace kwasm.sh with spinkube.dev
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Pfennig <[email protected]>
  • Loading branch information
0xE282B0 committed Mar 5, 2025
1 parent 48d2b8b commit 2b3fb21
Show file tree
Hide file tree
Showing 47 changed files with 318 additions and 366 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ registry: ghcr.io/your-gh-username/runtime-class-manager
The `Tiltfile` included in this repository will take care of the following:

- Create the `kwasm` namespace and install the controller helm-chart in it.
- Create the `runtime-class-manager` namespace and install the controller helm-chart in it.
- Inject the development image in the deployment.
- Automatically reload the controller when you make changes to the code.

To run the controller, you just need to run the following command against an empty cluster:

```console
$ tilt up --stream
tilt up --stream
```
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ $(ENVTEST): $(LOCALBIN)

.PHONY: create-test-cluster
create-kind-cluster:
kind create cluster --config ./hack/kind.yaml --name kwasm
kind create cluster --config ./hack/kind.yaml --name rcm

.PHONY: kind-delete
kind-delete:
kind delete cluster --name kwasm
kind delete cluster --name rcm

.PHONY: kind
kind: create-kind-cluster install
Expand Down
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: kwasm.sh
domain: spinkube.dev
layout:
- go.kubebuilder.io/v4
projectName: runtime-class-manager
Expand All @@ -12,18 +12,18 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: kwasm.sh
domain: spinkube.dev
group: runtime
kind: Shim
path: github.com/spinkube/runtime-class-manager/api/v1alpha1
version: v1alpha1
- controller: true
domain: kwasm.sh
domain: spinkube.dev
group: runtime
kind: Node
version: v1alpha1
- controller: true
domain: kwasm.sh
domain: spinkube.dev
group: runtime
kind: Job
version: v1alpha1
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

// Package v1alpha1 contains API Schema definitions for the runtime v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=runtime.kwasm.sh
// +groupName=runtime.spinkube.dev
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "runtime.kwasm.sh", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "runtime.spinkube.dev", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
2 changes: 1 addition & 1 deletion cmd/node-installer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Config struct {
Name string
ConfigPath string
}
Kwasm struct {
RCM struct {
Path string
AssetPath string
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/node-installer/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/default"),
Expand All @@ -68,7 +68,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/default"),
Expand All @@ -87,7 +87,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/unsupported"),
Expand All @@ -106,7 +106,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/microk8s"),
Expand All @@ -125,7 +125,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/k0s"),
Expand All @@ -144,7 +144,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/k3s"),
Expand All @@ -163,7 +163,7 @@ func Test_DetectDistro(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{""},
},
tests.FixtureFs("../../testdata/node-installer/distros/rke2"),
Expand Down
10 changes: 5 additions & 5 deletions cmd/node-installer/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,32 @@ var installCmd = &cobra.Command{
}

func init() {
installCmd.Flags().StringVarP(&config.Kwasm.AssetPath, "asset-path", "a", "/assets", "Path to the asset to install")
installCmd.Flags().StringVarP(&config.RCM.AssetPath, "asset-path", "a", "/assets", "Path to the asset to install")
rootCmd.AddCommand(installCmd)
}

func RunInstall(config Config, rootFs, hostFs afero.Fs, restarter containerd.Restarter) error {
// Get file or directory information.
info, err := rootFs.Stat(config.Kwasm.AssetPath)
info, err := rootFs.Stat(config.RCM.AssetPath)
if err != nil {
return err
}

var files []fs.FileInfo
// Check if the path is a directory.
if info.IsDir() {
files, err = afero.ReadDir(rootFs, config.Kwasm.AssetPath)
files, err = afero.ReadDir(rootFs, config.RCM.AssetPath)
if err != nil {
return err
}
} else {
// If the path is not a directory, add the file to the list of files.
files = append(files, info)
config.Kwasm.AssetPath = path.Dir(config.Kwasm.AssetPath)
config.RCM.AssetPath = path.Dir(config.RCM.AssetPath)
}

containerdConfig := containerd.NewConfig(hostFs, config.Runtime.ConfigPath, restarter)
shimConfig := shim.NewConfig(rootFs, hostFs, config.Kwasm.AssetPath, config.Kwasm.Path)
shimConfig := shim.NewConfig(rootFs, hostFs, config.RCM.AssetPath, config.RCM.Path)

anythingChanged := false
for _, file := range files {
Expand Down
4 changes: 2 additions & 2 deletions cmd/node-installer/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Test_RunInstall(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{"/containerd/missing-containerd-shim-config"},
},
tests.FixtureFs("../../testdata/node-installer"),
Expand All @@ -72,7 +72,7 @@ func Test_RunInstall(t *testing.T) {
struct {
Path string
AssetPath string
}{"/opt/kwasm", "/assets"},
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{"/containerd/existing-containerd-shim-config"},
},
tests.FixtureFs("../../testdata/node-installer"),
Expand Down
16 changes: 7 additions & 9 deletions cmd/node-installer/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ import (
"github.com/spf13/viper"
)

var (
config Config
)
var config Config

// rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{
Use: "kwasm-node-installer",
Short: "kwasm-node-installer manages containerd shims",
Use: "rcm-node-installer",
Short: "rcm-node-installer manages containerd shims",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
return initializeConfig(cmd)
},
Expand All @@ -52,14 +50,14 @@ func Execute() {
func init() {
rootCmd.PersistentFlags().StringVarP(&config.Runtime.Name, "runtime", "r", "containerd", "Set the container runtime to configure (containerd, cri-o)")
rootCmd.PersistentFlags().StringVarP(&config.Runtime.ConfigPath, "runtime-config", "c", "", "Path to the runtime config file. Will try to autodetect if left empty")
rootCmd.PersistentFlags().StringVarP(&config.Kwasm.Path, "kwasm-path", "k", "/opt/kwasm", "Working directory for kwasm on the host")
rootCmd.PersistentFlags().StringVarP(&config.RCM.Path, "rcm-path", "k", "/opt/rcm", "Working directory for the RuntimeClassManager on the host")
rootCmd.PersistentFlags().StringVarP(&config.Host.RootPath, "host-root", "H", "/", "Path to the host root path")
}

func initializeConfig(cmd *cobra.Command) error {
v := viper.New()

v.SetConfigName("kwasm")
v.SetConfigName("rcm")

v.AddConfigPath(".")
v.AddConfigPath("/etc")
Expand All @@ -70,8 +68,8 @@ func initializeConfig(cmd *cobra.Command) error {
}
}

// Environment variables are prefixed with KWASM_
v.SetEnvPrefix("KWASM")
// Environment variables are prefixed with RCM_
v.SetEnvPrefix("RCM")

// - is replaced with _ in environment variables
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
Expand Down
4 changes: 2 additions & 2 deletions cmd/node-installer/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func init() {
func RunUninstall(config Config, rootFs, hostFs afero.Fs, restarter containerd.Restarter) error {
slog.Info("uninstall called", "shim", config.Runtime.Name)
shimName := config.Runtime.Name
runtimeName := path.Join(config.Kwasm.Path, "bin", shimName)
runtimeName := path.Join(config.RCM.Path, "bin", shimName)

containerdConfig := containerd.NewConfig(hostFs, config.Runtime.ConfigPath, restarter)
shimConfig := shim.NewConfig(rootFs, hostFs, config.Kwasm.AssetPath, config.Kwasm.Path)
shimConfig := shim.NewConfig(rootFs, hostFs, config.RCM.AssetPath, config.RCM.Path)

binPath, err := shimConfig.Uninstall(shimName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/rcm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func main() {
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "7584d300.kwasm.sh",
LeaderElectionID: "7584d300.spinkube.dev",
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/runtime.kwasm.sh_shims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
name: shims.runtime.kwasm.sh
name: shims.runtime.spinkube.dev
spec:
group: runtime.kwasm.sh
group: runtime.spinkube.dev
names:
kind: Shim
listKind: ShimList
Expand Down
Loading

0 comments on commit 2b3fb21

Please sign in to comment.