Skip to content

Commit

Permalink
Add ReplicaCountStaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Sheiko committed Jul 12, 2023
1 parent aad4597 commit 8ec2740
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/app2kube/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type App struct {
Containers map[string]apiv1.Container `yaml:"containers"`
InitContainers map[string]apiv1.Container `yaml:"initContainers"`
ReplicaCount int32 `yaml:"replicaCount"`
ReplicaCountStaging int32 `yaml:"replicaCountStaging"`
RevisionHistoryLimit int32 `yaml:"revisionHistoryLimit"`
Strategy appsv1.DeploymentStrategy `yaml:"strategy"`
} `yaml:"deployment"`
Expand Down Expand Up @@ -228,6 +229,12 @@ func (app *App) LoadValues(valueFiles ValueFiles, values, stringValues, fileValu
app.Staging = strings.ToLower(app.Staging)
app.Branch = strings.ToLower(app.Branch)

if app.Deployment.ReplicaCountStaging > 0 {
app.Deployment.ReplicaCount = app.Deployment.ReplicaCountStaging
} else {
app.Deployment.ReplicaCount = 1
}

app.Labels["app.kubernetes.io/instance"] = truncateName(app.Staging)
if app.Branch != "" {
app.Labels["app.kubernetes.io/instance"] = truncateName(app.Staging + "-" + app.Branch)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app2kube/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func (app *App) GetDeployment() (deployment *appsv1.Deployment, err error) {
if len(app.Deployment.Containers) > 0 {
replicas := app.Deployment.ReplicaCount
if replicas < 1 || app.Staging != "" {
if replicas < 1 {
replicas = 1
}

Expand Down

0 comments on commit 8ec2740

Please sign in to comment.