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

app: backend: Add flag for watching plugins changes #2939

Open
wants to merge 1 commit 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
7 changes: 7 additions & 0 deletions app/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ const args = yargs(hideBin(process.argv))
describe: 'Disable use of GPU. For people who may have buggy graphics drivers',
type: 'boolean',
},
'watch-plugins-changes': {
describe: 'Reloads plugins when there are changes to them or their directory',
type: 'boolean',
},
})
.positional('kubeconfig', {
describe:
Expand Down Expand Up @@ -551,6 +555,9 @@ async function startServer(flags: string[] = []): Promise<ChildProcessWithoutNul
if (!!proxyUrls && proxyUrls.length > 0) {
serverArgs = serverArgs.concat(['--proxy-urls', proxyUrls.join(',')]);
}
if (args.watchPluginsChanges) {
serverArgs.push('--watch-plugins-changes');
}

const bundledPlugins = path.join(process.resourcesPath, '.plugins');

Expand Down
3 changes: 2 additions & 1 deletion backend/cmd/headlamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type HeadlampConfig struct {
insecure bool
enableHelm bool
enableDynamicClusters bool
watchPluginsChanges bool
port uint
kubeConfigPath string
staticDir string
Expand Down Expand Up @@ -355,7 +356,7 @@ func createHeadlampHandler(config *HeadlampConfig) http.Handler {

plugins.PopulatePluginsCache(config.staticPluginDir, config.pluginDir, config.cache)

if !config.useInCluster {
if !config.useInCluster || config.watchPluginsChanges {
// in-cluster mode is unlikely to want reloading plugins.
pluginEventChan := make(chan string)
go plugins.Watch(config.pluginDir, pluginEventChan)
Expand Down
1 change: 1 addition & 0 deletions backend/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func main() {
proxyURLs: strings.Split(conf.ProxyURLs, ","),
enableHelm: conf.EnableHelm,
enableDynamicClusters: conf.EnableDynamicClusters,
watchPluginsChanges: conf.WatchPluginsChanges,
cache: cache,
kubeConfigStore: kubeConfigStore,
multiplexer: multiplexer,
Expand Down
2 changes: 2 additions & 0 deletions backend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Config struct {
EnableHelm bool `koanf:"enable-helm"`
EnableDynamicClusters bool `koanf:"enable-dynamic-clusters"`
ListenAddr string `koanf:"listen-addr"`
WatchPluginsChanges bool `koanf:"watch-plugins-changes"`
Port uint `koanf:"port"`
KubeConfigPath string `koanf:"kubeconfig"`
StaticDir string `koanf:"html-static-dir"`
Expand Down Expand Up @@ -154,6 +155,7 @@ func flagset() *flag.FlagSet {
f.Bool("dev", false, "Allow connections from other origins")
f.Bool("insecure-ssl", false, "Accept/Ignore all server SSL certificates")
f.Bool("enable-dynamic-clusters", false, "Enable dynamic clusters, which stores stateless clusters in the frontend.")
f.Bool("watch-plugins-changes", true, "Reloads plugins when there are changes to them or their directory")

f.String("kubeconfig", "", "Absolute path to the kubeconfig file")
f.String("html-static-dir", "", "Static HTML directory to serve")
Expand Down
2 changes: 1 addition & 1 deletion docs/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ DOCKER_IMAGE_VERSION=development make image
#### Create a deployment yaml

```bash
kubectl create deployment headlamp -n kube-system --image=headlamp-k8s/headlamp:development -o yaml --dry-run -- /headlamp/headlamp-server -html-static-dir /headlamp/frontend -in-cluster -plugins-dir=/headlamp/plugins > minikube-headlamp.yaml
kubectl create deployment headlamp -n kube-system --image=headlamp-k8s/headlamp:development -o yaml --dry-run -- /headlamp/headlamp-server -html-static-dir /headlamp/frontend -in-cluster -watch-plugins-changes false -plugins-dir=/headlamp/plugins > minikube-headlamp.yaml
```

To use the local container image we change the `imagePullPolicy` to Never.
Expand Down
Loading