@@ -18,9 +18,11 @@ import (
1818 "github.com/k0sproject/k0s/internal/pkg/stringmap"
1919 "github.com/k0sproject/k0s/internal/pkg/sysinfo"
2020 "github.com/k0sproject/k0s/internal/supervised"
21+ "github.com/k0sproject/k0s/pkg/build"
2122 "github.com/k0sproject/k0s/pkg/component/iptables"
2223 "github.com/k0sproject/k0s/pkg/component/manager"
2324 "github.com/k0sproject/k0s/pkg/component/prober"
25+ "github.com/k0sproject/k0s/pkg/component/status"
2426 "github.com/k0sproject/k0s/pkg/component/worker"
2527 workerconfig "github.com/k0sproject/k0s/pkg/component/worker/config"
2628 "github.com/k0sproject/k0s/pkg/component/worker/containerd"
@@ -298,6 +300,27 @@ func (c *Command) Start(ctx context.Context, nodeName apitypes.NodeName, kubelet
298300
299301 addPlatformSpecificComponents (ctx , componentManager , c .K0sVars , controller , certManager )
300302
303+ if controller == nil {
304+ // if running inside a controller, status component is already running
305+ componentManager .Add (ctx , & status.Status {
306+ Prober : prober .DefaultProber ,
307+ StatusInformation : status.K0sStatus {
308+ Pid : os .Getpid (),
309+ Role : "worker" ,
310+ Args : os .Args ,
311+ Version : build .Version ,
312+ Workloads : true ,
313+ SingleNode : false ,
314+ K0sVars : c .K0sVars ,
315+ // worker does not have cluster config. this is only shown in "k0s status -o json".
316+ // todo: if it's needed, a worker side config client can be set up and used to load the config
317+ ClusterConfig : nil ,
318+ },
319+ CertManager : certManager ,
320+ Socket : c .K0sVars .StatusSocketPath ,
321+ })
322+ }
323+
301324 // extract needed components
302325 if err := componentManager .Init (ctx ); err != nil {
303326 return err
0 commit comments