@@ -33,6 +33,12 @@ import (
3333 "github.com/replicatedhq/embedded-cluster/pkg/spinner"
3434)
3535
36+ type Proxy struct {
37+ HTTPProxy string `json:"httpProxy"`
38+ HTTPSProxy string `json:"httpsProxy"`
39+ NoProxy string `json:"noProxy"`
40+ }
41+
3642// JoinCommandResponse is the response from the kots api we use to fetch the k0s join token.
3743type JoinCommandResponse struct {
3844 K0sJoinCommand string `json:"k0sJoinCommand"`
@@ -42,6 +48,7 @@ type JoinCommandResponse struct {
4248 EndUserK0sConfigOverrides string `json:"endUserK0sConfigOverrides"`
4349 MetricsBaseURL string `json:"metricsBaseURL"`
4450 AirgapRegistryAddress string `json:"airgapRegistryAddress"`
51+ Proxy * Proxy `json:"proxy"`
4552}
4653
4754// extractK0sConfigOverridePatch parses the provided override and returns a dig.Mapping that
@@ -197,6 +204,14 @@ var joinCommand = &cli.Command{
197204 }
198205 }
199206
207+ logrus .Debugf ("creating systemd unit files" )
208+ // both controller and worker nodes will have 'worker' in the join command
209+ if err := createSystemdUnitFiles (! strings .Contains (jcmd .K0sJoinCommand , "controller" ), jcmd .Proxy ); err != nil {
210+ err := fmt .Errorf ("unable to create systemd unit files: %w" , err )
211+ metrics .ReportJoinFailed (c .Context , jcmd .MetricsBaseURL , jcmd .ClusterID , err )
212+ return err
213+ }
214+
200215 logrus .Debugf ("joining node to cluster" )
201216 if err := runK0sInstallCommand (jcmd .K0sJoinCommand ); err != nil {
202217 err := fmt .Errorf ("unable to join node to cluster: %w" , err )
@@ -211,14 +226,6 @@ var joinCommand = &cli.Command{
211226 return err
212227 }
213228
214- logrus .Debugf ("creating systemd unit files" )
215- // both controller and worker nodes will have 'worker' in the join command
216- if err := createSystemdUnitFiles (! strings .Contains (jcmd .K0sJoinCommand , "controller" )); err != nil {
217- err := fmt .Errorf ("unable to create systemd unit files: %w" , err )
218- metrics .ReportJoinFailed (c .Context , jcmd .MetricsBaseURL , jcmd .ClusterID , err )
219- return err
220- }
221-
222229 logrus .Debugf ("starting %s service" , binName )
223230 if err := startK0sService (); err != nil {
224231 err := fmt .Errorf ("unable to start service: %w" , err )
@@ -384,28 +391,6 @@ func systemdUnitFileName() string {
384391 return fmt .Sprintf ("/etc/systemd/system/%s.service" , defaults .BinaryName ())
385392}
386393
387- // createSystemdUnitFiles links the k0s systemd unit file. this also creates a new
388- // systemd unit file for the local artifact mirror service.
389- func createSystemdUnitFiles (isWorker bool ) error {
390- dst := systemdUnitFileName ()
391- if _ , err := os .Lstat (dst ); err == nil {
392- if err := os .Remove (dst ); err != nil {
393- return err
394- }
395- }
396- src := "/etc/systemd/system/k0scontroller.service"
397- if isWorker {
398- src = "/etc/systemd/system/k0sworker.service"
399- }
400- if err := os .Symlink (src , dst ); err != nil {
401- return fmt .Errorf ("failed to create symlink: %w" , err )
402- }
403- if _ , err := helpers .RunCommand ("systemctl" , "daemon-reload" ); err != nil {
404- return fmt .Errorf ("unable to get reload systemctl daemon: %w" , err )
405- }
406- return installAndEnableLocalArtifactMirror ()
407- }
408-
409394// runK0sInstallCommand runs the k0s install command as provided by the kots
410395// adm api.
411396func runK0sInstallCommand (fullcmd string ) error {
0 commit comments