Skip to content

Commit

Permalink
Add support for init containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Sheiko committed Apr 6, 2021
1 parent a75a259 commit 4476f8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/app2kube/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type App struct {
Deployment struct {
BlueGreenColor string `yaml:"blueGreenColor"`
Containers map[string]apiv1.Container `yaml:"containers"`
InitContainers map[string]apiv1.Container `yaml:"initContainers"`
ReplicaCount int32 `yaml:"replicaCount"`
RevisionHistoryLimit int32 `yaml:"revisionHistoryLimit"`
Strategy appsv1.DeploymentStrategy `yaml:"strategy"`
Expand Down
11 changes: 11 additions & 0 deletions pkg/app2kube/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ func (app *App) GetDeployment() (deployment *appsv1.Deployment, err error) {
containers = append(containers, container)
}

var initContainers []apiv1.Container
for name, icontainer := range app.Deployment.InitContainers {
icontainer.Name = strings.ToLower(name)
err = app.processContainer(&icontainer)
if err != nil {
return
}
initContainers = append(initContainers, icontainer)
}

deployment = &appsv1.Deployment{
ObjectMeta: app.GetObjectMeta(app.GetDeploymentName()),
Spec: appsv1.DeploymentSpec{
Expand All @@ -42,6 +52,7 @@ func (app *App) GetDeployment() (deployment *appsv1.Deployment, err error) {
Spec: apiv1.PodSpec{
AutomountServiceAccountToken: &app.Common.MountServiceAccountToken,
Containers: containers,
InitContainers: initContainers,
DNSPolicy: app.Common.DNSPolicy,
EnableServiceLinks: &app.Common.EnableServiceLinks,
NodeSelector: app.Common.NodeSelector,
Expand Down

0 comments on commit 4476f8b

Please sign in to comment.