mirror of
https://github.com/rancher/rke.git
synced 2025-07-05 03:28:08 +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
|
package cluster
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rancher/rke/addons"
|
"github.com/rancher/rke/addons"
|
||||||
@ -66,10 +69,21 @@ func (c *Cluster) deployKubeDNS(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
log.Infof(ctx, "[addons] KubeDNS deployed successfully..")
|
log.Infof(ctx, "[addons] KubeDNS deployed successfully..")
|
||||||
return nil
|
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 {
|
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)
|
err := c.StoreAddonConfigMap(ctx, addonYaml, resourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,6 +40,7 @@ type Cluster struct {
|
|||||||
LocalConnDialerFactory hosts.DialerFactory
|
LocalConnDialerFactory hosts.DialerFactory
|
||||||
PrivateRegistriesMap map[string]v3.PrivateRegistry
|
PrivateRegistriesMap map[string]v3.PrivateRegistry
|
||||||
K8sWrapTransport k8s.WrapTransport
|
K8sWrapTransport k8s.WrapTransport
|
||||||
|
UseKubectlDeploy bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user