Skip to content

Commit

Permalink
SNRGY-1931 fix rancher 2 deploy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
franzmueller committed Apr 13, 2022
1 parent a71cc42 commit bff5e2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion pkg/deploy/rancher2-api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ func (r *Rancher2) UpdateContainer(id string, name string, image string, env map

func (r *Rancher2) CreateContainer(name string, image string, env map[string]string, restart bool) (id string, err error) {
request := gorequest.New().SetBasicAuth(r.accessKey, r.secretKey).TLSClientConfig(&tls.Config{InsecureSkipVerify: true})
r2Env := []Env{}
for k, v := range env {
r2Env = append(r2Env, Env{
Name: k,
Value: v,
})
}
reqBody := &Request{
Name: name,
NamespaceId: r.namespaceId,
Containers: []Container{{
Image: image,
Name: name,
Environment: env,
Env: r2Env,
ImagePullPolicy: "Always",
}},
Scheduling: Scheduling{Scheduler: "default-scheduler", Node: Node{RequireAll: []string{"role=worker"}}},
Expand Down
15 changes: 10 additions & 5 deletions pkg/deploy/rancher2-api/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ type Request struct {
}

type Container struct {
Image string `json:"image,omitempty"`
Name string `json:"name,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
Resources Resources `json:"resources,omitempty"`
Image string `json:"image,omitempty"`
Name string `json:"name,omitempty"`
Env []Env `json:"env,omitempty"`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
Resources Resources `json:"resources,omitempty"`
}
type Env struct {
Name string `json:"name"`
Value string `json:"value"`
}

type Resources struct {
Limits Limits `json:"limits,omitempty"`
}
Expand Down

0 comments on commit bff5e2d

Please sign in to comment.