mirror of
https://github.com/rancher/rke.git
synced 2025-07-04 19:17:16 +00:00
Add ability to deploy jobs with kubectl and not job task
This API is used solely in rancher local clusters.
This commit is contained in:
parent
bfa51fd41c
commit
fce6b15f18
@ -1,8 +1,11 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/rancher/rke/addons"
|
||||
@ -66,10 +69,21 @@ func (c *Cluster) deployKubeDNS(ctx context.Context) error {
|
||||
}
|
||||
log.Infof(ctx, "[addons] KubeDNS deployed successfully..")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) deployWithKubectl(ctx context.Context, addonYaml string) error {
|
||||
buf := bytes.NewBufferString(addonYaml)
|
||||
cmd := exec.Command("kubectl", "--kubeconfig", c.LocalKubeConfigPath, "apply", "-f", "-")
|
||||
cmd.Stdin = buf
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (c *Cluster) doAddonDeploy(ctx context.Context, addonYaml, resourceName string) error {
|
||||
if c.UseKubectlDeploy {
|
||||
return c.deployWithKubectl(ctx, addonYaml)
|
||||
}
|
||||
|
||||
err := c.StoreAddonConfigMap(ctx, addonYaml, resourceName)
|
||||
if err != nil {
|
||||
|
@ -40,6 +40,7 @@ type Cluster struct {
|
||||
LocalConnDialerFactory hosts.DialerFactory
|
||||
PrivateRegistriesMap map[string]v3.PrivateRegistry
|
||||
K8sWrapTransport k8s.WrapTransport
|
||||
UseKubectlDeploy bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user