From a4bcbd606105a255faf0638d90726b70cb135e73 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 11 Sep 2024 12:50:58 +0530 Subject: [PATCH 01/65] support for CdRollback and DeploymentHistory in configData API --- .../DeploymentConfigurationService.go | 183 ++++++++++++++++-- pkg/configDiff/bean/bean.go | 33 +++- pkg/pipeline/bean/ConfigMapBean.go | 1 + .../DeployedConfigurationHistoryService.go | 2 + wire_gen.go | 4 +- 5 files changed, 203 insertions(+), 20 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index f64de5cd2f7..1862af65359 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -3,9 +3,11 @@ package configDiff import ( "context" "encoding/json" + "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" + bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/configDiff/adaptor" @@ -15,6 +17,8 @@ import ( "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/bean" + repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + "github.com/go-pg/pg" "go.uber.org/zap" "net/http" "strconv" @@ -26,12 +30,15 @@ type DeploymentConfigurationService interface { } type DeploymentConfigurationServiceImpl struct { - logger *zap.SugaredLogger - configMapService pipeline.ConfigMapService - appRepository appRepository.AppRepository - environmentRepository repository.EnvironmentRepository - chartService chartService.ChartService - deploymentTemplateService generateManifest.DeploymentTemplateService + logger *zap.SugaredLogger + configMapService pipeline.ConfigMapService + appRepository appRepository.AppRepository + environmentRepository repository.EnvironmentRepository + chartService chartService.ChartService + deploymentTemplateService generateManifest.DeploymentTemplateService + deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository + pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository + configMapHistoryRepository repository3.ConfigMapHistoryRepository } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -40,14 +47,20 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, environmentRepository repository.EnvironmentRepository, chartService chartService.ChartService, deploymentTemplateService generateManifest.DeploymentTemplateService, + deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository, + pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository, + configMapHistoryRepository repository3.ConfigMapHistoryRepository, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ - logger: logger, - configMapService: configMapService, - appRepository: appRepository, - environmentRepository: environmentRepository, - chartService: chartService, - deploymentTemplateService: deploymentTemplateService, + logger: logger, + configMapService: configMapService, + appRepository: appRepository, + environmentRepository: environmentRepository, + chartService: chartService, + deploymentTemplateService: deploymentTemplateService, + deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, + pipelineStrategyHistoryRepository: pipelineStrategyHistoryRepository, + configMapHistoryRepository: configMapHistoryRepository, } return deploymentConfigurationService, nil @@ -102,7 +115,153 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con return nil, err } + switch configDataQueryParams.ConfigArea { + case bean2.CdRollback.ToString(): + return impl.getConfigDataForCdRollback(ctx, configDataQueryParams, appId, envId) + case bean2.DeploymentHistory.ToString(): + return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, appId, envId) + } + // this would be the default case + return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId) +} + +func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, + appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + // we would be expecting wfrId in case of getting data for cdRollback + +} + +func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*json.RawMessage, error) { + deploymentJson := &json.RawMessage{} + deploymentHistory, err := impl.deploymentTemplateHistoryRepository.GetHistoryByPipelineIdAndWfrId(configDataQueryParams.PipelineId, configDataQueryParams.WfrId) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in getting deployment template history for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } else if err == pg.ErrNoRows { + //history not created yet + return deploymentJson, nil + } + err = deploymentJson.UnmarshalJSON([]byte(deploymentHistory.Template)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "data", deploymentHistory.Template, "err", err) + return nil, err + } + return deploymentJson, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*json.RawMessage, error) { + pipelineStrategyJson := &json.RawMessage{} + pipelineStrategyHistory, err := impl.pipelineStrategyHistoryRepository.GetHistoryByPipelineIdAndWfrId(ctx, configDataQueryParams.PipelineId, configDataQueryParams.WfrId) + if err != nil && !errors.Is(err, pg.ErrNoRows) { + impl.logger.Errorw("error in checking if history exists for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } else if errors.Is(err, pg.ErrNoRows) { + return pipelineStrategyJson, nil + } + + err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategyHistory.Config)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "pipelineStrategyHistoryConfig", pipelineStrategyHistory.Config, "err", err) + return nil, err + } + return pipelineStrategyJson, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getConfigDataForDeploymentHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, + appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + // we would be expecting wfrId in case of getting data for Deployment history configDataDto := &bean2.DeploymentAndCmCsConfigDto{} + var err error + //fetching history for deployment config starts + deploymentConfigJson, err := impl.getDeploymentHistoryConfig(ctx, configDataQueryParams) + if err != nil { + impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getDeploymentHistoryConfig", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + if deploymentConfigJson != nil { + deploymentConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*deploymentConfigJson).WithResourceType(bean.DeploymentTemplate) + configDataDto.WithDeploymentTemplateData(deploymentConfig) + } + // fetching for deployment config ends + + // fetching for pipeline strategy config starts + pipelineConfigJson, err := impl.getPipelineStrategyConfigHistory(ctx, configDataQueryParams) + if err != nil { + impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getPipelineStrategyConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + if pipelineConfigJson != nil { + pipelineConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*pipelineConfigJson).WithResourceType(bean.PipelineStrategy) + configDataDto.WithPipelineConfigData(pipelineConfig) + } + // fetching for pipeline strategy config ends + + // fetching for cm config starts + cmConfigJson, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.CONFIGMAP_TYPE) + if err != nil { + impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getCmConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + if cmConfigJson != nil { + cmConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*cmConfigJson).WithResourceType(bean.CM) + configDataDto.WithConfigMapData(cmConfigData) + } + // fetching for cm config ends + + // fetching for cs config starts + secretConfigJson, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.SECRET_TYPE) + if err != nil { + impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getSecretConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + if secretConfigJson != nil { + secretConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*secretConfigJson).WithResourceType(bean.CS) + configDataDto.WithSecretData(secretConfigData) + } + // fetching for cs config ends + + return configDataDto, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, configType repository3.ConfigType) (*json.RawMessage, error) { + cmJson := &json.RawMessage{} + history, err := impl.configMapHistoryRepository.GetHistoryByPipelineIdAndWfrId(configDataQueryParams.PipelineId, configDataQueryParams.WfrId, configType) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in checking if cm cs history exists for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } else if err == pg.ErrNoRows { + return cmJson, nil + } + //var configData []*bean3.ConfigData + if configType == repository3.CONFIGMAP_TYPE { + configList := bean3.ConfigList{} + if len(history.Data) > 0 { + err = json.Unmarshal([]byte(history.Data), &configList) + if err != nil { + impl.logger.Debugw("error while Unmarshal", "err", err) + return nil, err + } + } + //configData = configList.ConfigData + } else if configType == repository3.SECRET_TYPE { + secretList := bean3.SecretList{} + if len(history.Data) > 0 { + err = json.Unmarshal([]byte(history.Data), &secretList) + if err != nil { + impl.logger.Debugw("error while Unmarshal", "err", err) + return nil, err + } + } + //configData = secretList.ConfigData + } + + return nil, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, + appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + configDataDto := &bean2.DeploymentAndCmCsConfigDto{} + var err error switch configDataQueryParams.ConfigType { default: // keeping default as PublishedOnly configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId) diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 2113ea81a65..2e13b2aea4d 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -25,6 +25,18 @@ const ( Overridden ConfigStage = "Overridden" ) +type ConfigArea string + +const ( + AppConfiguration ConfigArea = "AppConfiguration" + DeploymentHistory ConfigArea = "DeploymentHistory" + CdRollback ConfigArea = "CdRollback" +) + +func (r ConfigArea) ToString() string { + return string(r) +} + type ConfigProperty struct { Id int `json:"id"` Name string `json:"name"` @@ -71,8 +83,10 @@ func (r *ConfigProperty) GetIdentifier() ConfigPropertyIdentifier { } type DeploymentAndCmCsConfig struct { - ResourceType bean.ResourceType `json:"resourceType"` - Data json.RawMessage `json:"data"` + ResourceType bean.ResourceType `json:"resourceType"` + Data json.RawMessage `json:"data"` + VariableSnapshot string `json:"variableSnapshot"` + ResolvedValue string `json:"resolvedValue"` } func NewDeploymentAndCmCsConfig() *DeploymentAndCmCsConfig { @@ -93,6 +107,7 @@ type DeploymentAndCmCsConfigDto struct { DeploymentTemplate *DeploymentAndCmCsConfig `json:"deploymentTemplate"` ConfigMapsData *DeploymentAndCmCsConfig `json:"configMapData"` SecretsData *DeploymentAndCmCsConfig `json:"secretsData"` + PipelineConfigData *DeploymentAndCmCsConfig `json:"pipelineConfigData,omitempty"` IsAppAdmin bool `json:"isAppAdmin"` } @@ -112,17 +127,23 @@ func (r *DeploymentAndCmCsConfigDto) WithSecretData(data *DeploymentAndCmCsConfi r.SecretsData = data return r } +func (r *DeploymentAndCmCsConfigDto) WithPipelineConfigData(data *DeploymentAndCmCsConfig) *DeploymentAndCmCsConfigDto { + r.PipelineConfigData = data + return r +} type ConfigDataQueryParams struct { AppName string `schema:"appName"` EnvName string `schema:"envName"` ConfigType string `schema:"configType"` IdentifierId int `schema:"identifierId"` - PipelineId int `schema:"pipelineId"` // req for fetching previous deployments data - ResourceName string `schema:"resourceName"` - ResourceType string `schema:"resourceType"` - ResourceId int `schema:"resourceId"` + PipelineId int `schema:"pipelineId"` // req for fetching previous deployments data + ResourceName string `schema:"resourceName"` // used in case of cm and cs + ResourceType string `schema:"resourceType"` // used in case of cm and cs + ResourceId int `schema:"resourceId"` // used in case of cm and cs UserId int32 `schema:"-"` + WfrId int `schema:"wfrId"` + ConfigArea string `schema:"configArea"` } // FilterCriteria []string `schema:"filterCriteria"` diff --git a/pkg/pipeline/bean/ConfigMapBean.go b/pkg/pipeline/bean/ConfigMapBean.go index 2f572bd6058..3630a3aa7ec 100644 --- a/pkg/pipeline/bean/ConfigMapBean.go +++ b/pkg/pipeline/bean/ConfigMapBean.go @@ -120,6 +120,7 @@ const ( CM ResourceType = "ConfigMap" CS ResourceType = "Secret" DeploymentTemplate ResourceType = "Deployment Template" + PipelineStrategy ResourceType = "Pipeline Strategy" ) func (r ResourceType) ToString() string { diff --git a/pkg/pipeline/history/DeployedConfigurationHistoryService.go b/pkg/pipeline/history/DeployedConfigurationHistoryService.go index 26124a6df73..241574a2f18 100644 --- a/pkg/pipeline/history/DeployedConfigurationHistoryService.go +++ b/pkg/pipeline/history/DeployedConfigurationHistoryService.go @@ -152,6 +152,7 @@ func (impl *DeployedConfigurationHistoryServiceImpl) GetDeployedConfigurationByW impl.logger.Errorw("error in checking if history exists for deployment template", "err", err, "pipelineId", pipelineId, "wfrId", wfrId) return nil, err } + deploymentTemplateConfiguration := &DeploymentConfigurationDto{ Name: DEPLOYMENT_TEMPLATE_TYPE_HISTORY_COMPONENT, } @@ -161,6 +162,7 @@ func (impl *DeployedConfigurationHistoryServiceImpl) GetDeployedConfigurationByW deployedConfigurations = append(deployedConfigurations, deploymentTemplateConfiguration) //checking if pipeline strategy configuration for this pipelineId and wfrId exists or not + strategyHistoryId, exists, err := impl.strategyHistoryService.CheckIfHistoryExistsForPipelineIdAndWfrId(newCtx, pipelineId, wfrId) if err != nil { impl.logger.Errorw("error in checking if history exists for pipeline strategy", "err", err, "pipelineId", pipelineId, "wfrId", wfrId) diff --git a/wire_gen.go b/wire_gen.go index 9ad1f1575a8..c236db97e6c 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:generate go run github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject @@ -949,7 +949,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl) if err != nil { return nil, err } From e2ee5a6b9139f743dbf4d729469ff1ac9439a362 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 12 Sep 2024 16:55:56 +0530 Subject: [PATCH 02/65] support for getConfigDataForDeploymentHistory and getConfigDataForCdRollback in configData --- .../DeploymentConfigurationRestHandler.go | 3 +- pkg/bean/configSecretData.go | 3 + .../DeploymentConfigurationService.go | 178 ++++++++++++------ pkg/configDiff/adaptor/adaptor.go | 35 ++++ pkg/configDiff/bean/bean.go | 18 +- pkg/configDiff/utils/utils.go | 8 + pkg/pipeline/adapter/adapter.go | 119 ++++++++++++ pkg/pipeline/bean/ConfigMapBean.go | 2 + wire_gen.go | 2 +- 9 files changed, 304 insertions(+), 64 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 144838da010..f5a2551f816 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -97,8 +97,9 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp return } //RBAC END + userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object) - res, err := handler.deploymentConfigurationService.GetAllConfigData(r.Context(), configDataQueryParams) + res, err := handler.deploymentConfigurationService.GetAllConfigData(r.Context(), configDataQueryParams, userHasAdminAccess) if err != nil { handler.logger.Errorw("service err, GetAllConfigData ", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) diff --git a/pkg/bean/configSecretData.go b/pkg/bean/configSecretData.go index 61e55db588f..42803600f9d 100644 --- a/pkg/bean/configSecretData.go +++ b/pkg/bean/configSecretData.go @@ -29,6 +29,8 @@ type SecretList struct { ConfigData []*ConfigData `json:"secrets"` } +// there is an adapter written in pkg/bean folder to convert below ConfigData struct to pipeline/bean's ConfigData + type ConfigData struct { Name string `json:"name"` Type string `json:"type"` @@ -46,6 +48,7 @@ type ConfigData struct { RoleARN string `json:"roleARN"` SubPath bool `json:"subPath"` FilePermission string `json:"filePermission"` + Overridden bool `json:"overridden"` } type ExternalSecret struct { diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 1862af65359..46eb9112494 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -3,11 +3,9 @@ package configDiff import ( "context" "encoding/json" - "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" - bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/configDiff/adaptor" @@ -16,9 +14,13 @@ import ( "github.com/devtron-labs/devtron/pkg/configDiff/utils" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/pipeline" + "github.com/devtron-labs/devtron/pkg/pipeline/adapter" "github.com/devtron-labs/devtron/pkg/pipeline/bean" repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - "github.com/go-pg/pg" + "github.com/devtron-labs/devtron/pkg/variables" + "github.com/devtron-labs/devtron/pkg/variables/parsers" + repository6 "github.com/devtron-labs/devtron/pkg/variables/repository" + util2 "github.com/devtron-labs/devtron/util" "go.uber.org/zap" "net/http" "strconv" @@ -26,7 +28,7 @@ import ( type DeploymentConfigurationService interface { ConfigAutoComplete(appId int, envId int) (*bean2.ConfigDataResponse, error) - GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfigDto, error) + GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) } type DeploymentConfigurationServiceImpl struct { @@ -39,6 +41,7 @@ type DeploymentConfigurationServiceImpl struct { deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository configMapHistoryRepository repository3.ConfigMapHistoryRepository + scopedVariableManager variables.ScopedVariableCMCSManager } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -50,6 +53,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository, pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository, configMapHistoryRepository repository3.ConfigMapHistoryRepository, + scopedVariableManager variables.ScopedVariableCMCSManager, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ logger: logger, @@ -61,6 +65,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, pipelineStrategyHistoryRepository: pipelineStrategyHistoryRepository, configMapHistoryRepository: configMapHistoryRepository, + scopedVariableManager: scopedVariableManager, } return deploymentConfigurationService, nil @@ -95,7 +100,7 @@ func (impl *DeploymentConfigurationServiceImpl) ConfigAutoComplete(appId int, en return configDataResp, nil } -func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfigDto, error) { +func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { if !configDataQueryParams.IsValidConfigType() { return nil, &util.ApiError{HttpStatusCode: http.StatusBadRequest, Code: strconv.Itoa(http.StatusBadRequest), InternalMessage: bean2.InvalidConfigTypeErr, UserMessage: bean2.InvalidConfigTypeErr} } @@ -117,124 +122,121 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con switch configDataQueryParams.ConfigArea { case bean2.CdRollback.ToString(): - return impl.getConfigDataForCdRollback(ctx, configDataQueryParams, appId, envId) + return impl.getConfigDataForCdRollback(ctx, configDataQueryParams, userHasAdminAccess) case bean2.DeploymentHistory.ToString(): - return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, appId, envId) + return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) } // this would be the default case return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId) } -func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { - // we would be expecting wfrId in case of getting data for cdRollback - +func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { + // wfrId is expected in this case to return the expected data + return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) } -func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*json.RawMessage, error) { - deploymentJson := &json.RawMessage{} +func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfig, error) { + deploymentJson := json.RawMessage{} deploymentHistory, err := impl.deploymentTemplateHistoryRepository.GetHistoryByPipelineIdAndWfrId(configDataQueryParams.PipelineId, configDataQueryParams.WfrId) - if err != nil && err != pg.ErrNoRows { + if err != nil { impl.logger.Errorw("error in getting deployment template history for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err - } else if err == pg.ErrNoRows { - //history not created yet - return deploymentJson, nil } err = deploymentJson.UnmarshalJSON([]byte(deploymentHistory.Template)) if err != nil { impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "data", deploymentHistory.Template, "err", err) return nil, err } - return deploymentJson, nil + isSuperAdmin, err := util2.GetIsSuperAdminFromContext(ctx) + if err != nil { + return nil, err + } + reference := repository6.HistoryReference{ + HistoryReferenceId: deploymentHistory.Id, + HistoryReferenceType: repository6.HistoryReferenceTypeDeploymentTemplate, + } + variableSnapshotMap, resolvedTemplate, err := impl.scopedVariableManager.GetVariableSnapshotAndResolveTemplate(deploymentHistory.Template, parsers.JsonVariableTemplate, reference, isSuperAdmin, false) + if err != nil { + impl.logger.Errorw("error while resolving template from history", "deploymentHistoryId", deploymentHistory.Id, "pipelineId", configDataQueryParams.PipelineId, "err", err) + } + deploymentConfig := bean2.NewDeploymentAndCmCsConfig(). + WithConfigData(deploymentJson). + WithResourceType(bean.DeploymentTemplate). + WithVariableSnapshot(map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshotMap}). + WithResolvedValue(resolvedTemplate) + return deploymentConfig, nil } -func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*json.RawMessage, error) { - pipelineStrategyJson := &json.RawMessage{} +func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfig, error) { + pipelineStrategyJson := json.RawMessage{} pipelineStrategyHistory, err := impl.pipelineStrategyHistoryRepository.GetHistoryByPipelineIdAndWfrId(ctx, configDataQueryParams.PipelineId, configDataQueryParams.WfrId) - if err != nil && !errors.Is(err, pg.ErrNoRows) { + if err != nil { impl.logger.Errorw("error in checking if history exists for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err - } else if errors.Is(err, pg.ErrNoRows) { - return pipelineStrategyJson, nil } - err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategyHistory.Config)) if err != nil { impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "pipelineStrategyHistoryConfig", pipelineStrategyHistory.Config, "err", err) return nil, err } - return pipelineStrategyJson, nil + pipelineConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(pipelineStrategyJson).WithResourceType(bean.PipelineStrategy) + return pipelineConfig, nil } -func (impl *DeploymentConfigurationServiceImpl) getConfigDataForDeploymentHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { +func (impl *DeploymentConfigurationServiceImpl) getConfigDataForDeploymentHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { // we would be expecting wfrId in case of getting data for Deployment history configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var err error //fetching history for deployment config starts - deploymentConfigJson, err := impl.getDeploymentHistoryConfig(ctx, configDataQueryParams) + deploymentConfig, err := impl.getDeploymentHistoryConfig(ctx, configDataQueryParams) if err != nil { impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getDeploymentHistoryConfig", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - if deploymentConfigJson != nil { - deploymentConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*deploymentConfigJson).WithResourceType(bean.DeploymentTemplate) - configDataDto.WithDeploymentTemplateData(deploymentConfig) - } + configDataDto.WithDeploymentTemplateData(deploymentConfig) // fetching for deployment config ends // fetching for pipeline strategy config starts - pipelineConfigJson, err := impl.getPipelineStrategyConfigHistory(ctx, configDataQueryParams) + pipelineConfig, err := impl.getPipelineStrategyConfigHistory(ctx, configDataQueryParams) if err != nil { impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getPipelineStrategyConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - if pipelineConfigJson != nil { - pipelineConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*pipelineConfigJson).WithResourceType(bean.PipelineStrategy) - configDataDto.WithPipelineConfigData(pipelineConfig) - } + configDataDto.WithPipelineConfigData(pipelineConfig) // fetching for pipeline strategy config ends // fetching for cm config starts - cmConfigJson, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.CONFIGMAP_TYPE) + cmConfigData, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.CONFIGMAP_TYPE, userHasAdminAccess) if err != nil { impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getCmConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - if cmConfigJson != nil { - cmConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*cmConfigJson).WithResourceType(bean.CM) - configDataDto.WithConfigMapData(cmConfigData) - } + configDataDto.WithConfigMapData(cmConfigData) // fetching for cm config ends // fetching for cs config starts - secretConfigJson, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.SECRET_TYPE) + secretConfigDto, err := impl.getCmCsConfigHistory(ctx, configDataQueryParams, repository3.SECRET_TYPE, userHasAdminAccess) if err != nil { impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getSecretConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - if secretConfigJson != nil { - secretConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(*secretConfigJson).WithResourceType(bean.CS) - configDataDto.WithSecretData(secretConfigData) - } + configDataDto.WithSecretData(secretConfigDto) // fetching for cs config ends return configDataDto, nil } -func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, configType repository3.ConfigType) (*json.RawMessage, error) { - cmJson := &json.RawMessage{} +func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, configType repository3.ConfigType, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfig, error) { + var resourceType bean.ResourceType history, err := impl.configMapHistoryRepository.GetHistoryByPipelineIdAndWfrId(configDataQueryParams.PipelineId, configDataQueryParams.WfrId, configType) - if err != nil && err != pg.ErrNoRows { + if err != nil { impl.logger.Errorw("error in checking if cm cs history exists for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err - } else if err == pg.ErrNoRows { - return cmJson, nil } - //var configData []*bean3.ConfigData + var configData []*bean.ConfigData + configList := pipeline.ConfigsList{} + secretList := bean.SecretsList{} if configType == repository3.CONFIGMAP_TYPE { - configList := bean3.ConfigList{} if len(history.Data) > 0 { err = json.Unmarshal([]byte(history.Data), &configList) if err != nil { @@ -242,9 +244,9 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context return nil, err } } - //configData = configList.ConfigData + resourceType = bean.CM + configData = configList.ConfigData } else if configType == repository3.SECRET_TYPE { - secretList := bean3.SecretList{} if len(history.Data) > 0 { err = json.Unmarshal([]byte(history.Data), &secretList) if err != nil { @@ -252,10 +254,70 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context return nil, err } } - //configData = secretList.ConfigData + resourceType = bean.CS + configData = secretList.ConfigData } - return nil, nil + resolvedDataMap, variableSnapshotMap, err := impl.scopedVariableManager.GetResolvedCMCSHistoryDtos(ctx, configType, adaptor.ReverseConfigListConvertor(configList), history, adaptor.ReverseSecretListConvertor(secretList)) + if err != nil { + return nil, err + } + resolvedConfigDataList := make([]*bean.ConfigData, 0, len(resolvedDataMap)) + for _, resolvedConfigData := range resolvedDataMap { + resolvedConfigDataList = append(resolvedConfigDataList, adapter.ConvertConfigDataToPipelineConfigData(&resolvedConfigData)) + } + + if configType == repository3.SECRET_TYPE { + impl.encodeSecretDataFromNonAdminUsers(configData, userHasAdminAccess) + impl.encodeSecretDataFromNonAdminUsers(resolvedConfigDataList, userHasAdminAccess) + + } + + configDataReq := &bean.ConfigDataRequest{ConfigData: configData} + configDataJson, err := utils.ConvertToJsonRawMessage(configDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } + resolvedConfigDataReq := &bean.ConfigDataRequest{ConfigData: resolvedConfigDataList} + resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } + + cmConfigData := bean2.NewDeploymentAndCmCsConfig(). + WithConfigData(configDataJson). + WithResourceType(resourceType). + WithVariableSnapshot(variableSnapshotMap). + WithResolvedValue(resolvedConfigDataString) + return cmConfigData, nil +} + +func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUsers(configDataList []*bean.ConfigData, userHasAdminAccess bool) { + for _, config := range configDataList { + if config.Data != nil { + if !userHasAdminAccess { + //removing keys and sending + resultMap := make(map[string]string) + resultMapFinal := make(map[string]string) + err := json.Unmarshal(config.Data, &resultMap) + if err != nil { + impl.logger.Errorw("unmarshal failed", "error", err) + return + } + for key, _ := range resultMap { + //hard-coding values to show them as hidden to user + resultMapFinal[key] = "*****" + } + config.Data, err = utils.ConvertToJsonRawMessage(resultMapFinal) + if err != nil { + impl.logger.Errorw("error while marshaling request", "err", err) + return + } + } + } + } } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, diff --git a/pkg/configDiff/adaptor/adaptor.go b/pkg/configDiff/adaptor/adaptor.go index 4ab81eb2d11..6b93442ff49 100644 --- a/pkg/configDiff/adaptor/adaptor.go +++ b/pkg/configDiff/adaptor/adaptor.go @@ -1,7 +1,10 @@ package adaptor import ( + bean3 "github.com/devtron-labs/devtron/pkg/bean" bean2 "github.com/devtron-labs/devtron/pkg/configDiff/bean" + "github.com/devtron-labs/devtron/pkg/pipeline" + "github.com/devtron-labs/devtron/pkg/pipeline/adapter" "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) @@ -27,3 +30,35 @@ func GetCmCsAppAndEnvLevelMap(cMCSNamesAppLevel, cMCSNamesEnvLevel []bean.Config } return cMCSNamesAppLevelMap, cMCSNamesEnvLevelMap } + +func ConfigListConvertor(r bean3.ConfigList) pipeline.ConfigsList { + pipelineConfigData := make([]*bean.ConfigData, 0, len(r.ConfigData)) + for _, item := range r.ConfigData { + pipelineConfigData = append(pipelineConfigData, adapter.ConvertConfigDataToPipelineConfigData(item)) + } + return pipeline.ConfigsList{ConfigData: pipelineConfigData} +} + +func SecretListConvertor(r bean3.SecretList) bean.SecretsList { + pipelineConfigData := make([]*bean.ConfigData, 0, len(r.ConfigData)) + for _, item := range r.ConfigData { + pipelineConfigData = append(pipelineConfigData, adapter.ConvertConfigDataToPipelineConfigData(item)) + } + return bean.SecretsList{ConfigData: pipelineConfigData} +} + +func ReverseConfigListConvertor(r pipeline.ConfigsList) bean3.ConfigList { + configData := make([]*bean3.ConfigData, 0, len(r.ConfigData)) + for _, item := range r.ConfigData { + configData = append(configData, adapter.ConvertPipelineConfigDataToConfigData(item)) + } + return bean3.ConfigList{ConfigData: configData} +} + +func ReverseSecretListConvertor(r bean.SecretsList) bean3.SecretList { + configData := make([]*bean3.ConfigData, 0, len(r.ConfigData)) + for _, item := range r.ConfigData { + configData = append(configData, adapter.ConvertPipelineConfigDataToConfigData(item)) + } + return bean3.SecretList{ConfigData: configData} +} diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 2e13b2aea4d..8642903bdac 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -83,10 +83,10 @@ func (r *ConfigProperty) GetIdentifier() ConfigPropertyIdentifier { } type DeploymentAndCmCsConfig struct { - ResourceType bean.ResourceType `json:"resourceType"` - Data json.RawMessage `json:"data"` - VariableSnapshot string `json:"variableSnapshot"` - ResolvedValue string `json:"resolvedValue"` + ResourceType bean.ResourceType `json:"resourceType"` + Data json.RawMessage `json:"data"` + VariableSnapshot map[string]map[string]string `json:"variableSnapshot"` // for deployment->{Deployment Template: resolvedValuesMap}, for cm->{cmComponentName: resolvedValuesMap} + ResolvedValue string `json:"resolvedValue"` } func NewDeploymentAndCmCsConfig() *DeploymentAndCmCsConfig { @@ -103,6 +103,16 @@ func (r *DeploymentAndCmCsConfig) WithConfigData(data json.RawMessage) *Deployme return r } +func (r *DeploymentAndCmCsConfig) WithVariableSnapshot(snapshot map[string]map[string]string) *DeploymentAndCmCsConfig { + r.VariableSnapshot = snapshot + return r +} + +func (r *DeploymentAndCmCsConfig) WithResolvedValue(resolvedValue string) *DeploymentAndCmCsConfig { + r.ResolvedValue = resolvedValue + return r +} + type DeploymentAndCmCsConfigDto struct { DeploymentTemplate *DeploymentAndCmCsConfig `json:"deploymentTemplate"` ConfigMapsData *DeploymentAndCmCsConfig `json:"configMapData"` diff --git a/pkg/configDiff/utils/utils.go b/pkg/configDiff/utils/utils.go index 8185993775f..62d1272c312 100644 --- a/pkg/configDiff/utils/utils.go +++ b/pkg/configDiff/utils/utils.go @@ -14,3 +14,11 @@ func ConvertToJsonRawMessage(request interface{}) (json.RawMessage, error) { } return r, nil } + +func ConvertToString(req interface{}) (string, error) { + reqByte, err := json.Marshal(req) + if err != nil { + return "", err + } + return string(reqByte), nil +} diff --git a/pkg/pipeline/adapter/adapter.go b/pkg/pipeline/adapter/adapter.go index ed179e14588..bd1ef81821e 100644 --- a/pkg/pipeline/adapter/adapter.go +++ b/pkg/pipeline/adapter/adapter.go @@ -21,6 +21,7 @@ import ( dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/ciPipeline" + "github.com/devtron-labs/devtron/pkg/bean" pipelineConfigBean "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean/CiPipeline" "github.com/devtron-labs/devtron/pkg/pipeline/types" @@ -225,3 +226,121 @@ func GetSourceCiDownStreamResponse(linkedCIDetails []ciPipeline.LinkedCIDetails, } return response } + +func ConvertConfigDataToPipelineConfigData(r *bean.ConfigData) *pipelineConfigBean.ConfigData { + return &pipelineConfigBean.ConfigData{ + Name: r.Name, + Type: r.Type, + External: r.External, + MountPath: r.MountPath, + Data: r.Data, + DefaultData: r.DefaultData, + DefaultMountPath: r.DefaultMountPath, + Global: r.Global, + ExternalSecretType: r.ExternalSecretType, + ESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.ESOSecretData), + DefaultESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.DefaultESOSecretData), + ExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.ExternalSecret), + DefaultExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.DefaultExternalSecret), + RoleARN: r.RoleARN, + SubPath: r.SubPath, + FilePermission: r.FilePermission, + Overridden: r.Overridden, + } +} + +func ConvertESOSecretDataToPipelineESOSecretData(r bean.ESOSecretData) pipelineConfigBean.ESOSecretData { + return pipelineConfigBean.ESOSecretData{ + SecretStore: r.SecretStore, + SecretStoreRef: r.SecretStoreRef, + EsoData: ConvertEsoDataToPipelineEsoData(r.EsoData), + RefreshInterval: r.RefreshInterval, + } +} + +func ConvertExternalSecretToPipelineExternalSecret(r []bean.ExternalSecret) []pipelineConfigBean.ExternalSecret { + extSec := make([]pipelineConfigBean.ExternalSecret, 0, len(r)) + for _, item := range r { + newItem := pipelineConfigBean.ExternalSecret{ + Key: item.Key, + Name: item.Name, + Property: item.Property, + IsBinary: item.IsBinary, + } + extSec = append(extSec, newItem) + } + return extSec +} + +func ConvertEsoDataToPipelineEsoData(r []bean.ESOData) []pipelineConfigBean.ESOData { + newEsoData := make([]pipelineConfigBean.ESOData, 0, len(r)) + for _, item := range r { + newItem := pipelineConfigBean.ESOData{ + SecretKey: item.SecretKey, + Key: item.Key, + Property: item.Property, + } + newEsoData = append(newEsoData, newItem) + } + return newEsoData +} + +// reverse adapter for the above adapters + +func ConvertPipelineConfigDataToConfigData(r *pipelineConfigBean.ConfigData) *bean.ConfigData { + return &bean.ConfigData{ + Name: r.Name, + Type: r.Type, + External: r.External, + MountPath: r.MountPath, + Data: r.Data, + DefaultData: r.DefaultData, + DefaultMountPath: r.DefaultMountPath, + Global: r.Global, + ExternalSecretType: r.ExternalSecretType, + ESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.ESOSecretData), + DefaultESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.DefaultESOSecretData), + ExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.ExternalSecret), + DefaultExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.DefaultExternalSecret), + RoleARN: r.RoleARN, + SubPath: r.SubPath, + FilePermission: r.FilePermission, + Overridden: r.Overridden, + } +} + +func ConvertPipelineESOSecretDataToESOSecretData(r pipelineConfigBean.ESOSecretData) bean.ESOSecretData { + return bean.ESOSecretData{ + SecretStore: r.SecretStore, + SecretStoreRef: r.SecretStoreRef, + EsoData: ConvertPipelineEsoDataToEsoData(r.EsoData), + RefreshInterval: r.RefreshInterval, + } +} + +func ConvertPipelineExternalSecretToExternalSecret(r []pipelineConfigBean.ExternalSecret) []bean.ExternalSecret { + extSec := make([]bean.ExternalSecret, 0, len(r)) + for _, item := range r { + newItem := bean.ExternalSecret{ + Key: item.Key, + Name: item.Name, + Property: item.Property, + IsBinary: item.IsBinary, + } + extSec = append(extSec, newItem) + } + return extSec +} + +func ConvertPipelineEsoDataToEsoData(r []pipelineConfigBean.ESOData) []bean.ESOData { + newEsoData := make([]bean.ESOData, 0, len(r)) + for _, item := range r { + newItem := bean.ESOData{ + SecretKey: item.SecretKey, + Key: item.Key, + Property: item.Property, + } + newEsoData = append(newEsoData, newItem) + } + return newEsoData +} diff --git a/pkg/pipeline/bean/ConfigMapBean.go b/pkg/pipeline/bean/ConfigMapBean.go index 3630a3aa7ec..2f54aa07e79 100644 --- a/pkg/pipeline/bean/ConfigMapBean.go +++ b/pkg/pipeline/bean/ConfigMapBean.go @@ -41,6 +41,8 @@ type ESOData struct { Property string `json:"property,omitempty"` } +// there is an adapter written in pkg/bean folder to convert below ConfigData struct to pkg/bean's ConfigData + type ConfigData struct { Name string `json:"name"` Type string `json:"type"` diff --git a/wire_gen.go b/wire_gen.go index c236db97e6c..3d057526404 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -949,7 +949,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl) if err != nil { return nil, err } From f37964040b6bfd1f8e181c87e9b01b03b8c653fe Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Fri, 13 Sep 2024 02:42:51 +0530 Subject: [PATCH 03/65] resolve cm cs data in published config code incorporated --- .../DeploymentConfigurationService.go | 144 ++++++++++++++++-- pkg/configDiff/bean/bean.go | 15 ++ pkg/pipeline/DeploymentConfigService.go | 1 + wire_gen.go | 2 +- 4 files changed, 152 insertions(+), 10 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 46eb9112494..45b096b57d8 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -5,7 +5,9 @@ import ( "encoding/json" repository2 "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/util" + bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/configDiff/adaptor" @@ -17,10 +19,12 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/adapter" "github.com/devtron-labs/devtron/pkg/pipeline/bean" repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/variables/parsers" repository6 "github.com/devtron-labs/devtron/pkg/variables/repository" util2 "github.com/devtron-labs/devtron/util" + "github.com/go-pg/pg" "go.uber.org/zap" "net/http" "strconv" @@ -42,6 +46,8 @@ type DeploymentConfigurationServiceImpl struct { pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository configMapHistoryRepository repository3.ConfigMapHistoryRepository scopedVariableManager variables.ScopedVariableCMCSManager + configMapRepository chartConfig.ConfigMapRepository + deploymentConfigService pipeline.PipelineDeploymentConfigService } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -54,6 +60,8 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, pipelineStrategyHistoryRepository repository3.PipelineStrategyHistoryRepository, configMapHistoryRepository repository3.ConfigMapHistoryRepository, scopedVariableManager variables.ScopedVariableCMCSManager, + configMapRepository chartConfig.ConfigMapRepository, + deploymentConfigService pipeline.PipelineDeploymentConfigService, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ logger: logger, @@ -66,6 +74,8 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, pipelineStrategyHistoryRepository: pipelineStrategyHistoryRepository, configMapHistoryRepository: configMapHistoryRepository, scopedVariableManager: scopedVariableManager, + configMapRepository: configMapRepository, + deploymentConfigService: deploymentConfigService, } return deploymentConfigurationService, nil @@ -107,12 +117,15 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con var err error var envId int var appId int + var clusterId int if configDataQueryParams.IsEnvNameProvided() { - envId, err = impl.environmentRepository.FindIdByName(configDataQueryParams.EnvName) + env, err := impl.environmentRepository.FindByName(configDataQueryParams.EnvName) if err != nil { impl.logger.Errorw("GetAllConfigData, error in getting environment model by envName", "envName", configDataQueryParams.EnvName, "err", err) return nil, err } + envId = env.Id + clusterId = env.ClusterId } appId, err = impl.appRepository.FindAppIdByName(configDataQueryParams.AppName) if err != nil { @@ -127,7 +140,7 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) } // this would be the default case - return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId) + return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { @@ -321,12 +334,12 @@ func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUser } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + appId, envId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var err error switch configDataQueryParams.ConfigType { default: // keeping default as PublishedOnly - configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId) + configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) if err != nil { impl.logger.Errorw("GetAllConfigData, error in config data for PublishedOnly", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err @@ -371,7 +384,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly( return configDataDto, nil } -func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(envId, appId int) (*bean2.DeploymentAndCmCsConfigDto, error) { +func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} secretData, err := impl.getSecretConfigResponse("", 0, envId, appId) @@ -399,14 +412,127 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(e return nil, err } - cmConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(cmRespJson).WithResourceType(bean.CM) - secretConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(secretRespJson).WithResourceType(bean.CS) + resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in resolving cm and cs for published only config only response", "appId", appId, "envId", envId, "err", err) + return nil, err + } + + cmConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(cmRespJson).WithResourceType(bean.CM). + WithResolvedValue(resolvedCmCsMetadataDto.ResolvedConfigMapData).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCM) + + secretConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(secretRespJson).WithResourceType(bean.CS). + WithResolvedValue(resolvedCmCsMetadataDto.ResolvedSecretData).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCS) configDataDto.WithConfigMapData(cmConfigData).WithSecretData(secretConfigData) return configDataDto, nil } +func (impl *DeploymentConfigurationServiceImpl) getMergedCmCs(envId, appId int) (*bean2.CmCsMetadataDto, error) { + configAppLevel, err := impl.configMapRepository.GetByAppIdAppLevel(appId) + if err != nil && pg.ErrNoRows != err { + impl.logger.Errorw("error in getting CM/CS app level data", "appId", appId, "err", err) + return nil, err + } + var configMapAppLevel string + var secretAppLevel string + if configAppLevel != nil && configAppLevel.Id > 0 { + configMapAppLevel = configAppLevel.ConfigMapData + secretAppLevel = configAppLevel.SecretData + } + configEnvLevel, err := impl.configMapRepository.GetByAppIdAndEnvIdEnvLevel(appId, envId) + if err != nil && pg.ErrNoRows != err { + impl.logger.Errorw("error in getting CM/CS env level data", "appId", appId, "envId", envId, "err", err) + return nil, err + } + var configMapEnvLevel string + var secretEnvLevel string + if configEnvLevel != nil && configEnvLevel.Id > 0 { + configMapEnvLevel = configEnvLevel.ConfigMapData + secretEnvLevel = configEnvLevel.SecretData + } + mergedConfigMap, err := impl.deploymentConfigService.GetMergedCMCSConfigMap(configMapAppLevel, configMapEnvLevel, repository3.CONFIGMAP_TYPE) + if err != nil { + impl.logger.Errorw("error in merging app level and env level CM configs", "err", err) + return nil, err + } + + mergedSecret, err := impl.deploymentConfigService.GetMergedCMCSConfigMap(secretAppLevel, secretEnvLevel, repository3.SECRET_TYPE) + if err != nil { + impl.logger.Errorw("error in merging app level and env level CM configs", "err", err) + return nil, err + } + return &bean2.CmCsMetadataDto{ + CmMap: mergedConfigMap, + SecretMap: mergedSecret, + ConfigAppLevelId: configAppLevel.Id, + ConfigEnvLevelId: configEnvLevel.Id, + }, nil +} + +func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool) (*bean2.ResolvedCmCsMetadataDto, error) { + scope := resourceQualifiers.Scope{ + AppId: appId, + EnvId: envId, + ClusterId: clusterId, + } + cmcsMetadataDto, err := impl.getMergedCmCs(envId, appId) + if err != nil { + impl.logger.Errorw("error in getting merged cm cs", "appId", appId, "envId", envId, "err", err) + return nil, err + } + resolvedConfigList, resolvedSecretList, variableMapCM, variableMapCS, err := impl.scopedVariableManager.ResolveCMCS(ctx, scope, cmcsMetadataDto.ConfigAppLevelId, cmcsMetadataDto.ConfigEnvLevelId, cmcsMetadataDto.CmMap, cmcsMetadataDto.SecretMap) + if err != nil { + impl.logger.Errorw("error in resolving CM/CS", "scope", scope, "appId", appId, "envId", envId, "err", err) + return nil, err + } + + resolvedConfigString, resolvedSecretString, err := impl.getStringifiedCmCs(resolvedConfigList, resolvedSecretList, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in getStringifiedCmCs", "resolvedConfigList", resolvedConfigList, "err", err) + return nil, err + } + resolvedData := &bean2.ResolvedCmCsMetadataDto{ + VariableMapCM: variableMapCM, + VariableMapCS: variableMapCS, + ResolvedSecretData: resolvedSecretString, + ResolvedConfigMapData: resolvedConfigString, + } + + return resolvedData, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getStringifiedCmCs(resolvedCmMap map[string]*bean3.ConfigData, resolvedSecretMap map[string]*bean3.ConfigData, + userHasAdminAccess bool) (string, string, error) { + + resolvedConfigDataList := make([]*bean.ConfigData, 0, len(resolvedCmMap)) + resolvedSecretDataList := make([]*bean.ConfigData, 0, len(resolvedSecretMap)) + + for _, resolvedConfigData := range resolvedCmMap { + resolvedConfigDataList = append(resolvedConfigDataList, adapter.ConvertConfigDataToPipelineConfigData(resolvedConfigData)) + } + + for _, resolvedSecretData := range resolvedSecretMap { + resolvedSecretDataList = append(resolvedSecretDataList, adapter.ConvertConfigDataToPipelineConfigData(resolvedSecretData)) + } + if len(resolvedSecretMap) > 0 { + impl.encodeSecretDataFromNonAdminUsers(resolvedSecretDataList, userHasAdminAccess) + } + resolvedConfigDataReq := &bean.ConfigDataRequest{ConfigData: resolvedConfigDataList} + resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) + if err != nil { + impl.logger.Errorw(" error in converting resolved config data to string", "resolvedConfigDataReq", resolvedConfigDataReq, "err", err) + return "", "", err + } + resolvedSecretDataReq := &bean.ConfigDataRequest{ConfigData: resolvedSecretDataList} + resolvedSecretDataString, err := utils.ConvertToString(resolvedSecretDataReq) + if err != nil { + impl.logger.Errorw(" error in converting resolved config data to string", "err", err) + return "", "", err + } + return resolvedConfigDataString, resolvedSecretDataString, nil +} func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx context.Context, appId, envId int) (json.RawMessage, error) { if envId > 0 { return impl.getDeploymentTemplateForEnvLevel(ctx, appId, envId) @@ -415,13 +541,13 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx } func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + appId, envId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { if configDataQueryParams.IsRequestMadeForOneResource() { return impl.getCmCsEditDataForPublishedOnly(configDataQueryParams, envId, appId) } //ConfigMapsData and SecretsData are populated here - configData, err := impl.getCmCsPublishedConfigResponse(envId, appId) + configData, err := impl.getCmCsPublishedConfigResponse(ctx, envId, appId, clusterId, userHasAdminAccess) if err != nil { impl.logger.Errorw("getPublishedConfigData, error in getting cm cs for PublishedOnly state", "appName", configDataQueryParams.AppName, "envName", configDataQueryParams.EnvName, "err", err) return nil, err diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 8642903bdac..4e75357e048 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -4,6 +4,7 @@ import "C" import ( "encoding/json" "fmt" + bean3 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) @@ -181,3 +182,17 @@ func (r *ConfigDataQueryParams) IsRequestMadeForOneResource() bool { const ( InvalidConfigTypeErr = "invalid config type provided, please send a valid config type" ) + +type CmCsMetadataDto struct { + CmMap map[string]*bean3.ConfigData + SecretMap map[string]*bean3.ConfigData + ConfigAppLevelId int + ConfigEnvLevelId int +} + +type ResolvedCmCsMetadataDto struct { + ResolvedConfigMapData string + ResolvedSecretData string + VariableMapCM map[string]map[string]string + VariableMapCS map[string]map[string]string +} diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index 798f7da2c4d..ff699b722a5 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -38,6 +38,7 @@ import ( type PipelineDeploymentConfigService interface { GetLatestDeploymentConfigurationByPipelineId(ctx context.Context, pipelineId int, userHasAdminAccess bool) (*history.AllDeploymentConfigurationDetail, error) + GetMergedCMCSConfigMap(appLevelConfig, envLevelConfig string, configType repository2.ConfigType) (map[string]*bean.ConfigData, error) } type PipelineDeploymentConfigServiceImpl struct { diff --git a/wire_gen.go b/wire_gen.go index 3d057526404..49a316fd4ef 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -949,7 +949,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl) if err != nil { return nil, err } From aa565e0a0c22a63eefdd033edbe09f605fdbedc4 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 16 Sep 2024 14:54:41 +0530 Subject: [PATCH 04/65] wip: bug fixes --- .../DeploymentConfigurationRestHandler.go | 10 ++- .../DeploymentConfigurationService.go | 62 ++++++++++--------- .../DeploymentTemplateService.go | 30 +++++++++ 3 files changed, 71 insertions(+), 31 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index f5a2551f816..3c6876d9d1f 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -1,17 +1,20 @@ package restHandler import ( + "context" "fmt" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/configDiff" "github.com/devtron-labs/devtron/pkg/configDiff/bean" + util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" "github.com/gorilla/schema" "go.uber.org/zap" "gopkg.in/go-playground/validator.v9" "net/http" + "time" ) type DeploymentConfigurationRestHandler interface { @@ -97,9 +100,12 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp return } //RBAC END + isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*") userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object) - - res, err := handler.deploymentConfigurationService.GetAllConfigData(r.Context(), configDataQueryParams, userHasAdminAccess) + ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) + ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin) + defer cancel() + res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess) if err != nil { handler.logger.Errorw("service err, GetAllConfigData ", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 45b096b57d8..e80096ed96a 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -6,7 +6,6 @@ import ( repository2 "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/util" bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -26,8 +25,6 @@ import ( util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "go.uber.org/zap" - "net/http" - "strconv" ) type DeploymentConfigurationService interface { @@ -111,9 +108,6 @@ func (impl *DeploymentConfigurationServiceImpl) ConfigAutoComplete(appId int, en } func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { - if !configDataQueryParams.IsValidConfigType() { - return nil, &util.ApiError{HttpStatusCode: http.StatusBadRequest, Code: strconv.Itoa(http.StatusBadRequest), InternalMessage: bean2.InvalidConfigTypeErr, UserMessage: bean2.InvalidConfigTypeErr} - } var err error var envId int var appId int @@ -533,11 +527,32 @@ func (impl *DeploymentConfigurationServiceImpl) getStringifiedCmCs(resolvedCmMap } return resolvedConfigDataString, resolvedSecretDataString, nil } -func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx context.Context, appId, envId int) (json.RawMessage, error) { +func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx context.Context, appId, envId int) (*bean2.DeploymentAndCmCsConfig, error) { if envId > 0 { - return impl.getDeploymentTemplateForEnvLevel(ctx, appId, envId) + deplTemplateResp, err := impl.getDeploymentTemplateForEnvLevel(ctx, appId, envId) + if err != nil { + impl.logger.Errorw("error in getting deployment template env level", "err", err) + return nil, err + } + deploymentJson := json.RawMessage{} + err = deploymentJson.UnmarshalJSON([]byte(deplTemplateResp.Data)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "appId", appId, "envId", envId, "err", err) + return nil, err + } + + variableSnapShotMap := make(map[string]map[string]string, len(deplTemplateResp.VariableSnapshot)) + variableSnapShotMap[bean.DeploymentTemplate.ToString()] = deplTemplateResp.VariableSnapshot + + return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentJson).WithResourceType(bean.DeploymentTemplate). + WithResolvedValue(deplTemplateResp.ResolvedData).WithVariableSnapshot(variableSnapShotMap), nil + } + deplJson, err := impl.getBaseDeploymentTemplate(appId) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, getting base depl. template", "appid", appId, "err", err) + return nil, err } - return impl.getBaseDeploymentTemplate(appId) + return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deplJson).WithResourceType(bean.DeploymentTemplate), nil } func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, @@ -552,14 +567,13 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte impl.logger.Errorw("getPublishedConfigData, error in getting cm cs for PublishedOnly state", "appName", configDataQueryParams.AppName, "envName", configDataQueryParams.EnvName, "err", err) return nil, err } - deploymentTemplateJsonData, err := impl.getPublishedDeploymentConfig(ctx, appId, envId) + deploymentTemplateData, err := impl.getPublishedDeploymentConfig(ctx, appId, envId) if err != nil { impl.logger.Errorw("getPublishedConfigData, error in getting publishedOnly deployment config ", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - deploymentConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentTemplateJsonData).WithResourceType(bean.DeploymentTemplate) - configData.WithDeploymentTemplateData(deploymentConfig) + configData.WithDeploymentTemplateData(deploymentTemplateData) return configData, nil } @@ -569,35 +583,25 @@ func (impl *DeploymentConfigurationServiceImpl) getBaseDeploymentTemplate(appId impl.logger.Errorw("error in getting base deployment template for appId", "appId", appId, "err", err) return nil, err } + return deploymentTemplateData.DefaultAppOverride, nil } -func (impl *DeploymentConfigurationServiceImpl) getDeploymentTemplateForEnvLevel(ctx context.Context, appId, envId int) (json.RawMessage, error) { +func (impl *DeploymentConfigurationServiceImpl) getDeploymentTemplateForEnvLevel(ctx context.Context, appId, envId int) (generateManifest.DeploymentTemplateResponse, error) { deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ AppId: appId, EnvId: envId, RequestDataMode: generateManifest.Values, Type: repository2.PublishedOnEnvironments, } - deploymentTemplateResponse, err := impl.deploymentTemplateService.GetDeploymentTemplate(ctx, deploymentTemplateRequest) + var deploymentTemplateResponse generateManifest.DeploymentTemplateResponse + var err error + deploymentTemplateResponse, err = impl.deploymentTemplateService.GetDeploymentTemplate(ctx, deploymentTemplateRequest) if err != nil { impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in getting deployment template for ", "deploymentTemplateRequest", deploymentTemplateRequest, "err", err) - return nil, err - } - deploymentJson := json.RawMessage{} - err = deploymentJson.UnmarshalJSON([]byte(deploymentTemplateResponse.Data)) - if err != nil { - impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "data", deploymentTemplateResponse.Data, "err", err) - return nil, err - } - return deploymentJson, nil -} - -func (impl *DeploymentConfigurationServiceImpl) getDeploymentConfig(ctx context.Context, appId, envId int) (json.RawMessage, error) { - if envId > 0 { - return impl.getDeploymentTemplateForEnvLevel(ctx, appId, envId) + return deploymentTemplateResponse, err } - return impl.getBaseDeploymentTemplate(appId) + return deploymentTemplateResponse, nil } func (impl *DeploymentConfigurationServiceImpl) getSecretConfigResponse(resourceName string, resourceId, envId, appId int) (*bean.ConfigDataRequest, error) { diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index d4a7a2270d0..7148c1b4f2d 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -62,6 +62,7 @@ type DeploymentTemplateService interface { GetDeploymentTemplate(ctx context.Context, request DeploymentTemplateRequest) (DeploymentTemplateResponse, error) GenerateManifest(ctx context.Context, request *DeploymentTemplateRequest, valuesYaml string) (*openapi2.TemplateChartResponse, error) GetRestartWorkloadData(ctx context.Context, appIds []int, envId int) (*RestartPodResponse, error) + GetDeploymentTemplateWithResolvedData(ctx context.Context, request DeploymentTemplateRequest) (DeploymentTemplateResponse, error) } type DeploymentTemplateServiceImpl struct { Logger *zap.SugaredLogger @@ -243,6 +244,35 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont return result, nil } +func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplateWithResolvedData(ctx context.Context, request DeploymentTemplateRequest) (DeploymentTemplateResponse, error) { + var result DeploymentTemplateResponse + var values, resolvedValue string + var err error + var variableSnapshot map[string]string + + if request.Values != "" { + values = request.Values + resolvedValue, variableSnapshot, err = impl.resolveTemplateVariables(ctx, request.Values, request) + if err != nil { + return result, err + } + } + if request.RequestDataMode == Values { + result.Data = values + result.ResolvedData = resolvedValue + result.VariableSnapshot = variableSnapshot + return result, nil + } + + request = impl.setRequestMetadata(&request) + manifest, err := impl.GenerateManifest(ctx, &request, resolvedValue) + if err != nil { + return result, err + } + result.Data = *manifest.Manifest + return result, nil +} + func (impl DeploymentTemplateServiceImpl) setRequestMetadata(request *DeploymentTemplateRequest) DeploymentTemplateRequest { // set dummy data for templating. // for some case we may not know the envname and pipelinename, so we want to show this dummy data as a placeholder From 5ffb0f8b2801a4f964d8c4ebf26f8adf4b30220f Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 17 Sep 2024 16:26:04 +0530 Subject: [PATCH 05/65] wip: new config area to resolve data for given values --- .../DeploymentConfigurationService.go | 19 +++++++++++++++++++ pkg/configDiff/bean/bean.go | 2 ++ .../DeploymentTemplateService.go | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index e80096ed96a..5e16ed742c7 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -132,11 +132,30 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con return impl.getConfigDataForCdRollback(ctx, configDataQueryParams, userHasAdminAccess) case bean2.DeploymentHistory.ToString(): return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) + case bean2.ResolveData.ToString(): + // this only supports resolution of deployment template data as of now + return impl.getResolvedConfigDataForValues(ctx, configDataQueryParams.Values, appId, envId) } // this would be the default case return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) } +func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(ctx context.Context, values string, appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { + configDataDto := &bean2.DeploymentAndCmCsConfigDto{} + var err error + deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ + AppId: appId, + EnvId: envId, + RequestDataMode: generateManifest.Values, + } + resolvedTemplate, _, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, values, deploymentTemplateRequest) + if err != nil { + impl.logger.Errorw("error in getting resolved data for cm draft data ", "appid", appId, "err", err) + return nil, err + } + return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(resolvedTemplate)), nil +} + func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { // wfrId is expected in this case to return the expected data return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 4e75357e048..dde456f2760 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -32,6 +32,7 @@ const ( AppConfiguration ConfigArea = "AppConfiguration" DeploymentHistory ConfigArea = "DeploymentHistory" CdRollback ConfigArea = "CdRollback" + ResolveData ConfigArea = "ResolveData" ) func (r ConfigArea) ToString() string { @@ -155,6 +156,7 @@ type ConfigDataQueryParams struct { UserId int32 `schema:"-"` WfrId int `schema:"wfrId"` ConfigArea string `schema:"configArea"` + Values string `schema:"values"` } // FilterCriteria []string `schema:"filterCriteria"` diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 7148c1b4f2d..2ee90ab579a 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -63,6 +63,7 @@ type DeploymentTemplateService interface { GenerateManifest(ctx context.Context, request *DeploymentTemplateRequest, valuesYaml string) (*openapi2.TemplateChartResponse, error) GetRestartWorkloadData(ctx context.Context, appIds []int, envId int) (*RestartPodResponse, error) GetDeploymentTemplateWithResolvedData(ctx context.Context, request DeploymentTemplateRequest) (DeploymentTemplateResponse, error) + ResolveTemplateVariables(ctx context.Context, values string, request DeploymentTemplateRequest) (string, map[string]string, error) } type DeploymentTemplateServiceImpl struct { Logger *zap.SugaredLogger @@ -587,3 +588,21 @@ func (impl DeploymentTemplateServiceImpl) GetRestartWorkloadData(ctx context.Con } return podResp, nil } + +func (impl DeploymentTemplateServiceImpl) ResolveTemplateVariables(ctx context.Context, values string, request DeploymentTemplateRequest) (string, map[string]string, error) { + + isSuperAdmin, err := util2.GetIsSuperAdminFromContext(ctx) + if err != nil { + return values, nil, err + } + scope, err := impl.extractScopeData(request) + if err != nil { + return values, nil, err + } + maskUnknownVariableForHelmGenerate := request.RequestDataMode == Manifest + resolvedTemplate, variableSnapshot, err := impl.scopedVariableManager.ExtractVariablesAndResolveTemplate(scope, values, parsers.JsonVariableTemplate, isSuperAdmin, maskUnknownVariableForHelmGenerate) + if err != nil { + return values, variableSnapshot, err + } + return resolvedTemplate, variableSnapshot, nil +} From 6d95766104e9653249cc3c589d26a025c91e480c Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 17 Sep 2024 17:12:36 +0530 Subject: [PATCH 06/65] wip: fix --- pkg/configDiff/DeploymentConfigurationService.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 5e16ed742c7..3bb2e89d9fa 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -145,9 +145,11 @@ func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(c var err error deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ AppId: appId, - EnvId: envId, RequestDataMode: generateManifest.Values, } + if envId > 0 { + deploymentTemplateRequest.EnvId = envId + } resolvedTemplate, _, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, values, deploymentTemplateRequest) if err != nil { impl.logger.Errorw("error in getting resolved data for cm draft data ", "appid", appId, "err", err) From 4aad54a0da80ff63e4e2828c9948683c1140d659 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 17 Sep 2024 18:19:24 +0530 Subject: [PATCH 07/65] wip: marshal resolved template before sending back res p --- pkg/configDiff/DeploymentConfigurationService.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 3bb2e89d9fa..27e5c224c65 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -152,10 +152,15 @@ func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(c } resolvedTemplate, _, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, values, deploymentTemplateRequest) if err != nil { - impl.logger.Errorw("error in getting resolved data for cm draft data ", "appid", appId, "err", err) + impl.logger.Errorw("error in getting resolved data for cm draft data ", "appId", appId, "err", err) return nil, err } - return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(resolvedTemplate)), nil + resolvedJson, err := json.Marshal(resolvedTemplate) + if err != nil { + impl.logger.Errorw("marshalling resolved deployment template ", "appId", appId, "resolvedTemplate", resolvedTemplate, "err", err) + return nil, err + } + return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(string(resolvedJson))), nil } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { From 711b682bc07f218c43a19ba09efd43b152766b71 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 17 Sep 2024 18:54:55 +0530 Subject: [PATCH 08/65] convert to json raw message for resolved data --- .../DeploymentConfigurationService.go | 43 ++++++++++++++++--- pkg/configDiff/bean/bean.go | 4 +- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 27e5c224c65..8c9eef1df62 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -160,7 +160,12 @@ func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(c impl.logger.Errorw("marshalling resolved deployment template ", "appId", appId, "resolvedTemplate", resolvedTemplate, "err", err) return nil, err } - return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(string(resolvedJson))), nil + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedJson) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedJson, "err", err) + return nil, err + } + return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(resolvedConfigDataStringJson)), nil } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { @@ -192,11 +197,16 @@ func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx c if err != nil { impl.logger.Errorw("error while resolving template from history", "deploymentHistoryId", deploymentHistory.Id, "pipelineId", configDataQueryParams.PipelineId, "err", err) } + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedTemplate) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedTemplate", "resolvedTemplate", resolvedTemplate, "err", err) + return nil, err + } deploymentConfig := bean2.NewDeploymentAndCmCsConfig(). WithConfigData(deploymentJson). WithResourceType(bean.DeploymentTemplate). WithVariableSnapshot(map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshotMap}). - WithResolvedValue(resolvedTemplate) + WithResolvedValue(resolvedConfigDataStringJson) return deploymentConfig, nil } @@ -318,12 +328,16 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err } - + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedConfigDataString", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } cmConfigData := bean2.NewDeploymentAndCmCsConfig(). WithConfigData(configDataJson). WithResourceType(resourceType). WithVariableSnapshot(variableSnapshotMap). - WithResolvedValue(resolvedConfigDataString) + WithResolvedValue(resolvedConfigDataStringJson) return cmConfigData, nil } @@ -437,12 +451,22 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(c impl.logger.Errorw("error in resolving cm and cs for published only config only response", "appId", appId, "envId", envId, "err", err) return nil, err } + resolvedConfigMapDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedCmCsMetadataDto.ResolvedConfigMapData) + if err != nil { + impl.logger.Errorw("error in ConvertToJsonRawMessage for resolvedConfigMapDataStringJson", "resolvedCmData", resolvedCmCsMetadataDto.ResolvedConfigMapData, "err", err) + return nil, err + } + resolvedSecretDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedCmCsMetadataDto.ResolvedSecretData) + if err != nil { + impl.logger.Errorw(" error in ConvertToJsonRawMessage for resolvedConfigDataString", "err", err) + return nil, err + } cmConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(cmRespJson).WithResourceType(bean.CM). - WithResolvedValue(resolvedCmCsMetadataDto.ResolvedConfigMapData).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCM) + WithResolvedValue(resolvedConfigMapDataStringJson).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCM) secretConfigData := bean2.NewDeploymentAndCmCsConfig().WithConfigData(secretRespJson).WithResourceType(bean.CS). - WithResolvedValue(resolvedCmCsMetadataDto.ResolvedSecretData).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCS) + WithResolvedValue(resolvedSecretDataStringJson).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCS) configDataDto.WithConfigMapData(cmConfigData).WithSecretData(secretConfigData) return configDataDto, nil @@ -570,8 +594,13 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx variableSnapShotMap := make(map[string]map[string]string, len(deplTemplateResp.VariableSnapshot)) variableSnapShotMap[bean.DeploymentTemplate.ToString()] = deplTemplateResp.VariableSnapshot + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(deplTemplateResp.ResolvedData) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedConfigDataString", "resolvedData", deplTemplateResp.ResolvedData, "err", err) + return nil, err + } return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentJson).WithResourceType(bean.DeploymentTemplate). - WithResolvedValue(deplTemplateResp.ResolvedData).WithVariableSnapshot(variableSnapShotMap), nil + WithResolvedValue(resolvedConfigDataStringJson).WithVariableSnapshot(variableSnapShotMap), nil } deplJson, err := impl.getBaseDeploymentTemplate(appId) if err != nil { diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index dde456f2760..1f6805d1b20 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -88,7 +88,7 @@ type DeploymentAndCmCsConfig struct { ResourceType bean.ResourceType `json:"resourceType"` Data json.RawMessage `json:"data"` VariableSnapshot map[string]map[string]string `json:"variableSnapshot"` // for deployment->{Deployment Template: resolvedValuesMap}, for cm->{cmComponentName: resolvedValuesMap} - ResolvedValue string `json:"resolvedValue"` + ResolvedValue json.RawMessage `json:"resolvedValue"` } func NewDeploymentAndCmCsConfig() *DeploymentAndCmCsConfig { @@ -110,7 +110,7 @@ func (r *DeploymentAndCmCsConfig) WithVariableSnapshot(snapshot map[string]map[s return r } -func (r *DeploymentAndCmCsConfig) WithResolvedValue(resolvedValue string) *DeploymentAndCmCsConfig { +func (r *DeploymentAndCmCsConfig) WithResolvedValue(resolvedValue json.RawMessage) *DeploymentAndCmCsConfig { r.ResolvedValue = resolvedValue return r } From d0714dd58e03955c9860434f7d5bcfa30655c37e Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 17 Sep 2024 23:23:39 +0530 Subject: [PATCH 09/65] wip: fix --- pkg/configDiff/DeploymentConfigurationService.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 8c9eef1df62..d632cbf017a 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -155,14 +155,9 @@ func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(c impl.logger.Errorw("error in getting resolved data for cm draft data ", "appId", appId, "err", err) return nil, err } - resolvedJson, err := json.Marshal(resolvedTemplate) - if err != nil { - impl.logger.Errorw("marshalling resolved deployment template ", "appId", appId, "resolvedTemplate", resolvedTemplate, "err", err) - return nil, err - } - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedJson) + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedTemplate) if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedJson, "err", err) + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedTemplate, "err", err) return nil, err } return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(resolvedConfigDataStringJson)), nil From a7033a18454387daeda4fc0b0095e5ed5731da86 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 18 Sep 2024 14:01:53 +0530 Subject: [PATCH 10/65] wip: convert to json raw --- .../DeploymentConfigurationService.go | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index d632cbf017a..2eac95e67bb 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -155,12 +155,8 @@ func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(c impl.logger.Errorw("error in getting resolved data for cm draft data ", "appId", appId, "err", err) return nil, err } - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedTemplate) - if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedTemplate, "err", err) - return nil, err - } - return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(resolvedConfigDataStringJson)), nil + + return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(json.RawMessage(resolvedTemplate))), nil } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { @@ -192,16 +188,12 @@ func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx c if err != nil { impl.logger.Errorw("error while resolving template from history", "deploymentHistoryId", deploymentHistory.Id, "pipelineId", configDataQueryParams.PipelineId, "err", err) } - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedTemplate) - if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedTemplate", "resolvedTemplate", resolvedTemplate, "err", err) - return nil, err - } + deploymentConfig := bean2.NewDeploymentAndCmCsConfig(). WithConfigData(deploymentJson). WithResourceType(bean.DeploymentTemplate). WithVariableSnapshot(map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshotMap}). - WithResolvedValue(resolvedConfigDataStringJson) + WithResolvedValue(json.RawMessage(resolvedTemplate)) return deploymentConfig, nil } @@ -589,20 +581,27 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx variableSnapShotMap := make(map[string]map[string]string, len(deplTemplateResp.VariableSnapshot)) variableSnapShotMap[bean.DeploymentTemplate.ToString()] = deplTemplateResp.VariableSnapshot - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(deplTemplateResp.ResolvedData) - if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedConfigDataString", "resolvedData", deplTemplateResp.ResolvedData, "err", err) - return nil, err - } return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentJson).WithResourceType(bean.DeploymentTemplate). - WithResolvedValue(resolvedConfigDataStringJson).WithVariableSnapshot(variableSnapShotMap), nil + WithResolvedValue(json.RawMessage(deplTemplateResp.ResolvedData)).WithVariableSnapshot(variableSnapShotMap), nil } deplJson, err := impl.getBaseDeploymentTemplate(appId) if err != nil { - impl.logger.Errorw("getDeploymentTemplateForEnvLevel, getting base depl. template", "appid", appId, "err", err) + impl.logger.Errorw("getting base depl. template", "appid", appId, "err", err) + return nil, err + } + deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ + AppId: appId, + RequestDataMode: generateManifest.Values, + } + resolvedTemplate, variableSnapshot, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, string(deplJson), deploymentTemplateRequest) + if err != nil { + impl.logger.Errorw("error in getting resolved data for base deployment template", "appid", appId, "err", err) return nil, err } - return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deplJson).WithResourceType(bean.DeploymentTemplate), nil + + variableSnapShotMap := map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshot} + return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deplJson).WithResourceType(bean.DeploymentTemplate). + WithResolvedValue(json.RawMessage(resolvedTemplate)).WithVariableSnapshot(variableSnapShotMap), nil } func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, From 28dcbd4d4c6d96eca78a51f196e157e67a20e71d Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 18 Sep 2024 18:19:57 +0530 Subject: [PATCH 11/65] wip: take values from path param values --- api/restHandler/DeploymentConfigurationRestHandler.go | 5 ++++- api/router/DeploymentConfigRouter.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 3c6876d9d1f..eeb0c2c2ae5 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -10,6 +10,7 @@ import ( "github.com/devtron-labs/devtron/pkg/configDiff/bean" util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" + "github.com/gorilla/mux" "github.com/gorilla/schema" "go.uber.org/zap" "gopkg.in/go-playground/validator.v9" @@ -90,7 +91,9 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - + vars := mux.Vars(r) + values := vars["values"] + configDataQueryParams.Values = values //RBAC START token := r.Header.Get(common.TokenHeaderKey) object := handler.enforcerUtil.GetAppRBACName(configDataQueryParams.AppName) diff --git a/api/router/DeploymentConfigRouter.go b/api/router/DeploymentConfigRouter.go index a8a568d6046..5dbab24b306 100644 --- a/api/router/DeploymentConfigRouter.go +++ b/api/router/DeploymentConfigRouter.go @@ -26,6 +26,6 @@ func (router DeploymentConfigurationRouterImpl) initDeploymentConfigurationRoute Methods("GET") configRouter.Path("/data"). HandlerFunc(router.deploymentGroupRestHandler.GetConfigData). - Methods("GET") + Methods("POST") } From 425780f09a9b692bc317630dd7b90afa74f9b939 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 18 Sep 2024 19:03:31 +0530 Subject: [PATCH 12/65] decode values payload --- .../DeploymentConfigurationRestHandler.go | 15 +++++++++++---- pkg/configDiff/bean/bean.go | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index eeb0c2c2ae5..fd0b06ad56b 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -2,6 +2,7 @@ package restHandler import ( "context" + "encoding/json" "fmt" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" @@ -10,7 +11,6 @@ import ( "github.com/devtron-labs/devtron/pkg/configDiff/bean" util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" - "github.com/gorilla/mux" "github.com/gorilla/schema" "go.uber.org/zap" "gopkg.in/go-playground/validator.v9" @@ -91,9 +91,16 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - vars := mux.Vars(r) - values := vars["values"] - configDataQueryParams.Values = values + valuesPayload := &bean.ValuesDto{} + configDataQueryParams.UserId = userId + decoder := json.NewDecoder(r.Body) + err = decoder.Decode(valuesPayload) + if err != nil { + handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + configDataQueryParams.Values = valuesPayload.Values //RBAC START token := r.Header.Get(common.TokenHeaderKey) object := handler.enforcerUtil.GetAppRBACName(configDataQueryParams.AppName) diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 1f6805d1b20..e897ce010be 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -198,3 +198,7 @@ type ResolvedCmCsMetadataDto struct { VariableMapCM map[string]map[string]string VariableMapCS map[string]map[string]string } + +type ValuesDto struct { + Values string `json:"values"` +} From fa5217176089a037e863fab4c44284f718781b12 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 18 Sep 2024 22:48:26 +0530 Subject: [PATCH 13/65] if content of post config data is >0 then only parse the payload else not --- .../DeploymentConfigurationRestHandler.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index fd0b06ad56b..9e853e7dd26 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -91,16 +91,19 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - valuesPayload := &bean.ValuesDto{} - configDataQueryParams.UserId = userId - decoder := json.NewDecoder(r.Body) - err = decoder.Decode(valuesPayload) - if err != nil { - handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return + if r.ContentLength > 0 { + valuesPayload := &bean.ValuesDto{} + decoder := json.NewDecoder(r.Body) + err = decoder.Decode(valuesPayload) + if err != nil { + handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + configDataQueryParams.Values = valuesPayload.Values } - configDataQueryParams.Values = valuesPayload.Values + + configDataQueryParams.UserId = userId //RBAC START token := r.Header.Get(common.TokenHeaderKey) object := handler.enforcerUtil.GetAppRBACName(configDataQueryParams.AppName) From 530301eb9c663f1596d1687ef890a17d7fd164d9 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 23 Sep 2024 00:32:01 +0530 Subject: [PATCH 14/65] add template version and isAppMetrics enabled in case of deployment template and some more metadata added for pipeline strategy --- .../DeploymentConfigurationService.go | 38 +++++++++++---- pkg/configDiff/bean/bean.go | 25 ++++++++++ .../DeploymentTemplateService.go | 48 +++++++++++++++---- pkg/generateManifest/bean.go | 8 ++-- wire_gen.go | 4 +- 5 files changed, 98 insertions(+), 25 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 2eac95e67bb..17218aec6b2 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -13,6 +13,7 @@ import ( bean2 "github.com/devtron-labs/devtron/pkg/configDiff/bean" "github.com/devtron-labs/devtron/pkg/configDiff/helper" "github.com/devtron-labs/devtron/pkg/configDiff/utils" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/adapter" @@ -45,6 +46,7 @@ type DeploymentConfigurationServiceImpl struct { scopedVariableManager variables.ScopedVariableCMCSManager configMapRepository chartConfig.ConfigMapRepository deploymentConfigService pipeline.PipelineDeploymentConfigService + chartRefService chartRef.ChartRefService } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -59,6 +61,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, scopedVariableManager variables.ScopedVariableCMCSManager, configMapRepository chartConfig.ConfigMapRepository, deploymentConfigService pipeline.PipelineDeploymentConfigService, + chartRefService chartRef.ChartRefService, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ logger: logger, @@ -73,6 +76,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, scopedVariableManager: scopedVariableManager, configMapRepository: configMapRepository, deploymentConfigService: deploymentConfigService, + chartRefService: chartRefService, } return deploymentConfigurationService, nil @@ -193,7 +197,8 @@ func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx c WithConfigData(deploymentJson). WithResourceType(bean.DeploymentTemplate). WithVariableSnapshot(map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshotMap}). - WithResolvedValue(json.RawMessage(resolvedTemplate)) + WithResolvedValue(json.RawMessage(resolvedTemplate)). + WithDeploymentConfigMetadata(deploymentHistory.TemplateVersion, deploymentHistory.IsAppMetricsEnabled) return deploymentConfig, nil } @@ -209,7 +214,10 @@ func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyConfigHistory impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "pipelineStrategyHistoryConfig", pipelineStrategyHistory.Config, "err", err) return nil, err } - pipelineConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(pipelineStrategyJson).WithResourceType(bean.PipelineStrategy) + pipelineConfig := bean2.NewDeploymentAndCmCsConfig(). + WithConfigData(pipelineStrategyJson). + WithResourceType(bean.PipelineStrategy). + WithPipelineStrategyMetadata(pipelineStrategyHistory.PipelineTriggerType, string(pipelineStrategyHistory.Strategy)) return pipelineConfig, nil } @@ -582,9 +590,10 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx variableSnapShotMap[bean.DeploymentTemplate.ToString()] = deplTemplateResp.VariableSnapshot return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentJson).WithResourceType(bean.DeploymentTemplate). - WithResolvedValue(json.RawMessage(deplTemplateResp.ResolvedData)).WithVariableSnapshot(variableSnapShotMap), nil + WithResolvedValue(json.RawMessage(deplTemplateResp.ResolvedData)).WithVariableSnapshot(variableSnapShotMap). + WithDeploymentConfigMetadata(deplTemplateResp.TemplateVersion, deplTemplateResp.IsAppMetricsEnabled), nil } - deplJson, err := impl.getBaseDeploymentTemplate(appId) + deplMetadata, err := impl.getBaseDeploymentTemplate(appId) if err != nil { impl.logger.Errorw("getting base depl. template", "appid", appId, "err", err) return nil, err @@ -593,15 +602,16 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx AppId: appId, RequestDataMode: generateManifest.Values, } - resolvedTemplate, variableSnapshot, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, string(deplJson), deploymentTemplateRequest) + resolvedTemplate, variableSnapshot, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, string(deplMetadata.DeploymentTemplateJson), deploymentTemplateRequest) if err != nil { impl.logger.Errorw("error in getting resolved data for base deployment template", "appid", appId, "err", err) return nil, err } variableSnapShotMap := map[string]map[string]string{bean.DeploymentTemplate.ToString(): variableSnapshot} - return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deplJson).WithResourceType(bean.DeploymentTemplate). - WithResolvedValue(json.RawMessage(resolvedTemplate)).WithVariableSnapshot(variableSnapShotMap), nil + return bean2.NewDeploymentAndCmCsConfig().WithConfigData(deplMetadata.DeploymentTemplateJson).WithResourceType(bean.DeploymentTemplate). + WithResolvedValue(json.RawMessage(resolvedTemplate)).WithVariableSnapshot(variableSnapShotMap). + WithDeploymentConfigMetadata(deplMetadata.TemplateVersion, deplMetadata.IsAppMetricsEnabled), nil } func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, @@ -626,14 +636,22 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte return configData, nil } -func (impl *DeploymentConfigurationServiceImpl) getBaseDeploymentTemplate(appId int) (json.RawMessage, error) { +func (impl *DeploymentConfigurationServiceImpl) getBaseDeploymentTemplate(appId int) (*bean2.DeploymentTemplateMetadata, error) { deploymentTemplateData, err := impl.chartService.FindLatestChartForAppByAppId(appId) if err != nil { impl.logger.Errorw("error in getting base deployment template for appId", "appId", appId, "err", err) return nil, err } - - return deploymentTemplateData.DefaultAppOverride, nil + _, _, version, _, err := impl.chartRefService.GetRefChart(deploymentTemplateData.ChartRefId) + if err != nil { + impl.logger.Errorw("error in getting chart ref by chartRefId ", "chartRefId", deploymentTemplateData.ChartRefId, "err", err) + return nil, err + } + return &bean2.DeploymentTemplateMetadata{ + DeploymentTemplateJson: deploymentTemplateData.DefaultAppOverride, + IsAppMetricsEnabled: deploymentTemplateData.IsAppMetricsEnabled, + TemplateVersion: version, + }, nil } func (impl *DeploymentConfigurationServiceImpl) getDeploymentTemplateForEnvLevel(ctx context.Context, appId, envId int) (generateManifest.DeploymentTemplateResponse, error) { diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index e897ce010be..84e07ce2573 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -4,6 +4,7 @@ import "C" import ( "encoding/json" "fmt" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" bean3 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) @@ -89,6 +90,12 @@ type DeploymentAndCmCsConfig struct { Data json.RawMessage `json:"data"` VariableSnapshot map[string]map[string]string `json:"variableSnapshot"` // for deployment->{Deployment Template: resolvedValuesMap}, for cm->{cmComponentName: resolvedValuesMap} ResolvedValue json.RawMessage `json:"resolvedValue"` + // for deployment template + TemplateVersion string `json:"templateVersion,omitempty"` + IsAppMetricsEnabled bool `json:"isAppMetricsEnabled,omitempty"` + //for pipeline strategy + PipelineTriggerType pipelineConfig.TriggerType `json:"pipelineTriggerType,omitempty"` + Strategy string `json:"strategy,omitempty"` } func NewDeploymentAndCmCsConfig() *DeploymentAndCmCsConfig { @@ -115,6 +122,18 @@ func (r *DeploymentAndCmCsConfig) WithResolvedValue(resolvedValue json.RawMessag return r } +func (r *DeploymentAndCmCsConfig) WithDeploymentConfigMetadata(templateVersion string, isAppMetricsEnabled bool) *DeploymentAndCmCsConfig { + r.TemplateVersion = templateVersion + r.IsAppMetricsEnabled = isAppMetricsEnabled + return r +} + +func (r *DeploymentAndCmCsConfig) WithPipelineStrategyMetadata(pipelineTriggerType pipelineConfig.TriggerType, strategy string) *DeploymentAndCmCsConfig { + r.PipelineTriggerType = pipelineTriggerType + r.Strategy = strategy + return r +} + type DeploymentAndCmCsConfigDto struct { DeploymentTemplate *DeploymentAndCmCsConfig `json:"deploymentTemplate"` ConfigMapsData *DeploymentAndCmCsConfig `json:"configMapData"` @@ -202,3 +221,9 @@ type ResolvedCmCsMetadataDto struct { type ValuesDto struct { Values string `json:"values"` } + +type DeploymentTemplateMetadata struct { + DeploymentTemplateJson json.RawMessage + TemplateVersion string + IsAppMetricsEnabled bool +} diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 2ee90ab579a..0bb0d6275bd 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -203,6 +203,7 @@ func (impl DeploymentTemplateServiceImpl) FetchDeploymentsWithChartRefs(appId in func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Context, request DeploymentTemplateRequest) (DeploymentTemplateResponse, error) { var result DeploymentTemplateResponse + var response *DeploymentTemplateResponse var values, resolvedValue string var err error var variableSnapshot map[string]string @@ -219,9 +220,9 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont _, values, err = impl.chartRefService.GetAppOverrideForDefaultTemplate(request.ChartRefId) resolvedValue = values case repository.PublishedOnEnvironments: - values, resolvedValue, variableSnapshot, err = impl.fetchResolvedTemplateForPublishedEnvs(ctx, request) + response, err = impl.fetchResolvedTemplateForPublishedEnvs(ctx, request) case repository.DeployedOnSelfEnvironment, repository.DeployedOnOtherEnvironment: - values, resolvedValue, variableSnapshot, err = impl.fetchTemplateForDeployedEnv(ctx, request) + response, err = impl.fetchTemplateForDeployedEnv(ctx, request) } if err != nil { impl.Logger.Errorw("error in getting values", "err", err) @@ -233,9 +234,18 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont result.Data = values result.ResolvedData = resolvedValue result.VariableSnapshot = variableSnapshot + if response != nil { + result.Data = response.Data + result.ResolvedData = response.ResolvedData + result.VariableSnapshot = response.VariableSnapshot + result.TemplateVersion = response.TemplateVersion + result.IsAppMetricsEnabled = response.IsAppMetricsEnabled + } return result, nil } - + if variableSnapshot != nil { + result.VariableSnapshot = variableSnapshot + } request = impl.setRequestMetadata(&request) manifest, err := impl.GenerateManifest(ctx, &request, resolvedValue) if err != nil { @@ -312,7 +322,7 @@ func (impl DeploymentTemplateServiceImpl) setRequestMetadata(request *Deployment return *request } -func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs(ctx context.Context, request DeploymentTemplateRequest) (string, string, map[string]string, error) { +func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs(ctx context.Context, request DeploymentTemplateRequest) (*DeploymentTemplateResponse, error) { var values string override, err := impl.propertiesConfigService.GetEnvironmentProperties(request.AppId, request.EnvId, request.ChartRefId) if err == nil && override.GlobalConfig != nil { @@ -323,24 +333,42 @@ func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs( } } else { impl.Logger.Errorw("error in getting overridden values", "err", err) - return "", "", nil, err + return nil, err + } + _, _, version, _, err := impl.chartRefService.GetRefChart(request.ChartRefId) + if err != nil { + impl.Logger.Errorw("error in getting chart ref by chartRefId ", "chartRefId", request.ChartRefId, "err", err) + return nil, err } resolvedTemplate, variableSnapshot, err := impl.resolveTemplateVariables(ctx, values, request) if err != nil { - return values, values, variableSnapshot, err + impl.Logger.Errorw("error in resolving template variables for env override ", "values", values, "err", err) + return nil, err } - return values, resolvedTemplate, variableSnapshot, nil + return &DeploymentTemplateResponse{ + Data: values, + ResolvedData: resolvedTemplate, + VariableSnapshot: variableSnapshot, + TemplateVersion: version, + IsAppMetricsEnabled: *override.AppMetrics, + }, nil } -func (impl DeploymentTemplateServiceImpl) fetchTemplateForDeployedEnv(ctx context.Context, request DeploymentTemplateRequest) (string, string, map[string]string, error) { +func (impl DeploymentTemplateServiceImpl) fetchTemplateForDeployedEnv(ctx context.Context, request DeploymentTemplateRequest) (*DeploymentTemplateResponse, error) { historyObject, err := impl.deploymentTemplateHistoryService.GetHistoryForDeployedTemplateById(ctx, request.DeploymentTemplateHistoryId, request.PipelineId) if err != nil { impl.Logger.Errorw("error in getting deployment template history", "err", err, "id", request.DeploymentTemplateHistoryId, "pipelineId", request.PipelineId) - return "", "", nil, err + return nil, err } //todo Subhashish solve variable leak - return historyObject.CodeEditorValue.Value, historyObject.CodeEditorValue.ResolvedValue, historyObject.CodeEditorValue.VariableSnapshot, nil + return &DeploymentTemplateResponse{ + Data: historyObject.CodeEditorValue.Value, + ResolvedData: historyObject.CodeEditorValue.ResolvedValue, + VariableSnapshot: historyObject.CodeEditorValue.VariableSnapshot, + TemplateVersion: historyObject.TemplateVersion, + IsAppMetricsEnabled: *historyObject.IsAppMetricsEnabled, + }, nil } func (impl DeploymentTemplateServiceImpl) resolveTemplateVariables(ctx context.Context, values string, request DeploymentTemplateRequest) (string, map[string]string, error) { diff --git a/pkg/generateManifest/bean.go b/pkg/generateManifest/bean.go index 124a0cf0831..26a465dd3f4 100644 --- a/pkg/generateManifest/bean.go +++ b/pkg/generateManifest/bean.go @@ -69,9 +69,11 @@ var ReleaseIdentifier = &gRPC.ReleaseIdentifier{ } type DeploymentTemplateResponse struct { - Data string `json:"data"` - ResolvedData string `json:"resolvedData"` - VariableSnapshot map[string]string `json:"variableSnapshot"` + Data string `json:"data"` + ResolvedData string `json:"resolvedData"` + VariableSnapshot map[string]string `json:"variableSnapshot"` + TemplateVersion string `json:"-"` + IsAppMetricsEnabled bool `json:"-"` } type RestartPodResponse struct { diff --git a/wire_gen.go b/wire_gen.go index 193b737d359..8c581de9e1e 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:generate go run github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject @@ -949,7 +949,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl, chartRefServiceImpl) if err != nil { return nil, err } From 89656bfe8a945643322ffa71abfdaa47e2d72297 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 25 Sep 2024 18:19:26 +0530 Subject: [PATCH 15/65] pipeline strategy in published data req --- .../DeploymentConfigurationService.go | 39 ++++++++++++++++++- pkg/pipeline/DeploymentConfigService.go | 1 + wire_gen.go | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 17218aec6b2..34bd16b3ec1 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -6,6 +6,7 @@ import ( repository2 "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -47,6 +48,7 @@ type DeploymentConfigurationServiceImpl struct { configMapRepository chartConfig.ConfigMapRepository deploymentConfigService pipeline.PipelineDeploymentConfigService chartRefService chartRef.ChartRefService + pipelineRepository pipelineConfig.PipelineRepository } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -62,6 +64,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, configMapRepository chartConfig.ConfigMapRepository, deploymentConfigService pipeline.PipelineDeploymentConfigService, chartRefService chartRef.ChartRefService, + pipelineRepository pipelineConfig.PipelineRepository, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ logger: logger, @@ -77,6 +80,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, configMapRepository: configMapRepository, deploymentConfigService: deploymentConfigService, chartRefService: chartRefService, + pipelineRepository: pipelineRepository, } return deploymentConfigurationService, nil @@ -631,11 +635,44 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte impl.logger.Errorw("getPublishedConfigData, error in getting publishedOnly deployment config ", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - configData.WithDeploymentTemplateData(deploymentTemplateData) + + pipelineConfigData, err := impl.getPublishedPipelineStrategyConfig(ctx, appId, envId) + if err != nil { + impl.logger.Errorw("getPublishedConfigData, error in getting publishedOnly pipeline strategy ", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + configData.WithPipelineConfigData(pipelineConfigData) return configData, nil } +func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConfig(ctx context.Context, appId int, envId int) (*bean2.DeploymentAndCmCsConfig, error) { + pipelineStrategyJson := json.RawMessage{} + pipelineConfig := bean2.NewDeploymentAndCmCsConfig() + if envId == 0 { + return pipelineConfig, nil + } + pipeline, err := impl.pipelineRepository.FindActiveByAppIdAndEnvId(appId, envId) + if err != nil { + impl.logger.Errorw("error in FindActiveByAppIdAndEnvId", "appId", appId, "envId", envId, "err", err) + return nil, err + } + pipelineStrategy, err := impl.deploymentConfigService.GetLatestPipelineStrategyConfig(pipeline) + if err != nil { + impl.logger.Errorw("error in GetLatestPipelineStrategyConfig", "pipelineId", pipeline.Id, "err", err) + return nil, err + } + err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategy.CodeEditorValue.Value)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "err", err) + return nil, err + } + pipelineConfig.WithConfigData(pipelineStrategyJson). + WithResourceType(bean.PipelineStrategy). + WithPipelineStrategyMetadata(pipelineStrategy.PipelineTriggerType, string(pipelineStrategy.Strategy)) + return pipelineConfig, nil +} + func (impl *DeploymentConfigurationServiceImpl) getBaseDeploymentTemplate(appId int) (*bean2.DeploymentTemplateMetadata, error) { deploymentTemplateData, err := impl.chartService.FindLatestChartForAppByAppId(appId) if err != nil { diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index ff699b722a5..bb35e4fc41d 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -39,6 +39,7 @@ import ( type PipelineDeploymentConfigService interface { GetLatestDeploymentConfigurationByPipelineId(ctx context.Context, pipelineId int, userHasAdminAccess bool) (*history.AllDeploymentConfigurationDetail, error) GetMergedCMCSConfigMap(appLevelConfig, envLevelConfig string, configType repository2.ConfigType) (map[string]*bean.ConfigData, error) + GetLatestPipelineStrategyConfig(pipeline *pipelineConfig.Pipeline) (*history.HistoryDetailDto, error) } type PipelineDeploymentConfigServiceImpl struct { diff --git a/wire_gen.go b/wire_gen.go index 578b2e3cfe4..bb140cf073c 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -949,7 +949,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl, chartRefServiceImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl, chartRefServiceImpl, pipelineRepositoryImpl) if err != nil { return nil, err } From 53e102a9d7990afca523b4f20dedc730bcf7a8f9 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 26 Sep 2024 13:49:54 +0530 Subject: [PATCH 16/65] making config/data api backward compatible --- .../DeploymentConfigurationRestHandler.go | 21 +++++++++++-------- api/router/DeploymentConfigRouter.go | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 9e853e7dd26..13926f7fbd6 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -91,16 +91,19 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - if r.ContentLength > 0 { - valuesPayload := &bean.ValuesDto{} - decoder := json.NewDecoder(r.Body) - err = decoder.Decode(valuesPayload) - if err != nil { - handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return + switch r.Method { + case http.MethodPost: + if r.ContentLength > 0 { + valuesPayload := &bean.ValuesDto{} + decoder := json.NewDecoder(r.Body) + err = decoder.Decode(valuesPayload) + if err != nil { + handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + configDataQueryParams.Values = valuesPayload.Values } - configDataQueryParams.Values = valuesPayload.Values } configDataQueryParams.UserId = userId diff --git a/api/router/DeploymentConfigRouter.go b/api/router/DeploymentConfigRouter.go index 5dbab24b306..b442c134244 100644 --- a/api/router/DeploymentConfigRouter.go +++ b/api/router/DeploymentConfigRouter.go @@ -26,6 +26,6 @@ func (router DeploymentConfigurationRouterImpl) initDeploymentConfigurationRoute Methods("GET") configRouter.Path("/data"). HandlerFunc(router.deploymentGroupRestHandler.GetConfigData). - Methods("POST") + Methods("GET", "POST") } From 060d5d7157d1039b51713c5c474074730e70b806 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 26 Sep 2024 16:33:27 +0530 Subject: [PATCH 17/65] handle for pg no rows --- pkg/configDiff/DeploymentConfigurationService.go | 6 +++++- pkg/configDiff/bean/bean.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 34bd16b3ec1..58b7155a5d4 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -7,6 +7,7 @@ import ( appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" bean3 "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -27,6 +28,7 @@ import ( util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "go.uber.org/zap" + "net/http" ) type DeploymentConfigurationService interface { @@ -175,9 +177,11 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx c func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfig, error) { deploymentJson := json.RawMessage{} deploymentHistory, err := impl.deploymentTemplateHistoryRepository.GetHistoryByPipelineIdAndWfrId(configDataQueryParams.PipelineId, configDataQueryParams.WfrId) - if err != nil { + if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("error in getting deployment template history for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err + } else if util.IsErrNoRows(err) { + return nil, util.GetApiError(http.StatusNotFound, bean2.NoDeploymentDoneForSelectedImage, bean2.NoDeploymentDoneForSelectedImage) } err = deploymentJson.UnmarshalJSON([]byte(deploymentHistory.Template)) if err != nil { diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 84e07ce2573..1ccf3039509 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -227,3 +227,7 @@ type DeploymentTemplateMetadata struct { TemplateVersion string IsAppMetricsEnabled bool } + +const ( + NoDeploymentDoneForSelectedImage = "there were no deployments done for the selected image" +) From 7a7627e5420b2d04177835c0bd4c06789af3d439 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 7 Oct 2024 12:34:42 +0530 Subject: [PATCH 18/65] merge develop here --- cmd/external-app/wire_gen.go | 2 +- go.mod | 4 +- go.sum | 2 + pkg/pipeline/adapter/adapter.go | 6 +- vendor/github.com/docker/distribution/LICENSE | 202 ++++++++ .../docker/distribution/digestset/set.go | 247 ++++++++++ .../docker/distribution/reference/helpers.go | 42 ++ .../distribution/reference/normalize.go | 199 ++++++++ .../distribution/reference/reference.go | 433 ++++++++++++++++++ .../docker/distribution/reference/regexp.go | 143 ++++++ vendor/modules.txt | 4 + 11 files changed, 1280 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/docker/distribution/LICENSE create mode 100644 vendor/github.com/docker/distribution/digestset/set.go create mode 100644 vendor/github.com/docker/distribution/reference/helpers.go create mode 100644 vendor/github.com/docker/distribution/reference/normalize.go create mode 100644 vendor/github.com/docker/distribution/reference/reference.go create mode 100644 vendor/github.com/docker/distribution/reference/regexp.go diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 9c1d691030b..db064d11f40 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -317,7 +317,7 @@ func InitializeApp() (*App, error) { environmentRestHandlerImpl := cluster2.NewEnvironmentRestHandlerImpl(environmentServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceImpl, k8sServiceImpl, k8sCommonServiceImpl) environmentRouterImpl := cluster2.NewEnvironmentRouterImpl(environmentRestHandlerImpl) ciPipelineRepositoryImpl := pipelineConfig.NewCiPipelineRepositoryImpl(db, sugaredLogger, transactionUtilImpl) - enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) + enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl, dbMigrationServiceImpl) k8sApplicationRestHandlerImpl := application2.NewK8sApplicationRestHandlerImpl(sugaredLogger, k8sApplicationServiceImpl, pumpImpl, terminalSessionHandlerImpl, enforcerImpl, enforcerUtilHelmImpl, enforcerUtilImpl, helmAppServiceImpl, userServiceImpl, k8sCommonServiceImpl, validate, environmentVariables, fluxApplicationServiceImpl, argoApplicationReadServiceImpl) k8sApplicationRouterImpl := application2.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceImpl, attributesServiceImpl) diff --git a/go.mod b/go.mod index 28b83cf7db7..07f32cd764e 100644 --- a/go.mod +++ b/go.mod @@ -212,7 +212,7 @@ require ( github.com/nats-io/nats.go v1.28.0 // indirect github.com/nats-io/nkeys v0.4.6 // indirect github.com/nats-io/nuid v1.0.1 // indirect - github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect @@ -282,6 +282,8 @@ require ( xorm.io/xorm v1.0.3 // indirect ) +require github.com/docker/distribution v2.8.2+incompatible + require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect replace ( diff --git a/go.sum b/go.sum index 9f48ec4b438..ff05b0d06f9 100644 --- a/go.sum +++ b/go.sum @@ -807,6 +807,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/cli v24.0.6+incompatible h1:fF+XCQCgJjjQNIMjzaSmiKJSCcfcXb3TWTcc7GAneOY= github.com/docker/cli v24.0.6+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= diff --git a/pkg/pipeline/adapter/adapter.go b/pkg/pipeline/adapter/adapter.go index bd1ef81821e..feb6991b8c0 100644 --- a/pkg/pipeline/adapter/adapter.go +++ b/pkg/pipeline/adapter/adapter.go @@ -244,6 +244,7 @@ func ConvertConfigDataToPipelineConfigData(r *bean.ConfigData) *pipelineConfigBe DefaultExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.DefaultExternalSecret), RoleARN: r.RoleARN, SubPath: r.SubPath, + ESOSubPath: r.ESOSubPath, FilePermission: r.FilePermission, Overridden: r.Overridden, } @@ -253,7 +254,7 @@ func ConvertESOSecretDataToPipelineESOSecretData(r bean.ESOSecretData) pipelineC return pipelineConfigBean.ESOSecretData{ SecretStore: r.SecretStore, SecretStoreRef: r.SecretStoreRef, - EsoData: ConvertEsoDataToPipelineEsoData(r.EsoData), + ESOData: ConvertEsoDataToPipelineEsoData(r.ESOData), RefreshInterval: r.RefreshInterval, } } @@ -304,6 +305,7 @@ func ConvertPipelineConfigDataToConfigData(r *pipelineConfigBean.ConfigData) *be DefaultExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.DefaultExternalSecret), RoleARN: r.RoleARN, SubPath: r.SubPath, + ESOSubPath: r.ESOSubPath, FilePermission: r.FilePermission, Overridden: r.Overridden, } @@ -313,7 +315,7 @@ func ConvertPipelineESOSecretDataToESOSecretData(r pipelineConfigBean.ESOSecretD return bean.ESOSecretData{ SecretStore: r.SecretStore, SecretStoreRef: r.SecretStoreRef, - EsoData: ConvertPipelineEsoDataToEsoData(r.EsoData), + ESOData: ConvertPipelineEsoDataToEsoData(r.ESOData), RefreshInterval: r.RefreshInterval, } } diff --git a/vendor/github.com/docker/distribution/LICENSE b/vendor/github.com/docker/distribution/LICENSE new file mode 100644 index 00000000000..e06d2081865 --- /dev/null +++ b/vendor/github.com/docker/distribution/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/docker/distribution/digestset/set.go b/vendor/github.com/docker/distribution/digestset/set.go new file mode 100644 index 00000000000..71327dca720 --- /dev/null +++ b/vendor/github.com/docker/distribution/digestset/set.go @@ -0,0 +1,247 @@ +package digestset + +import ( + "errors" + "sort" + "strings" + "sync" + + digest "github.com/opencontainers/go-digest" +) + +var ( + // ErrDigestNotFound is used when a matching digest + // could not be found in a set. + ErrDigestNotFound = errors.New("digest not found") + + // ErrDigestAmbiguous is used when multiple digests + // are found in a set. None of the matching digests + // should be considered valid matches. + ErrDigestAmbiguous = errors.New("ambiguous digest string") +) + +// Set is used to hold a unique set of digests which +// may be easily referenced by easily referenced by a string +// representation of the digest as well as short representation. +// The uniqueness of the short representation is based on other +// digests in the set. If digests are omitted from this set, +// collisions in a larger set may not be detected, therefore it +// is important to always do short representation lookups on +// the complete set of digests. To mitigate collisions, an +// appropriately long short code should be used. +type Set struct { + mutex sync.RWMutex + entries digestEntries +} + +// NewSet creates an empty set of digests +// which may have digests added. +func NewSet() *Set { + return &Set{ + entries: digestEntries{}, + } +} + +// checkShortMatch checks whether two digests match as either whole +// values or short values. This function does not test equality, +// rather whether the second value could match against the first +// value. +func checkShortMatch(alg digest.Algorithm, hex, shortAlg, shortHex string) bool { + if len(hex) == len(shortHex) { + if hex != shortHex { + return false + } + if len(shortAlg) > 0 && string(alg) != shortAlg { + return false + } + } else if !strings.HasPrefix(hex, shortHex) { + return false + } else if len(shortAlg) > 0 && string(alg) != shortAlg { + return false + } + return true +} + +// Lookup looks for a digest matching the given string representation. +// If no digests could be found ErrDigestNotFound will be returned +// with an empty digest value. If multiple matches are found +// ErrDigestAmbiguous will be returned with an empty digest value. +func (dst *Set) Lookup(d string) (digest.Digest, error) { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + if len(dst.entries) == 0 { + return "", ErrDigestNotFound + } + var ( + searchFunc func(int) bool + alg digest.Algorithm + hex string + ) + dgst, err := digest.Parse(d) + if err == digest.ErrDigestInvalidFormat { + hex = d + searchFunc = func(i int) bool { + return dst.entries[i].val >= d + } + } else { + hex = dgst.Hex() + alg = dgst.Algorithm() + searchFunc = func(i int) bool { + if dst.entries[i].val == hex { + return dst.entries[i].alg >= alg + } + return dst.entries[i].val >= hex + } + } + idx := sort.Search(len(dst.entries), searchFunc) + if idx == len(dst.entries) || !checkShortMatch(dst.entries[idx].alg, dst.entries[idx].val, string(alg), hex) { + return "", ErrDigestNotFound + } + if dst.entries[idx].alg == alg && dst.entries[idx].val == hex { + return dst.entries[idx].digest, nil + } + if idx+1 < len(dst.entries) && checkShortMatch(dst.entries[idx+1].alg, dst.entries[idx+1].val, string(alg), hex) { + return "", ErrDigestAmbiguous + } + + return dst.entries[idx].digest, nil +} + +// Add adds the given digest to the set. An error will be returned +// if the given digest is invalid. If the digest already exists in the +// set, this operation will be a no-op. +func (dst *Set) Add(d digest.Digest) error { + if err := d.Validate(); err != nil { + return err + } + dst.mutex.Lock() + defer dst.mutex.Unlock() + entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} + searchFunc := func(i int) bool { + if dst.entries[i].val == entry.val { + return dst.entries[i].alg >= entry.alg + } + return dst.entries[i].val >= entry.val + } + idx := sort.Search(len(dst.entries), searchFunc) + if idx == len(dst.entries) { + dst.entries = append(dst.entries, entry) + return nil + } else if dst.entries[idx].digest == d { + return nil + } + + entries := append(dst.entries, nil) + copy(entries[idx+1:], entries[idx:len(entries)-1]) + entries[idx] = entry + dst.entries = entries + return nil +} + +// Remove removes the given digest from the set. An err will be +// returned if the given digest is invalid. If the digest does +// not exist in the set, this operation will be a no-op. +func (dst *Set) Remove(d digest.Digest) error { + if err := d.Validate(); err != nil { + return err + } + dst.mutex.Lock() + defer dst.mutex.Unlock() + entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} + searchFunc := func(i int) bool { + if dst.entries[i].val == entry.val { + return dst.entries[i].alg >= entry.alg + } + return dst.entries[i].val >= entry.val + } + idx := sort.Search(len(dst.entries), searchFunc) + // Not found if idx is after or value at idx is not digest + if idx == len(dst.entries) || dst.entries[idx].digest != d { + return nil + } + + entries := dst.entries + copy(entries[idx:], entries[idx+1:]) + entries = entries[:len(entries)-1] + dst.entries = entries + + return nil +} + +// All returns all the digests in the set +func (dst *Set) All() []digest.Digest { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + retValues := make([]digest.Digest, len(dst.entries)) + for i := range dst.entries { + retValues[i] = dst.entries[i].digest + } + + return retValues +} + +// ShortCodeTable returns a map of Digest to unique short codes. The +// length represents the minimum value, the maximum length may be the +// entire value of digest if uniqueness cannot be achieved without the +// full value. This function will attempt to make short codes as short +// as possible to be unique. +func ShortCodeTable(dst *Set, length int) map[digest.Digest]string { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + m := make(map[digest.Digest]string, len(dst.entries)) + l := length + resetIdx := 0 + for i := 0; i < len(dst.entries); i++ { + var short string + extended := true + for extended { + extended = false + if len(dst.entries[i].val) <= l { + short = dst.entries[i].digest.String() + } else { + short = dst.entries[i].val[:l] + for j := i + 1; j < len(dst.entries); j++ { + if checkShortMatch(dst.entries[j].alg, dst.entries[j].val, "", short) { + if j > resetIdx { + resetIdx = j + } + extended = true + } else { + break + } + } + if extended { + l++ + } + } + } + m[dst.entries[i].digest] = short + if i >= resetIdx { + l = length + } + } + return m +} + +type digestEntry struct { + alg digest.Algorithm + val string + digest digest.Digest +} + +type digestEntries []*digestEntry + +func (d digestEntries) Len() int { + return len(d) +} + +func (d digestEntries) Less(i, j int) bool { + if d[i].val != d[j].val { + return d[i].val < d[j].val + } + return d[i].alg < d[j].alg +} + +func (d digestEntries) Swap(i, j int) { + d[i], d[j] = d[j], d[i] +} diff --git a/vendor/github.com/docker/distribution/reference/helpers.go b/vendor/github.com/docker/distribution/reference/helpers.go new file mode 100644 index 00000000000..978df7eabbf --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/helpers.go @@ -0,0 +1,42 @@ +package reference + +import "path" + +// IsNameOnly returns true if reference only contains a repo name. +func IsNameOnly(ref Named) bool { + if _, ok := ref.(NamedTagged); ok { + return false + } + if _, ok := ref.(Canonical); ok { + return false + } + return true +} + +// FamiliarName returns the familiar name string +// for the given named, familiarizing if needed. +func FamiliarName(ref Named) string { + if nn, ok := ref.(normalizedNamed); ok { + return nn.Familiar().Name() + } + return ref.Name() +} + +// FamiliarString returns the familiar string representation +// for the given reference, familiarizing if needed. +func FamiliarString(ref Reference) string { + if nn, ok := ref.(normalizedNamed); ok { + return nn.Familiar().String() + } + return ref.String() +} + +// FamiliarMatch reports whether ref matches the specified pattern. +// See https://godoc.org/path#Match for supported patterns. +func FamiliarMatch(pattern string, ref Reference) (bool, error) { + matched, err := path.Match(pattern, FamiliarString(ref)) + if namedRef, isNamed := ref.(Named); isNamed && !matched { + matched, _ = path.Match(pattern, FamiliarName(namedRef)) + } + return matched, err +} diff --git a/vendor/github.com/docker/distribution/reference/normalize.go b/vendor/github.com/docker/distribution/reference/normalize.go new file mode 100644 index 00000000000..b3dfb7a6d7e --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/normalize.go @@ -0,0 +1,199 @@ +package reference + +import ( + "errors" + "fmt" + "strings" + + "github.com/docker/distribution/digestset" + "github.com/opencontainers/go-digest" +) + +var ( + legacyDefaultDomain = "index.docker.io" + defaultDomain = "docker.io" + officialRepoName = "library" + defaultTag = "latest" +) + +// normalizedNamed represents a name which has been +// normalized and has a familiar form. A familiar name +// is what is used in Docker UI. An example normalized +// name is "docker.io/library/ubuntu" and corresponding +// familiar name of "ubuntu". +type normalizedNamed interface { + Named + Familiar() Named +} + +// ParseNormalizedNamed parses a string into a named reference +// transforming a familiar name from Docker UI to a fully +// qualified reference. If the value may be an identifier +// use ParseAnyReference. +func ParseNormalizedNamed(s string) (Named, error) { + if ok := anchoredIdentifierRegexp.MatchString(s); ok { + return nil, fmt.Errorf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings", s) + } + domain, remainder := splitDockerDomain(s) + var remoteName string + if tagSep := strings.IndexRune(remainder, ':'); tagSep > -1 { + remoteName = remainder[:tagSep] + } else { + remoteName = remainder + } + if strings.ToLower(remoteName) != remoteName { + return nil, errors.New("invalid reference format: repository name must be lowercase") + } + + ref, err := Parse(domain + "/" + remainder) + if err != nil { + return nil, err + } + named, isNamed := ref.(Named) + if !isNamed { + return nil, fmt.Errorf("reference %s has no name", ref.String()) + } + return named, nil +} + +// ParseDockerRef normalizes the image reference following the docker convention. This is added +// mainly for backward compatibility. +// The reference returned can only be either tagged or digested. For reference contains both tag +// and digest, the function returns digested reference, e.g. docker.io/library/busybox:latest@ +// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as +// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa. +func ParseDockerRef(ref string) (Named, error) { + named, err := ParseNormalizedNamed(ref) + if err != nil { + return nil, err + } + if _, ok := named.(NamedTagged); ok { + if canonical, ok := named.(Canonical); ok { + // The reference is both tagged and digested, only + // return digested. + newNamed, err := WithName(canonical.Name()) + if err != nil { + return nil, err + } + newCanonical, err := WithDigest(newNamed, canonical.Digest()) + if err != nil { + return nil, err + } + return newCanonical, nil + } + } + return TagNameOnly(named), nil +} + +// splitDockerDomain splits a repository name to domain and remotename string. +// If no valid domain is found, the default domain is used. Repository name +// needs to be already validated before. +func splitDockerDomain(name string) (domain, remainder string) { + i := strings.IndexRune(name, '/') + if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") { + domain, remainder = defaultDomain, name + } else { + domain, remainder = name[:i], name[i+1:] + } + if domain == legacyDefaultDomain { + domain = defaultDomain + } + if domain == defaultDomain && !strings.ContainsRune(remainder, '/') { + remainder = officialRepoName + "/" + remainder + } + return +} + +// familiarizeName returns a shortened version of the name familiar +// to to the Docker UI. Familiar names have the default domain +// "docker.io" and "library/" repository prefix removed. +// For example, "docker.io/library/redis" will have the familiar +// name "redis" and "docker.io/dmcgowan/myapp" will be "dmcgowan/myapp". +// Returns a familiarized named only reference. +func familiarizeName(named namedRepository) repository { + repo := repository{ + domain: named.Domain(), + path: named.Path(), + } + + if repo.domain == defaultDomain { + repo.domain = "" + // Handle official repositories which have the pattern "library/" + if split := strings.Split(repo.path, "/"); len(split) == 2 && split[0] == officialRepoName { + repo.path = split[1] + } + } + return repo +} + +func (r reference) Familiar() Named { + return reference{ + namedRepository: familiarizeName(r.namedRepository), + tag: r.tag, + digest: r.digest, + } +} + +func (r repository) Familiar() Named { + return familiarizeName(r) +} + +func (t taggedReference) Familiar() Named { + return taggedReference{ + namedRepository: familiarizeName(t.namedRepository), + tag: t.tag, + } +} + +func (c canonicalReference) Familiar() Named { + return canonicalReference{ + namedRepository: familiarizeName(c.namedRepository), + digest: c.digest, + } +} + +// TagNameOnly adds the default tag "latest" to a reference if it only has +// a repo name. +func TagNameOnly(ref Named) Named { + if IsNameOnly(ref) { + namedTagged, err := WithTag(ref, defaultTag) + if err != nil { + // Default tag must be valid, to create a NamedTagged + // type with non-validated input the WithTag function + // should be used instead + panic(err) + } + return namedTagged + } + return ref +} + +// ParseAnyReference parses a reference string as a possible identifier, +// full digest, or familiar name. +func ParseAnyReference(ref string) (Reference, error) { + if ok := anchoredIdentifierRegexp.MatchString(ref); ok { + return digestReference("sha256:" + ref), nil + } + if dgst, err := digest.Parse(ref); err == nil { + return digestReference(dgst), nil + } + + return ParseNormalizedNamed(ref) +} + +// ParseAnyReferenceWithSet parses a reference string as a possible short +// identifier to be matched in a digest set, a full digest, or familiar name. +func ParseAnyReferenceWithSet(ref string, ds *digestset.Set) (Reference, error) { + if ok := anchoredShortIdentifierRegexp.MatchString(ref); ok { + dgst, err := ds.Lookup(ref) + if err == nil { + return digestReference(dgst), nil + } + } else { + if dgst, err := digest.Parse(ref); err == nil { + return digestReference(dgst), nil + } + } + + return ParseNormalizedNamed(ref) +} diff --git a/vendor/github.com/docker/distribution/reference/reference.go b/vendor/github.com/docker/distribution/reference/reference.go new file mode 100644 index 00000000000..b7cd00b0d68 --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/reference.go @@ -0,0 +1,433 @@ +// Package reference provides a general type to represent any way of referencing images within the registry. +// Its main purpose is to abstract tags and digests (content-addressable hash). +// +// Grammar +// +// reference := name [ ":" tag ] [ "@" digest ] +// name := [domain '/'] path-component ['/' path-component]* +// domain := domain-component ['.' domain-component]* [':' port-number] +// domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/ +// port-number := /[0-9]+/ +// path-component := alpha-numeric [separator alpha-numeric]* +// alpha-numeric := /[a-z0-9]+/ +// separator := /[_.]|__|[-]*/ +// +// tag := /[\w][\w.-]{0,127}/ +// +// digest := digest-algorithm ":" digest-hex +// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]* +// digest-algorithm-separator := /[+.-_]/ +// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/ +// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value +// +// identifier := /[a-f0-9]{64}/ +// short-identifier := /[a-f0-9]{6,64}/ +package reference + +import ( + "errors" + "fmt" + "strings" + + "github.com/opencontainers/go-digest" +) + +const ( + // NameTotalLengthMax is the maximum total number of characters in a repository name. + NameTotalLengthMax = 255 +) + +var ( + // ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference. + ErrReferenceInvalidFormat = errors.New("invalid reference format") + + // ErrTagInvalidFormat represents an error while trying to parse a string as a tag. + ErrTagInvalidFormat = errors.New("invalid tag format") + + // ErrDigestInvalidFormat represents an error while trying to parse a string as a tag. + ErrDigestInvalidFormat = errors.New("invalid digest format") + + // ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters. + ErrNameContainsUppercase = errors.New("repository name must be lowercase") + + // ErrNameEmpty is returned for empty, invalid repository names. + ErrNameEmpty = errors.New("repository name must have at least one component") + + // ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax. + ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax) + + // ErrNameNotCanonical is returned when a name is not canonical. + ErrNameNotCanonical = errors.New("repository name must be canonical") +) + +// Reference is an opaque object reference identifier that may include +// modifiers such as a hostname, name, tag, and digest. +type Reference interface { + // String returns the full reference + String() string +} + +// Field provides a wrapper type for resolving correct reference types when +// working with encoding. +type Field struct { + reference Reference +} + +// AsField wraps a reference in a Field for encoding. +func AsField(reference Reference) Field { + return Field{reference} +} + +// Reference unwraps the reference type from the field to +// return the Reference object. This object should be +// of the appropriate type to further check for different +// reference types. +func (f Field) Reference() Reference { + return f.reference +} + +// MarshalText serializes the field to byte text which +// is the string of the reference. +func (f Field) MarshalText() (p []byte, err error) { + return []byte(f.reference.String()), nil +} + +// UnmarshalText parses text bytes by invoking the +// reference parser to ensure the appropriately +// typed reference object is wrapped by field. +func (f *Field) UnmarshalText(p []byte) error { + r, err := Parse(string(p)) + if err != nil { + return err + } + + f.reference = r + return nil +} + +// Named is an object with a full name +type Named interface { + Reference + Name() string +} + +// Tagged is an object which has a tag +type Tagged interface { + Reference + Tag() string +} + +// NamedTagged is an object including a name and tag. +type NamedTagged interface { + Named + Tag() string +} + +// Digested is an object which has a digest +// in which it can be referenced by +type Digested interface { + Reference + Digest() digest.Digest +} + +// Canonical reference is an object with a fully unique +// name including a name with domain and digest +type Canonical interface { + Named + Digest() digest.Digest +} + +// namedRepository is a reference to a repository with a name. +// A namedRepository has both domain and path components. +type namedRepository interface { + Named + Domain() string + Path() string +} + +// Domain returns the domain part of the Named reference +func Domain(named Named) string { + if r, ok := named.(namedRepository); ok { + return r.Domain() + } + domain, _ := splitDomain(named.Name()) + return domain +} + +// Path returns the name without the domain part of the Named reference +func Path(named Named) (name string) { + if r, ok := named.(namedRepository); ok { + return r.Path() + } + _, path := splitDomain(named.Name()) + return path +} + +func splitDomain(name string) (string, string) { + match := anchoredNameRegexp.FindStringSubmatch(name) + if len(match) != 3 { + return "", name + } + return match[1], match[2] +} + +// SplitHostname splits a named reference into a +// hostname and name string. If no valid hostname is +// found, the hostname is empty and the full value +// is returned as name +// DEPRECATED: Use Domain or Path +func SplitHostname(named Named) (string, string) { + if r, ok := named.(namedRepository); ok { + return r.Domain(), r.Path() + } + return splitDomain(named.Name()) +} + +// Parse parses s and returns a syntactically valid Reference. +// If an error was encountered it is returned, along with a nil Reference. +// NOTE: Parse will not handle short digests. +func Parse(s string) (Reference, error) { + matches := ReferenceRegexp.FindStringSubmatch(s) + if matches == nil { + if s == "" { + return nil, ErrNameEmpty + } + if ReferenceRegexp.FindStringSubmatch(strings.ToLower(s)) != nil { + return nil, ErrNameContainsUppercase + } + return nil, ErrReferenceInvalidFormat + } + + if len(matches[1]) > NameTotalLengthMax { + return nil, ErrNameTooLong + } + + var repo repository + + nameMatch := anchoredNameRegexp.FindStringSubmatch(matches[1]) + if len(nameMatch) == 3 { + repo.domain = nameMatch[1] + repo.path = nameMatch[2] + } else { + repo.domain = "" + repo.path = matches[1] + } + + ref := reference{ + namedRepository: repo, + tag: matches[2], + } + if matches[3] != "" { + var err error + ref.digest, err = digest.Parse(matches[3]) + if err != nil { + return nil, err + } + } + + r := getBestReferenceType(ref) + if r == nil { + return nil, ErrNameEmpty + } + + return r, nil +} + +// ParseNamed parses s and returns a syntactically valid reference implementing +// the Named interface. The reference must have a name and be in the canonical +// form, otherwise an error is returned. +// If an error was encountered it is returned, along with a nil Reference. +// NOTE: ParseNamed will not handle short digests. +func ParseNamed(s string) (Named, error) { + named, err := ParseNormalizedNamed(s) + if err != nil { + return nil, err + } + if named.String() != s { + return nil, ErrNameNotCanonical + } + return named, nil +} + +// WithName returns a named object representing the given string. If the input +// is invalid ErrReferenceInvalidFormat will be returned. +func WithName(name string) (Named, error) { + if len(name) > NameTotalLengthMax { + return nil, ErrNameTooLong + } + + match := anchoredNameRegexp.FindStringSubmatch(name) + if match == nil || len(match) != 3 { + return nil, ErrReferenceInvalidFormat + } + return repository{ + domain: match[1], + path: match[2], + }, nil +} + +// WithTag combines the name from "name" and the tag from "tag" to form a +// reference incorporating both the name and the tag. +func WithTag(name Named, tag string) (NamedTagged, error) { + if !anchoredTagRegexp.MatchString(tag) { + return nil, ErrTagInvalidFormat + } + var repo repository + if r, ok := name.(namedRepository); ok { + repo.domain = r.Domain() + repo.path = r.Path() + } else { + repo.path = name.Name() + } + if canonical, ok := name.(Canonical); ok { + return reference{ + namedRepository: repo, + tag: tag, + digest: canonical.Digest(), + }, nil + } + return taggedReference{ + namedRepository: repo, + tag: tag, + }, nil +} + +// WithDigest combines the name from "name" and the digest from "digest" to form +// a reference incorporating both the name and the digest. +func WithDigest(name Named, digest digest.Digest) (Canonical, error) { + if !anchoredDigestRegexp.MatchString(digest.String()) { + return nil, ErrDigestInvalidFormat + } + var repo repository + if r, ok := name.(namedRepository); ok { + repo.domain = r.Domain() + repo.path = r.Path() + } else { + repo.path = name.Name() + } + if tagged, ok := name.(Tagged); ok { + return reference{ + namedRepository: repo, + tag: tagged.Tag(), + digest: digest, + }, nil + } + return canonicalReference{ + namedRepository: repo, + digest: digest, + }, nil +} + +// TrimNamed removes any tag or digest from the named reference. +func TrimNamed(ref Named) Named { + domain, path := SplitHostname(ref) + return repository{ + domain: domain, + path: path, + } +} + +func getBestReferenceType(ref reference) Reference { + if ref.Name() == "" { + // Allow digest only references + if ref.digest != "" { + return digestReference(ref.digest) + } + return nil + } + if ref.tag == "" { + if ref.digest != "" { + return canonicalReference{ + namedRepository: ref.namedRepository, + digest: ref.digest, + } + } + return ref.namedRepository + } + if ref.digest == "" { + return taggedReference{ + namedRepository: ref.namedRepository, + tag: ref.tag, + } + } + + return ref +} + +type reference struct { + namedRepository + tag string + digest digest.Digest +} + +func (r reference) String() string { + return r.Name() + ":" + r.tag + "@" + r.digest.String() +} + +func (r reference) Tag() string { + return r.tag +} + +func (r reference) Digest() digest.Digest { + return r.digest +} + +type repository struct { + domain string + path string +} + +func (r repository) String() string { + return r.Name() +} + +func (r repository) Name() string { + if r.domain == "" { + return r.path + } + return r.domain + "/" + r.path +} + +func (r repository) Domain() string { + return r.domain +} + +func (r repository) Path() string { + return r.path +} + +type digestReference digest.Digest + +func (d digestReference) String() string { + return digest.Digest(d).String() +} + +func (d digestReference) Digest() digest.Digest { + return digest.Digest(d) +} + +type taggedReference struct { + namedRepository + tag string +} + +func (t taggedReference) String() string { + return t.Name() + ":" + t.tag +} + +func (t taggedReference) Tag() string { + return t.tag +} + +type canonicalReference struct { + namedRepository + digest digest.Digest +} + +func (c canonicalReference) String() string { + return c.Name() + "@" + c.digest.String() +} + +func (c canonicalReference) Digest() digest.Digest { + return c.digest +} diff --git a/vendor/github.com/docker/distribution/reference/regexp.go b/vendor/github.com/docker/distribution/reference/regexp.go new file mode 100644 index 00000000000..78603493203 --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/regexp.go @@ -0,0 +1,143 @@ +package reference + +import "regexp" + +var ( + // alphaNumericRegexp defines the alpha numeric atom, typically a + // component of names. This only allows lower case characters and digits. + alphaNumericRegexp = match(`[a-z0-9]+`) + + // separatorRegexp defines the separators allowed to be embedded in name + // components. This allow one period, one or two underscore and multiple + // dashes. + separatorRegexp = match(`(?:[._]|__|[-]*)`) + + // nameComponentRegexp restricts registry path component names to start + // with at least one letter or number, with following parts able to be + // separated by one period, one or two underscore and multiple dashes. + nameComponentRegexp = expression( + alphaNumericRegexp, + optional(repeated(separatorRegexp, alphaNumericRegexp))) + + // domainComponentRegexp restricts the registry domain component of a + // repository name to start with a component as defined by DomainRegexp + // and followed by an optional port. + domainComponentRegexp = match(`(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])`) + + // DomainRegexp defines the structure of potential domain components + // that may be part of image names. This is purposely a subset of what is + // allowed by DNS to ensure backwards compatibility with Docker image + // names. + DomainRegexp = expression( + domainComponentRegexp, + optional(repeated(literal(`.`), domainComponentRegexp)), + optional(literal(`:`), match(`[0-9]+`))) + + // TagRegexp matches valid tag names. From docker/docker:graph/tags.go. + TagRegexp = match(`[\w][\w.-]{0,127}`) + + // anchoredTagRegexp matches valid tag names, anchored at the start and + // end of the matched string. + anchoredTagRegexp = anchored(TagRegexp) + + // DigestRegexp matches valid digests. + DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`) + + // anchoredDigestRegexp matches valid digests, anchored at the start and + // end of the matched string. + anchoredDigestRegexp = anchored(DigestRegexp) + + // NameRegexp is the format for the name component of references. The + // regexp has capturing groups for the domain and name part omitting + // the separating forward slash from either. + NameRegexp = expression( + optional(DomainRegexp, literal(`/`)), + nameComponentRegexp, + optional(repeated(literal(`/`), nameComponentRegexp))) + + // anchoredNameRegexp is used to parse a name value, capturing the + // domain and trailing components. + anchoredNameRegexp = anchored( + optional(capture(DomainRegexp), literal(`/`)), + capture(nameComponentRegexp, + optional(repeated(literal(`/`), nameComponentRegexp)))) + + // ReferenceRegexp is the full supported format of a reference. The regexp + // is anchored and has capturing groups for name, tag, and digest + // components. + ReferenceRegexp = anchored(capture(NameRegexp), + optional(literal(":"), capture(TagRegexp)), + optional(literal("@"), capture(DigestRegexp))) + + // IdentifierRegexp is the format for string identifier used as a + // content addressable identifier using sha256. These identifiers + // are like digests without the algorithm, since sha256 is used. + IdentifierRegexp = match(`([a-f0-9]{64})`) + + // ShortIdentifierRegexp is the format used to represent a prefix + // of an identifier. A prefix may be used to match a sha256 identifier + // within a list of trusted identifiers. + ShortIdentifierRegexp = match(`([a-f0-9]{6,64})`) + + // anchoredIdentifierRegexp is used to check or match an + // identifier value, anchored at start and end of string. + anchoredIdentifierRegexp = anchored(IdentifierRegexp) + + // anchoredShortIdentifierRegexp is used to check if a value + // is a possible identifier prefix, anchored at start and end + // of string. + anchoredShortIdentifierRegexp = anchored(ShortIdentifierRegexp) +) + +// match compiles the string to a regular expression. +var match = regexp.MustCompile + +// literal compiles s into a literal regular expression, escaping any regexp +// reserved characters. +func literal(s string) *regexp.Regexp { + re := match(regexp.QuoteMeta(s)) + + if _, complete := re.LiteralPrefix(); !complete { + panic("must be a literal") + } + + return re +} + +// expression defines a full expression, where each regular expression must +// follow the previous. +func expression(res ...*regexp.Regexp) *regexp.Regexp { + var s string + for _, re := range res { + s += re.String() + } + + return match(s) +} + +// optional wraps the expression in a non-capturing group and makes the +// production optional. +func optional(res ...*regexp.Regexp) *regexp.Regexp { + return match(group(expression(res...)).String() + `?`) +} + +// repeated wraps the regexp in a non-capturing group to get one or more +// matches. +func repeated(res ...*regexp.Regexp) *regexp.Regexp { + return match(group(expression(res...)).String() + `+`) +} + +// group wraps the regexp in a non-capturing group. +func group(res ...*regexp.Regexp) *regexp.Regexp { + return match(`(?:` + expression(res...).String() + `)`) +} + +// capture wraps the expression in a capturing group. +func capture(res ...*regexp.Regexp) *regexp.Regexp { + return match(`(` + expression(res...).String() + `)`) +} + +// anchored anchors the regular expression by adding start and end delimiters. +func anchored(res ...*regexp.Regexp) *regexp.Regexp { + return match(`^` + expression(res...).String() + `$`) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1c716e9c1b8..dfcaa933c76 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -386,6 +386,10 @@ github.com/distribution/reference # github.com/docker/cli v24.0.6+incompatible ## explicit github.com/docker/cli/cli/config/types +# github.com/docker/distribution v2.8.2+incompatible +## explicit +github.com/docker/distribution/digestset +github.com/docker/distribution/reference # github.com/emicklei/go-restful/v3 v3.11.0 ## explicit; go 1.13 github.com/emicklei/go-restful/v3 From a7202006047f0913b8831283a303384bbb1be6ee Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 7 Oct 2024 14:15:02 +0530 Subject: [PATCH 19/65] fix for chart version --- pkg/generateManifest/DeploymentTemplateService.go | 2 +- pkg/pipeline/PropertiesConfig.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 0bb0d6275bd..2b98cd4c63a 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -335,7 +335,7 @@ func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs( impl.Logger.Errorw("error in getting overridden values", "err", err) return nil, err } - _, _, version, _, err := impl.chartRefService.GetRefChart(request.ChartRefId) + _, _, version, _, err := impl.chartRefService.GetRefChart(override.EnvironmentConfig.ChartRefId) if err != nil { impl.Logger.Errorw("error in getting chart ref by chartRefId ", "chartRefId", request.ChartRefId, "err", err) return nil, err diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 26c387897ef..ad4e2806d67 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -129,6 +129,9 @@ func (impl PropertiesConfigServiceImpl) GetEnvironmentProperties(appId, environm IsBasicViewLocked: envOverride.IsBasicViewLocked, CurrentViewEditor: envOverride.CurrentViewEditor, } + if chartRefId == 0 && envOverride.Chart != nil { + environmentProperties.ChartRefId = envOverride.Chart.ChartRefId + } if environmentPropertiesResponse.Namespace == "" { environmentPropertiesResponse.Namespace = envOverride.Namespace @@ -140,8 +143,10 @@ func (impl PropertiesConfigServiceImpl) GetEnvironmentProperties(appId, environm } if errors.IsNotFound(err) { environmentProperties.Id = 0 - environmentProperties.ChartRefId = chartRefId environmentProperties.IsOverride = false + if chartRefId > 0 { + environmentProperties.ChartRefId = chartRefId + } } else { environmentProperties.Id = ecOverride.Id environmentProperties.Latest = ecOverride.Latest @@ -153,6 +158,9 @@ func (impl PropertiesConfigServiceImpl) GetEnvironmentProperties(appId, environm environmentProperties.Active = ecOverride.Active environmentProperties.IsBasicViewLocked = ecOverride.IsBasicViewLocked environmentProperties.CurrentViewEditor = ecOverride.CurrentViewEditor + if chartRefId == 0 && ecOverride.Chart != nil { + environmentProperties.ChartRefId = ecOverride.Chart.ChartRefId + } } environmentPropertiesResponse.ChartRefId = chartRefId environmentPropertiesResponse.EnvironmentConfig = *environmentProperties From 596b86beb5022a93bde14a6d26e3724ecb5a4e77 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 7 Oct 2024 19:40:14 +0530 Subject: [PATCH 20/65] remove getResolvedConfigDataForValues --- .../DeploymentConfigurationRestHandler.go | 15 ------------- api/router/DeploymentConfigRouter.go | 2 +- .../DeploymentConfigurationService.go | 22 ------------------- pkg/configDiff/bean/bean.go | 1 - 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 13926f7fbd6..2e29d68cb69 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -2,7 +2,6 @@ package restHandler import ( "context" - "encoding/json" "fmt" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" @@ -91,20 +90,6 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - switch r.Method { - case http.MethodPost: - if r.ContentLength > 0 { - valuesPayload := &bean.ValuesDto{} - decoder := json.NewDecoder(r.Body) - err = decoder.Decode(valuesPayload) - if err != nil { - handler.logger.Errorw("error in decoding the request payload", "err", err, "requestBody", r.Body) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - configDataQueryParams.Values = valuesPayload.Values - } - } configDataQueryParams.UserId = userId //RBAC START diff --git a/api/router/DeploymentConfigRouter.go b/api/router/DeploymentConfigRouter.go index b442c134244..a8a568d6046 100644 --- a/api/router/DeploymentConfigRouter.go +++ b/api/router/DeploymentConfigRouter.go @@ -26,6 +26,6 @@ func (router DeploymentConfigurationRouterImpl) initDeploymentConfigurationRoute Methods("GET") configRouter.Path("/data"). HandlerFunc(router.deploymentGroupRestHandler.GetConfigData). - Methods("GET", "POST") + Methods("GET") } diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 58b7155a5d4..1ba6d6e7c54 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -142,33 +142,11 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con return impl.getConfigDataForCdRollback(ctx, configDataQueryParams, userHasAdminAccess) case bean2.DeploymentHistory.ToString(): return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) - case bean2.ResolveData.ToString(): - // this only supports resolution of deployment template data as of now - return impl.getResolvedConfigDataForValues(ctx, configDataQueryParams.Values, appId, envId) } // this would be the default case return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) } -func (impl *DeploymentConfigurationServiceImpl) getResolvedConfigDataForValues(ctx context.Context, values string, appId, envId int) (*bean2.DeploymentAndCmCsConfigDto, error) { - configDataDto := &bean2.DeploymentAndCmCsConfigDto{} - var err error - deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ - AppId: appId, - RequestDataMode: generateManifest.Values, - } - if envId > 0 { - deploymentTemplateRequest.EnvId = envId - } - resolvedTemplate, _, err := impl.deploymentTemplateService.ResolveTemplateVariables(ctx, values, deploymentTemplateRequest) - if err != nil { - impl.logger.Errorw("error in getting resolved data for cm draft data ", "appId", appId, "err", err) - return nil, err - } - - return configDataDto.WithDeploymentTemplateData(bean2.NewDeploymentAndCmCsConfig().WithResolvedValue(json.RawMessage(resolvedTemplate))), nil -} - func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { // wfrId is expected in this case to return the expected data return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 1ccf3039509..94bc3ff7a40 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -175,7 +175,6 @@ type ConfigDataQueryParams struct { UserId int32 `schema:"-"` WfrId int `schema:"wfrId"` ConfigArea string `schema:"configArea"` - Values string `schema:"values"` } // FilterCriteria []string `schema:"filterCriteria"` From 9b7b568783ded402f171d0bef17efc3d4289d915 Mon Sep 17 00:00:00 2001 From: ayu-devtron <167413063+ayu-devtron@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:01:17 +0530 Subject: [PATCH 21/65] initialise acd client (#5965) --- pkg/argoApplication/ArgoApplicationServiceExtended.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/argoApplication/ArgoApplicationServiceExtended.go b/pkg/argoApplication/ArgoApplicationServiceExtended.go index 348fccd040f..bb4bdbaf5b3 100644 --- a/pkg/argoApplication/ArgoApplicationServiceExtended.go +++ b/pkg/argoApplication/ArgoApplicationServiceExtended.go @@ -35,7 +35,7 @@ func NewArgoApplicationServiceExtendedServiceImpl(logger *zap.SugaredLogger, argoUserService argo.ArgoUserService, helmAppClient gRPC.HelmAppClient, helmAppService service.HelmAppService, k8sApplicationService application.K8sApplicationService, - readService read.ArgoApplicationReadService) *ArgoApplicationServiceExtendedImpl { + readService read.ArgoApplicationReadService, acdClient application3.ServiceClient) *ArgoApplicationServiceExtendedImpl { return &ArgoApplicationServiceExtendedImpl{ ArgoApplicationServiceImpl: &ArgoApplicationServiceImpl{ logger: logger, @@ -47,6 +47,7 @@ func NewArgoApplicationServiceExtendedServiceImpl(logger *zap.SugaredLogger, k8sApplicationService: k8sApplicationService, readService: readService, }, + acdClient: acdClient, } } From fba905e92537c0c7b7ac2ec05a7758d61786d761 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 8 Oct 2024 13:05:01 +0530 Subject: [PATCH 22/65] handle nil pipeline strategy in case of custom chart --- .../DeploymentConfigurationRestHandler.go | 4 ++-- pkg/configDiff/DeploymentConfigurationService.go | 13 +++++++++---- pkg/generateManifest/DeploymentTemplateService.go | 7 ++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 2e29d68cb69..e19dcb91ed2 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -103,9 +103,9 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp //RBAC END isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*") userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object) - ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) + ctx, _ := context.WithTimeout(r.Context(), 60*time.Second) ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin) - defer cancel() + res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess) if err != nil { handler.logger.Errorw("service err, GetAllConfigData ", "err", err) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 1ba6d6e7c54..70c11dfdd6f 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -27,6 +27,7 @@ import ( repository6 "github.com/devtron-labs/devtron/pkg/variables/repository" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" + "github.com/juju/errors" "go.uber.org/zap" "net/http" ) @@ -190,18 +191,20 @@ func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx c func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyConfigHistory(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfig, error) { pipelineStrategyJson := json.RawMessage{} + pipelineConfig := bean2.NewDeploymentAndCmCsConfig() pipelineStrategyHistory, err := impl.pipelineStrategyHistoryRepository.GetHistoryByPipelineIdAndWfrId(ctx, configDataQueryParams.PipelineId, configDataQueryParams.WfrId) - if err != nil { + if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("error in checking if history exists for pipelineId and wfrId", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err + } else if util.IsErrNoRows(err) { + return pipelineConfig, nil } err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategyHistory.Config)) if err != nil { impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "pipelineStrategyHistoryConfig", pipelineStrategyHistory.Config, "err", err) return nil, err } - pipelineConfig := bean2.NewDeploymentAndCmCsConfig(). - WithConfigData(pipelineStrategyJson). + pipelineConfig.WithConfigData(pipelineStrategyJson). WithResourceType(bean.PipelineStrategy). WithPipelineStrategyMetadata(pipelineStrategyHistory.PipelineTriggerType, string(pipelineStrategyHistory.Strategy)) return pipelineConfig, nil @@ -640,9 +643,11 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConf return nil, err } pipelineStrategy, err := impl.deploymentConfigService.GetLatestPipelineStrategyConfig(pipeline) - if err != nil { + if err != nil && !errors.IsNotFound(err) { impl.logger.Errorw("error in GetLatestPipelineStrategyConfig", "pipelineId", pipeline.Id, "err", err) return nil, err + } else if errors.IsNotFound(err) { + return pipelineConfig, nil } err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategy.CodeEditorValue.Value)) if err != nil { diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 2b98cd4c63a..037f6dd7740 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -335,7 +335,12 @@ func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs( impl.Logger.Errorw("error in getting overridden values", "err", err) return nil, err } - _, _, version, _, err := impl.chartRefService.GetRefChart(override.EnvironmentConfig.ChartRefId) + // handle here for chart ref id in case + chartRefId := override.EnvironmentConfig.ChartRefId + if chartRefId == 0 { + chartRefId = override.GlobalChartRefId + } + _, _, version, _, err := impl.chartRefService.GetRefChart(chartRefId) if err != nil { impl.Logger.Errorw("error in getting chart ref by chartRefId ", "chartRefId", request.ChartRefId, "err", err) return nil, err From ae9c3aa74e4bcdcd2e9ad9172d4035bda64951ea Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 8 Oct 2024 13:47:41 +0530 Subject: [PATCH 23/65] revert defer cancel --- api/restHandler/DeploymentConfigurationRestHandler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index e19dcb91ed2..2e29d68cb69 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -103,9 +103,9 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp //RBAC END isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*") userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object) - ctx, _ := context.WithTimeout(r.Context(), 60*time.Second) + ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin) - + defer cancel() res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess) if err != nil { handler.logger.Errorw("service err, GetAllConfigData ", "err", err) From f575c999b77535aca40a06a8448d7bab97a5d130 Mon Sep 17 00:00:00 2001 From: Rajeev Date: Tue, 8 Oct 2024 17:06:46 +0530 Subject: [PATCH 24/65] removed the field cia --- internal/sql/repository/AppListingRepository.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 85ffb4cb5e1..071948bca48 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -363,7 +363,6 @@ func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx contex " env.cluster_id," + " env.is_virtual_environment," + " cl.cluster_name," + - " cia.image," + " p.id as cd_pipeline_id," + " p.ci_pipeline_id," + " p.trigger_type" + From a83f5ccbd9c18a9b9b3a74bc140b2e943bbdc270 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 8 Oct 2024 17:34:06 +0530 Subject: [PATCH 25/65] code review :- 1 --- api/restHandler/DeploymentConfigurationRestHandler.go | 2 +- pkg/configDiff/DeploymentConfigurationService.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/restHandler/DeploymentConfigurationRestHandler.go b/api/restHandler/DeploymentConfigurationRestHandler.go index 2e29d68cb69..7a9f4676290 100644 --- a/api/restHandler/DeploymentConfigurationRestHandler.go +++ b/api/restHandler/DeploymentConfigurationRestHandler.go @@ -104,8 +104,8 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*") userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object) ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) - ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin) defer cancel() + ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin) res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess) if err != nil { handler.logger.Errorw("service err, GetAllConfigData ", "err", err) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 70c11dfdd6f..3c1fe04cf4f 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -263,7 +263,8 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context var configData []*bean.ConfigData configList := pipeline.ConfigsList{} secretList := bean.SecretsList{} - if configType == repository3.CONFIGMAP_TYPE { + switch configType { + case repository3.CONFIGMAP_TYPE: if len(history.Data) > 0 { err = json.Unmarshal([]byte(history.Data), &configList) if err != nil { @@ -273,7 +274,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context } resourceType = bean.CM configData = configList.ConfigData - } else if configType == repository3.SECRET_TYPE { + case repository3.SECRET_TYPE: if len(history.Data) > 0 { err = json.Unmarshal([]byte(history.Data), &secretList) if err != nil { @@ -283,6 +284,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context } resourceType = bean.CS configData = secretList.ConfigData + } resolvedDataMap, variableSnapshotMap, err := impl.scopedVariableManager.GetResolvedCMCSHistoryDtos(ctx, configType, adaptor.ReverseConfigListConvertor(configList), history, adaptor.ReverseSecretListConvertor(secretList)) @@ -632,7 +634,6 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte } func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConfig(ctx context.Context, appId int, envId int) (*bean2.DeploymentAndCmCsConfig, error) { - pipelineStrategyJson := json.RawMessage{} pipelineConfig := bean2.NewDeploymentAndCmCsConfig() if envId == 0 { return pipelineConfig, nil @@ -649,6 +650,7 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConf } else if errors.IsNotFound(err) { return pipelineConfig, nil } + pipelineStrategyJson := json.RawMessage{} err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategy.CodeEditorValue.Value)) if err != nil { impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "err", err) From 228e8e88bfad8d9dd774b5da0e2e49ac2259fc5f Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 9 Oct 2024 12:56:11 +0530 Subject: [PATCH 26/65] remove pipelineStrategy --- pkg/configDiff/DeploymentConfigurationService.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 3c1fe04cf4f..fadeeb0e23e 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -229,7 +229,10 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForDeploymentHistor impl.logger.Errorw("getConfigDataForDeploymentHistory, error in getPipelineStrategyConfigHistory", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - configDataDto.WithPipelineConfigData(pipelineConfig) + if len(pipelineConfig.Data) > 0 { + configDataDto.WithPipelineConfigData(pipelineConfig) + } + // fetching for pipeline strategy config ends // fetching for cm config starts @@ -629,7 +632,9 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte impl.logger.Errorw("getPublishedConfigData, error in getting publishedOnly pipeline strategy ", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } - configData.WithPipelineConfigData(pipelineConfigData) + if len(pipelineConfigData.Data) > 0 { + configData.WithPipelineConfigData(pipelineConfigData) + } return configData, nil } From 57eb6b6300b154eb62197e80f1dcc59dc18c0612 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 10 Oct 2024 13:12:27 +0530 Subject: [PATCH 27/65] wire fix --- wire_gen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wire_gen.go b/wire_gen.go index 436aac5874b..0bee1a76cdc 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -439,7 +439,7 @@ func InitializeApp() (*App, error) { ciWorkflowRepositoryImpl := pipelineConfig.NewCiWorkflowRepositoryImpl(db, sugaredLogger) ciPipelineMaterialRepositoryImpl := pipelineConfig.NewCiPipelineMaterialRepositoryImpl(db, sugaredLogger) ciArtifactRepositoryImpl := repository2.NewCiArtifactRepositoryImpl(db, sugaredLogger) - eventSimpleFactoryImpl := client2.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, ciArtifactRepositoryImpl) + eventSimpleFactoryImpl := client2.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, environmentRepositoryImpl, ciArtifactRepositoryImpl) applicationServiceClientImpl := application.NewApplicationClientImpl(sugaredLogger, argoCDConnectionManagerImpl) configMapRepositoryImpl := chartConfig.NewConfigMapRepositoryImpl(sugaredLogger, db) chartRepositoryImpl := chartRepoRepository.NewChartRepository(db, transactionUtilImpl) @@ -722,7 +722,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationReadServiceImpl) + argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationReadServiceImpl, applicationServiceClientImpl) installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, k8sServiceImpl, deploymentConfigServiceImpl, ociRegistryConfigRepositoryImpl, argoApplicationServiceExtendedImpl) chartGroupEntriesRepositoryImpl := repository17.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository17.NewChartGroupReposotoryImpl(db, sugaredLogger) From 7f8b3d0e21709401eef344de9b88584158fbe60f Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 10 Oct 2024 15:25:36 +0530 Subject: [PATCH 28/65] add wfr_id in template/list api --- internal/sql/repository/DeploymentTemplateRepository.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/sql/repository/DeploymentTemplateRepository.go b/internal/sql/repository/DeploymentTemplateRepository.go index 00116eb20b4..053e7c8395e 100644 --- a/internal/sql/repository/DeploymentTemplateRepository.go +++ b/internal/sql/repository/DeploymentTemplateRepository.go @@ -38,6 +38,7 @@ type DeploymentTemplateComparisonMetadata struct { EnvironmentId int `json:"environmentId,omitempty"` EnvironmentName string `json:"environmentName,omitempty"` DeploymentTemplateHistoryId int `json:"deploymentTemplateHistoryId,omitempty"` + WfrId int `json:"wfrId,omitempty"` StartedOn *time.Time `json:"startedOn,omitempty"` FinishedOn *time.Time `json:"finishedOn,omitempty"` Status string `json:"status,omitempty"` @@ -69,7 +70,7 @@ func (impl DeploymentTemplateRepositoryImpl) FetchDeploymentHistoryWithChartRefs limit := 15 query := "select p.id as pipeline_id, dth.id as deployment_template_history_id," + - " wfr.finished_on, wfr.status, c.chart_ref_id, c.chart_version FROM cd_workflow_runner wfr" + + " wfr.id as wfr_id, wfr.finished_on, wfr.status, c.chart_ref_id, c.chart_version FROM cd_workflow_runner wfr" + " JOIN cd_workflow wf ON wf.id = wfr.cd_workflow_id JOIN pipeline p ON p.id = wf.pipeline_id" + " JOIN deployment_template_history dth ON dth.deployed_on = wfr.started_on " + "JOIN pipeline_config_override pco ON pco.cd_workflow_id = wf.id " + From c632f2de6d133c597af47beb4ef7f03ba89a99ba Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 10 Oct 2024 18:05:57 +0530 Subject: [PATCH 29/65] handle forceabort case:- terminate workflow in this case and then mark force aborted in ci_workflow table --- pkg/pipeline/CiHandler.go | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 65237aa2e20..a8d8d912acc 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -592,20 +592,9 @@ func (impl *CiHandlerImpl) GetBuildHistory(pipelineId int, appId int, offset int func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, error) { workflow, err := impl.ciWorkflowRepository.FindById(workflowId) if err != nil { - impl.Logger.Errorw("err", "err", err) + impl.Logger.Errorw("error in finding ci-workflow by workflow id", "ciWorkflowId", workflowId, "err", err) return 0, err } - if !(string(v1alpha1.NodePending) == workflow.Status || string(v1alpha1.NodeRunning) == workflow.Status) { - if forceAbort { - return impl.cancelBuildAfterStartWorkflowStage(workflow) - } else { - return 0, &util.ApiError{Code: "200", HttpStatusCode: 400, UserMessage: "cannot cancel build, build not in progress"} - } - } - //this arises when someone deletes the workflow in resource browser and wants to force abort a ci - if workflow.Status == string(v1alpha1.NodeRunning) && forceAbort { - return impl.cancelBuildAfterStartWorkflowStage(workflow) - } isExt := workflow.Namespace != DefaultCiWorkflowNamespace var env *repository3.Environment var restConfig *rest.Config @@ -618,12 +607,20 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er // Terminate workflow err = impl.workflowService.TerminateWorkflow(workflow.ExecutorType, workflow.Name, workflow.Namespace, restConfig, isExt, env) - if err != nil && strings.Contains(err.Error(), "cannot find workflow") { + if err != nil && forceAbort { + impl.Logger.Errorw("error in terminating workflow, with force abort flag flag as true", "workflowName", workflow.Name, "err", err) + //ignoring error in case of force abort later updating workflow with force abort + } else if err != nil && strings.Contains(err.Error(), "cannot find workflow") { return 0, &util.ApiError{Code: "200", HttpStatusCode: http.StatusBadRequest, UserMessage: err.Error()} } else if err != nil { impl.Logger.Errorw("cannot terminate wf", "err", err) return 0, err } + err = impl.handleForceAbortCase(workflow, forceAbort) + if err != nil { + impl.Logger.Errorw("error in handleForceAbortCase", "forceAbortFlag", forceAbort, "workflow", workflow, "err", err) + return 0, err + } workflow.Status = executors.WorkflowCancel if workflow.ExecutorType == cdWorkflow.WORKFLOW_EXECUTOR_TYPE_SYSTEM { @@ -652,16 +649,32 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er return workflow.Id, nil } -func (impl *CiHandlerImpl) cancelBuildAfterStartWorkflowStage(workflow *pipelineConfig.CiWorkflow) (int, error) { +func (impl *CiHandlerImpl) handleForceAbortCase(workflow *pipelineConfig.CiWorkflow, forceAbort bool) error { + isWorkflowInNonTerminalStage := workflow.Status == string(v1alpha1.NodePending) || workflow.Status == string(v1alpha1.NodeRunning) + if !isWorkflowInNonTerminalStage { + if forceAbort { + return impl.updateWorkflowForForceAbort(workflow) + } else { + return &util.ApiError{Code: "200", HttpStatusCode: 400, UserMessage: "cannot cancel build, build not in progress"} + } + } + //this arises when someone deletes the workflow in resource browser and wants to force abort a ci + if workflow.Status == string(v1alpha1.NodeRunning) && forceAbort { + return impl.updateWorkflowForForceAbort(workflow) + } + return nil +} + +func (impl *CiHandlerImpl) updateWorkflowForForceAbort(workflow *pipelineConfig.CiWorkflow) error { workflow.Status = executors.WorkflowCancel workflow.PodStatus = string(bean.Failed) workflow.Message = ABORT_MESSAGE_AFTER_STARTING_STAGE err := impl.ciWorkflowRepository.UpdateWorkFlow(workflow) if err != nil { impl.Logger.Errorw("error in updating workflow status", "err", err) - return 0, err + return err } - return workflow.Id, nil + return nil } func (impl *CiHandlerImpl) getRestConfig(workflow *pipelineConfig.CiWorkflow) (*rest.Config, error) { From c56c4c9d3b90174e08b83aadb52548fc599895b7 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 10 Oct 2024 19:21:42 +0530 Subject: [PATCH 30/65] code review changes --- .../DeploymentTemplateService.go | 2 +- pkg/pipeline/adapter/adapter.go | 83 ++++++++++--------- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 037f6dd7740..1a56931c711 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -347,7 +347,7 @@ func (impl DeploymentTemplateServiceImpl) fetchResolvedTemplateForPublishedEnvs( } resolvedTemplate, variableSnapshot, err := impl.resolveTemplateVariables(ctx, values, request) if err != nil { - impl.Logger.Errorw("error in resolving template variables for env override ", "values", values, "err", err) + impl.Logger.Errorw("error in resolving template variables for env override ", "deploymentTemplateRequest", request, "err", err) return nil, err } return &DeploymentTemplateResponse{ diff --git a/pkg/pipeline/adapter/adapter.go b/pkg/pipeline/adapter/adapter.go index feb6991b8c0..e587a119bc4 100644 --- a/pkg/pipeline/adapter/adapter.go +++ b/pkg/pipeline/adapter/adapter.go @@ -228,26 +228,29 @@ func GetSourceCiDownStreamResponse(linkedCIDetails []ciPipeline.LinkedCIDetails, } func ConvertConfigDataToPipelineConfigData(r *bean.ConfigData) *pipelineConfigBean.ConfigData { - return &pipelineConfigBean.ConfigData{ - Name: r.Name, - Type: r.Type, - External: r.External, - MountPath: r.MountPath, - Data: r.Data, - DefaultData: r.DefaultData, - DefaultMountPath: r.DefaultMountPath, - Global: r.Global, - ExternalSecretType: r.ExternalSecretType, - ESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.ESOSecretData), - DefaultESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.DefaultESOSecretData), - ExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.ExternalSecret), - DefaultExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.DefaultExternalSecret), - RoleARN: r.RoleARN, - SubPath: r.SubPath, - ESOSubPath: r.ESOSubPath, - FilePermission: r.FilePermission, - Overridden: r.Overridden, + if r != nil { + return &pipelineConfigBean.ConfigData{ + Name: r.Name, + Type: r.Type, + External: r.External, + MountPath: r.MountPath, + Data: r.Data, + DefaultData: r.DefaultData, + DefaultMountPath: r.DefaultMountPath, + Global: r.Global, + ExternalSecretType: r.ExternalSecretType, + ESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.ESOSecretData), + DefaultESOSecretData: ConvertESOSecretDataToPipelineESOSecretData(r.DefaultESOSecretData), + ExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.ExternalSecret), + DefaultExternalSecret: ConvertExternalSecretToPipelineExternalSecret(r.DefaultExternalSecret), + RoleARN: r.RoleARN, + SubPath: r.SubPath, + ESOSubPath: r.ESOSubPath, + FilePermission: r.FilePermission, + Overridden: r.Overridden, + } } + return &pipelineConfigBean.ConfigData{} } func ConvertESOSecretDataToPipelineESOSecretData(r bean.ESOSecretData) pipelineConfigBean.ESOSecretData { @@ -289,26 +292,30 @@ func ConvertEsoDataToPipelineEsoData(r []bean.ESOData) []pipelineConfigBean.ESOD // reverse adapter for the above adapters func ConvertPipelineConfigDataToConfigData(r *pipelineConfigBean.ConfigData) *bean.ConfigData { - return &bean.ConfigData{ - Name: r.Name, - Type: r.Type, - External: r.External, - MountPath: r.MountPath, - Data: r.Data, - DefaultData: r.DefaultData, - DefaultMountPath: r.DefaultMountPath, - Global: r.Global, - ExternalSecretType: r.ExternalSecretType, - ESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.ESOSecretData), - DefaultESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.DefaultESOSecretData), - ExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.ExternalSecret), - DefaultExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.DefaultExternalSecret), - RoleARN: r.RoleARN, - SubPath: r.SubPath, - ESOSubPath: r.ESOSubPath, - FilePermission: r.FilePermission, - Overridden: r.Overridden, + if r != nil { + return &bean.ConfigData{ + Name: r.Name, + Type: r.Type, + External: r.External, + MountPath: r.MountPath, + Data: r.Data, + DefaultData: r.DefaultData, + DefaultMountPath: r.DefaultMountPath, + Global: r.Global, + ExternalSecretType: r.ExternalSecretType, + ESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.ESOSecretData), + DefaultESOSecretData: ConvertPipelineESOSecretDataToESOSecretData(r.DefaultESOSecretData), + ExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.ExternalSecret), + DefaultExternalSecret: ConvertPipelineExternalSecretToExternalSecret(r.DefaultExternalSecret), + RoleARN: r.RoleARN, + SubPath: r.SubPath, + ESOSubPath: r.ESOSubPath, + FilePermission: r.FilePermission, + Overridden: r.Overridden, + } } + return &bean.ConfigData{} + } func ConvertPipelineESOSecretDataToESOSecretData(r pipelineConfigBean.ESOSecretData) bean.ESOSecretData { From 9ab04731f9e521d755bdcae12c1830e9c4b6f331 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:33:53 +0530 Subject: [PATCH 31/65] chore: Main sync develop (#5983) * initialise acd client (#5964) * auth group fix (#5966) * query params append fix (#5967) * bluk edit cm and secret fix (#5968) * removed the field cia (#5969) * query fix (#5971) * rollback fix (#5972) * fix: copy container image version * fix: cluster and env prod/non prod not propagated in notification event payload * common-lib update * error handling while creating github repo (#5978) --------- Co-authored-by: ayu-devtron <167413063+ayu-devtron@users.noreply.github.com> Co-authored-by: Shivam Nagar <124123645+Shivam-nagar23@users.noreply.github.com> Co-authored-by: Prakash Co-authored-by: Rajeev Ranjan <90333766+RajeevRanjan27@users.noreply.github.com> Co-authored-by: Ash-exp Co-authored-by: Gireesh Naidu Co-authored-by: Gireesh Naidu <111440205+gireesh-naidu@users.noreply.github.com> Co-authored-by: prakhar katiyar <39842461+prkhrkat@users.noreply.github.com> --- api/auth/user/UserRestHandler.go | 56 ++++++++++--------- api/auth/user/util/util.go | 16 ++++++ client/events/EventBuilder.go | 18 ++++-- client/events/EventClient.go | 2 + go.mod | 2 +- go.sum | 4 +- .../AppListingRepositoryQueryBuilder.go | 5 +- pkg/app/AppService.go | 4 +- pkg/app/DeploymentEventHandler.go | 2 +- pkg/auth/user/RoleGroupService.go | 5 +- pkg/auth/user/UserService.go | 8 ++- pkg/auth/user/helper/helper.go | 4 ++ pkg/bulkAction/BulkUpdateService.go | 13 +++-- pkg/deployment/gitOps/git/GitServiceGithub.go | 9 ++- .../manifest/ManifestCreationService.go | 18 +++--- .../devtronApps/PostStageTriggerService.go | 2 +- .../devtronApps/PreStageTriggerService.go | 2 +- .../trigger/devtronApps/TriggerService.go | 2 +- .../in/WorkflowEventProcessorService.go | 2 +- pkg/pipeline/CiHandler.go | 2 +- pkg/pipeline/CiService.go | 2 +- pkg/pipeline/pipelineStageVariableParser.go | 4 +- pkg/workflow/dag/WorkflowDagExecutor.go | 4 +- util/SQLUtil.go | 8 +++ 24 files changed, 124 insertions(+), 70 deletions(-) diff --git a/api/auth/user/UserRestHandler.go b/api/auth/user/UserRestHandler.go index 107c3c42c81..fda5f0f23be 100644 --- a/api/auth/user/UserRestHandler.go +++ b/api/auth/user/UserRestHandler.go @@ -1190,7 +1190,7 @@ func (handler UserRestHandlerImpl) checkRBACForUserCreate(token string, requestS } func (handler UserRestHandlerImpl) checkRBACForUserUpdate(token string, userInfo *bean.UserInfo, isUserAlreadySuperAdmin bool, eliminatedRoleFilters, - eliminatedGroupRoles []*repository.RoleModel) (isAuthorised bool, err error) { + eliminatedGroupRoles []*repository.RoleModel, mapOfExistingUserRoleGroup map[string]bool) (isAuthorised bool, err error) { isActionUserSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*") requestSuperAdmin := userInfo.SuperAdmin if (requestSuperAdmin || isUserAlreadySuperAdmin) && !isActionUserSuperAdmin { @@ -1241,33 +1241,37 @@ func (handler UserRestHandlerImpl) checkRBACForUserUpdate(token string, userInfo } } if len(roleGroups) > 0 { // auth check inside groups - groupRoles, err := handler.roleGroupService.FetchRolesForUserRoleGroups(roleGroups) - if err != nil && err != pg.ErrNoRows { - handler.logger.Errorw("service err, UpdateUser", "err", err, "payload", roleGroups) - return false, err - } - if len(groupRoles) > 0 { - for _, groupRole := range groupRoles { - switch { - case groupRole.Action == bean.ACTION_SUPERADMIN: - isAuthorised = isActionUserSuperAdmin - case groupRole.AccessType == bean.APP_ACCESS_TYPE_HELM || groupRole.Entity == bean2.EntityJobs: - isAuthorised = isActionUserSuperAdmin - case len(groupRole.Team) > 0: - isAuthorised = handler.enforcer.Enforce(token, casbin.ResourceUser, casbin.ActionCreate, groupRole.Team) - case groupRole.Entity == bean.CLUSTER_ENTITIY: - isAuthorised = handler.userCommonService.CheckRbacForClusterEntity(groupRole.Cluster, groupRole.Namespace, groupRole.Group, groupRole.Kind, groupRole.Resource, token, handler.CheckManagerAuth) - case groupRole.Entity == bean.CHART_GROUP_ENTITY: - isAuthorised = true - default: - isAuthorised = false - } - if !isAuthorised { - return false, nil + //filter out roleGroups (existing has to be ignore while checking rbac) + filteredRoleGroups := util2.FilterRoleGroupIfAlreadyPresent(roleGroups, mapOfExistingUserRoleGroup) + if len(filteredRoleGroups) > 0 { + groupRoles, err := handler.roleGroupService.FetchRolesForUserRoleGroups(roleGroups) + if err != nil && err != pg.ErrNoRows { + handler.logger.Errorw("service err, UpdateUser", "err", err, "filteredRoleGroups", filteredRoleGroups) + return false, err + } + if len(groupRoles) > 0 { + for _, groupRole := range groupRoles { + switch { + case groupRole.Action == bean.ACTION_SUPERADMIN: + isAuthorised = isActionUserSuperAdmin + case groupRole.AccessType == bean.APP_ACCESS_TYPE_HELM || groupRole.Entity == bean2.EntityJobs: + isAuthorised = isActionUserSuperAdmin + case len(groupRole.Team) > 0: + isAuthorised = handler.enforcer.Enforce(token, casbin.ResourceUser, casbin.ActionCreate, groupRole.Team) + case groupRole.Entity == bean.CLUSTER_ENTITIY: + isAuthorised = handler.userCommonService.CheckRbacForClusterEntity(groupRole.Cluster, groupRole.Namespace, groupRole.Group, groupRole.Kind, groupRole.Resource, token, handler.CheckManagerAuth) + case groupRole.Entity == bean.CHART_GROUP_ENTITY: + isAuthorised = true + default: + isAuthorised = false + } + if !isAuthorised { + return false, nil + } } + } else { + isAuthorised = false } - } else { - isAuthorised = false } } } diff --git a/api/auth/user/util/util.go b/api/auth/user/util/util.go index b71035132e8..d4fbad25c82 100644 --- a/api/auth/user/util/util.go +++ b/api/auth/user/util/util.go @@ -16,9 +16,25 @@ package util +import ( + "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/pkg/auth/user/helper" +) + func IsGroupsPresent(groups []string) bool { if len(groups) > 0 { return true } return false } + +func FilterRoleGroupIfAlreadyPresent(roleGroups []bean.UserRoleGroup, mapOfExistingUserRoleGroup map[string]bool) []bean.UserRoleGroup { + finalRoleGroups := make([]bean.UserRoleGroup, 0, len(roleGroups)) + for _, roleGrp := range roleGroups { + if _, ok := mapOfExistingUserRoleGroup[helper.GetCasbinNameFromRoleGroupName(roleGrp.RoleGroup.Name)]; !ok { + finalRoleGroups = append(finalRoleGroups, roleGrp) + } + } + return finalRoleGroups + +} diff --git a/client/events/EventBuilder.go b/client/events/EventBuilder.go index 48318b8091e..8f1ae9183f3 100644 --- a/client/events/EventBuilder.go +++ b/client/events/EventBuilder.go @@ -19,6 +19,7 @@ package client import ( "context" "fmt" + repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository" "strings" "time" @@ -35,7 +36,7 @@ import ( ) type EventFactory interface { - Build(eventType util.EventType, sourceId *int, appId int, envId *int, pipelineType util.PipelineType) Event + Build(eventType util.EventType, sourceId *int, appId int, envId *int, pipelineType util.PipelineType) (Event, error) BuildExtraCDData(event Event, wfr *pipelineConfig.CdWorkflowRunner, pipelineOverrideId int, stage bean2.WorkflowType) Event BuildExtraCIData(event Event, material *MaterialTriggerInfo) Event //BuildFinalData(event Event) *Payload @@ -50,6 +51,7 @@ type EventSimpleFactoryImpl struct { ciPipelineRepository pipelineConfig.CiPipelineRepository pipelineRepository pipelineConfig.PipelineRepository userRepository repository.UserRepository + envRepository repository4.EnvironmentRepository ciArtifactRepository repository2.CiArtifactRepository } @@ -57,7 +59,7 @@ func NewEventSimpleFactoryImpl(logger *zap.SugaredLogger, cdWorkflowRepository p pipelineOverrideRepository chartConfig.PipelineOverrideRepository, ciWorkflowRepository pipelineConfig.CiWorkflowRepository, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, pipelineRepository pipelineConfig.PipelineRepository, - userRepository repository.UserRepository, ciArtifactRepository repository2.CiArtifactRepository) *EventSimpleFactoryImpl { + userRepository repository.UserRepository, envRepository repository4.EnvironmentRepository, ciArtifactRepository repository2.CiArtifactRepository) *EventSimpleFactoryImpl { return &EventSimpleFactoryImpl{ logger: logger, cdWorkflowRepository: cdWorkflowRepository, @@ -68,10 +70,11 @@ func NewEventSimpleFactoryImpl(logger *zap.SugaredLogger, cdWorkflowRepository p pipelineRepository: pipelineRepository, userRepository: userRepository, ciArtifactRepository: ciArtifactRepository, + envRepository: envRepository, } } -func (impl *EventSimpleFactoryImpl) Build(eventType util.EventType, sourceId *int, appId int, envId *int, pipelineType util.PipelineType) Event { +func (impl *EventSimpleFactoryImpl) Build(eventType util.EventType, sourceId *int, appId int, envId *int, pipelineType util.PipelineType) (Event, error) { correlationId := uuid.NewV4() event := Event{} event.EventTypeId = int(eventType) @@ -80,12 +83,19 @@ func (impl *EventSimpleFactoryImpl) Build(eventType util.EventType, sourceId *in } event.AppId = appId if envId != nil { + env, err := impl.envRepository.FindById(*envId) + if err != nil { + impl.logger.Errorw("error in getting env", "envId", *envId, "err", err) + return event, err + } event.EnvId = *envId + event.ClusterId = env.ClusterId + event.IsProdEnv = env.Default } event.PipelineType = string(pipelineType) event.CorrelationId = fmt.Sprintf("%s", correlationId) event.EventTime = time.Now().Format(bean.LayoutRFC3339) - return event + return event, nil } func (impl *EventSimpleFactoryImpl) BuildExtraCDData(event Event, wfr *pipelineConfig.CdWorkflowRunner, pipelineOverrideId int, stage bean2.WorkflowType) Event { diff --git a/client/events/EventClient.go b/client/events/EventClient.go index 4cfbf796618..98a26aa298e 100644 --- a/client/events/EventClient.go +++ b/client/events/EventClient.go @@ -69,6 +69,8 @@ type Event struct { TeamId int `json:"teamId"` AppId int `json:"appId"` EnvId int `json:"envId"` + IsProdEnv bool `json:"isProdEnv"` + ClusterId int `json:"clusterId"` CdWorkflowType bean.WorkflowType `json:"cdWorkflowType,omitempty"` CdWorkflowRunnerId int `json:"cdWorkflowRunnerId"` CiWorkflowRunnerId int `json:"ciWorkflowRunnerId"` diff --git a/go.mod b/go.mod index 8acf08f1211..099524b3fbe 100644 --- a/go.mod +++ b/go.mod @@ -288,7 +288,7 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect replace ( github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.10 - github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082547-2dffd643a849 + github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127 github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5 k8s.io/api => k8s.io/api v0.29.7 diff --git a/go.sum b/go.sum index a1c304459e1..2fcf7dcfa69 100644 --- a/go.sum +++ b/go.sum @@ -794,8 +794,8 @@ github.com/devtron-labs/argo-workflows/v3 v3.5.10 h1:6rxQOesOzDz6SgQCMDQNHaehsKF github.com/devtron-labs/argo-workflows/v3 v3.5.10/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 h1:2+Q7Jdhpo/uMiaQiZZzAh+ZX7wEJIFuMFG6DEiMuo64= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8/go.mod h1:702R6WIf5y9UzKGoCGxQ+x3l5Ws+l0fXg2xlCpSGFZI= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082547-2dffd643a849 h1:93zOd28I0n7FdidXYBPHtHJ2o2UKimTpPoMGfLAu4lY= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082547-2dffd643a849/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da h1:vC6SMz6BM1doN+ZBGiDGyERJ/LphFQi5+Ab/YQkNJVo= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU= github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y= github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys= diff --git a/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go b/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go index a27e1e85553..bfb751025d1 100644 --- a/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go +++ b/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go @@ -174,7 +174,8 @@ func (impl AppListingRepositoryQueryBuilder) BuildAppListingQueryLastDeploymentT func (impl AppListingRepositoryQueryBuilder) GetAppIdsQueryWithPaginationForLastDeployedSearch(appListingFilter AppListingFilter) (string, []interface{}) { join, queryParams := impl.CommonJoinSubQuery(appListingFilter) countQuery := " (SELECT count(distinct(a.id)) as count FROM app a " + join + ") AS total_count " - + // appending query params for count query as well + queryParams = append(queryParams, queryParams...) query := "SELECT a.id as app_id,MAX(pco.id) as last_deployed_time, " + countQuery + ` FROM pipeline p INNER JOIN pipeline_config_override pco ON pco.pipeline_id = p.id and p.deleted=false @@ -259,7 +260,7 @@ func (impl AppListingRepositoryQueryBuilder) buildAppListingWhereCondition(appLi } if isNotDeployedFilterApplied { deploymentAppType := "manifest_download" - whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type != ? || dc.deployment_app_type != ? ) or a.id NOT IN (SELECT app_id from pipeline) " + whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type != ? or dc.deployment_app_type != ? ) or a.id NOT IN (SELECT app_id from pipeline) " queryParams = append(queryParams, false, deploymentAppType, deploymentAppType) if len(appStatusExcludingNotDeployed) > 0 { whereCondition += " or aps.status IN (?) " diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index a31d15d334e..2018f5cd0d6 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -811,7 +811,7 @@ func (impl *AppServiceImpl) UpdatePipelineStatusTimelineForApplicationChanges(ap } func (impl *AppServiceImpl) WriteCDSuccessEvent(appId int, envId int, override *chartConfig.PipelineOverride) { - event := impl.eventFactory.Build(util.Success, &override.PipelineId, appId, &envId, util.CD) + event, _ := impl.eventFactory.Build(util.Success, &override.PipelineId, appId, &envId, util.CD) impl.logger.Debugw("event WriteCDSuccessEvent", "event", event, "override", override) event = impl.eventFactory.BuildExtraCDData(event, nil, override.Id, bean.CD_WORKFLOW_TYPE_DEPLOY) _, evtErr := impl.eventClient.WriteNotificationEvent(event) @@ -1056,7 +1056,7 @@ type PipelineMaterialInfo struct { func buildCDTriggerEvent(impl *AppServiceImpl, overrideRequest *bean.ValuesOverrideRequest, pipeline *pipelineConfig.Pipeline, envOverride *chartConfig.EnvConfigOverride, materialInfo map[string]string, artifact *repository.CiArtifact) client.Event { - event := impl.eventFactory.Build(util.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util.CD) + event, _ := impl.eventFactory.Build(util.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util.CD) return event } diff --git a/pkg/app/DeploymentEventHandler.go b/pkg/app/DeploymentEventHandler.go index e313febb9f1..564622486a1 100644 --- a/pkg/app/DeploymentEventHandler.go +++ b/pkg/app/DeploymentEventHandler.go @@ -51,7 +51,7 @@ func NewDeploymentEventHandlerImpl(logger *zap.SugaredLogger, appListingService } func (impl *DeploymentEventHandlerImpl) WriteCDDeploymentEvent(pipelineId, appId, envId int, eventType util.EventType) { - event := impl.eventFactory.Build(eventType, &pipelineId, appId, &envId, util.CD) + event, _ := impl.eventFactory.Build(eventType, &pipelineId, appId, &envId, util.CD) impl.logger.Debugw("event WriteCDDeploymentEvent", "event", event) event = impl.eventFactory.BuildExtraCDData(event, nil, 0, bean.CD_WORKFLOW_TYPE_DEPLOY) _, evtErr := impl.eventClient.WriteNotificationEvent(event) diff --git a/pkg/auth/user/RoleGroupService.go b/pkg/auth/user/RoleGroupService.go index 85d591ed453..3712f991d42 100644 --- a/pkg/auth/user/RoleGroupService.go +++ b/pkg/auth/user/RoleGroupService.go @@ -19,6 +19,7 @@ package user import ( "errors" "fmt" + helper2 "github.com/devtron-labs/devtron/pkg/auth/user/helper" "github.com/devtron-labs/devtron/pkg/auth/user/repository/helper" "net/http" "strings" @@ -101,9 +102,7 @@ func (impl RoleGroupServiceImpl) CreateRoleGroup(request *bean.RoleGroup) (*bean Name: request.Name, Description: request.Description, } - rgName := strings.ToLower(request.Name) - object := "group:" + strings.ReplaceAll(rgName, " ", "_") - + object := helper2.GetCasbinNameFromRoleGroupName(request.Name) exists, err := impl.roleGroupRepository.CheckRoleGroupExistByCasbinName(object) if err != nil { impl.logger.Errorw("error in getting role group by casbin name", "err", err, "casbinName", object) diff --git a/pkg/auth/user/UserService.go b/pkg/auth/user/UserService.go index 22438b4e88b..31924d98103 100644 --- a/pkg/auth/user/UserService.go +++ b/pkg/auth/user/UserService.go @@ -54,7 +54,7 @@ type UserService interface { CreateUser(userInfo *bean.UserInfo, token string, managerAuth func(resource, token string, object string) bool) ([]*bean.UserInfo, error) SelfRegisterUserIfNotExists(userInfo *bean.UserInfo) ([]*bean.UserInfo, error) UpdateUser(userInfo *bean.UserInfo, token string, checkRBACForUserUpdate func(token string, userInfo *bean.UserInfo, isUserAlreadySuperAdmin bool, - eliminatedRoleFilters, eliminatedGroupRoles []*repository.RoleModel) (isAuthorised bool, err error), managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, error) + eliminatedRoleFilters, eliminatedGroupRoles []*repository.RoleModel, mapOfExistingUserRoleGroup map[string]bool) (isAuthorised bool, err error), managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, error) GetById(id int32) (*bean.UserInfo, error) GetAll() ([]bean.UserInfo, error) GetAllWithFilters(request *bean.ListingRequest) (*bean.UserListingResponse, error) @@ -635,7 +635,7 @@ func (impl *UserServiceImpl) mergeUserRoleGroup(oldUserRoleGroups []bean.UserRol } func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, checkRBACForUserUpdate func(token string, userInfo *bean.UserInfo, - isUserAlreadySuperAdmin bool, eliminatedRoleFilters, eliminatedGroupRoles []*repository.RoleModel) (isAuthorised bool, err error), managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, error) { + isUserAlreadySuperAdmin bool, eliminatedRoleFilters, eliminatedGroupRoles []*repository.RoleModel, mapOfExistingUserRoleGroup map[string]bool) (isAuthorised bool, err error), managerAuth func(resource, token string, object string) bool) (*bean.UserInfo, error) { //checking if request for same user is being processed isLocked := impl.getUserReqLockStateById(userInfo.Id) if isLocked { @@ -684,6 +684,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c //loading policy for safety casbin2.LoadPolicy() var eliminatedRoles, eliminatedGroupRoles []*repository.RoleModel + mapOfExistingUserRoleGroup := make(map[string]bool) if userInfo.SuperAdmin == false { //Starts Role and Mapping userRoleModels, err := impl.userAuthRepository.GetUserRoleMappingByUserId(model.Id) @@ -732,6 +733,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c } for _, oldItem := range userCasbinRoles { oldGroupMap[oldItem] = oldItem + mapOfExistingUserRoleGroup[oldItem] = true } // START GROUP POLICY for _, item := range userInfo.UserRoleGroup { @@ -802,7 +804,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c } if checkRBACForUserUpdate != nil { - isAuthorised, err := checkRBACForUserUpdate(token, userInfo, isUserSuperAdmin, eliminatedRoles, eliminatedGroupRoles) + isAuthorised, err := checkRBACForUserUpdate(token, userInfo, isUserSuperAdmin, eliminatedRoles, eliminatedGroupRoles, mapOfExistingUserRoleGroup) if err != nil { impl.logger.Errorw("error in checking RBAC for user update", "err", err, "userInfo", userInfo) return nil, err diff --git a/pkg/auth/user/helper/helper.go b/pkg/auth/user/helper/helper.go index 06f949a7c67..b7b332e06ed 100644 --- a/pkg/auth/user/helper/helper.go +++ b/pkg/auth/user/helper/helper.go @@ -93,3 +93,7 @@ func CreateErrorMessageForUserRoleGroups(restrictedGroups []bean2.RestrictedGrou } return errorMessageForGroupsWithoutSuperAdmin, errorMessageForGroupsWithSuperAdmin } + +func GetCasbinNameFromRoleGroupName(name string) string { + return "group:" + strings.ReplaceAll(strings.ToLower(name), " ", "_") +} diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index 337c4a61f12..1388a057d3b 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -48,6 +48,7 @@ import ( repository4 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/variables" repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" + util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" jsonpatch "github.com/evanphx/json-patch" "github.com/go-pg/pg" @@ -201,7 +202,8 @@ func (impl BulkUpdateServiceImpl) GetBulkAppName(bulkUpdatePayload *BulkUpdatePa //For ConfigMap if bulkUpdatePayload.ConfigMap != nil && bulkUpdatePayload.ConfigMap.Spec != nil && len(bulkUpdatePayload.ConfigMap.Spec.Names) != 0 { - configMapAppModels, err := impl.bulkUpdateRepository.FindCMBulkAppModelForGlobal(appNameIncludes, appNameExcludes, bulkUpdatePayload.ConfigMap.Spec.Names) + cmNames := util2.GetCopyByValueObject(bulkUpdatePayload.ConfigMap.Spec.Names) + configMapAppModels, err := impl.bulkUpdateRepository.FindCMBulkAppModelForGlobal(appNameIncludes, appNameExcludes, cmNames) if err != nil { impl.logger.Errorw("error in fetching bulk app model for global", "err", err) return nil, err @@ -234,7 +236,8 @@ func (impl BulkUpdateServiceImpl) GetBulkAppName(bulkUpdatePayload *BulkUpdatePa } //For Secret if bulkUpdatePayload.Secret != nil && bulkUpdatePayload.Secret.Spec != nil && len(bulkUpdatePayload.Secret.Spec.Names) != 0 { - secretAppModels, err := impl.bulkUpdateRepository.FindSecretBulkAppModelForGlobal(appNameIncludes, appNameExcludes, bulkUpdatePayload.Secret.Spec.Names) + secretNames := util2.GetCopyByValueObject(bulkUpdatePayload.Secret.Spec.Names) + secretAppModels, err := impl.bulkUpdateRepository.FindSecretBulkAppModelForGlobal(appNameIncludes, appNameExcludes, secretNames) if err != nil { impl.logger.Errorw("error in fetching bulk app model for global", "err", err) return nil, err @@ -287,7 +290,8 @@ func (impl BulkUpdateServiceImpl) GetBulkAppName(bulkUpdatePayload *BulkUpdatePa } //For ConfigMap if bulkUpdatePayload.ConfigMap != nil && bulkUpdatePayload.ConfigMap.Spec != nil && len(bulkUpdatePayload.ConfigMap.Spec.Names) != 0 { - configMapEnvModels, err := impl.bulkUpdateRepository.FindCMBulkAppModelForEnv(appNameIncludes, appNameExcludes, envId, bulkUpdatePayload.ConfigMap.Spec.Names) + cmNames := util2.GetCopyByValueObject(bulkUpdatePayload.ConfigMap.Spec.Names) + configMapEnvModels, err := impl.bulkUpdateRepository.FindCMBulkAppModelForEnv(appNameIncludes, appNameExcludes, envId, cmNames) if err != nil { impl.logger.Errorw("error in fetching bulk app model for global", "err", err) return nil, err @@ -322,7 +326,8 @@ func (impl BulkUpdateServiceImpl) GetBulkAppName(bulkUpdatePayload *BulkUpdatePa } //For Secret if bulkUpdatePayload.Secret != nil && bulkUpdatePayload.Secret.Spec != nil && len(bulkUpdatePayload.Secret.Spec.Names) != 0 { - secretEnvModels, err := impl.bulkUpdateRepository.FindSecretBulkAppModelForEnv(appNameIncludes, appNameExcludes, envId, bulkUpdatePayload.Secret.Spec.Names) + secretNames := util2.GetCopyByValueObject(bulkUpdatePayload.Secret.Spec.Names) + secretEnvModels, err := impl.bulkUpdateRepository.FindSecretBulkAppModelForEnv(appNameIncludes, appNameExcludes, envId, secretNames) if err != nil { impl.logger.Errorw("error in fetching bulk app model for global", "err", err) return nil, err diff --git a/pkg/deployment/gitOps/git/GitServiceGithub.go b/pkg/deployment/gitOps/git/GitServiceGithub.go index 06e78162f36..603adb329bb 100644 --- a/pkg/deployment/gitOps/git/GitServiceGithub.go +++ b/pkg/deployment/gitOps/git/GitServiceGithub.go @@ -127,20 +127,23 @@ func (impl GitHubClient) CreateRepository(ctx context.Context, config *bean2.Git } private := true // visibility := "private" - r, _, err := impl.client.Repositories.Create(ctx, impl.org, + r, _, err1 := impl.client.Repositories.Create(ctx, impl.org, &github.Repository{Name: &config.GitRepoName, Description: &config.Description, Private: &private, // Visibility: &visibility, }) - if err != nil { + if err1 != nil { impl.logger.Errorw("error in creating github repo, ", "repo", config.GitRepoName, "err", err) - detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err + url, err = impl.GetRepoUrl(config) if err != nil { impl.logger.Errorw("error in getting github repo", "repo", config.GitRepoName, "err", err) + detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err1 return "", true, detailedErrorGitOpsConfigActions } + detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, GetRepoUrlStage) + return url, false, detailedErrorGitOpsConfigActions } impl.logger.Infow("github repo created ", "r", r.CloneURL) detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, CreateRepoStage) diff --git a/pkg/deployment/manifest/ManifestCreationService.go b/pkg/deployment/manifest/ManifestCreationService.go index cbb37243bb7..1ceee64fe96 100644 --- a/pkg/deployment/manifest/ManifestCreationService.go +++ b/pkg/deployment/manifest/ManifestCreationService.go @@ -257,7 +257,7 @@ func (impl *ManifestCreationServiceImpl) GetValuesOverrideForTrigger(overrideReq configMapJson, err = impl.getConfigMapAndSecretJsonV2(newCtx, request, envOverride) if err != nil { impl.logger.Errorw("error in fetching config map n secret ", "err", err) - configMapJson = nil + configMapJson.MergedJson = nil } appLabelJsonByte, err = impl.appCrudOperationService.GetAppLabelsForDeployment(newCtx, overrideRequest.AppId, overrideRequest.AppName, overrideRequest.EnvName) if err != nil { @@ -267,15 +267,15 @@ func (impl *ManifestCreationServiceImpl) GetValuesOverrideForTrigger(overrideReq mergedValues, err := impl.mergeOverrideValues(envOverride, releaseOverrideJson, configMapJson.MergedJson, appLabelJsonByte, strategy) appName := pipeline.DeploymentAppName var k8sErr error - mergedValues, k8sErr = impl.updatedExternalCmCsHashForTrigger(newCtx, overrideRequest.ClusterId, - envOverride.Namespace, mergedValues, configMapJson.ExternalCmList, configMapJson.ExternalCsList) - if k8sErr != nil { - impl.logger.Errorw("error in updating external cm cs hash for trigger", - "clusterId", overrideRequest.ClusterId, "namespace", envOverride.Namespace, "err", k8sErr) - // error is not returned as it's not blocking for deployment process - // blocking deployments based on this use case can vary for user to user - } if !envOverride.Environment.IsVirtualEnvironment { + mergedValues, k8sErr = impl.updatedExternalCmCsHashForTrigger(newCtx, overrideRequest.ClusterId, + envOverride.Namespace, mergedValues, configMapJson.ExternalCmList, configMapJson.ExternalCsList) + if k8sErr != nil { + impl.logger.Errorw("error in updating external cm cs hash for trigger", + "clusterId", overrideRequest.ClusterId, "namespace", envOverride.Namespace, "err", k8sErr) + // error is not returned as it's not blocking for deployment process + // blocking deployments based on this use case can vary for user to user + } mergedValues, err = impl.autoscalingCheckBeforeTrigger(newCtx, appName, envOverride.Namespace, mergedValues, overrideRequest) if err != nil { impl.logger.Errorw("error in autoscaling check before trigger", "pipelineId", overrideRequest.PipelineId, "err", err) diff --git a/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go b/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go index 2e43e52781e..c88c975ee7e 100644 --- a/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go +++ b/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go @@ -117,7 +117,7 @@ func (impl *TriggerServiceImpl) TriggerPostStage(request bean.TriggerRequest) er impl.logger.Error("error in updating image path reservation ids in cd workflow runner", "err", "err") } - event := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util2.CD) + event, _ := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util2.CD) impl.logger.Debugw("event Cd Post Trigger", "event", event) event = impl.eventFactory.BuildExtraCDData(event, &wfr, 0, bean2.CD_WORKFLOW_TYPE_POST) _, evtErr := impl.eventClient.WriteNotificationEvent(event) diff --git a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go index 7689cbadabd..010d3986d57 100644 --- a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go +++ b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go @@ -959,7 +959,7 @@ func (impl *TriggerServiceImpl) sendPreStageNotification(ctx context.Context, cd return err } - event := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util2.CD) + event, _ := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, &pipeline.EnvironmentId, util2.CD) impl.logger.Debugw("event PreStageTrigger", "event", event) event = impl.eventFactory.BuildExtraCDData(event, &wfr, 0, bean2.CD_WORKFLOW_TYPE_PRE) _, span := otel.Tracer("orchestrator").Start(ctx, "eventClient.WriteNotificationEvent") diff --git a/pkg/deployment/trigger/devtronApps/TriggerService.go b/pkg/deployment/trigger/devtronApps/TriggerService.go index bd68e0db372..49ad2949eca 100644 --- a/pkg/deployment/trigger/devtronApps/TriggerService.go +++ b/pkg/deployment/trigger/devtronApps/TriggerService.go @@ -1315,7 +1315,7 @@ func (impl *TriggerServiceImpl) helmInstallReleaseWithCustomChart(ctx context.Co func (impl *TriggerServiceImpl) writeCDTriggerEvent(overrideRequest *bean3.ValuesOverrideRequest, artifact *repository3.CiArtifact, releaseId, pipelineOverrideId int) { - event := impl.eventFactory.Build(util2.Trigger, &overrideRequest.PipelineId, overrideRequest.AppId, &overrideRequest.EnvId, util2.CD) + event, _ := impl.eventFactory.Build(util2.Trigger, &overrideRequest.PipelineId, overrideRequest.AppId, &overrideRequest.EnvId, util2.CD) impl.logger.Debugw("event writeCDTriggerEvent", "event", event) event = impl.eventFactory.BuildExtraCDData(event, nil, pipelineOverrideId, bean3.CD_WORKFLOW_TYPE_DEPLOY) _, evtErr := impl.eventClient.WriteNotificationEvent(event) diff --git a/pkg/eventProcessor/in/WorkflowEventProcessorService.go b/pkg/eventProcessor/in/WorkflowEventProcessorService.go index 552843bb807..e30c5ad516b 100644 --- a/pkg/eventProcessor/in/WorkflowEventProcessorService.go +++ b/pkg/eventProcessor/in/WorkflowEventProcessorService.go @@ -459,7 +459,7 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDWorkflowStatusUpdate() error } if wfr.WorkflowType == apiBean.CD_WORKFLOW_TYPE_PRE || wfr.WorkflowType == apiBean.CD_WORKFLOW_TYPE_POST { - event := impl.eventFactory.Build(eventType, &wfr.CdWorkflow.PipelineId, wfr.CdWorkflow.Pipeline.AppId, &wfr.CdWorkflow.Pipeline.EnvironmentId, eventUtil.CD) + event, _ := impl.eventFactory.Build(eventType, &wfr.CdWorkflow.PipelineId, wfr.CdWorkflow.Pipeline.AppId, &wfr.CdWorkflow.Pipeline.EnvironmentId, eventUtil.CD) impl.logger.Debugw("event pre stage", "event", event) event = impl.eventFactory.BuildExtraCDData(event, wfr, 0, wfr.WorkflowType) _, evtErr := impl.eventClient.WriteNotificationEvent(event) diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 65237aa2e20..1488002b366 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -1187,7 +1187,7 @@ func extractErrorCode(msg string) int { } func (impl *CiHandlerImpl) WriteCIFailEvent(ciWorkflow *pipelineConfig.CiWorkflow) { - event := impl.eventFactory.Build(util2.Fail, &ciWorkflow.CiPipelineId, ciWorkflow.CiPipeline.AppId, nil, util2.CI) + event, _ := impl.eventFactory.Build(util2.Fail, &ciWorkflow.CiPipelineId, ciWorkflow.CiPipeline.AppId, nil, util2.CI) material := &client.MaterialTriggerInfo{} material.GitTriggers = ciWorkflow.GitTriggers event.CiWorkflowRunnerId = ciWorkflow.Id diff --git a/pkg/pipeline/CiService.go b/pkg/pipeline/CiService.go index dcc73450cf4..70c5464f442 100644 --- a/pkg/pipeline/CiService.go +++ b/pkg/pipeline/CiService.go @@ -422,7 +422,7 @@ func (impl *CiServiceImpl) getEnvironmentForJob(pipeline *pipelineConfig.CiPipel } func (impl *CiServiceImpl) WriteCITriggerEvent(trigger types.Trigger, pipeline *pipelineConfig.CiPipeline, workflowRequest *types.WorkflowRequest) { - event := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, nil, util2.CI) + event, _ := impl.eventFactory.Build(util2.Trigger, &pipeline.Id, pipeline.AppId, nil, util2.CI) material := &client.MaterialTriggerInfo{} material.GitTriggers = trigger.CommitHashes diff --git a/pkg/pipeline/pipelineStageVariableParser.go b/pkg/pipeline/pipelineStageVariableParser.go index 3dc9a9150d1..3cd5300d5a3 100644 --- a/pkg/pipeline/pipelineStageVariableParser.go +++ b/pkg/pipeline/pipelineStageVariableParser.go @@ -34,8 +34,8 @@ type RefPluginName = string const ( COPY_CONTAINER_IMAGE RefPluginName = "Copy container image" - COPY_CONTAINER_IMAGE_VERSION_V1 = "v1.0.0" - COPY_CONTAINER_IMAGE_VERSION_V2 = "v1.1.0" + COPY_CONTAINER_IMAGE_VERSION_V1 = "1.0.0" + COPY_CONTAINER_IMAGE_VERSION_V2 = "2.0.0" EMPTY_STRING = " " ) diff --git a/pkg/workflow/dag/WorkflowDagExecutor.go b/pkg/workflow/dag/WorkflowDagExecutor.go index f2545e81be2..671400fedde 100644 --- a/pkg/workflow/dag/WorkflowDagExecutor.go +++ b/pkg/workflow/dag/WorkflowDagExecutor.go @@ -942,7 +942,7 @@ func (impl *WorkflowDagExecutorImpl) deactivateUnusedPaths(reserveImagePathIds [ } func (impl *WorkflowDagExecutorImpl) WriteCiSuccessEvent(request *bean2.CiArtifactWebhookRequest, pipeline *pipelineConfig.CiPipeline, artifact *repository.CiArtifact) { - event := impl.eventFactory.Build(util2.Success, &pipeline.Id, pipeline.AppId, nil, util2.CI) + event, _ := impl.eventFactory.Build(util2.Success, &pipeline.Id, pipeline.AppId, nil, util2.CI) event.CiArtifactId = artifact.Id if artifact.WorkflowId != nil { event.CiWorkflowRunnerId = *artifact.WorkflowId @@ -996,7 +996,7 @@ func (impl *WorkflowDagExecutorImpl) HandleCiStepFailedEvent(ciPipelineId int, r } func (impl *WorkflowDagExecutorImpl) WriteCiStepFailedEvent(pipeline *pipelineConfig.CiPipeline, request *bean2.CiArtifactWebhookRequest, ciWorkflow *pipelineConfig.CiWorkflow) { - event := impl.eventFactory.Build(util2.Fail, &pipeline.Id, pipeline.AppId, nil, util2.CI) + event, _ := impl.eventFactory.Build(util2.Fail, &pipeline.Id, pipeline.AppId, nil, util2.CI) material := &client.MaterialTriggerInfo{} material.GitTriggers = ciWorkflow.GitTriggers event.CiWorkflowRunnerId = ciWorkflow.Id diff --git a/util/SQLUtil.go b/util/SQLUtil.go index a0fa81a3d84..af64343e491 100644 --- a/util/SQLUtil.go +++ b/util/SQLUtil.go @@ -8,3 +8,11 @@ import "fmt" func GetLIKEClauseQueryParam(s string) string { return fmt.Sprintf("%%%s%%", s) } + +func GetCopyByValueObject[T any](input []T) []T { + res := make([]T, 0, len(input)) + for _, item := range input { + res = append(res, item) + } + return res +} From 308394f8700b9b58b6ad94da2db7d3d8493c8227 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 14 Oct 2024 18:55:41 +0530 Subject: [PATCH 32/65] terminate workflow refactoring --- pkg/pipeline/CdHandler.go | 10 +++++++++- pkg/pipeline/CiHandler.go | 13 +++++++++++-- pkg/pipeline/WorkflowService.go | 20 ++++++++++---------- pkg/pipeline/types/CiCdConfig.go | 11 +++++++++++ wire_gen.go | 2 +- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 68900146147..b98ff4e7469 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -175,7 +175,15 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int, } } // Terminate workflow - err = impl.workflowService.TerminateWorkflow(workflowRunner.ExecutorType, workflowRunner.Name, workflowRunner.Namespace, restConfig, isExtCluster, nil) + cancelWfDtoRequest := &types.CancelWfRequestDto{ + ExecutorType: workflowRunner.ExecutorType, + Name: workflowRunner.Name, + Namespace: workflowRunner.Namespace, + RestConfig: restConfig, + IsExt: isExtCluster, + Environment: nil, + } + err = impl.workflowService.TerminateWorkflow(cancelWfDtoRequest) if err != nil { impl.Logger.Error("cannot terminate wf runner", "err", err) return 0, err diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index a8d8d912acc..d676e46050a 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -604,9 +604,18 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er return 0, err } } - // Terminate workflow - err = impl.workflowService.TerminateWorkflow(workflow.ExecutorType, workflow.Name, workflow.Namespace, restConfig, isExt, env) + cancelWfDtoRequest := &types.CancelWfRequestDto{ + ExecutorType: workflow.ExecutorType, + Name: workflow.Name, + Namespace: workflow.Namespace, + RestConfig: restConfig, + IsExt: isExt, + Environment: env, + ForceAbort: forceAbort, + } + // Terminate workflow + err = impl.workflowService.TerminateWorkflow(cancelWfDtoRequest) if err != nil && forceAbort { impl.Logger.Errorw("error in terminating workflow, with force abort flag flag as true", "workflowName", workflow.Name, "err", err) //ignoring error in case of force abort later updating workflow with force abort diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index 81f312058c6..263de6faa0f 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -51,7 +51,7 @@ type WorkflowService interface { GetWorkflowStatus(executorType cdWorkflow.WorkflowExecutorType, name string, namespace string, restConfig *rest.Config) (*types.WorkflowStatus, error) // ListAllWorkflows(namespace string) (*v1alpha1.WorkflowList, error) // UpdateWorkflow(wf *v1alpha1.Workflow) (*v1alpha1.Workflow, error) - TerminateWorkflow(executorType cdWorkflow.WorkflowExecutorType, name string, namespace string, restConfig *rest.Config, isExt bool, environment *repository.Environment) error + TerminateWorkflow(cancelWfDtoRequest *types.CancelWfRequestDto) error } type WorkflowServiceImpl struct { @@ -352,24 +352,24 @@ func (impl *WorkflowServiceImpl) GetWorkflowStatus(executorType cdWorkflow.Workf return wfStatus, err } -func (impl *WorkflowServiceImpl) TerminateWorkflow(executorType cdWorkflow.WorkflowExecutorType, name string, namespace string, restConfig *rest.Config, isExt bool, environment *repository.Environment) error { - impl.Logger.Debugw("terminating wf", "name", name) +func (impl *WorkflowServiceImpl) TerminateWorkflow(cancelWfDtoRequest *types.CancelWfRequestDto) error { + impl.Logger.Debugw("terminating wf", "name", cancelWfDtoRequest.Name) var err error - if executorType != "" { - workflowExecutor := impl.getWorkflowExecutor(executorType) + if cancelWfDtoRequest.ExecutorType != "" { + workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) if workflowExecutor == nil { return errors.New("workflow executor not found") } - if restConfig == nil { - restConfig = impl.config + if cancelWfDtoRequest.RestConfig == nil { + cancelWfDtoRequest.RestConfig = impl.config } - err = workflowExecutor.TerminateWorkflow(name, namespace, restConfig) + err = workflowExecutor.TerminateWorkflow(cancelWfDtoRequest.Name, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) } else { - wfClient, err := impl.getWfClient(environment, namespace, isExt) + wfClient, err := impl.getWfClient(cancelWfDtoRequest.Environment, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.IsExt) if err != nil { return err } - err = util.TerminateWorkflow(context.Background(), wfClient, name) + err = util.TerminateWorkflow(context.Background(), wfClient, cancelWfDtoRequest.Name) } return err } diff --git a/pkg/pipeline/types/CiCdConfig.go b/pkg/pipeline/types/CiCdConfig.go index 91a48f7d952..569b76dc39a 100644 --- a/pkg/pipeline/types/CiCdConfig.go +++ b/pkg/pipeline/types/CiCdConfig.go @@ -25,6 +25,7 @@ import ( blob_storage "github.com/devtron-labs/common-lib/blob-storage" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow" + "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/pipeline/bean" v12 "k8s.io/api/core/v1" "k8s.io/client-go/rest" @@ -37,6 +38,16 @@ import ( "time" ) +type CancelWfRequestDto struct { + ExecutorType cdWorkflow.WorkflowExecutorType + Name string + Namespace string + RestConfig *rest.Config + IsExt bool + Environment *repository.Environment + ForceAbort bool +} + // build infra configurations like ciTimeout,ciCpuLimit,ciMemLimit,ciCpuReq,ciMemReq are being managed by infraConfig service type CiCdConfig struct { diff --git a/wire_gen.go b/wire_gen.go index f3f6bfe3434..eaf6c8e67fb 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -722,7 +722,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationReadServiceImpl) + argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationReadServiceImpl, applicationServiceClientImpl) installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, k8sServiceImpl, deploymentConfigServiceImpl, ociRegistryConfigRepositoryImpl, argoApplicationServiceExtendedImpl) chartGroupEntriesRepositoryImpl := repository17.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository17.NewChartGroupReposotoryImpl(db, sugaredLogger) From e70db6419372dcd5134e64ca1baf5dbd50119fd6 Mon Sep 17 00:00:00 2001 From: Rajeev Ranjan <90333766+RajeevRanjan27@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:48:05 +0530 Subject: [PATCH 33/65] fix: deployment window FIXED type (#5986) * updated the common lib hash * updated the common lib hash --- go.mod | 2 +- go.sum | 4 ++-- vendor/modules.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 099524b3fbe..1efd69ec72a 100644 --- a/go.mod +++ b/go.mod @@ -288,7 +288,7 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect replace ( github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.10 - github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da + github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127 github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5 k8s.io/api => k8s.io/api v0.29.7 diff --git a/go.sum b/go.sum index 2fcf7dcfa69..8b6d8016e78 100644 --- a/go.sum +++ b/go.sum @@ -794,8 +794,8 @@ github.com/devtron-labs/argo-workflows/v3 v3.5.10 h1:6rxQOesOzDz6SgQCMDQNHaehsKF github.com/devtron-labs/argo-workflows/v3 v3.5.10/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 h1:2+Q7Jdhpo/uMiaQiZZzAh+ZX7wEJIFuMFG6DEiMuo64= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8/go.mod h1:702R6WIf5y9UzKGoCGxQ+x3l5Ws+l0fXg2xlCpSGFZI= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da h1:vC6SMz6BM1doN+ZBGiDGyERJ/LphFQi5+Ab/YQkNJVo= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c h1:8WIzXcESSOAfkF7SmNLvxNxMnNS9DJtji6qlJr/5XzI= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU= github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y= github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys= diff --git a/vendor/modules.txt b/vendor/modules.txt index 451b8c7c4b5..b53070b21c5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -344,7 +344,7 @@ github.com/devtron-labs/authenticator/jwt github.com/devtron-labs/authenticator/middleware github.com/devtron-labs/authenticator/oidc github.com/devtron-labs/authenticator/password -# github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da +# github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c ## explicit; go 1.21 github.com/devtron-labs/common-lib/async github.com/devtron-labs/common-lib/blob-storage @@ -2212,7 +2212,7 @@ xorm.io/xorm/log xorm.io/xorm/names xorm.io/xorm/schemas xorm.io/xorm/tags -# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da +# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c # github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127 # github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5 # k8s.io/api => k8s.io/api v0.29.7 From aa670f1dda941d58995535bec08d1bf9e3f79f1c Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 02:57:00 +0530 Subject: [PATCH 34/65] scope var fix --- .../repository/EnvironmentRepository.go | 13 +++++++ .../DeploymentConfigurationService.go | 35 +++++++++++-------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/pkg/cluster/repository/EnvironmentRepository.go b/pkg/cluster/repository/EnvironmentRepository.go index 048aa83ae76..a5c43168ae6 100644 --- a/pkg/cluster/repository/EnvironmentRepository.go +++ b/pkg/cluster/repository/EnvironmentRepository.go @@ -80,6 +80,7 @@ type EnvironmentRepository interface { FindAllActiveWithFilter() ([]*Environment, error) FindEnvClusterInfosByIds([]int) ([]*EnvCluserInfo, error) FindEnvLinkedWithCiPipelines(externalCi bool, ciPipelineIds []int) ([]*Environment, error) + FindEnvByNameWithClusterDetails(envName string) (*Environment, error) } func NewEnvironmentRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger, appStatusRepository appStatus.AppStatusRepository) *EnvironmentRepositoryImpl { @@ -160,6 +161,18 @@ func (repositoryImpl EnvironmentRepositoryImpl) FindByName(name string) (*Enviro return environment, err } +func (repositoryImpl EnvironmentRepositoryImpl) FindEnvByNameWithClusterDetails(envName string) (*Environment, error) { + environment := &Environment{} + err := repositoryImpl.dbConnection. + Model(environment). + Column("environment.*", "Cluster"). + Where("environment.environment_name = ?", envName). + Where("environment.active = ?", true). + Limit(1). + Select() + return environment, err +} + func (repositoryImpl EnvironmentRepositoryImpl) FindIdByName(name string) (int, error) { environment := &Environment{} err := repositoryImpl.dbConnection. diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index fadeeb0e23e..c946132f021 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -120,17 +120,21 @@ func (impl *DeploymentConfigurationServiceImpl) ConfigAutoComplete(appId int, en func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { var err error - var envId int - var appId int - var clusterId int + var envId, appId, clusterId int + systemMetadata := &resourceQualifiers.SystemMetadata{ + AppName: configDataQueryParams.AppName, + } if configDataQueryParams.IsEnvNameProvided() { - env, err := impl.environmentRepository.FindByName(configDataQueryParams.EnvName) + env, err := impl.environmentRepository.FindEnvByNameWithClusterDetails(configDataQueryParams.EnvName) if err != nil { impl.logger.Errorw("GetAllConfigData, error in getting environment model by envName", "envName", configDataQueryParams.EnvName, "err", err) return nil, err } envId = env.Id clusterId = env.ClusterId + systemMetadata.EnvironmentName = env.Name + systemMetadata.Namespace = env.Name + systemMetadata.ClusterName = env.Cluster.ClusterName } appId, err = impl.appRepository.FindAppIdByName(configDataQueryParams.AppName) if err != nil { @@ -145,7 +149,7 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) } // this would be the default case - return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) + return impl.getConfigDataForAppConfiguration(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess, systemMetadata) } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { @@ -357,12 +361,12 @@ func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUser } func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { + appId, envId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var err error switch configDataQueryParams.ConfigType { default: // keeping default as PublishedOnly - configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess) + configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess, systemMetadata) if err != nil { impl.logger.Errorw("GetAllConfigData, error in config data for PublishedOnly", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err @@ -407,7 +411,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly( return configDataDto, nil } -func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { +func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} secretData, err := impl.getSecretConfigResponse("", 0, envId, appId) @@ -435,7 +439,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(c return nil, err } - resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess) + resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess, systemMetadata) if err != nil { impl.logger.Errorw("error in resolving cm and cs for published only config only response", "appId", appId, "envId", envId, "err", err) return nil, err @@ -504,11 +508,12 @@ func (impl *DeploymentConfigurationServiceImpl) getMergedCmCs(envId, appId int) }, nil } -func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool) (*bean2.ResolvedCmCsMetadataDto, error) { +func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.ResolvedCmCsMetadataDto, error) { scope := resourceQualifiers.Scope{ - AppId: appId, - EnvId: envId, - ClusterId: clusterId, + AppId: appId, + EnvId: envId, + ClusterId: clusterId, + SystemMetadata: systemMetadata, } cmcsMetadataDto, err := impl.getMergedCmCs(envId, appId) if err != nil { @@ -609,13 +614,13 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedDeploymentConfig(ctx } func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, - appId, envId, clusterId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { + appId, envId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { if configDataQueryParams.IsRequestMadeForOneResource() { return impl.getCmCsEditDataForPublishedOnly(configDataQueryParams, envId, appId) } //ConfigMapsData and SecretsData are populated here - configData, err := impl.getCmCsPublishedConfigResponse(ctx, envId, appId, clusterId, userHasAdminAccess) + configData, err := impl.getCmCsPublishedConfigResponse(ctx, envId, appId, clusterId, userHasAdminAccess, systemMetadata) if err != nil { impl.logger.Errorw("getPublishedConfigData, error in getting cm cs for PublishedOnly state", "appName", configDataQueryParams.AppName, "envName", configDataQueryParams.EnvName, "err", err) return nil, err From 494d30bbe006c5cbdeeb2ed5424ad674672e6b43 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 03:18:40 +0530 Subject: [PATCH 35/65] edit resource --- .../DeploymentConfigurationService.go | 32 ++++++++++++++-- pkg/configDiff/helper/helper.go | 38 +++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index c946132f021..93eceba8908 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -375,7 +375,8 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration return configDataDto, nil } -func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly(configDataQueryParams *bean2.ConfigDataQueryParams, envId, appId int) (*bean2.DeploymentAndCmCsConfigDto, error) { +func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, envId, + appId int, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var resourceType bean.ResourceType @@ -401,11 +402,29 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly( impl.logger.Errorw("getCmCsEditDataForPublishedOnly, error in converting to json raw message", "configDataQueryParams", configDataQueryParams, "err", err) return nil, err } + resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess, configDataQueryParams.ResourceName, resourceType, systemMetadata) + if err != nil { + impl.logger.Errorw("error in resolving cm and cs for published only config only response", "appId", appId, "envId", envId, "err", err) + return nil, err + } cmCsConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(respJson).WithResourceType(resourceType) + if resourceType == bean.CS { + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedCmCsMetadataDto.ResolvedSecretData) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage ", "err", err) + return nil, err + } + cmCsConfig.WithResolvedValue(resolvedConfigDataStringJson).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCS) configDataDto.WithSecretData(cmCsConfig) } else if resourceType == bean.CM { + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedCmCsMetadataDto.ResolvedConfigMapData) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "ResolvedConfigMapData", resolvedCmCsMetadataDto.ResolvedConfigMapData, "err", err) + return nil, err + } + cmCsConfig.WithResolvedValue(resolvedConfigDataStringJson).WithVariableSnapshot(resolvedCmCsMetadataDto.VariableMapCM) configDataDto.WithConfigMapData(cmCsConfig) } return configDataDto, nil @@ -439,7 +458,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsPublishedConfigResponse(c return nil, err } - resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess, systemMetadata) + resolvedCmCsMetadataDto, err := impl.ResolveCmCs(ctx, envId, appId, clusterId, userHasAdminAccess, "", "", systemMetadata) if err != nil { impl.logger.Errorw("error in resolving cm and cs for published only config only response", "appId", appId, "envId", envId, "err", err) return nil, err @@ -508,7 +527,8 @@ func (impl *DeploymentConfigurationServiceImpl) getMergedCmCs(envId, appId int) }, nil } -func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.ResolvedCmCsMetadataDto, error) { +func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, envId, appId, clusterId int, userHasAdminAccess bool, + resourceName string, resourceType bean.ResourceType, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.ResolvedCmCsMetadataDto, error) { scope := resourceQualifiers.Scope{ AppId: appId, EnvId: envId, @@ -520,6 +540,10 @@ func (impl *DeploymentConfigurationServiceImpl) ResolveCmCs(ctx context.Context, impl.logger.Errorw("error in getting merged cm cs", "appId", appId, "envId", envId, "err", err) return nil, err } + // if resourceName is provided then, resolve cmcs request is for single resource, then remove other data from merged cmCs + if len(resourceName) > 0 { + helper.FilterOutMergedCmCsForResourceName(cmcsMetadataDto, resourceName, resourceType) + } resolvedConfigList, resolvedSecretList, variableMapCM, variableMapCS, err := impl.scopedVariableManager.ResolveCMCS(ctx, scope, cmcsMetadataDto.ConfigAppLevelId, cmcsMetadataDto.ConfigEnvLevelId, cmcsMetadataDto.CmMap, cmcsMetadataDto.SecretMap) if err != nil { impl.logger.Errorw("error in resolving CM/CS", "scope", scope, "appId", appId, "envId", envId, "err", err) @@ -617,7 +641,7 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte appId, envId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { if configDataQueryParams.IsRequestMadeForOneResource() { - return impl.getCmCsEditDataForPublishedOnly(configDataQueryParams, envId, appId) + return impl.getCmCsEditDataForPublishedOnly(ctx, configDataQueryParams, envId, appId, clusterId, userHasAdminAccess, systemMetadata) } //ConfigMapsData and SecretsData are populated here configData, err := impl.getCmCsPublishedConfigResponse(ctx, envId, appId, clusterId, userHasAdminAccess, systemMetadata) diff --git a/pkg/configDiff/helper/helper.go b/pkg/configDiff/helper/helper.go index 70082a7bea6..3bf5e5ffaab 100644 --- a/pkg/configDiff/helper/helper.go +++ b/pkg/configDiff/helper/helper.go @@ -1,7 +1,9 @@ package helper import ( + bean3 "github.com/devtron-labs/devtron/pkg/bean" bean2 "github.com/devtron-labs/devtron/pkg/configDiff/bean" + "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) func GetCombinedPropertiesMap(cmcsKeyPropertyAppLevelMap, cmcsKeyPropertyEnvLevelMap map[string]*bean2.ConfigProperty) []*bean2.ConfigProperty { @@ -18,3 +20,39 @@ func GetCombinedPropertiesMap(cmcsKeyPropertyAppLevelMap, cmcsKeyPropertyEnvLeve } return combinedProperties } + +func GetKeysToDelete(cmcsData map[string]*bean3.ConfigData, resourceName string) []string { + keysToDelete := make([]string, 0, len(cmcsData)) + for key, _ := range cmcsData { + if key != resourceName { + keysToDelete = append(keysToDelete, key) + } + } + return keysToDelete +} + +func FilterOutMergedCmCsForResourceName(cmcsMerged *bean2.CmCsMetadataDto, resourceName string, resourceType bean.ResourceType) { + for _, key := range GetKeysToDelete(cmcsMerged.SecretMap, resourceName) { + delete(cmcsMerged.SecretMap, key) + } + for _, key := range GetKeysToDelete(cmcsMerged.CmMap, resourceName) { + delete(cmcsMerged.CmMap, key) + } + + // handle the case when a cm and a cs can have a same name, in that case, check from resource type if correct key is filtered out or not + if resourceType == bean.CS { + if len(cmcsMerged.CmMap) > 0 { + // delete all elements from cmMap as requested resource is of secret type + for key, _ := range cmcsMerged.CmMap { + delete(cmcsMerged.CmMap, key) + } + } + } else if resourceType == bean.CM { + if len(cmcsMerged.SecretMap) > 0 { + // delete all elements from secretMap as requested resource is of secret type + for key, _ := range cmcsMerged.SecretMap { + delete(cmcsMerged.SecretMap, key) + } + } + } +} From 177520aa55d84f9e29e3ff874f90e914adf9cfc1 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 12:10:52 +0530 Subject: [PATCH 36/65] TerminateDanglingWorkflow func in systemworkflowexec and argoworkflowexec --- pkg/pipeline/CiHandler.go | 7 ++++-- pkg/pipeline/WorkflowService.go | 24 +++++++++++++++++++ .../executors/ArgoWorkflowExecutor.go | 5 ++++ .../executors/SystemWorkflowExecutor.go | 4 ++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 917cfe18da9..347c92e0c1c 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -612,13 +612,16 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er RestConfig: restConfig, IsExt: isExt, Environment: env, - ForceAbort: forceAbort, } // Terminate workflow err = impl.workflowService.TerminateWorkflow(cancelWfDtoRequest) if err != nil && forceAbort { impl.Logger.Errorw("error in terminating workflow, with force abort flag flag as true", "workflowName", workflow.Name, "err", err) - //ignoring error in case of force abort later updating workflow with force abort + err1 := impl.workflowService.TerminateDanglingWorkflows(cancelWfDtoRequest) + if err1 != nil { + impl.Logger.Errorw("error in terminating dangling workflows", "cancelWfDtoRequest", cancelWfDtoRequest, "err", err) + return 0, err1 + } } else if err != nil && strings.Contains(err.Error(), "cannot find workflow") { return 0, &util.ApiError{Code: "200", HttpStatusCode: http.StatusBadRequest, UserMessage: err.Error()} } else if err != nil { diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index 263de6faa0f..b17d57c85b1 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -52,6 +52,7 @@ type WorkflowService interface { // ListAllWorkflows(namespace string) (*v1alpha1.WorkflowList, error) // UpdateWorkflow(wf *v1alpha1.Workflow) (*v1alpha1.Workflow, error) TerminateWorkflow(cancelWfDtoRequest *types.CancelWfRequestDto) error + TerminateDanglingWorkflows(cancelWfDtoRequest *types.CancelWfRequestDto) error } type WorkflowServiceImpl struct { @@ -373,6 +374,29 @@ func (impl *WorkflowServiceImpl) TerminateWorkflow(cancelWfDtoRequest *types.Can } return err } + +func (impl *WorkflowServiceImpl) TerminateDanglingWorkflows(cancelWfDtoRequest *types.CancelWfRequestDto) error { + impl.Logger.Debugw("terminating dangling wf", "name", cancelWfDtoRequest.Name) + var err error + if cancelWfDtoRequest.ExecutorType != "" { + workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) + if workflowExecutor == nil { + return errors.New("workflow executor not found") + } + if cancelWfDtoRequest.RestConfig == nil { + cancelWfDtoRequest.RestConfig = impl.config + } + err = workflowExecutor.TerminateWorkflow(cancelWfDtoRequest.Name, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) + } else { + wfClient, err := impl.getWfClient(cancelWfDtoRequest.Environment, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.IsExt) + if err != nil { + return err + } + err = util.TerminateWorkflow(context.Background(), wfClient, cancelWfDtoRequest.Name) + } + return err +} + func (impl *WorkflowServiceImpl) getRuntimeEnvClientInstance(environment *repository.Environment) (v1alpha12.WorkflowInterface, error) { restConfig, err, _ := impl.k8sCommonService.GetRestConfigByClusterId(context.Background(), environment.ClusterId) if err != nil { diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index 0f622717f6c..5eb4a063c8e 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -59,6 +59,7 @@ type WorkflowExecutor interface { TerminateWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error GetWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) (*unstructured.UnstructuredList, error) GetWorkflowStatus(workflowName string, namespace string, clusterConfig *rest.Config) (*types.WorkflowStatus, error) + TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error } type ArgoWorkflowExecutor interface { @@ -89,6 +90,10 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateWorkflow(workflowName string, nam return err } +func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error { + +} + func (impl *ArgoWorkflowExecutorImpl) ExecuteWorkflow(workflowTemplate bean.WorkflowTemplate) (*unstructured.UnstructuredList, error) { entryPoint := workflowTemplate.WorkflowType diff --git a/pkg/pipeline/executors/SystemWorkflowExecutor.go b/pkg/pipeline/executors/SystemWorkflowExecutor.go index 69cf5bb7d4c..f63fcca6131 100644 --- a/pkg/pipeline/executors/SystemWorkflowExecutor.go +++ b/pkg/pipeline/executors/SystemWorkflowExecutor.go @@ -114,6 +114,10 @@ func (impl *SystemWorkflowExecutorImpl) TerminateWorkflow(workflowName string, n return err } +func (impl *SystemWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error { + +} + func (impl *SystemWorkflowExecutorImpl) GetWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) (*unstructured.UnstructuredList, error) { templatesList := &unstructured.UnstructuredList{} _, clientset, err := impl.k8sUtil.GetK8sConfigAndClientsByRestConfig(clusterConfig) From 5ffb3dd9acb0d918e8eeb61ad72dbff589447c4d Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 12:32:44 +0530 Subject: [PATCH 37/65] previous deployments stage added --- .../DeploymentConfigurationService.go | 121 +++++++++++++++- pkg/configDiff/adaptor/adaptor.go | 7 +- pkg/configDiff/bean/bean.go | 1 + pkg/pipeline/ConfigMapService.go | 32 ++--- pkg/pipeline/bean/ConfigMapBean.go | 4 + .../history/ConfigMapHistoryService.go | 133 ++++++++++++++++++ .../DeploymentTemplateHistoryService.go | 11 ++ .../repository/ConfigMapHistoryRepository.go | 19 +++ .../PipelineStrategyHistoryRepository.go | 9 ++ wire_gen.go | 2 +- 10 files changed, 315 insertions(+), 24 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 93eceba8908..7966efa159e 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -20,6 +20,7 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/adapter" "github.com/devtron-labs/devtron/pkg/pipeline/bean" + "github.com/devtron-labs/devtron/pkg/pipeline/history" repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" @@ -52,6 +53,8 @@ type DeploymentConfigurationServiceImpl struct { deploymentConfigService pipeline.PipelineDeploymentConfigService chartRefService chartRef.ChartRefService pipelineRepository pipelineConfig.PipelineRepository + deploymentTemplateHistoryService history.DeploymentTemplateHistoryService + configMapHistoryService history.ConfigMapHistoryService } func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, @@ -68,6 +71,8 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, deploymentConfigService pipeline.PipelineDeploymentConfigService, chartRefService chartRef.ChartRefService, pipelineRepository pipelineConfig.PipelineRepository, + deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, + configMapHistoryService history.ConfigMapHistoryService, ) (*DeploymentConfigurationServiceImpl, error) { deploymentConfigurationService := &DeploymentConfigurationServiceImpl{ logger: logger, @@ -84,6 +89,8 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger, deploymentConfigService: deploymentConfigService, chartRefService: chartRefService, pipelineRepository: pipelineRepository, + deploymentTemplateHistoryService: deploymentTemplateHistoryService, + configMapHistoryService: configMapHistoryService, } return deploymentConfigurationService, nil @@ -268,7 +275,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context return nil, err } var configData []*bean.ConfigData - configList := pipeline.ConfigsList{} + configList := bean.ConfigsList{} secretList := bean.SecretsList{} switch configType { case repository3.CONFIGMAP_TYPE: @@ -360,11 +367,123 @@ func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUser } } +func (impl *DeploymentConfigurationServiceImpl) getCmCsDataForPreviousDeployments(ctx context.Context, deploymentTemplateHistoryId, pipelineId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { + + configDataDto := &bean2.DeploymentAndCmCsConfigDto{} + + deplTemplateHistory, err := impl.deploymentTemplateHistoryService.GetTemplateHistoryModelForDeployedTemplateById(deploymentTemplateHistoryId, pipelineId) + if err != nil { + impl.logger.Errorw("error in getting deployment template history", "err", err, "deploymentTemplateHistoryId", deploymentTemplateHistoryId, "pipelineId", pipelineId) + return nil, err + } + + secretConfigData, cmConfigData, err := impl.configMapHistoryService.GetConfigmapHistoryDataByDeployedOnAndPipelineId(ctx, pipelineId, deplTemplateHistory.DeployedOn, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in getting secretData and cmData", "err", err, "deploymentTemplateHistoryId", deploymentTemplateHistoryId, "pipelineId", pipelineId) + return nil, err + } + configDataDto.WithConfigMapData(cmConfigData).WithSecretData(secretConfigData) + return configDataDto, nil + +} +func (impl *DeploymentConfigurationServiceImpl) getPipelineStrategyForPreviousDeployments(ctx context.Context, deploymentTemplateHistoryId, pipelineId int) (*bean2.DeploymentAndCmCsConfig, error) { + pipelineStrategyJson := json.RawMessage{} + pipelineConfig := bean2.NewDeploymentAndCmCsConfig() + deplTemplateHistory, err := impl.deploymentTemplateHistoryService.GetTemplateHistoryModelForDeployedTemplateById(deploymentTemplateHistoryId, pipelineId) + if err != nil { + impl.logger.Errorw("error in getting deployment template history", "deploymentTemplateHistoryId", deploymentTemplateHistoryId, "pipelineId", pipelineId, "err", err) + return nil, err + } + pipelineStrategyHistory, err := impl.pipelineStrategyHistoryRepository.FindPipelineStrategyForDeployedOnAndPipelineId(pipelineId, deplTemplateHistory.DeployedOn) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Errorw("error in FindPipelineStrategyForDeployedOnAndPipelineId", "deploymentTemplateHistoryId", deploymentTemplateHistoryId, "deployedOn", deplTemplateHistory.DeployedOn, "pipelineId", pipelineId, "err", err) + return nil, err + } else if util.IsErrNoRows(err) { + return pipelineConfig, nil + } + err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategyHistory.Config)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "err", err) + return nil, err + } + pipelineConfig.WithConfigData(pipelineStrategyJson). + WithResourceType(bean.PipelineStrategy). + WithPipelineStrategyMetadata(pipelineStrategyHistory.PipelineTriggerType, string(pipelineStrategyHistory.Strategy)) + return pipelineConfig, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getDeploymentsConfigForPreviousDeployments(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, + appId, envId int) (generateManifest.DeploymentTemplateResponse, error) { + deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ + PipelineId: configDataQueryParams.PipelineId, + DeploymentTemplateHistoryId: configDataQueryParams.IdentifierId, + RequestDataMode: generateManifest.Values, + Type: repository2.DeployedOnSelfEnvironment, + } + var deploymentTemplateResponse generateManifest.DeploymentTemplateResponse + deploymentTemplateResponse, err := impl.deploymentTemplateService.GetDeploymentTemplate(ctx, deploymentTemplateRequest) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in getting deployment template for ", "deploymentTemplateRequest", deploymentTemplateRequest, "err", err) + return deploymentTemplateResponse, err + } + + return deploymentTemplateResponse, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getDeploymentAndCmCsConfigDataForPreviousDeployments(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, + appId, envId int, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { + + // getting DeploymentAndCmCsConfigDto obj with cm and cs data populated + configDataDto, err := impl.getCmCsDataForPreviousDeployments(ctx, configDataQueryParams.IdentifierId, configDataQueryParams.PipelineId, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in getting cm cs for PreviousDeployments state", "deploymentTemplateHistoryId", configDataQueryParams.IdentifierId, "pipelineId", configDataQueryParams.PipelineId, "err", err) + return nil, err + } + pipelineStrategy, err := impl.getPipelineStrategyForPreviousDeployments(ctx, configDataQueryParams.IdentifierId, configDataQueryParams.PipelineId) + if err != nil { + impl.logger.Errorw(" error in getting cm cs for PreviousDeployments state", "deploymentTemplateHistoryId", configDataQueryParams.IdentifierId, "pipelineId", configDataQueryParams.PipelineId, "err", err) + return nil, err + } + if len(pipelineStrategy.Data) > 0 { + configDataDto.WithPipelineConfigData(pipelineStrategy) + } + + deploymentTemplateData, err := impl.getDeploymentsConfigForPreviousDeployments(ctx, configDataQueryParams, appId, envId) + if err != nil { + impl.logger.Errorw("error in getting deployment config", "appName", configDataQueryParams.AppName, "envName", configDataQueryParams.EnvName, "err", err) + return nil, err + } + deploymentJson := json.RawMessage{} + err = deploymentJson.UnmarshalJSON([]byte(deploymentTemplateData.Data)) + if err != nil { + impl.logger.Errorw("error in unmarshalling string deploymentTemplateResponse data into json Raw message", "appName", configDataQueryParams.AppName, "envName", configDataQueryParams.EnvName, "err", err) + return nil, err + } + variableSnapShotMap := map[string]map[string]string{bean.DeploymentTemplate.ToString(): deploymentTemplateData.VariableSnapshot} + + deploymentConfig := bean2.NewDeploymentAndCmCsConfig(). + WithDeploymentConfigMetadata(deploymentTemplateData.TemplateVersion, deploymentTemplateData.IsAppMetricsEnabled). + WithConfigData(deploymentJson). + WithResourceType(bean.DeploymentTemplate). + WithResolvedValue(json.RawMessage(deploymentTemplateData.ResolvedData)). + WithVariableSnapshot(variableSnapShotMap) + + configDataDto.WithDeploymentTemplateData(deploymentConfig) + + return configDataDto, nil +} + func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, appId, envId, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var err error switch configDataQueryParams.ConfigType { + case bean2.PreviousDeployments.ToString(): + configDataDto, err = impl.getDeploymentAndCmCsConfigDataForPreviousDeployments(ctx, configDataQueryParams, appId, envId, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("GetAllConfigData, error in config data for Previous Deployments", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } default: // keeping default as PublishedOnly configDataDto, err = impl.getPublishedConfigData(ctx, configDataQueryParams, appId, envId, clusterId, userHasAdminAccess, systemMetadata) if err != nil { diff --git a/pkg/configDiff/adaptor/adaptor.go b/pkg/configDiff/adaptor/adaptor.go index 6b93442ff49..6fd46129fe1 100644 --- a/pkg/configDiff/adaptor/adaptor.go +++ b/pkg/configDiff/adaptor/adaptor.go @@ -3,7 +3,6 @@ package adaptor import ( bean3 "github.com/devtron-labs/devtron/pkg/bean" bean2 "github.com/devtron-labs/devtron/pkg/configDiff/bean" - "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/adapter" "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) @@ -31,12 +30,12 @@ func GetCmCsAppAndEnvLevelMap(cMCSNamesAppLevel, cMCSNamesEnvLevel []bean.Config return cMCSNamesAppLevelMap, cMCSNamesEnvLevelMap } -func ConfigListConvertor(r bean3.ConfigList) pipeline.ConfigsList { +func ConfigListConvertor(r bean3.ConfigList) bean.ConfigsList { pipelineConfigData := make([]*bean.ConfigData, 0, len(r.ConfigData)) for _, item := range r.ConfigData { pipelineConfigData = append(pipelineConfigData, adapter.ConvertConfigDataToPipelineConfigData(item)) } - return pipeline.ConfigsList{ConfigData: pipelineConfigData} + return bean.ConfigsList{ConfigData: pipelineConfigData} } func SecretListConvertor(r bean3.SecretList) bean.SecretsList { @@ -47,7 +46,7 @@ func SecretListConvertor(r bean3.SecretList) bean.SecretsList { return bean.SecretsList{ConfigData: pipelineConfigData} } -func ReverseConfigListConvertor(r pipeline.ConfigsList) bean3.ConfigList { +func ReverseConfigListConvertor(r bean.ConfigsList) bean3.ConfigList { configData := make([]*bean3.ConfigData, 0, len(r.ConfigData)) for _, item := range r.ConfigData { configData = append(configData, adapter.ConvertPipelineConfigDataToConfigData(item)) diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 94bc3ff7a40..b1ce5540325 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -13,6 +13,7 @@ type ConfigState string const ( PublishedConfigState ConfigState = "PublishedOnly" + PreviousDeployments ConfigState = "PreviousDeployments" ) func (r ConfigState) ToString() string { diff --git a/pkg/pipeline/ConfigMapService.go b/pkg/pipeline/ConfigMapService.go index d2e0bb883c9..bbfb74148bf 100644 --- a/pkg/pipeline/ConfigMapService.go +++ b/pkg/pipeline/ConfigMapService.go @@ -47,10 +47,6 @@ const ( HashiCorpVault string = "HashiCorpVault" ) -type ConfigsList struct { - ConfigData []*bean.ConfigData `json:"maps"` -} - type ConfigMapService interface { CMGlobalAddUpdate(configMapRequest *bean.ConfigDataRequest) (*bean.ConfigDataRequest, error) CMGlobalFetch(appId int) (*bean.ConfigDataRequest, error) @@ -165,7 +161,7 @@ func (impl ConfigMapServiceImpl) CMGlobalAddUpdate(configMapRequest *bean.Config impl.logger.Errorw("error while fetching from db", "error", err) return nil, err } - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -208,7 +204,7 @@ func (impl ConfigMapServiceImpl) CMGlobalAddUpdate(configMapRequest *bean.Config } else { //creating config map record for first time - configsList := &ConfigsList{ + configsList := &bean.ConfigsList{ ConfigData: configMapRequest.ConfigData, } configDataByte, err := json.Marshal(configsList) @@ -254,7 +250,7 @@ func (impl ConfigMapServiceImpl) CMGlobalFetch(appId int) (*bean.ConfigDataReque impl.logger.Debugw("no config map data found for this request", "appId", appId) } - configMapGlobalList := &ConfigsList{} + configMapGlobalList := &bean.ConfigsList{} if len(configMapGlobal.ConfigMapData) > 0 { err = json.Unmarshal([]byte(configMapGlobal.ConfigMapData), configMapGlobalList) if err != nil { @@ -301,7 +297,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentAddUpdate(configMapRequest *bean.C return nil, err } if err == nil && model.Id > 0 { - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -345,7 +341,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentAddUpdate(configMapRequest *bean.C } else if err == pg.ErrNoRows { //creating config map record for first time - configsList := &ConfigsList{ + configsList := &bean.ConfigsList{ ConfigData: configMapRequest.ConfigData, } configDataByte, err := json.Marshal(configsList) @@ -391,7 +387,7 @@ func (impl ConfigMapServiceImpl) CMGlobalFetchForEdit(name string, id int) (*bea impl.logger.Debugw("no config map data found for this request", "id", id) } - configMapGlobalList := &ConfigsList{} + configMapGlobalList := &bean.ConfigsList{} if len(configMapGlobal.ConfigMapData) > 0 { err = json.Unmarshal([]byte(configMapGlobal.ConfigMapData), configMapGlobalList) if err != nil { @@ -439,7 +435,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentFetch(appId int, envId int) (*bean if pg.ErrNoRows == err { impl.logger.Debugw("no config map data found for this request", "appId", appId) } - configMapGlobalList := &ConfigsList{} + configMapGlobalList := &bean.ConfigsList{} if len(configMapGlobal.ConfigMapData) > 0 { err = json.Unmarshal([]byte(configMapGlobal.ConfigMapData), configMapGlobalList) if err != nil { @@ -454,7 +450,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentFetch(appId int, envId int) (*bean if pg.ErrNoRows == err { impl.logger.Debugw("no config map data found for this request", "appId", appId) } - configsListEnvLevel := &ConfigsList{} + configsListEnvLevel := &bean.ConfigsList{} if len(configMapEnvLevel.ConfigMapData) > 0 { err = json.Unmarshal([]byte(configMapEnvLevel.ConfigMapData), configsListEnvLevel) if err != nil { @@ -918,7 +914,7 @@ func (impl ConfigMapServiceImpl) CMGlobalDelete(name string, id int, userId int3 impl.logger.Errorw("error while fetching from db", "error", err) return false, err } - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -974,7 +970,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentDelete(name string, id int, userId impl.logger.Errorw("error while fetching from db", "error", err) return false, err } - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -1140,7 +1136,7 @@ func (impl ConfigMapServiceImpl) CMGlobalDeleteByAppId(name string, appId int, u impl.logger.Errorw("error while fetching from db", "error", err) return false, err } - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -1190,7 +1186,7 @@ func (impl ConfigMapServiceImpl) CMEnvironmentDeleteByAppIdAndEnvId(name string, impl.logger.Errorw("error while fetching from db", "error", err) return false, err } - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} found := false var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { @@ -1540,7 +1536,7 @@ func (impl ConfigMapServiceImpl) ConfigSecretGlobalBulkPatch(bulkPatchRequest *b continue } if bulkPatchRequest.Type == "CM" { - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { err = json.Unmarshal([]byte(model.ConfigMapData), configsList) @@ -1645,7 +1641,7 @@ func (impl ConfigMapServiceImpl) ConfigSecretEnvironmentBulkPatch(bulkPatchReque continue } if bulkPatchRequest.Type == "CM" { - configsList := &ConfigsList{} + configsList := &bean.ConfigsList{} var configs []*bean.ConfigData if len(model.ConfigMapData) > 0 { err = json.Unmarshal([]byte(model.ConfigMapData), configsList) diff --git a/pkg/pipeline/bean/ConfigMapBean.go b/pkg/pipeline/bean/ConfigMapBean.go index 5f194ebe1f1..65cb8af637b 100644 --- a/pkg/pipeline/bean/ConfigMapBean.go +++ b/pkg/pipeline/bean/ConfigMapBean.go @@ -119,6 +119,10 @@ type SecretsList struct { ConfigData []*ConfigData `json:"secrets"` } +type ConfigsList struct { + ConfigData []*ConfigData `json:"maps"` +} + type ConfigNameAndType struct { Id int Name string diff --git a/pkg/pipeline/history/ConfigMapHistoryService.go b/pkg/pipeline/history/ConfigMapHistoryService.go index 4f56673bd1e..107f486dea4 100644 --- a/pkg/pipeline/history/ConfigMapHistoryService.go +++ b/pkg/pipeline/history/ConfigMapHistoryService.go @@ -20,6 +20,11 @@ import ( "context" "encoding/json" "errors" + "github.com/devtron-labs/devtron/pkg/configDiff/adaptor" + bean2 "github.com/devtron-labs/devtron/pkg/configDiff/bean" + "github.com/devtron-labs/devtron/pkg/configDiff/utils" + "github.com/devtron-labs/devtron/pkg/pipeline/adapter" + bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" globalUtil "github.com/devtron-labs/devtron/util" "time" @@ -48,6 +53,8 @@ type ConfigMapHistoryService interface { CheckIfTriggerHistoryExistsForPipelineIdOnTime(pipelineId int, deployedOn time.Time) (cmId int, csId int, exists bool, err error) GetDeployedHistoryDetailForCMCSByPipelineIdAndWfrId(ctx context.Context, pipelineId, wfrId int, configType repository.ConfigType, userHasAdminAccess bool) ([]*ComponentLevelHistoryDetailDto, error) ConvertConfigDataToComponentLevelDto(config *bean.ConfigData, configType repository.ConfigType, userHasAdminAccess bool) (*ComponentLevelHistoryDetailDto, error) + + GetConfigmapHistoryDataByDeployedOnAndPipelineId(ctx context.Context, pipelineId int, deployedOn time.Time, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfig, *bean2.DeploymentAndCmCsConfig, error) } type ConfigMapHistoryServiceImpl struct { @@ -691,3 +698,129 @@ func (impl ConfigMapHistoryServiceImpl) CheckIfTriggerHistoryExistsForPipelineId } return cmId, csId, exists, nil } + +func (impl ConfigMapHistoryServiceImpl) GetConfigmapHistoryDataByDeployedOnAndPipelineId(ctx context.Context, pipelineId int, deployedOn time.Time, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfig, *bean2.DeploymentAndCmCsConfig, error) { + secretConfigData, err := impl.getResolvedConfigData(ctx, pipelineId, deployedOn, repository.SECRET_TYPE, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in getting resolved secret config data in case of previous deployments ", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, nil, err + } + cmConfigData, err := impl.getResolvedConfigData(ctx, pipelineId, deployedOn, repository.CONFIGMAP_TYPE, userHasAdminAccess) + if err != nil { + impl.logger.Errorw("error in getting resolved cm config data in case of previous deployments ", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, nil, err + } + + return secretConfigData, cmConfigData, nil +} + +func (impl *ConfigMapHistoryServiceImpl) getResolvedConfigData(ctx context.Context, pipelineId int, deployedOn time.Time, configType repository.ConfigType, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfig, error) { + configsList := &bean3.ConfigsList{} + secretsList := &bean3.SecretsList{} + var err error + history, err := impl.configMapHistoryRepository.GetDeployedHistoryByPipelineIdAndDeployedOn(pipelineId, deployedOn, configType) + if err != nil { + impl.logger.Errorw("error in getting deployed history by pipeline id and deployed on", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, err + } + if configType == repository.SECRET_TYPE { + _, secretsList, err = impl.getConfigDataRequestForHistory(history) + if err != nil { + impl.logger.Errorw("error in getting config data request for history", "err", err) + return nil, err + } + } else if configType == repository.CONFIGMAP_TYPE { + configsList, _, err = impl.getConfigDataRequestForHistory(history) + if err != nil { + impl.logger.Errorw("error in getting config data request for history", "cmCsHistory", history, "err", err) + return nil, err + } + } + + resolvedDataMap, variableSnapshotMap, err := impl.scopedVariableManager.GetResolvedCMCSHistoryDtos(ctx, configType, adaptor.ReverseConfigListConvertor(*configsList), history, adaptor.ReverseSecretListConvertor(*secretsList)) + if err != nil { + return nil, err + } + resolvedConfigDataList := make([]*bean3.ConfigData, 0, len(resolvedDataMap)) + for _, resolvedConfigData := range resolvedDataMap { + resolvedConfigDataList = append(resolvedConfigDataList, adapter.ConvertConfigDataToPipelineConfigData(&resolvedConfigData)) + } + configDataReq := &bean3.ConfigDataRequest{} + var resourceType bean3.ResourceType + if configType == repository.SECRET_TYPE { + impl.encodeSecretDataFromNonAdminUsers(secretsList.ConfigData, userHasAdminAccess) + impl.encodeSecretDataFromNonAdminUsers(resolvedConfigDataList, userHasAdminAccess) + configDataReq.ConfigData = secretsList.ConfigData + resourceType = bean3.CS + } else if configType == repository.CONFIGMAP_TYPE { + configDataReq.ConfigData = configsList.ConfigData + resourceType = bean3.CM + } + + configDataJson, err := utils.ConvertToJsonRawMessage(configDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, err + } + resolvedConfigDataReq := &bean3.ConfigDataRequest{ConfigData: resolvedConfigDataList} + resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, err + } + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedConfigDataStringJson, "err", err) + return nil, err + } + return bean2.NewDeploymentAndCmCsConfig().WithConfigData(configDataJson).WithResourceType(resourceType). + WithVariableSnapshot(variableSnapshotMap).WithResolvedValue(resolvedConfigDataStringJson), nil +} + +func (impl *ConfigMapHistoryServiceImpl) encodeSecretDataFromNonAdminUsers(configDataList []*bean3.ConfigData, userHasAdminAccess bool) { + for _, config := range configDataList { + if config.Data != nil { + if !userHasAdminAccess { + //removing keys and sending + resultMap := make(map[string]string) + resultMapFinal := make(map[string]string) + err := json.Unmarshal(config.Data, &resultMap) + if err != nil { + impl.logger.Errorw("unmarshal failed", "error", err) + return + } + for key, _ := range resultMap { + //hard-coding values to show them as hidden to user + resultMapFinal[key] = "*****" + } + config.Data, err = utils.ConvertToJsonRawMessage(resultMapFinal) + if err != nil { + impl.logger.Errorw("error while marshaling request", "err", err) + return + } + } + } + } +} + +func (impl ConfigMapHistoryServiceImpl) getConfigDataRequestForHistory(history *repository.ConfigmapAndSecretHistory) (*bean3.ConfigsList, *bean3.SecretsList, error) { + + configsList := &bean3.ConfigsList{} + secretsList := &bean3.SecretsList{} + if history.IsConfigmapHistorySecretType() { + err := json.Unmarshal([]byte(history.Data), secretsList) + if err != nil { + impl.logger.Errorw("error while Unmarshal in secret history data", "error", err) + return configsList, secretsList, err + } + return configsList, secretsList, nil + } else if history.IsConfigmapHistoryConfigMapType() { + err := json.Unmarshal([]byte(history.Data), configsList) + if err != nil { + impl.logger.Errorw("error while Unmarshal in config history data", "historyData", history.Data, "error", err) + return configsList, secretsList, err + } + return configsList, secretsList, nil + } + return configsList, secretsList, nil +} diff --git a/pkg/pipeline/history/DeploymentTemplateHistoryService.go b/pkg/pipeline/history/DeploymentTemplateHistoryService.go index 276a0905002..d2eac61f809 100644 --- a/pkg/pipeline/history/DeploymentTemplateHistoryService.go +++ b/pkg/pipeline/history/DeploymentTemplateHistoryService.go @@ -50,6 +50,8 @@ type DeploymentTemplateHistoryService interface { // used for rollback GetDeployedHistoryByPipelineIdAndWfrId(ctx context.Context, pipelineId, wfrId int) (*HistoryDetailDto, error) + + GetTemplateHistoryModelForDeployedTemplateById(deploymentTemplateHistoryId, pipelineId int) (*repository.DeploymentTemplateHistory, error) } type DeploymentTemplateHistoryServiceImpl struct { @@ -407,3 +409,12 @@ func (impl DeploymentTemplateHistoryServiceImpl) CheckIfTriggerHistoryExistsForP exists = true return deploymentTemplateHistoryId, exists, err } + +func (impl DeploymentTemplateHistoryServiceImpl) GetTemplateHistoryModelForDeployedTemplateById(deploymentTemplateHistoryId, pipelineId int) (*repository.DeploymentTemplateHistory, error) { + history, err := impl.deploymentTemplateHistoryRepository.GetHistoryForDeployedTemplateById(deploymentTemplateHistoryId, pipelineId) + if err != nil { + impl.logger.Errorw("error in getting deployment template history", "err", err, "deploymentTemplateHistoryId", deploymentTemplateHistoryId, "pipelineId", pipelineId) + return nil, err + } + return history, nil +} diff --git a/pkg/pipeline/history/repository/ConfigMapHistoryRepository.go b/pkg/pipeline/history/repository/ConfigMapHistoryRepository.go index e3a6918ee66..ebf45afe844 100644 --- a/pkg/pipeline/history/repository/ConfigMapHistoryRepository.go +++ b/pkg/pipeline/history/repository/ConfigMapHistoryRepository.go @@ -39,6 +39,7 @@ type ConfigMapHistoryRepository interface { GetHistoryByPipelineIdAndWfrId(pipelineId, wfrId int, configType ConfigType) (*ConfigmapAndSecretHistory, error) GetDeployedHistoryForPipelineIdOnTime(pipelineId int, deployedOn time.Time, configType ConfigType) (*ConfigmapAndSecretHistory, error) GetDeployedHistoryList(pipelineId, baseConfigId int, configType ConfigType, componentName string) ([]*ConfigmapAndSecretHistory, error) + GetDeployedHistoryByPipelineIdAndDeployedOn(pipelineId int, deployedOn time.Time, configType ConfigType) (*ConfigmapAndSecretHistory, error) } type ConfigMapHistoryRepositoryImpl struct { @@ -71,6 +72,13 @@ type ConfigmapAndSecretHistory struct { DeployedByEmailId string `sql:"-"` } +func (r *ConfigmapAndSecretHistory) IsConfigmapHistorySecretType() bool { + return r.DataType == SECRET_TYPE +} + +func (r *ConfigmapAndSecretHistory) IsConfigmapHistoryConfigMapType() bool { + return r.DataType == CONFIGMAP_TYPE +} func (impl ConfigMapHistoryRepositoryImpl) CreateHistory(tx *pg.Tx, model *ConfigmapAndSecretHistory) (*ConfigmapAndSecretHistory, error) { var err error if tx != nil { @@ -149,3 +157,14 @@ func (impl ConfigMapHistoryRepositoryImpl) GetDeployedHistoryForPipelineIdOnTime Select() return &history, err } + +func (impl ConfigMapHistoryRepositoryImpl) GetDeployedHistoryByPipelineIdAndDeployedOn(pipelineId int, deployedOn time.Time, configType ConfigType) (*ConfigmapAndSecretHistory, error) { + var history ConfigmapAndSecretHistory + err := impl.dbConnection.Model(&history). + Where("pipeline_id = ?", pipelineId). + Where("data_type = ?", configType). + Where("deployed_on = ?", deployedOn). + Where("deployed = ?", true). + Select() + return &history, err +} diff --git a/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go b/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go index 092a81239ec..755d38686cc 100644 --- a/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go +++ b/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go @@ -35,6 +35,7 @@ type PipelineStrategyHistoryRepository interface { GetHistoryByPipelineIdAndWfrId(ctx context.Context, pipelineId, wfrId int) (*PipelineStrategyHistory, error) CheckIfTriggerHistoryExistsForPipelineIdOnTime(pipelineId int, deployedOn time.Time) (bool, error) GetDeployedHistoryList(pipelineId, baseConfigId int) ([]*PipelineStrategyHistory, error) + FindPipelineStrategyForDeployedOnAndPipelineId(pipelineId int, deployedOn time.Time) (PipelineStrategyHistory, error) } type PipelineStrategyHistoryRepositoryImpl struct { @@ -145,3 +146,11 @@ func (impl PipelineStrategyHistoryRepositoryImpl) CheckIfTriggerHistoryExistsFor Exists() return exists, err } + +func (impl PipelineStrategyHistoryRepositoryImpl) FindPipelineStrategyForDeployedOnAndPipelineId(pipelineId int, deployedOn time.Time) (PipelineStrategyHistory, error) { + var history PipelineStrategyHistory + err := impl.dbConnection.Model(&history). + Where("pipeline_strategy_history.deployed_on = ?", deployedOn). + Where("pipeline_strategy_history.pipeline_id = ?", pipelineId).Select() + return history, err +} diff --git a/wire_gen.go b/wire_gen.go index 0bee1a76cdc..a53fca7b976 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -951,7 +951,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl, chartRefServiceImpl, pipelineRepositoryImpl) + deploymentConfigurationServiceImpl, err := configDiff.NewDeploymentConfigurationServiceImpl(sugaredLogger, configMapServiceImpl, appRepositoryImpl, environmentRepositoryImpl, chartServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentTemplateHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, configMapRepositoryImpl, pipelineDeploymentConfigServiceImpl, chartRefServiceImpl, pipelineRepositoryImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl) if err != nil { return nil, err } From 5b6e9f839e54d0e248545f8b1b375a2031d7f3f1 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 13:20:35 +0530 Subject: [PATCH 38/65] TerminateDanglingWorkflows flow written for both argo and system executor --- pkg/pipeline/CiHandler.go | 6 ++-- pkg/pipeline/WorkflowService.go | 30 ++++++---------- .../executors/ArgoWorkflowExecutor.go | 34 +++++++++++++++++-- .../executors/SystemWorkflowExecutor.go | 31 +++++++++++++++-- pkg/pipeline/types/CiCdConfig.go | 15 ++++---- 5 files changed, 83 insertions(+), 33 deletions(-) diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 347c92e0c1c..e6fd3776550 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -607,7 +607,7 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er // Terminate workflow cancelWfDtoRequest := &types.CancelWfRequestDto{ ExecutorType: workflow.ExecutorType, - Name: workflow.Name, + WorkflowName: workflow.Name, Namespace: workflow.Namespace, RestConfig: restConfig, IsExt: isExt, @@ -617,10 +617,12 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er err = impl.workflowService.TerminateWorkflow(cancelWfDtoRequest) if err != nil && forceAbort { impl.Logger.Errorw("error in terminating workflow, with force abort flag flag as true", "workflowName", workflow.Name, "err", err) + + cancelWfDtoRequest.WorkflowGenerateName = fmt.Sprintf("%d-%s-", workflowId, workflow.Name) err1 := impl.workflowService.TerminateDanglingWorkflows(cancelWfDtoRequest) if err1 != nil { impl.Logger.Errorw("error in terminating dangling workflows", "cancelWfDtoRequest", cancelWfDtoRequest, "err", err) - return 0, err1 + // ignoring error here in case of force abort, confirmed from product } } else if err != nil && strings.Contains(err.Error(), "cannot find workflow") { return 0, &util.ApiError{Code: "200", HttpStatusCode: http.StatusBadRequest, UserMessage: err.Error()} diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index b17d57c85b1..e3f5454c0fa 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -354,7 +354,7 @@ func (impl *WorkflowServiceImpl) GetWorkflowStatus(executorType cdWorkflow.Workf } func (impl *WorkflowServiceImpl) TerminateWorkflow(cancelWfDtoRequest *types.CancelWfRequestDto) error { - impl.Logger.Debugw("terminating wf", "name", cancelWfDtoRequest.Name) + impl.Logger.Debugw("terminating wf", "name", cancelWfDtoRequest.WorkflowName) var err error if cancelWfDtoRequest.ExecutorType != "" { workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) @@ -364,36 +364,28 @@ func (impl *WorkflowServiceImpl) TerminateWorkflow(cancelWfDtoRequest *types.Can if cancelWfDtoRequest.RestConfig == nil { cancelWfDtoRequest.RestConfig = impl.config } - err = workflowExecutor.TerminateWorkflow(cancelWfDtoRequest.Name, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) + err = workflowExecutor.TerminateWorkflow(cancelWfDtoRequest.WorkflowName, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) } else { wfClient, err := impl.getWfClient(cancelWfDtoRequest.Environment, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.IsExt) if err != nil { return err } - err = util.TerminateWorkflow(context.Background(), wfClient, cancelWfDtoRequest.Name) + err = util.TerminateWorkflow(context.Background(), wfClient, cancelWfDtoRequest.WorkflowName) } return err } func (impl *WorkflowServiceImpl) TerminateDanglingWorkflows(cancelWfDtoRequest *types.CancelWfRequestDto) error { - impl.Logger.Debugw("terminating dangling wf", "name", cancelWfDtoRequest.Name) + impl.Logger.Debugw("terminating dangling wf", "name", cancelWfDtoRequest.WorkflowName) var err error - if cancelWfDtoRequest.ExecutorType != "" { - workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) - if workflowExecutor == nil { - return errors.New("workflow executor not found") - } - if cancelWfDtoRequest.RestConfig == nil { - cancelWfDtoRequest.RestConfig = impl.config - } - err = workflowExecutor.TerminateWorkflow(cancelWfDtoRequest.Name, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) - } else { - wfClient, err := impl.getWfClient(cancelWfDtoRequest.Environment, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.IsExt) - if err != nil { - return err - } - err = util.TerminateWorkflow(context.Background(), wfClient, cancelWfDtoRequest.Name) + workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) + if workflowExecutor == nil { + return errors.New("workflow executor not found") + } + if cancelWfDtoRequest.RestConfig == nil { + cancelWfDtoRequest.RestConfig = impl.config } + err = workflowExecutor.TerminateDanglingWorkflow(cancelWfDtoRequest.WorkflowGenerateName, cancelWfDtoRequest.Namespace, cancelWfDtoRequest.RestConfig) return err } diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index 5eb4a063c8e..c2d13755384 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -59,7 +59,7 @@ type WorkflowExecutor interface { TerminateWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error GetWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) (*unstructured.UnstructuredList, error) GetWorkflowStatus(workflowName string, namespace string, clusterConfig *rest.Config) (*types.WorkflowStatus, error) - TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error + TerminateDanglingWorkflow(workflowGenerateName string, namespace string, clusterConfig *rest.Config) error } type ArgoWorkflowExecutor interface { @@ -90,8 +90,36 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateWorkflow(workflowName string, nam return err } -func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error { - +func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerateName string, namespace string, clusterConfig *rest.Config) error { + impl.logger.Debugw("terminating dangling wf", "workflowGenerateName", workflowGenerateName) + wfClient, err := impl.getClientInstance(namespace, clusterConfig) + if err != nil { + impl.logger.Errorw("cannot build wf client", "workflowGenerateName", workflowGenerateName, "err", err) + return err + } + wfList, err := wfClient.List(context.Background(), v1.ListOptions{}) + if err != nil { + impl.logger.Errorw("error in fetching list of workflows", "namespace", namespace, "err", err) + return err + } + var wfToDelete v1alpha1.Workflow + for _, wf := range wfList.Items { + if wf.GenerateName == workflowGenerateName { + wfToDelete = wf + break + } + } + _, err = wfClient.Get(context.Background(), wfToDelete.Name, v1.GetOptions{}) + if err != nil { + impl.logger.Errorw("cannot find workflow", "name", wfToDelete.Name, "err", err) + return errors.New("cannot find workflow " + wfToDelete.Name) + } + err = util.TerminateWorkflow(context.Background(), wfClient, wfToDelete.Name) + if err != nil { + impl.logger.Errorw("error in terminating argo executor workflow", "name", wfToDelete.Name, "err", err) + return err + } + return nil } func (impl *ArgoWorkflowExecutorImpl) ExecuteWorkflow(workflowTemplate bean.WorkflowTemplate) (*unstructured.UnstructuredList, error) { diff --git a/pkg/pipeline/executors/SystemWorkflowExecutor.go b/pkg/pipeline/executors/SystemWorkflowExecutor.go index f63fcca6131..267858daa5a 100644 --- a/pkg/pipeline/executors/SystemWorkflowExecutor.go +++ b/pkg/pipeline/executors/SystemWorkflowExecutor.go @@ -114,8 +114,35 @@ func (impl *SystemWorkflowExecutorImpl) TerminateWorkflow(workflowName string, n return err } -func (impl *SystemWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) error { - +func (impl *SystemWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerateName string, namespace string, clusterConfig *rest.Config) error { + _, clientset, err := impl.k8sUtil.GetK8sConfigAndClientsByRestConfig(clusterConfig) + if err != nil { + impl.logger.Errorw("error occurred while creating k8s client", "workflowGenerateName", workflowGenerateName, "namespace", namespace, "err", err) + return err + } + jobList, err := clientset.BatchV1().Jobs(namespace).List(context.Background(), v12.ListOptions{}) + if err != nil { + impl.logger.Errorw("error occurred while fetching jobs list for terminating dangling workflows", "namespace", namespace, "err", err) + return err + } + var jobToDelete v1.Job + for _, job := range jobList.Items { + if job.ObjectMeta.GenerateName == workflowGenerateName { + jobToDelete = job + break + } + } + if len(jobToDelete.Name) > 0 { + err = clientset.BatchV1().Jobs(namespace).Delete(context.Background(), jobToDelete.Name, v12.DeleteOptions{}) + if err != nil { + if errors.IsNotFound(err) { + err = fmt.Errorf("cannot find job workflow %s", jobToDelete.Name) + } + impl.logger.Errorw("error occurred while deleting workflow", "workflowName", jobToDelete.Name, "namespace", namespace, "err", err) + return err + } + } + return nil } func (impl *SystemWorkflowExecutorImpl) GetWorkflow(workflowName string, namespace string, clusterConfig *rest.Config) (*unstructured.UnstructuredList, error) { diff --git a/pkg/pipeline/types/CiCdConfig.go b/pkg/pipeline/types/CiCdConfig.go index 569b76dc39a..f5bcadd57ec 100644 --- a/pkg/pipeline/types/CiCdConfig.go +++ b/pkg/pipeline/types/CiCdConfig.go @@ -39,13 +39,14 @@ import ( ) type CancelWfRequestDto struct { - ExecutorType cdWorkflow.WorkflowExecutorType - Name string - Namespace string - RestConfig *rest.Config - IsExt bool - Environment *repository.Environment - ForceAbort bool + ExecutorType cdWorkflow.WorkflowExecutorType + WorkflowName string + Namespace string + RestConfig *rest.Config + IsExt bool + Environment *repository.Environment + ForceAbort bool + WorkflowGenerateName string } // build infra configurations like ciTimeout,ciCpuLimit,ciMemLimit,ciCpuReq,ciMemReq are being managed by infraConfig service From 34bea344204bb8aca5b47fbc8b8a2ef93bb4a36f Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 13:23:20 +0530 Subject: [PATCH 39/65] fix --- pkg/pipeline/CdHandler.go | 2 +- wire_gen.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index b98ff4e7469..38f4de3c3a1 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -177,7 +177,7 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int, // Terminate workflow cancelWfDtoRequest := &types.CancelWfRequestDto{ ExecutorType: workflowRunner.ExecutorType, - Name: workflowRunner.Name, + WorkflowName: workflowRunner.Name, Namespace: workflowRunner.Namespace, RestConfig: restConfig, IsExt: isExtCluster, diff --git a/wire_gen.go b/wire_gen.go index eaf6c8e67fb..da93048b885 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -439,7 +439,7 @@ func InitializeApp() (*App, error) { ciWorkflowRepositoryImpl := pipelineConfig.NewCiWorkflowRepositoryImpl(db, sugaredLogger) ciPipelineMaterialRepositoryImpl := pipelineConfig.NewCiPipelineMaterialRepositoryImpl(db, sugaredLogger) ciArtifactRepositoryImpl := repository2.NewCiArtifactRepositoryImpl(db, sugaredLogger) - eventSimpleFactoryImpl := client2.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, ciArtifactRepositoryImpl) + eventSimpleFactoryImpl := client2.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, environmentRepositoryImpl, ciArtifactRepositoryImpl) applicationServiceClientImpl := application.NewApplicationClientImpl(sugaredLogger, argoCDConnectionManagerImpl) configMapRepositoryImpl := chartConfig.NewConfigMapRepositoryImpl(sugaredLogger, db) chartRepositoryImpl := chartRepoRepository.NewChartRepository(db, transactionUtilImpl) From 6080ec95f5e65164bd687e45ac63d1f02497df2c Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 14:04:12 +0530 Subject: [PATCH 40/65] check put for force abort --- pkg/pipeline/CiHandler.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index e6fd3776550..ac813e3aa8f 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -630,10 +630,13 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er impl.Logger.Errorw("cannot terminate wf", "err", err) return 0, err } - err = impl.handleForceAbortCase(workflow, forceAbort) - if err != nil { - impl.Logger.Errorw("error in handleForceAbortCase", "forceAbortFlag", forceAbort, "workflow", workflow, "err", err) - return 0, err + if forceAbort { + err = impl.handleForceAbortCase(workflow, forceAbort) + if err != nil { + impl.Logger.Errorw("error in handleForceAbortCase", "forceAbortFlag", forceAbort, "workflow", workflow, "err", err) + return 0, err + } + return workflow.Id, nil } workflow.Status = executors.WorkflowCancel From 168dd9367f3e34fc2866e0030561054b6c937566 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Tue, 15 Oct 2024 15:31:15 +0530 Subject: [PATCH 41/65] added a check in TerminateDanglingWorkflow for argo wf exec --- .../executors/ArgoWorkflowExecutor.go | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index c2d13755384..fae45e78bad 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -109,15 +109,17 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerate break } } - _, err = wfClient.Get(context.Background(), wfToDelete.Name, v1.GetOptions{}) - if err != nil { - impl.logger.Errorw("cannot find workflow", "name", wfToDelete.Name, "err", err) - return errors.New("cannot find workflow " + wfToDelete.Name) - } - err = util.TerminateWorkflow(context.Background(), wfClient, wfToDelete.Name) - if err != nil { - impl.logger.Errorw("error in terminating argo executor workflow", "name", wfToDelete.Name, "err", err) - return err + if len(wfToDelete.Name) > 0 { + _, err = wfClient.Get(context.Background(), wfToDelete.Name, v1.GetOptions{}) + if err != nil { + impl.logger.Errorw("cannot find workflow", "name", wfToDelete.Name, "err", err) + return errors.New("cannot find workflow " + wfToDelete.Name) + } + err = util.TerminateWorkflow(context.Background(), wfClient, wfToDelete.Name) + if err != nil { + impl.logger.Errorw("error in terminating argo executor workflow", "name", wfToDelete.Name, "err", err) + return err + } } return nil } From bba878a36858549c484e268a6ce658e821041cf0 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Wed, 16 Oct 2024 11:26:28 +0530 Subject: [PATCH 42/65] fix --- pkg/pipeline/executors/ArgoWorkflowExecutor.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index fae45e78bad..b932771cf1c 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -110,11 +110,6 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerate } } if len(wfToDelete.Name) > 0 { - _, err = wfClient.Get(context.Background(), wfToDelete.Name, v1.GetOptions{}) - if err != nil { - impl.logger.Errorw("cannot find workflow", "name", wfToDelete.Name, "err", err) - return errors.New("cannot find workflow " + wfToDelete.Name) - } err = util.TerminateWorkflow(context.Background(), wfClient, wfToDelete.Name) if err != nil { impl.logger.Errorw("error in terminating argo executor workflow", "name", wfToDelete.Name, "err", err) From 2cff70285ae6f7b05d2adb065aea3e12d3eae76a Mon Sep 17 00:00:00 2001 From: Shivam Nagar <124123645+Shivam-nagar23@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:04:54 +0530 Subject: [PATCH 43/65] terminal role (#5991) --- scripts/casbin/10_terminal.down.sql | 1 + scripts/casbin/10_terminal.up.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 scripts/casbin/10_terminal.down.sql create mode 100644 scripts/casbin/10_terminal.up.sql diff --git a/scripts/casbin/10_terminal.down.sql b/scripts/casbin/10_terminal.down.sql new file mode 100644 index 00000000000..e19c73b16c3 --- /dev/null +++ b/scripts/casbin/10_terminal.down.sql @@ -0,0 +1 @@ +DELETE FROM casbin_rule where v0='role:super-admin___' and v1='terminal'; \ No newline at end of file diff --git a/scripts/casbin/10_terminal.up.sql b/scripts/casbin/10_terminal.up.sql new file mode 100644 index 00000000000..09e46eede25 --- /dev/null +++ b/scripts/casbin/10_terminal.up.sql @@ -0,0 +1,2 @@ +INSERT INTO "public"."casbin_rule" ("p_type", "v0", "v1", "v2", "v3", "v4", "v5") VALUES +('p','role:super-admin___','terminal','*','*','allow',''); \ No newline at end of file From 73ad83ea58d1119cfc3c867317931b7e09c639cb Mon Sep 17 00:00:00 2001 From: iamayushm <32041961+iamayushm@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:48:27 +0900 Subject: [PATCH 44/65] fix helm deployment status (#5996) --- .../sql/repository/pipelineConfig/CdWorfkflowRepository.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go b/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go index cb81f4ca1b4..abd44441035 100644 --- a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go +++ b/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go @@ -693,9 +693,10 @@ func (impl *CdWorkflowRepositoryImpl) GetLatestTriggersOfHelmPipelinesStuckInNon Where("cd_workflow_runner.cd_workflow_id in"+ " (SELECT max(cd_workflow.id) as id from cd_workflow"+ " INNER JOIN cd_workflow_runner on cd_workflow.id = cd_workflow_runner.cd_workflow_id"+ - " WHERE cd_workflow_runner.status != ?"+ + " WHERE cd_workflow_runner.workflow_type = ? "+ + " AND cd_workflow_runner.status != ?"+ " GROUP BY cd_workflow.pipeline_id"+ - " ORDER BY cd_workflow.pipeline_id desc)", cdWorkflow.WorkflowInQueue). + " ORDER BY cd_workflow.pipeline_id desc)", apiBean.CD_WORKFLOW_TYPE_DEPLOY, cdWorkflow.WorkflowInQueue). Where("(cd_workflow__pipeline.deployment_app_type=? or dc.deployment_app_type=?)", util.PIPELINE_DEPLOYMENT_TYPE_HELM, util.PIPELINE_DEPLOYMENT_TYPE_HELM). Where("cd_workflow_runner.started_on > NOW() - INTERVAL '? hours'", getPipelineDeployedWithinHours). Where("cd_workflow__pipeline.deleted=?", false). From ebcfd494c54cf510eb7077b3c7576ef2d5ec2418 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 17 Oct 2024 13:40:07 +0530 Subject: [PATCH 45/65] code review incorporation :- kartik --- pkg/cluster/repository/EnvironmentRepository.go | 1 - pkg/configDiff/DeploymentConfigurationService.go | 15 +++++++-------- pkg/configDiff/bean/bean.go | 4 +++- pkg/generateManifest/DeploymentTemplateService.go | 10 ++++------ pkg/generateManifest/adapter.go | 14 ++++++++++++++ pkg/pipeline/history/ConfigMapHistoryService.go | 7 +------ 6 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 pkg/generateManifest/adapter.go diff --git a/pkg/cluster/repository/EnvironmentRepository.go b/pkg/cluster/repository/EnvironmentRepository.go index a5c43168ae6..15e806e2ca9 100644 --- a/pkg/cluster/repository/EnvironmentRepository.go +++ b/pkg/cluster/repository/EnvironmentRepository.go @@ -168,7 +168,6 @@ func (repositoryImpl EnvironmentRepositoryImpl) FindEnvByNameWithClusterDetails( Column("environment.*", "Cluster"). Where("environment.environment_name = ?", envName). Where("environment.active = ?", true). - Limit(1). Select() return environment, err } diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 7966efa159e..4e0f6b166f2 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -31,6 +31,7 @@ import ( "github.com/juju/errors" "go.uber.org/zap" "net/http" + "strconv" ) type DeploymentConfigurationService interface { @@ -140,7 +141,7 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con envId = env.Id clusterId = env.ClusterId systemMetadata.EnvironmentName = env.Name - systemMetadata.Namespace = env.Name + systemMetadata.Namespace = env.Namespace systemMetadata.ClusterName = env.Cluster.ClusterName } appId, err = impl.appRepository.FindAppIdByName(configDataQueryParams.AppName) @@ -161,6 +162,9 @@ func (impl *DeploymentConfigurationServiceImpl) GetAllConfigData(ctx context.Con func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, userHasAdminAccess bool) (*bean2.DeploymentAndCmCsConfigDto, error) { // wfrId is expected in this case to return the expected data + if configDataQueryParams.WfrId == 0 { + return nil, &util.ApiError{HttpStatusCode: http.StatusNotFound, Code: strconv.Itoa(http.StatusNotFound), InternalMessage: bean2.ExpectedWfrIdNotPassedInQueryParamErr, UserMessage: bean2.ExpectedWfrIdNotPassedInQueryParamErr} + } return impl.getConfigDataForDeploymentHistory(ctx, configDataQueryParams, userHasAdminAccess) } @@ -323,12 +327,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context return nil, err } resolvedConfigDataReq := &bean.ConfigDataRequest{ConfigData: resolvedConfigDataList} - resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) - if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) - return nil, err - } - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataReq) if err != nil { impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedConfigDataString", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err @@ -355,7 +354,7 @@ func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUser } for key, _ := range resultMap { //hard-coding values to show them as hidden to user - resultMapFinal[key] = "*****" + resultMapFinal[key] = bean2.SecretMaskedValue } config.Data, err = utils.ConvertToJsonRawMessage(resultMapFinal) if err != nil { diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index b1ce5540325..30e183a229a 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -229,5 +229,7 @@ type DeploymentTemplateMetadata struct { } const ( - NoDeploymentDoneForSelectedImage = "there were no deployments done for the selected image" + NoDeploymentDoneForSelectedImage = "there were no deployments done for the selected image" + ExpectedWfrIdNotPassedInQueryParamErr = "wfrId is expected in the query param which was not passed" + SecretMaskedValue = "*****" ) diff --git a/pkg/generateManifest/DeploymentTemplateService.go b/pkg/generateManifest/DeploymentTemplateService.go index 1a56931c711..fadd1927261 100644 --- a/pkg/generateManifest/DeploymentTemplateService.go +++ b/pkg/generateManifest/DeploymentTemplateService.go @@ -235,11 +235,7 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont result.ResolvedData = resolvedValue result.VariableSnapshot = variableSnapshot if response != nil { - result.Data = response.Data - result.ResolvedData = response.ResolvedData - result.VariableSnapshot = response.VariableSnapshot - result.TemplateVersion = response.TemplateVersion - result.IsAppMetricsEnabled = response.IsAppMetricsEnabled + result = ConvertPointerDeploymentTemplateResponseToNonPointer(response) } return result, nil } @@ -251,7 +247,9 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont if err != nil { return result, err } - result.Data = *manifest.Manifest + if manifest != nil { + result.Data = *manifest.Manifest + } return result, nil } diff --git a/pkg/generateManifest/adapter.go b/pkg/generateManifest/adapter.go new file mode 100644 index 00000000000..ca5755aa64c --- /dev/null +++ b/pkg/generateManifest/adapter.go @@ -0,0 +1,14 @@ +package generateManifest + +func ConvertPointerDeploymentTemplateResponseToNonPointer(r *DeploymentTemplateResponse) DeploymentTemplateResponse { + if r != nil { + return DeploymentTemplateResponse{ + Data: r.Data, + ResolvedData: r.ResolvedData, + VariableSnapshot: r.VariableSnapshot, + TemplateVersion: r.TemplateVersion, + IsAppMetricsEnabled: r.IsAppMetricsEnabled, + } + } + return DeploymentTemplateResponse{} +} diff --git a/pkg/pipeline/history/ConfigMapHistoryService.go b/pkg/pipeline/history/ConfigMapHistoryService.go index 107f486dea4..07c375db8d7 100644 --- a/pkg/pipeline/history/ConfigMapHistoryService.go +++ b/pkg/pipeline/history/ConfigMapHistoryService.go @@ -763,12 +763,7 @@ func (impl *ConfigMapHistoryServiceImpl) getResolvedConfigData(ctx context.Conte return nil, err } resolvedConfigDataReq := &bean3.ConfigDataRequest{ConfigData: resolvedConfigDataList} - resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) - if err != nil { - impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) - return nil, err - } - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataReq) if err != nil { impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedConfigDataStringJson, "err", err) return nil, err From 0078d8040ffb23b815386fc96f985fac7f806390 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Thu, 17 Oct 2024 15:09:53 +0530 Subject: [PATCH 46/65] code review incorporation :- kartik 2 --- pkg/generateManifest/adapter.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pkg/generateManifest/adapter.go b/pkg/generateManifest/adapter.go index ca5755aa64c..9528ec2d8b2 100644 --- a/pkg/generateManifest/adapter.go +++ b/pkg/generateManifest/adapter.go @@ -2,13 +2,7 @@ package generateManifest func ConvertPointerDeploymentTemplateResponseToNonPointer(r *DeploymentTemplateResponse) DeploymentTemplateResponse { if r != nil { - return DeploymentTemplateResponse{ - Data: r.Data, - ResolvedData: r.ResolvedData, - VariableSnapshot: r.VariableSnapshot, - TemplateVersion: r.TemplateVersion, - IsAppMetricsEnabled: r.IsAppMetricsEnabled, - } + return *r } return DeploymentTemplateResponse{} } From 0f766a86602a8b48830a7c5058b007a7da0ab3a0 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 18 Oct 2024 19:36:20 +0530 Subject: [PATCH 47/65] reverted changes --- pkg/configDiff/DeploymentConfigurationService.go | 7 ++++++- pkg/pipeline/history/ConfigMapHistoryService.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index 4e0f6b166f2..a1ea3d2482d 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -327,7 +327,12 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context return nil, err } resolvedConfigDataReq := &bean.ConfigDataRequest{ConfigData: resolvedConfigDataList} - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataReq) + resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) + return nil, err + } + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) if err != nil { impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedConfigDataString", "pipelineId", configDataQueryParams.PipelineId, "wfrId", configDataQueryParams.WfrId, "err", err) return nil, err diff --git a/pkg/pipeline/history/ConfigMapHistoryService.go b/pkg/pipeline/history/ConfigMapHistoryService.go index 07c375db8d7..107f486dea4 100644 --- a/pkg/pipeline/history/ConfigMapHistoryService.go +++ b/pkg/pipeline/history/ConfigMapHistoryService.go @@ -763,7 +763,12 @@ func (impl *ConfigMapHistoryServiceImpl) getResolvedConfigData(ctx context.Conte return nil, err } resolvedConfigDataReq := &bean3.ConfigDataRequest{ConfigData: resolvedConfigDataList} - resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataReq) + resolvedConfigDataString, err := utils.ConvertToString(resolvedConfigDataReq) + if err != nil { + impl.logger.Errorw("getCmCsPublishedConfigResponse, error in converting config data to json raw message", "pipelineId", pipelineId, "deployedOn", deployedOn, "err", err) + return nil, err + } + resolvedConfigDataStringJson, err := utils.ConvertToJsonRawMessage(resolvedConfigDataString) if err != nil { impl.logger.Errorw("getCmCsPublishedConfigResponse, error in ConvertToJsonRawMessage for resolvedJson", "resolvedJson", resolvedConfigDataStringJson, "err", err) return nil, err From 01079610b2fcfae4cf51ca7599df29e34540e096 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Sun, 20 Oct 2024 16:58:54 +0530 Subject: [PATCH 48/65] add label of generateName prefix in workfow template and cancel workflow using label selector --- .../DeploymentPipelineRestHandler.go | 9 ++- pkg/pipeline/CdHandler.go | 55 ++++++++++++++++--- pkg/pipeline/CiHandler.go | 12 ++-- pkg/pipeline/WorkflowService.go | 4 +- .../executors/ArgoWorkflowExecutor.go | 14 ++--- .../executors/SystemWorkflowExecutor.go | 16 ++---- pkg/pipeline/types/Workflow.go | 18 +++--- 7 files changed, 84 insertions(+), 44 deletions(-) diff --git a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go index 950468f79f1..abf07d80794 100644 --- a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go @@ -2071,6 +2071,13 @@ func (handler *PipelineConfigRestHandlerImpl) CancelStage(w http.ResponseWriter, common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } + var forceAbort bool + forceAbort, err = strconv.ParseBool(r.URL.Query().Get("forceAbort")) + if err != nil { + handler.Logger.Errorw("request err, CancelWorkflow", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } handler.Logger.Infow("request payload, CancelStage", "pipelineId", pipelineId, "workflowRunnerId", workflowRunnerId) //RBAC @@ -2082,7 +2089,7 @@ func (handler *PipelineConfigRestHandlerImpl) CancelStage(w http.ResponseWriter, } //RBAC - resp, err := handler.cdHandler.CancelStage(workflowRunnerId, userId) + resp, err := handler.cdHandler.CancelStage(workflowRunnerId, forceAbort, userId) if err != nil { handler.Logger.Errorw("service err, CancelStage", "err", err, "pipelineId", pipelineId, "workflowRunnerId", workflowRunnerId) if util.IsErrNoRows(err) { diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 38f4de3c3a1..e62d080bee5 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/adapter/cdWorkflow" + bean2 "github.com/devtron-labs/devtron/pkg/bean" common2 "github.com/devtron-labs/devtron/pkg/deployment/common" util2 "github.com/devtron-labs/devtron/pkg/pipeline/util" "os" @@ -64,7 +65,7 @@ type CdHandler interface { FetchCdWorkflowDetails(appId int, environmentId int, pipelineId int, buildId int) (types.WorkflowResponse, error) DownloadCdWorkflowArtifacts(buildId int) (*os.File, error) FetchCdPrePostStageStatus(pipelineId int) ([]pipelineBean.CdWorkflowWithArtifact, error) - CancelStage(workflowRunnerId int, userId int32) (int, error) + CancelStage(workflowRunnerId int, forceAbort bool, userId int32) (int, error) FetchAppWorkflowStatusForTriggerView(appId int) ([]*pipelineConfig.CdWorkflowStatus, error) FetchAppWorkflowStatusForTriggerViewForEnvironment(request resourceGroup2.ResourceGroupingRequest, token string) ([]*pipelineConfig.CdWorkflowStatus, error) FetchAppDeploymentStatusForEnvironments(request resourceGroup2.ResourceGroupingRequest, token string) ([]*pipelineConfig.AppDeploymentStatus, error) @@ -133,16 +134,12 @@ func NewCdHandlerImpl(Logger *zap.SugaredLogger, userService user.UserService, return cdh } -func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int, error) { +func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, forceAbort bool, userId int32) (int, error) { workflowRunner, err := impl.cdWorkflowRepository.FindWorkflowRunnerById(workflowRunnerId) if err != nil { impl.Logger.Errorw("err", "err", err) return 0, err } - if !(string(v1alpha1.NodePending) == workflowRunner.Status || string(v1alpha1.NodeRunning) == workflowRunner.Status) { - impl.Logger.Info("cannot cancel stage, stage not in progress") - return 0, errors.New("cannot cancel stage, stage not in progress") - } pipeline, err := impl.pipelineRepository.FindById(workflowRunner.CdWorkflow.PipelineId) if err != nil { impl.Logger.Errorw("error while fetching cd pipeline", "err", err) @@ -184,10 +181,26 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int, Environment: nil, } err = impl.workflowService.TerminateWorkflow(cancelWfDtoRequest) - if err != nil { + if err != nil && forceAbort { + impl.Logger.Errorw("error in terminating workflow, with force abort flag as true", "workflowName", workflowRunner.Name, "err", err) + cancelWfDtoRequest.WorkflowGenerateName = fmt.Sprintf("%d-%s", workflowRunnerId, workflowRunner.Name) + err1 := impl.workflowService.TerminateDanglingWorkflows(cancelWfDtoRequest) + if err1 != nil { + impl.Logger.Errorw("error in terminating dangling workflows", "cancelWfDtoRequest", cancelWfDtoRequest, "err", err) + // ignoring error here in case of force abort, confirmed from product + } + } else if err != nil { impl.Logger.Error("cannot terminate wf runner", "err", err) return 0, err } + if forceAbort { + err = impl.handleForceAbortCaseForCdStage(workflowRunner, forceAbort) + if err != nil { + impl.Logger.Errorw("error in handleForceAbortCaseForCdStage", "forceAbortFlag", forceAbort, "workflowRunner", workflowRunner, "err", err) + return 0, err + } + return workflowRunner.Id, nil + } if len(workflowRunner.ImagePathReservationIds) > 0 { err := impl.customTagService.DeactivateImagePathReservationByImageIds(workflowRunner.ImagePathReservationIds) if err != nil { @@ -206,6 +219,34 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int, return workflowRunner.Id, nil } +func (impl *CdHandlerImpl) updateWorkflowRunnerForForceAbort(workflowRunner *pipelineConfig.CdWorkflowRunner) error { + workflowRunner.Status = executors.WorkflowCancel + workflowRunner.PodStatus = string(bean2.Failed) + workflowRunner.Message = FORCE_ABORT_MESSAGE_AFTER_STARTING_STAGE + err := impl.cdWorkflowRepository.UpdateWorkFlowRunner(workflowRunner) + if err != nil { + impl.Logger.Errorw("error in updating workflow status in cd workflow runner in force abort case", "err", err) + return err + } + return nil +} + +func (impl *CdHandlerImpl) handleForceAbortCaseForCdStage(workflowRunner *pipelineConfig.CdWorkflowRunner, forceAbort bool) error { + isWorkflowInNonTerminalStage := workflowRunner.Status == string(v1alpha1.NodePending) || workflowRunner.Status == string(v1alpha1.NodeRunning) + if !isWorkflowInNonTerminalStage { + if forceAbort { + return impl.updateWorkflowRunnerForForceAbort(workflowRunner) + } else { + return &util.ApiError{Code: "200", HttpStatusCode: 400, UserMessage: "cannot cancel stage, stage not in progress"} + } + } + //this arises when someone deletes the workflow in resource browser and wants to force abort a cd stage(pre/post) + if workflowRunner.Status == string(v1alpha1.NodeRunning) && forceAbort { + return impl.updateWorkflowRunnerForForceAbort(workflowRunner) + } + return nil +} + func (impl *CdHandlerImpl) UpdateWorkflow(workflowStatus v1alpha1.WorkflowStatus) (int, string, error) { wfStatusRs := impl.extractWorkfowStatus(workflowStatus) workflowName, status, podStatus, message, podName := wfStatusRs.WorkflowName, wfStatusRs.Status, wfStatusRs.PodStatus, wfStatusRs.Message, wfStatusRs.PodName diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index ac813e3aa8f..b247a2f9919 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -163,7 +163,7 @@ const Running = "Running" const Starting = "Starting" const POD_DELETED_MESSAGE = "pod deleted" const TERMINATE_MESSAGE = "workflow shutdown with strategy: Terminate" -const ABORT_MESSAGE_AFTER_STARTING_STAGE = "workflow shutdown with strategy: Force Abort" +const FORCE_ABORT_MESSAGE_AFTER_STARTING_STAGE = "workflow shutdown with strategy: Force Abort" func (impl *CiHandlerImpl) CheckAndReTriggerCI(workflowStatus v1alpha1.WorkflowStatus) error { @@ -618,7 +618,7 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er if err != nil && forceAbort { impl.Logger.Errorw("error in terminating workflow, with force abort flag flag as true", "workflowName", workflow.Name, "err", err) - cancelWfDtoRequest.WorkflowGenerateName = fmt.Sprintf("%d-%s-", workflowId, workflow.Name) + cancelWfDtoRequest.WorkflowGenerateName = fmt.Sprintf("%d-%s", workflowId, workflow.Name) err1 := impl.workflowService.TerminateDanglingWorkflows(cancelWfDtoRequest) if err1 != nil { impl.Logger.Errorw("error in terminating dangling workflows", "cancelWfDtoRequest", cancelWfDtoRequest, "err", err) @@ -631,9 +631,9 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er return 0, err } if forceAbort { - err = impl.handleForceAbortCase(workflow, forceAbort) + err = impl.handleForceAbortCaseForCi(workflow, forceAbort) if err != nil { - impl.Logger.Errorw("error in handleForceAbortCase", "forceAbortFlag", forceAbort, "workflow", workflow, "err", err) + impl.Logger.Errorw("error in handleForceAbortCaseForCi", "forceAbortFlag", forceAbort, "workflow", workflow, "err", err) return 0, err } return workflow.Id, nil @@ -666,7 +666,7 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int, forceAbort bool) (int, er return workflow.Id, nil } -func (impl *CiHandlerImpl) handleForceAbortCase(workflow *pipelineConfig.CiWorkflow, forceAbort bool) error { +func (impl *CiHandlerImpl) handleForceAbortCaseForCi(workflow *pipelineConfig.CiWorkflow, forceAbort bool) error { isWorkflowInNonTerminalStage := workflow.Status == string(v1alpha1.NodePending) || workflow.Status == string(v1alpha1.NodeRunning) if !isWorkflowInNonTerminalStage { if forceAbort { @@ -685,7 +685,7 @@ func (impl *CiHandlerImpl) handleForceAbortCase(workflow *pipelineConfig.CiWorkf func (impl *CiHandlerImpl) updateWorkflowForForceAbort(workflow *pipelineConfig.CiWorkflow) error { workflow.Status = executors.WorkflowCancel workflow.PodStatus = string(bean.Failed) - workflow.Message = ABORT_MESSAGE_AFTER_STARTING_STAGE + workflow.Message = FORCE_ABORT_MESSAGE_AFTER_STARTING_STAGE err := impl.ciWorkflowRepository.UpdateWorkFlow(workflow) if err != nil { impl.Logger.Errorw("error in updating workflow status", "err", err) diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index e3f5454c0fa..454716724bd 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -158,12 +158,12 @@ func (impl *WorkflowServiceImpl) createWorkflowTemplate(workflowRequest *types.W } workflowMainContainer, err := workflowRequest.GetWorkflowMainContainer(impl.ciCdConfig, infraConfiguration, workflowJson, &workflowTemplate, workflowConfigMaps, workflowSecrets) - if err != nil { impl.Logger.Errorw("error occurred while getting workflow main container", "err", err) return bean3.WorkflowTemplate{}, err } - + // if anyone wants to add extra labels in workflow template then leverage below func. + workflowRequest.AddExtraLabelsInWorkflowTemplate() workflowTemplate.Containers = []v12.Container{workflowMainContainer} impl.updateBlobStorageConfig(workflowRequest, &workflowTemplate) if workflowRequest.Type == bean3.CI_WORKFLOW_PIPELINE_TYPE || workflowRequest.Type == bean3.JOB_WORKFLOW_PIPELINE_TYPE { diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index b932771cf1c..7b6997900db 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -97,22 +97,16 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerate impl.logger.Errorw("cannot build wf client", "workflowGenerateName", workflowGenerateName, "err", err) return err } - wfList, err := wfClient.List(context.Background(), v1.ListOptions{}) + jobSelectorLabel := fmt.Sprintf("%s=%s", types.WorkflowGenerateNamePrefix, workflowGenerateName) + wfList, err := wfClient.List(context.Background(), v1.ListOptions{LabelSelector: jobSelectorLabel}) if err != nil { impl.logger.Errorw("error in fetching list of workflows", "namespace", namespace, "err", err) return err } - var wfToDelete v1alpha1.Workflow for _, wf := range wfList.Items { - if wf.GenerateName == workflowGenerateName { - wfToDelete = wf - break - } - } - if len(wfToDelete.Name) > 0 { - err = util.TerminateWorkflow(context.Background(), wfClient, wfToDelete.Name) + err = util.TerminateWorkflow(context.Background(), wfClient, wf.Name) if err != nil { - impl.logger.Errorw("error in terminating argo executor workflow", "name", wfToDelete.Name, "err", err) + impl.logger.Errorw("error in terminating argo executor workflow", "name", wf.Name, "err", err) return err } } diff --git a/pkg/pipeline/executors/SystemWorkflowExecutor.go b/pkg/pipeline/executors/SystemWorkflowExecutor.go index 267858daa5a..a26c05f6940 100644 --- a/pkg/pipeline/executors/SystemWorkflowExecutor.go +++ b/pkg/pipeline/executors/SystemWorkflowExecutor.go @@ -120,25 +120,19 @@ func (impl *SystemWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenera impl.logger.Errorw("error occurred while creating k8s client", "workflowGenerateName", workflowGenerateName, "namespace", namespace, "err", err) return err } - jobList, err := clientset.BatchV1().Jobs(namespace).List(context.Background(), v12.ListOptions{}) + jobSelectorLabel := fmt.Sprintf("%s=%s", types2.WorkflowGenerateNamePrefix, workflowGenerateName) + jobList, err := clientset.BatchV1().Jobs(namespace).List(context.Background(), v12.ListOptions{LabelSelector: jobSelectorLabel}) if err != nil { impl.logger.Errorw("error occurred while fetching jobs list for terminating dangling workflows", "namespace", namespace, "err", err) return err } - var jobToDelete v1.Job for _, job := range jobList.Items { - if job.ObjectMeta.GenerateName == workflowGenerateName { - jobToDelete = job - break - } - } - if len(jobToDelete.Name) > 0 { - err = clientset.BatchV1().Jobs(namespace).Delete(context.Background(), jobToDelete.Name, v12.DeleteOptions{}) + err = clientset.BatchV1().Jobs(namespace).Delete(context.Background(), job.Name, v12.DeleteOptions{}) if err != nil { if errors.IsNotFound(err) { - err = fmt.Errorf("cannot find job workflow %s", jobToDelete.Name) + err = fmt.Errorf("cannot find job workflow %s", job.Name) } - impl.logger.Errorw("error occurred while deleting workflow", "workflowName", jobToDelete.Name, "namespace", namespace, "err", err) + impl.logger.Errorw("error occurred while deleting workflow", "workflowName", job.Name, "namespace", namespace, "err", err) return err } } diff --git a/pkg/pipeline/types/Workflow.go b/pkg/pipeline/types/Workflow.go index 23fa62023dc..ef6014351a1 100644 --- a/pkg/pipeline/types/Workflow.go +++ b/pkg/pipeline/types/Workflow.go @@ -151,6 +151,10 @@ type WorkflowRequest struct { HostUrl string `json:"hostUrl"` } +func (workflowRequest *WorkflowRequest) AddExtraLabelsInWorkflowTemplate() { + workflowRequest.AppLabels[WorkflowGenerateNamePrefix] = workflowRequest.WorkflowNamePrefix +} + func (workflowRequest *WorkflowRequest) updateExternalRunMetadata() { pipeline := workflowRequest.Pipeline env := workflowRequest.Env @@ -589,13 +593,13 @@ func updateContainerEnvs(isCM bool, workflowMainContainer *v1.Container, configS } } -const PRE = "PRE" - -const POST = "POST" - -const CI_NODE_PVC_ALL_ENV = "devtron.ai/ci-pvc-all" - -const CI_NODE_PVC_PIPELINE_PREFIX = "devtron.ai/ci-pvc" +const ( + PRE = "PRE" + POST = "POST" + CI_NODE_PVC_ALL_ENV = "devtron.ai/ci-pvc-all" + CI_NODE_PVC_PIPELINE_PREFIX = "devtron.ai/ci-pvc" + WorkflowGenerateNamePrefix = "devtron.ai/generate-name-prefix" +) type CiArtifactDTO struct { Id int `json:"id"` From 77950002776aaad2aaa23497119c56eef275aec2 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 21 Oct 2024 12:09:27 +0530 Subject: [PATCH 49/65] default version support --- .../DeploymentConfigurationService.go | 39 +++++++++++++++++++ pkg/configDiff/bean/bean.go | 1 + 2 files changed, 40 insertions(+) diff --git a/pkg/configDiff/DeploymentConfigurationService.go b/pkg/configDiff/DeploymentConfigurationService.go index a1ea3d2482d..160e620df23 100644 --- a/pkg/configDiff/DeploymentConfigurationService.go +++ b/pkg/configDiff/DeploymentConfigurationService.go @@ -482,6 +482,13 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration configDataDto := &bean2.DeploymentAndCmCsConfigDto{} var err error switch configDataQueryParams.ConfigType { + case bean2.DefaultVersion.ToString(): + configDataDto, err = impl.getDeploymentAndCmCsConfigDataForDefaultVersion(ctx, configDataQueryParams) + if err != nil { + impl.logger.Errorw("GetAllConfigData, error in config data for Default version", "configDataQueryParams", configDataQueryParams, "err", err) + return nil, err + } + //no cm or cs to send for default versions case bean2.PreviousDeployments.ToString(): configDataDto, err = impl.getDeploymentAndCmCsConfigDataForPreviousDeployments(ctx, configDataQueryParams, appId, envId, userHasAdminAccess) if err != nil { @@ -498,6 +505,38 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration return configDataDto, nil } +func (impl *DeploymentConfigurationServiceImpl) getDeploymentsConfigForDefaultVersion(ctx context.Context, chartRefId int) (json.RawMessage, error) { + deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{ + ChartRefId: chartRefId, + RequestDataMode: generateManifest.Values, + Type: repository2.DefaultVersions, + } + deploymentTemplateResponse, err := impl.deploymentTemplateService.GetDeploymentTemplate(ctx, deploymentTemplateRequest) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in getting deployment template for ", "deploymentTemplateRequest", deploymentTemplateRequest, "err", err) + return nil, err + } + deploymentJson := json.RawMessage{} + err = deploymentJson.UnmarshalJSON([]byte(deploymentTemplateResponse.Data)) + if err != nil { + impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "data", deploymentTemplateResponse.Data, "err", err) + return nil, err + } + return deploymentJson, nil +} + +func (impl *DeploymentConfigurationServiceImpl) getDeploymentAndCmCsConfigDataForDefaultVersion(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfigDto, error) { + configData := &bean2.DeploymentAndCmCsConfigDto{} + deploymentTemplateJsonData, err := impl.getDeploymentsConfigForDefaultVersion(ctx, configDataQueryParams.IdentifierId) + if err != nil { + impl.logger.Errorw("GetAllConfigData, error in getting deployment config for default version", "chartRefId", configDataQueryParams.IdentifierId, "err", err) + return nil, err + } + deploymentConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentTemplateJsonData).WithResourceType(bean.DeploymentTemplate) + configData.WithDeploymentTemplateData(deploymentConfig) + return configData, nil +} + func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, envId, appId int, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) { configDataDto := &bean2.DeploymentAndCmCsConfigDto{} diff --git a/pkg/configDiff/bean/bean.go b/pkg/configDiff/bean/bean.go index 30e183a229a..da4905e29c8 100644 --- a/pkg/configDiff/bean/bean.go +++ b/pkg/configDiff/bean/bean.go @@ -14,6 +14,7 @@ type ConfigState string const ( PublishedConfigState ConfigState = "PublishedOnly" PreviousDeployments ConfigState = "PreviousDeployments" + DefaultVersion ConfigState = "DefaultVersion" ) func (r ConfigState) ToString() string { From 0cc28c33e74f3ba1a630a87f684bc53d1d01f5ec Mon Sep 17 00:00:00 2001 From: iamayushm <32041961+iamayushm@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:00:52 +0900 Subject: [PATCH 50/65] chore: Trigger clean (#6004) * trigger service import * manual Cd trigger sync * migration point * trigger service code sync * wf runner impl * return chartType * cd WIP * pree deploy sorted * refactor stage one * misc: Replaced != with <> for PostgreSQL compatibility (#5987) * error handling while creating github repo * Replaced != with <> for PostgreSQL compatibility * removed deployment group validation when deleting CD pipelines (#5989) * extracting logic for cd trigger in function (already present on enterprise) * adding extra error * wip: adding back migration code --------- Co-authored-by: nishant Co-authored-by: prakhar katiyar <39842461+prkhrkat@users.noreply.github.com> --- .../trigger/PipelineTriggerRestHandler.go | 4 +- .../AppListingRepositoryQueryBuilder.go | 2 +- .../deployedApp/DeployedAppService.go | 2 +- .../gitOps/git/GitOperationService.go | 5 + .../devtronApps/PreStageTriggerService.go | 51 ++++ .../trigger/devtronApps/TriggerService.go | 235 +++++++++++------- .../trigger/devtronApps/bean/bean.go | 11 + .../in/CDPipelineEventProcessorService.go | 2 +- .../DeploymentPipelineConfigService.go | 26 -- pkg/workflow/dag/WorkflowDagExecutor.go | 36 +-- wire_gen.go | 4 +- 11 files changed, 232 insertions(+), 146 deletions(-) diff --git a/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go b/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go index 6415e556a05..0902c3eb837 100644 --- a/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go +++ b/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go @@ -144,14 +144,14 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit triggerContext := bean3.TriggerContext{ Context: ctx, } - mergeResp, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest) + mergeResp, helmPackageName, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest) span.End() if err != nil { handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest) common.WriteJsonResp(w, err, err.Error(), http.StatusInternalServerError) return } - res := map[string]interface{}{"releaseId": mergeResp} + res := map[string]interface{}{"releaseId": mergeResp, "helmPackageName": helmPackageName} common.WriteJsonResp(w, err, res, http.StatusOK) } diff --git a/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go b/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go index bfb751025d1..ae7d0136966 100644 --- a/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go +++ b/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go @@ -260,7 +260,7 @@ func (impl AppListingRepositoryQueryBuilder) buildAppListingWhereCondition(appLi } if isNotDeployedFilterApplied { deploymentAppType := "manifest_download" - whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type != ? or dc.deployment_app_type != ? ) or a.id NOT IN (SELECT app_id from pipeline) " + whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type <> ? or dc.deployment_app_type <> ? ) or a.id NOT IN (SELECT app_id from pipeline) " queryParams = append(queryParams, false, deploymentAppType, deploymentAppType) if len(appStatusExcludingNotDeployed) > 0 { whereCondition += " or aps.status IN (?) " diff --git a/pkg/deployment/deployedApp/DeployedAppService.go b/pkg/deployment/deployedApp/DeployedAppService.go index 64f0b0b1a1f..be9e9f8d623 100644 --- a/pkg/deployment/deployedApp/DeployedAppService.go +++ b/pkg/deployment/deployedApp/DeployedAppService.go @@ -110,7 +110,7 @@ func (impl *DeployedAppServiceImpl) StopStartApp(ctx context.Context, stopReques Context: ctx, ReferenceId: stopRequest.ReferenceId, } - id, err := impl.cdTriggerService.ManualCdTrigger(triggerContext, overrideRequest) + id, _, err := impl.cdTriggerService.ManualCdTrigger(triggerContext, overrideRequest) if err != nil { impl.logger.Errorw("error in stopping app", "err", err, "appId", stopRequest.AppId, "envId", stopRequest.EnvironmentId) return 0, err diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index 5ce732825de..7e3b9eb4bb5 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -56,6 +56,7 @@ type GitOperationService interface { CloneInDir(repoUrl, chartDir string) (string, error) ReloadGitOpsProvider() error UpdateGitHostUrlByProvider(request *apiBean.GitOpsConfigDto) error + GetRepoUrlWithUserName(url string) (string, error) } type GitOperationServiceImpl struct { @@ -475,3 +476,7 @@ func (impl *GitOperationServiceImpl) addConfigFileToChart(config *ChartConfig, d } return nil } + +func (impl *GitOperationServiceImpl) GetRepoUrlWithUserName(url string) (string, error) { + return url, nil +} diff --git a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go index 010d3986d57..33e47e6b1a9 100644 --- a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go +++ b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go @@ -146,6 +146,57 @@ func (impl *TriggerServiceImpl) TriggerPreStage(request bean.TriggerRequest) err return nil } +func (impl *TriggerServiceImpl) TriggerAutoCDOnPreStageSuccess(triggerContext bean.TriggerContext, cdPipelineId, ciArtifactId, workflowId int, triggerdBy int32, scanExecutionHistoryId int) error { + pipeline, err := impl.pipelineRepository.FindById(cdPipelineId) + if err != nil { + return err + } + if pipeline.TriggerType == pipelineConfig.TRIGGER_TYPE_AUTOMATIC { + ciArtifact, err := impl.ciArtifactRepository.Get(ciArtifactId) + if err != nil { + return err + } + cdWorkflow, err := impl.cdWorkflowRepository.FindById(workflowId) + if err != nil { + return err + } + // TODO : confirm about this logic used for applyAuth + + // checking if deployment is triggered already, then ignore trigger + deploymentTriggeredAlready := impl.checkDeploymentTriggeredAlready(cdWorkflow.Id) + if deploymentTriggeredAlready { + impl.logger.Warnw("deployment is already triggered, so ignoring this msg", "cdPipelineId", cdPipelineId, "ciArtifactId", ciArtifactId, "workflowId", workflowId) + return nil + } + + triggerRequest := bean.TriggerRequest{ + CdWf: cdWorkflow, + Pipeline: pipeline, + Artifact: ciArtifact, + TriggeredBy: triggerdBy, + TriggerContext: triggerContext, + } + + triggerRequest.TriggerContext.Context = context.Background() + err = impl.TriggerAutomaticDeployment(triggerRequest) + if err != nil { + return err + } + } + return nil +} +func (impl *TriggerServiceImpl) checkDeploymentTriggeredAlready(wfId int) bool { + deploymentTriggeredAlready := false + // TODO : need to check this logic for status check in case of multiple deployments requirement for same workflow + workflowRunner, err := impl.cdWorkflowRepository.FindByWorkflowIdAndRunnerType(context.Background(), wfId, bean2.CD_WORKFLOW_TYPE_DEPLOY) + if err != nil { + impl.logger.Errorw("error occurred while fetching workflow runner", "wfId", wfId, "err", err) + return deploymentTriggeredAlready + } + deploymentTriggeredAlready = workflowRunner.CdWorkflowId == wfId + return deploymentTriggeredAlready +} + func (impl *TriggerServiceImpl) createStartingWfAndRunner(request bean.TriggerRequest, triggeredAt time.Time) (*pipelineConfig.CdWorkflow, *pipelineConfig.CdWorkflowRunner, error) { triggeredBy := request.TriggeredBy artifact := request.Artifact diff --git a/pkg/deployment/trigger/devtronApps/TriggerService.go b/pkg/deployment/trigger/devtronApps/TriggerService.go index 49ad2949eca..a4ffae1c152 100644 --- a/pkg/deployment/trigger/devtronApps/TriggerService.go +++ b/pkg/deployment/trigger/devtronApps/TriggerService.go @@ -56,6 +56,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/common" bean9 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest" bean5 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "github.com/devtron-labs/devtron/pkg/deployment/manifest/publish" @@ -77,7 +78,7 @@ import ( "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/workflow/cd" - util3 "github.com/devtron-labs/devtron/util" + globalUtil "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" util2 "github.com/devtron-labs/devtron/util/event" "github.com/devtron-labs/devtron/util/rbac" @@ -100,9 +101,11 @@ type TriggerService interface { TriggerPostStage(request bean.TriggerRequest) error TriggerPreStage(request bean.TriggerRequest) error + TriggerAutoCDOnPreStageSuccess(triggerContext bean.TriggerContext, cdPipelineId, ciArtifactId, workflowId int, triggerdBy int32, scanExecutionHistoryId int) error + TriggerStageForBulk(triggerRequest bean.TriggerRequest) error - ManualCdTrigger(triggerContext bean.TriggerContext, overrideRequest *bean3.ValuesOverrideRequest) (int, error) + ManualCdTrigger(triggerContext bean.TriggerContext, overrideRequest *bean3.ValuesOverrideRequest) (int, string, error) TriggerAutomaticDeployment(request bean.TriggerRequest) error TriggerRelease(overrideRequest *bean3.ValuesOverrideRequest, envDeploymentConfig *bean9.DeploymentConfig, ctx context.Context, triggeredAt time.Time, triggeredBy int32) (releaseNo int, err error) @@ -120,7 +123,7 @@ type TriggerServiceImpl struct { chartTemplateService util.ChartTemplateService eventFactory client.EventFactory eventClient client.EventClient - globalEnvVariables *util3.GlobalEnvVariables + globalEnvVariables *globalUtil.GlobalEnvVariables workflowEventPublishService out.WorkflowEventPublishService manifestCreationService manifest.ManifestCreationService deployedConfigurationHistoryService history.DeployedConfigurationHistoryService @@ -163,8 +166,9 @@ type TriggerServiceImpl struct { K8sUtil *util5.K8sServiceImpl transactionUtilImpl *sql.TransactionUtilImpl deploymentConfigService common.DeploymentConfigService - deploymentServiceTypeConfig *util3.DeploymentServiceTypeConfig + deploymentServiceTypeConfig *globalUtil.DeploymentServiceTypeConfig ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator + gitOperationService git.GitOperationService attributeService attributes.AttributesService } @@ -197,7 +201,7 @@ func NewTriggerServiceImpl(logger *zap.SugaredLogger, helmAppClient gRPC.HelmAppClient, eventFactory client.EventFactory, eventClient client.EventClient, - envVariables *util3.EnvironmentVariables, + envVariables *globalUtil.EnvironmentVariables, appRepository appRepository.AppRepository, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, imageScanHistoryRepository security.ImageScanHistoryRepository, @@ -220,7 +224,9 @@ func NewTriggerServiceImpl(logger *zap.SugaredLogger, K8sUtil *util5.K8sServiceImpl, transactionUtilImpl *sql.TransactionUtilImpl, deploymentConfigService common.DeploymentConfigService, - ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator, attributeService attributes.AttributesService, + ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator, + gitOperationService git.GitOperationService, + attributeService attributes.AttributesService, ) (*TriggerServiceImpl, error) { impl := &TriggerServiceImpl{ logger: logger, @@ -277,6 +283,7 @@ func NewTriggerServiceImpl(logger *zap.SugaredLogger, deploymentConfigService: deploymentConfigService, deploymentServiceTypeConfig: envVariables.DeploymentServiceTypeConfig, ciCdPipelineOrchestrator: ciCdPipelineOrchestrator, + gitOperationService: gitOperationService, attributeService: attributeService, } config, err := types.GetCdConfig() @@ -369,54 +376,91 @@ func (impl *TriggerServiceImpl) validateDeploymentTriggerRequest(ctx context.Con } // TODO: write a wrapper to handle auto and manual trigger -func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerContext, overrideRequest *bean3.ValuesOverrideRequest) (int, error) { +func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerContext, overrideRequest *bean3.ValuesOverrideRequest) (int, string, error) { + + triggerContext.TriggerType = bean.Manual //setting triggeredAt variable to have consistent data for various audit log places in db for deployment time triggeredAt := time.Now() releaseId := 0 ctx := triggerContext.Context - var err error cdPipeline, err := impl.getCdPipelineForManualCdTrigger(ctx, overrideRequest.PipelineId) if err != nil { - return 0, err + if overrideRequest.WfrId != 0 { + err2 := impl.cdWorkflowCommonService.MarkDeploymentFailedForRunnerId(overrideRequest.WfrId, err, overrideRequest.UserId) + if err2 != nil { + impl.logger.Errorw("error while updating current runner status to failed, ManualCdTrigger", "cdWfr", overrideRequest.WfrId, "err2", err2) + } + } + return 0, "", err } envDeploymentConfig, err := impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(cdPipeline.AppId, cdPipeline.EnvironmentId) if err != nil { impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", cdPipeline.AppId, "envId", cdPipeline.EnvironmentId, "err", err) - return 0, err + return 0, "", err } adapter.SetPipelineFieldsInOverrideRequest(overrideRequest, cdPipeline, envDeploymentConfig) + ciArtifactId := overrideRequest.CiArtifactId + + _, span := otel.Tracer("orchestrator").Start(ctx, "ciArtifactRepository.Get") + artifact, err := impl.ciArtifactRepository.Get(ciArtifactId) + span.End() + if err != nil { + impl.logger.Errorw("error in getting CiArtifact", "CiArtifactId", overrideRequest.CiArtifactId, "err", err) + return 0, "", err + } + + // Migration of deprecated DataSource Type + if artifact.IsMigrationRequired() { + migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id) + if migrationErr != nil { + impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id) + } + } + + _, imageTag, err := artifact.ExtractImageRepoAndTag() + if err != nil { + impl.logger.Errorw("error in getting image tag and repo", "err", err) + } + helmPackageName := fmt.Sprintf("%s-%s-%s", cdPipeline.App.AppName, cdPipeline.Environment.Name, imageTag) switch overrideRequest.CdWorkflowType { case bean3.CD_WORKFLOW_TYPE_PRE: - _, span := otel.Tracer("orchestrator").Start(ctx, "ciArtifactRepository.Get") - artifact, err := impl.ciArtifactRepository.Get(overrideRequest.CiArtifactId) - span.End() - if err != nil { - impl.logger.Errorw("error in getting CiArtifact", "CiArtifactId", overrideRequest.CiArtifactId, "err", err) - return 0, err - } - // Migration of deprecated DataSource Type - if artifact.IsMigrationRequired() { - migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id) - if migrationErr != nil { - impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id) + var cdWf *pipelineConfig.CdWorkflow + if overrideRequest.CdWorkflowId == 0 { + cdWf = &pipelineConfig.CdWorkflow{ + CiArtifactId: artifact.Id, + PipelineId: cdPipeline.Id, + AuditLog: sql.AuditLog{CreatedOn: triggeredAt, CreatedBy: 1, UpdatedOn: triggeredAt, UpdatedBy: 1}, + } + err := impl.cdWorkflowRepository.SaveWorkFlow(ctx, cdWf) + if err != nil { + return 0, "", err + } + } else { + cdWf, err = impl.cdWorkflowRepository.FindById(overrideRequest.CdWorkflowId) + if err != nil { + impl.logger.Errorw("error in TriggerPreStage, ManualCdTrigger", "err", err) + return 0, "", err } } + overrideRequest.CdWorkflowId = cdWf.Id + _, span = otel.Tracer("orchestrator").Start(ctx, "TriggerPreStage") triggerRequest := bean.TriggerRequest{ - CdWf: nil, + CdWf: cdWf, Artifact: artifact, Pipeline: cdPipeline, TriggeredBy: overrideRequest.UserId, ApplyAuth: false, TriggerContext: triggerContext, RefCdWorkflowRunnerId: 0, + CdWorkflowRunnerId: overrideRequest.WfrId, } err = impl.TriggerPreStage(triggerRequest) span.End() if err != nil { impl.logger.Errorw("error in TriggerPreStage, ManualCdTrigger", "err", err) - return 0, err + return 0, "", err } case bean3.CD_WORKFLOW_TYPE_DEPLOY: if overrideRequest.DeploymentType == models.DEPLOYMENTTYPE_UNKNOWN { @@ -426,7 +470,7 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte cdWf, err := impl.cdWorkflowRepository.FindByWorkflowIdAndRunnerType(ctx, overrideRequest.CdWorkflowId, bean3.CD_WORKFLOW_TYPE_PRE) if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("error in getting cdWorkflow, ManualCdTrigger", "CdWorkflowId", overrideRequest.CdWorkflowId, "err", err) - return 0, err + return 0, "", err } cdWorkflowId := cdWf.CdWorkflowId @@ -439,7 +483,7 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte err := impl.cdWorkflowRepository.SaveWorkFlow(ctx, cdWf) if err != nil { impl.logger.Errorw("error in creating cdWorkflow, ManualCdTrigger", "PipelineId", overrideRequest.PipelineId, "err", err) - return 0, err + return 0, "", err } cdWorkflowId = cdWf.Id } @@ -457,43 +501,29 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte ReferenceId: triggerContext.ReferenceId, } savedWfr, err := impl.cdWorkflowRepository.SaveWorkFlowRunner(runner) - overrideRequest.WfrId = savedWfr.Id if err != nil { impl.logger.Errorw("err in creating cdWorkflowRunner, ManualCdTrigger", "cdWorkflowId", cdWorkflowId, "err", err) - return 0, err + return 0, "", err } runner.CdWorkflow = &pipelineConfig.CdWorkflow{ Pipeline: cdPipeline, } + overrideRequest.WfrId = savedWfr.Id overrideRequest.CdWorkflowId = cdWorkflowId // creating cd pipeline status timeline for deployment initialisation - timeline := impl.pipelineStatusTimelineService.NewDevtronAppPipelineStatusTimelineDbObject(savedWfr.Id, timelineStatus.TIMELINE_STATUS_DEPLOYMENT_INITIATED, timelineStatus.TIMELINE_DESCRIPTION_DEPLOYMENT_INITIATED, overrideRequest.UserId) - _, span := otel.Tracer("orchestrator").Start(ctx, "cdPipelineStatusTimelineRepo.SaveTimelineForACDHelmApps") + timeline := impl.pipelineStatusTimelineService.NewDevtronAppPipelineStatusTimelineDbObject(runner.Id, timelineStatus.TIMELINE_STATUS_DEPLOYMENT_INITIATED, timelineStatus.TIMELINE_DESCRIPTION_DEPLOYMENT_INITIATED, overrideRequest.UserId) + _, span = otel.Tracer("orchestrator").Start(ctx, "cdPipelineStatusTimelineRepo.SaveTimelineForACDHelmApps") _, err = impl.pipelineStatusTimelineService.SaveTimelineIfNotAlreadyPresent(timeline, nil) span.End() if err != nil { impl.logger.Errorw("error in creating timeline status for deployment initiation, ManualCdTrigger", "err", err, "timeline", timeline) } - _, span = otel.Tracer("orchestrator").Start(ctx, "ciArtifactRepository.Get") - artifact, err := impl.ciArtifactRepository.Get(overrideRequest.CiArtifactId) - span.End() - if err != nil { - impl.logger.Errorw("error in getting ciArtifact, ManualCdTrigger", "CiArtifactId", overrideRequest.CiArtifactId, "err", err) - return 0, err - } - // Migration of deprecated DataSource Type - if artifact.IsMigrationRequired() { - migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id) - if migrationErr != nil { - impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id) - } - } if isNotHibernateRequest(overrideRequest.DeploymentType) { validationErr := impl.validateDeploymentTriggerRequest(ctx, runner, cdPipeline, artifact.ImageDigest, envDeploymentConfig, overrideRequest.UserId) if validationErr != nil { impl.logger.Errorw("validation error deployment request", "cdWfr", runner.Id, "err", validationErr) - return 0, validationErr + return 0, "", validationErr } } // Deploy the release @@ -505,57 +535,58 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte if err != nil { impl.logger.Errorw("error while updating current runner status to failed", "cdWfr", runner.Id, "err", err) } - return 0, releaseErr + return 0, "", releaseErr } case bean3.CD_WORKFLOW_TYPE_POST: cdWfRunner, err := impl.cdWorkflowRepository.FindByWorkflowIdAndRunnerType(ctx, overrideRequest.CdWorkflowId, bean3.CD_WORKFLOW_TYPE_DEPLOY) if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("err in getting cdWorkflowRunner, ManualCdTrigger", "cdWorkflowId", overrideRequest.CdWorkflowId, "err", err) - return 0, err + return 0, "", err } var cdWf *pipelineConfig.CdWorkflow if cdWfRunner.CdWorkflowId == 0 { cdWf = &pipelineConfig.CdWorkflow{ - CiArtifactId: overrideRequest.CiArtifactId, + CiArtifactId: ciArtifactId, PipelineId: overrideRequest.PipelineId, AuditLog: sql.AuditLog{CreatedOn: triggeredAt, CreatedBy: overrideRequest.UserId, UpdatedOn: triggeredAt, UpdatedBy: overrideRequest.UserId}, } err := impl.cdWorkflowRepository.SaveWorkFlow(ctx, cdWf) if err != nil { impl.logger.Errorw("error in creating cdWorkflow, ManualCdTrigger", "CdWorkflowId", overrideRequest.CdWorkflowId, "err", err) - return 0, err + return 0, "", err } + overrideRequest.CdWorkflowId = cdWf.Id } else { - _, span := otel.Tracer("orchestrator").Start(ctx, "cdWorkflowRepository.FindById") + _, span = otel.Tracer("orchestrator").Start(ctx, "cdWorkflowRepository.FindById") cdWf, err = impl.cdWorkflowRepository.FindById(overrideRequest.CdWorkflowId) span.End() if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("error in getting cdWorkflow, ManualCdTrigger", "CdWorkflowId", overrideRequest.CdWorkflowId, "err", err) - return 0, err + return 0, "", err } } - _, span := otel.Tracer("orchestrator").Start(ctx, "TriggerPostStage") + _, span = otel.Tracer("orchestrator").Start(ctx, "TriggerPostStage") triggerRequest := bean.TriggerRequest{ CdWf: cdWf, Pipeline: cdPipeline, TriggeredBy: overrideRequest.UserId, RefCdWorkflowRunnerId: 0, TriggerContext: triggerContext, + CdWorkflowRunnerId: overrideRequest.WfrId, } err = impl.TriggerPostStage(triggerRequest) span.End() if err != nil { impl.logger.Errorw("error in TriggerPostStage, ManualCdTrigger", "CdWorkflowId", cdWf.Id, "err", err) - return 0, err + return 0, "", err } default: impl.logger.Errorw("invalid CdWorkflowType, ManualCdTrigger", "CdWorkflowType", overrideRequest.CdWorkflowType, "err", err) - return 0, fmt.Errorf("invalid CdWorkflowType %s for the trigger request", string(overrideRequest.CdWorkflowType)) + return 0, "", fmt.Errorf("invalid CdWorkflowType %s for the trigger request", string(overrideRequest.CdWorkflowType)) } - - return releaseId, err + return releaseId, helmPackageName, err } func isNotHibernateRequest(deploymentType models.DeploymentType) bool { @@ -643,8 +674,12 @@ func (impl *TriggerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR func (impl *TriggerServiceImpl) TriggerCD(ctx context.Context, artifact *repository3.CiArtifact, cdWorkflowId, wfrId int, pipeline *pipelineConfig.Pipeline, envDeploymentConfig *bean9.DeploymentConfig, triggeredAt time.Time) error { impl.logger.Debugw("automatic pipeline trigger attempt async", "artifactId", artifact.Id) - - return impl.triggerReleaseAsync(ctx, artifact, cdWorkflowId, wfrId, pipeline, envDeploymentConfig, triggeredAt) + err := impl.triggerReleaseAsync(ctx, artifact, cdWorkflowId, wfrId, pipeline, envDeploymentConfig, triggeredAt) + if err != nil { + impl.logger.Errorw("error in cd trigger", "err", err) + return err + } + return err } func (impl *TriggerServiceImpl) triggerReleaseAsync(ctx context.Context, artifact *repository3.CiArtifact, cdWorkflowId, wfrId int, pipeline *pipelineConfig.Pipeline, envDeploymentConfig *bean9.DeploymentConfig, triggeredAt time.Time) error { @@ -841,10 +876,10 @@ func (impl *TriggerServiceImpl) performGitOps(ctx context.Context, impl.logger.Errorw("error in building manifest push template", "err", err) return err } - manifestPushService := impl.getManifestPushService(triggerEvent) + manifestPushService := impl.getManifestPushService(triggerEvent.ManifestStorageType) manifestPushResponse := manifestPushService.PushChart(newCtx, manifestPushTemplate) if manifestPushResponse.Error != nil { - impl.logger.Errorw("error in pushing manifest to git", "err", manifestPushResponse.Error, "git_repo_url", manifestPushTemplate.RepoUrl) + impl.logger.Errorw("error in pushing manifest to git/helm", "err", manifestPushResponse.Error, "git_repo_url", manifestPushTemplate.RepoUrl) return manifestPushResponse.Error } if manifestPushResponse.IsNewGitRepoConfigured() { @@ -907,7 +942,7 @@ func (impl *TriggerServiceImpl) triggerPipeline(overrideRequest *bean3.ValuesOve } } - go impl.writeCDTriggerEvent(overrideRequest, valuesOverrideResponse.Artifact, valuesOverrideResponse.PipelineOverride.PipelineReleaseCounter, valuesOverrideResponse.PipelineOverride.Id) + go impl.writeCDTriggerEvent(overrideRequest, valuesOverrideResponse.Artifact, valuesOverrideResponse.PipelineOverride.PipelineReleaseCounter, valuesOverrideResponse.PipelineOverride.Id, overrideRequest.WfrId) _ = impl.markImageScanDeployed(newCtx, overrideRequest.AppId, overrideRequest.EnvId, overrideRequest.ClusterId, valuesOverrideResponse.Artifact.ImageDigest, valuesOverrideResponse.Artifact.ScanEnabled, valuesOverrideResponse.Artifact.Image) @@ -961,9 +996,9 @@ func (impl *TriggerServiceImpl) buildManifestPushTemplate(overrideRequest *bean3 return manifestPushTemplate, err } -func (impl *TriggerServiceImpl) getManifestPushService(triggerEvent bean.TriggerEvent) publish.ManifestPushService { +func (impl *TriggerServiceImpl) getManifestPushService(storageType string) publish.ManifestPushService { var manifestPushService publish.ManifestPushService - if triggerEvent.ManifestStorageType == bean2.ManifestStorageGit { + if storageType == bean2.ManifestStorageGit { manifestPushService = impl.gitOpsManifestPushService } return manifestPushService @@ -972,23 +1007,31 @@ func (impl *TriggerServiceImpl) getManifestPushService(triggerEvent bean.Trigger func (impl *TriggerServiceImpl) deployApp(ctx context.Context, overrideRequest *bean3.ValuesOverrideRequest, valuesOverrideResponse *app.ValuesOverrideResponse, triggerEvent bean.TriggerEvent) error { newCtx, span := otel.Tracer("orchestrator").Start(ctx, "TriggerServiceImpl.deployApp") defer span.End() + var referenceChartByte []byte + var err error + if util.IsAcdApp(overrideRequest.DeploymentAppType) && triggerEvent.DeployArgoCdApp { - err := impl.deployArgoCdApp(newCtx, overrideRequest, valuesOverrideResponse) + err = impl.deployArgoCdApp(newCtx, overrideRequest, valuesOverrideResponse) if err != nil { impl.logger.Errorw("error in deploying app on ArgoCd", "err", err) return err } } else if util.IsHelmApp(overrideRequest.DeploymentAppType) { - _, err := impl.createHelmAppForCdPipeline(newCtx, overrideRequest, valuesOverrideResponse) + _, referenceChartByte, err = impl.createHelmAppForCdPipeline(newCtx, overrideRequest, valuesOverrideResponse) if err != nil { impl.logger.Errorw("error in creating or updating helm application for cd pipeline", "err", err) return err } } + impl.postDeployHook(overrideRequest, valuesOverrideResponse, referenceChartByte, err) return nil } -func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, overrideRequest *bean3.ValuesOverrideRequest, valuesOverrideResponse *app.ValuesOverrideResponse) (bool, error) { +func (impl *TriggerServiceImpl) postDeployHook(overrideRequest *bean3.ValuesOverrideRequest, valuesOverrideResponse *app.ValuesOverrideResponse, referenceChartByte []byte, err error) { + impl.logger.Debugw("no post deploy hook registered") +} + +func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, overrideRequest *bean3.ValuesOverrideRequest, valuesOverrideResponse *app.ValuesOverrideResponse) (bool, []byte, error) { newCtx, span := otel.Tracer("orchestrator").Start(ctx, "TriggerServiceImpl.createHelmAppForCdPipeline") defer span.End() pipelineModel := valuesOverrideResponse.Pipeline @@ -1001,7 +1044,7 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, } referenceTemplate := envOverride.Chart.ReferenceTemplate referenceTemplatePath := path.Join(bean5.RefChartDirPath, referenceTemplate) - + var referenceChartByte []byte if util.IsHelmApp(valuesOverrideResponse.DeploymentConfig.DeploymentAppType) { var sanitizedK8sVersion string //handle specific case for all cronjob charts from cronjob-chart_1-2-0 to cronjob-chart_1-5-0 where semverCompare @@ -1012,17 +1055,17 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, k8sServerVersion, err := impl.K8sUtil.GetKubeVersion() if err != nil { impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err) - return false, err + return false, nil, err } sanitizedK8sVersion = k8s2.StripPrereleaseFromK8sVersion(k8sServerVersion.String()) } - referenceChartByte := envOverride.Chart.ReferenceChart + referenceChartByte = envOverride.Chart.ReferenceChart // here updating reference chart into database. if len(envOverride.Chart.ReferenceChart) == 0 { refChartByte, err := impl.chartTemplateService.GetByteArrayRefChart(chartMetaData, referenceTemplatePath) if err != nil { impl.logger.Errorw("ref chart commit error on cd trigger", "err", err, "req", overrideRequest) - return false, err + return false, nil, err } ch := envOverride.Chart ch.ReferenceChart = refChartByte @@ -1031,7 +1074,7 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, err = impl.chartRepository.Update(ch) if err != nil { impl.logger.Errorw("chart update error", "err", err, "req", overrideRequest) - return false, err + return false, nil, err } referenceChartByte = refChartByte } @@ -1074,15 +1117,15 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, if err != nil { impl.logger.Errorw("error in updating helm application for cd pipelineModel", "err", err) if util.IsErrorContextCancelled(err) { - return false, cdWorkflow.ErrorDeploymentSuperseded + return false, nil, cdWorkflow.ErrorDeploymentSuperseded } else if util.IsErrorContextDeadlineExceeded(err) { - return false, context.DeadlineExceeded + return false, nil, context.DeadlineExceeded } apiError := clientErrors.ConvertToApiError(err) if apiError != nil { - return false, apiError + return false, nil, apiError } - return false, err + return false, nil, err } else { impl.logger.Debugw("updated helm application", "response", updateApplicationResponse, "isSuccess", updateApplicationResponse.Success) } @@ -1095,7 +1138,7 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, // For connection related errors, no need to update the db if err != nil && strings.Contains(err.Error(), "connection error") { impl.logger.Errorw("error in helm install custom chart", "err", err) - return false, err + return false, nil, err } // IMP: update cd pipelineModel to mark deployment app created, even if helm install fails @@ -1109,20 +1152,20 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, impl.logger.Errorw("failed to update deployment app created flag in pipelineModel table", "err", err) } if util.IsErrorContextCancelled(err) { - return false, cdWorkflow.ErrorDeploymentSuperseded + return false, nil, cdWorkflow.ErrorDeploymentSuperseded } else if util.IsErrorContextDeadlineExceeded(err) { - return false, context.DeadlineExceeded + return false, nil, context.DeadlineExceeded } apiError := clientErrors.ConvertToApiError(err) if apiError != nil { - return false, apiError + return false, nil, apiError } - return false, err + return false, nil, err } if pgErr != nil { impl.logger.Errorw("failed to update deployment app created flag in pipelineModel table", "err", err) - return false, err + return false, nil, err } impl.logger.Debugw("received helm release response", "helmResponse", helmResponse, "isSuccess", helmResponse.Success) @@ -1132,10 +1175,10 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(ctx context.Context, err := impl.cdWorkflowCommonService.UpdateNonTerminalStatusInRunner(newCtx, overrideRequest.WfrId, overrideRequest.UserId, cdWorkflow.WorkflowInProgress) if err != nil { impl.logger.Errorw("error in updating the workflow runner status, createHelmAppForCdPipeline", "err", err) - return false, err + return false, nil, err } } - return true, nil + return true, referenceChartByte, nil } func (impl *TriggerServiceImpl) deployArgoCdApp(ctx context.Context, overrideRequest *bean3.ValuesOverrideRequest, @@ -1208,6 +1251,11 @@ func (impl *TriggerServiceImpl) updateArgoPipeline(ctx context.Context, pipeline TargetRevision: bean7.TargetRevisionMaster, PatchType: bean7.PatchTypeMerge, } + url, err := impl.gitOperationService.GetRepoUrlWithUserName(deploymentConfig.RepoURL) + if err != nil { + return false, err + } + patchRequestDto.GitRepoUrl = url err = impl.argoClientWrapperService.PatchArgoCdApp(newCtx, patchRequestDto) if err != nil { impl.logger.Errorw("error in patching argo pipeline", "err", err, "req", patchRequestDto) @@ -1270,6 +1318,10 @@ func (impl *TriggerServiceImpl) createArgoApplicationIfRequired(ctx context.Cont RepoUrl: chart.GitRepoUrl, AutoSyncEnabled: impl.ACDConfig.ArgoCDAutoSyncEnabled, } + appRequest.RepoUrl, err = impl.gitOperationService.GetRepoUrlWithUserName(appRequest.RepoUrl) + if err != nil { + return "", err + } argoAppName, err := impl.argoK8sClient.CreateAcdApp(newCtx, appRequest, argocdServer.ARGOCD_APPLICATION_TEMPLATE) if err != nil { return "", err @@ -1313,11 +1365,19 @@ func (impl *TriggerServiceImpl) helmInstallReleaseWithCustomChart(ctx context.Co return impl.helmAppClient.InstallReleaseWithCustomChart(newCtx, &helmInstallRequest) } -func (impl *TriggerServiceImpl) writeCDTriggerEvent(overrideRequest *bean3.ValuesOverrideRequest, artifact *repository3.CiArtifact, releaseId, pipelineOverrideId int) { +func (impl *TriggerServiceImpl) getEnrichedWorkflowRunner(overrideRequest *bean3.ValuesOverrideRequest, artifact *repository3.CiArtifact, wfrId int) *pipelineConfig.CdWorkflowRunner { + return nil +} + +func (impl *TriggerServiceImpl) writeCDTriggerEvent(overrideRequest *bean3.ValuesOverrideRequest, artifact *repository3.CiArtifact, releaseId, pipelineOverrideId, wfrId int) { - event, _ := impl.eventFactory.Build(util2.Trigger, &overrideRequest.PipelineId, overrideRequest.AppId, &overrideRequest.EnvId, util2.CD) - impl.logger.Debugw("event writeCDTriggerEvent", "event", event) - event = impl.eventFactory.BuildExtraCDData(event, nil, pipelineOverrideId, bean3.CD_WORKFLOW_TYPE_DEPLOY) + event, err := impl.eventFactory.Build(util2.Trigger, &overrideRequest.PipelineId, overrideRequest.AppId, &overrideRequest.EnvId, util2.CD) + if err != nil { + impl.logger.Errorw("error in building cd trigger event", "cdPipelineId", overrideRequest.PipelineId, "err", err) + } + impl.logger.Debugw("event WriteCDTriggerEvent", "event", event) + wfr := impl.getEnrichedWorkflowRunner(overrideRequest, artifact, wfrId) + event = impl.eventFactory.BuildExtraCDData(event, wfr, pipelineOverrideId, bean3.CD_WORKFLOW_TYPE_DEPLOY) _, evtErr := impl.eventClient.WriteNotificationEvent(event) if evtErr != nil { impl.logger.Errorw("CD trigger event not sent", "error", evtErr) @@ -1355,6 +1415,7 @@ func (impl *TriggerServiceImpl) markImageScanDeployed(ctx context.Context, appId imageDigest string, isScanEnabled bool, image string) error { _, span := otel.Tracer("orchestrator").Start(ctx, "TriggerServiceImpl.markImageScanDeployed") defer span.End() + // TODO KB: send NATS event for self consumption impl.logger.Debugw("mark image scan deployed for devtron app, from cd auto or manual trigger", "imageDigest", imageDigest) executionHistory, err := impl.imageScanHistoryRepository.FindByImageAndDigest(imageDigest, image) if err != nil && !errors.Is(err, pg.ErrNoRows) { diff --git a/pkg/deployment/trigger/devtronApps/bean/bean.go b/pkg/deployment/trigger/devtronApps/bean/bean.go index c4f4a5ca5cb..bd4b5f13ab0 100644 --- a/pkg/deployment/trigger/devtronApps/bean/bean.go +++ b/pkg/deployment/trigger/devtronApps/bean/bean.go @@ -48,6 +48,7 @@ type TriggerRequest struct { RefCdWorkflowRunnerId int RunStageInEnvNamespace string WorkflowType bean.WorkflowType + CdWorkflowRunnerId int TriggerContext } @@ -58,8 +59,18 @@ type TriggerContext struct { // ReferenceId is a unique identifier for the workflow runner // refer pipelineConfig.CdWorkflowRunner ReferenceId *string + + // manual or automatic + TriggerType TriggerType } +type TriggerType int + +const ( + Automatic TriggerType = 1 + Manual TriggerType = 2 +) + type DeploymentType = string const ( diff --git a/pkg/eventProcessor/in/CDPipelineEventProcessorService.go b/pkg/eventProcessor/in/CDPipelineEventProcessorService.go index 669ce12ebdb..108f36c3941 100644 --- a/pkg/eventProcessor/in/CDPipelineEventProcessorService.go +++ b/pkg/eventProcessor/in/CDPipelineEventProcessorService.go @@ -86,7 +86,7 @@ func (impl *CDPipelineEventProcessorImpl) SubscribeCDBulkTriggerTopic() error { ReferenceId: pointer.String(msg.MsgId), Context: ctx, } - _, err = impl.cdTriggerService.ManualCdTrigger(triggerContext, event.ValuesOverrideRequest) + _, _, err = impl.cdTriggerService.ManualCdTrigger(triggerContext, event.ValuesOverrideRequest) if err != nil { impl.logger.Errorw("Error triggering CD", "topic", pubsub.CD_BULK_DEPLOY_TRIGGER_TOPIC, "msg", msg.Data, "err", err) } diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 92b3e61fc31..155687645f6 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -708,19 +708,6 @@ func (impl *CdPipelineConfigServiceImpl) DeleteCdPipeline(pipeline *pipelineConf return deleteResponse, err } - //getting deployment group for this pipeline - deploymentGroupNames, err := impl.deploymentGroupRepository.GetNamesByAppIdAndEnvId(pipeline.EnvironmentId, pipeline.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting deployment group names by appId and envId", "err", err) - return deleteResponse, err - } else if len(deploymentGroupNames) > 0 { - groupNamesByte, err := json.Marshal(deploymentGroupNames) - if err != nil { - impl.logger.Errorw("error in marshaling deployment group names", "err", err, "deploymentGroupNames", deploymentGroupNames) - } - impl.logger.Debugw("cannot delete cd pipeline, is being used in deployment group") - return deleteResponse, fmt.Errorf("Please remove this CD pipeline from deployment groups : %s", string(groupNamesByte)) - } dbConnection := impl.pipelineRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -2034,19 +2021,6 @@ func (impl *CdPipelineConfigServiceImpl) DeleteCdPipelinePartial(pipeline *pipel return deleteResponse, err } - //getting deployment group for this pipeline - deploymentGroupNames, err := impl.deploymentGroupRepository.GetNamesByAppIdAndEnvId(pipeline.EnvironmentId, pipeline.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting deployment group names by appId and envId", "err", err) - return deleteResponse, err - } else if len(deploymentGroupNames) > 0 { - groupNamesByte, err := json.Marshal(deploymentGroupNames) - if err != nil { - impl.logger.Errorw("error in marshaling deployment group names", "err", err, "deploymentGroupNames", deploymentGroupNames) - } - impl.logger.Debugw("cannot delete cd pipeline, is being used in deployment group") - return deleteResponse, fmt.Errorf("Please remove this CD pipeline from deployment groups : %s", string(groupNamesByte)) - } dbConnection := impl.pipelineRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { diff --git a/pkg/workflow/dag/WorkflowDagExecutor.go b/pkg/workflow/dag/WorkflowDagExecutor.go index 671400fedde..d174bf6029f 100644 --- a/pkg/workflow/dag/WorkflowDagExecutor.go +++ b/pkg/workflow/dag/WorkflowDagExecutor.go @@ -575,32 +575,16 @@ func (impl *WorkflowDagExecutorImpl) HandlePreStageSuccessEvent(triggerContext t impl.logger.Errorw("error in saving plugin artifacts", "err", err) return err } - if pipeline.TriggerType == pipelineConfig.TRIGGER_TYPE_AUTOMATIC { - if len(PreCDArtifacts) > 0 { - ciArtifact = PreCDArtifacts[0] // deployment will be trigger with artifact copied by plugin - } - cdWorkflow, err := impl.cdWorkflowRepository.FindById(cdStageCompleteEvent.WorkflowId) - if err != nil { - return err - } - //passing applyAuth as false since this event is for auto trigger and user who already has access to this cd can trigger pre cd also - applyAuth := false - if cdStageCompleteEvent.TriggeredBy != 1 { - applyAuth = true - } - triggerRequest := triggerBean.TriggerRequest{ - CdWf: cdWorkflow, - Pipeline: pipeline, - Artifact: ciArtifact, - ApplyAuth: applyAuth, - TriggeredBy: cdStageCompleteEvent.TriggeredBy, - TriggerContext: triggerContext, - } - triggerRequest.TriggerContext.Context = context.Background() - err = impl.cdTriggerService.TriggerAutomaticDeployment(triggerRequest) - if err != nil { - return err - } + ciArtifactId := 0 + if len(PreCDArtifacts) > 0 { + ciArtifactId = PreCDArtifacts[len(PreCDArtifacts)-1].Id // deployment will be trigger with artifact copied by plugin + } else { + ciArtifactId = cdStageCompleteEvent.CiArtifactDTO.Id + } + err = impl.cdTriggerService.TriggerAutoCDOnPreStageSuccess(triggerContext, cdStageCompleteEvent.CdPipelineId, ciArtifactId, cdStageCompleteEvent.WorkflowId, cdStageCompleteEvent.TriggeredBy, 0) + if err != nil { + impl.logger.Errorw("error in triggering cd on pre cd succcess", "err", err) + return err } } return nil diff --git a/wire_gen.go b/wire_gen.go index a53fca7b976..110c18853a3 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run github.com/google/wire/cmd/wire +//go:generate go run -mod=mod github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject @@ -662,7 +662,7 @@ func InitializeApp() (*App, error) { manifestPushConfigRepositoryImpl := repository10.NewManifestPushConfigRepository(sugaredLogger, db) scanToolExecutionHistoryMappingRepositoryImpl := security.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) imageScanServiceImpl := security2.NewImageScanServiceImpl(sugaredLogger, imageScanHistoryRepositoryImpl, imageScanResultRepositoryImpl, imageScanObjectMetaRepositoryImpl, cveStoreRepositoryImpl, imageScanDeployInfoRepositoryImpl, userServiceImpl, teamRepositoryImpl, appRepositoryImpl, environmentServiceImpl, ciArtifactRepositoryImpl, policyServiceImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, scanToolMetadataRepositoryImpl, scanToolExecutionHistoryMappingRepositoryImpl, cvePolicyRepositoryImpl) - triggerServiceImpl, err := devtronApps.NewTriggerServiceImpl(sugaredLogger, cdWorkflowCommonServiceImpl, gitOpsManifestPushServiceImpl, gitOpsConfigReadServiceImpl, argoK8sClientImpl, acdConfig, argoClientWrapperServiceImpl, pipelineStatusTimelineServiceImpl, chartTemplateServiceImpl, workflowEventPublishServiceImpl, manifestCreationServiceImpl, deployedConfigurationHistoryServiceImpl, argoUserServiceImpl, pipelineStageServiceImpl, globalPluginServiceImpl, customTagServiceImpl, pluginInputVariableParserImpl, prePostCdScriptHistoryServiceImpl, scopedVariableCMCSManagerImpl, workflowServiceImpl, imageDigestPolicyServiceImpl, userServiceImpl, clientImpl, helmAppServiceImpl, enforcerUtilImpl, userDeploymentRequestServiceImpl, helmAppClientImpl, eventSimpleFactoryImpl, eventRESTClientImpl, environmentVariables, appRepositoryImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, pipelineRepositoryImpl, pipelineOverrideRepositoryImpl, manifestPushConfigRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, cdWorkflowRepositoryImpl, ciWorkflowRepositoryImpl, ciArtifactRepositoryImpl, ciTemplateServiceImpl, materialRepositoryImpl, appLabelRepositoryImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, dockerArtifactStoreRepositoryImpl, imageScanServiceImpl, k8sServiceImpl, transactionUtilImpl, deploymentConfigServiceImpl, ciCdPipelineOrchestratorImpl, attributesServiceImpl) + triggerServiceImpl, err := devtronApps.NewTriggerServiceImpl(sugaredLogger, cdWorkflowCommonServiceImpl, gitOpsManifestPushServiceImpl, gitOpsConfigReadServiceImpl, argoK8sClientImpl, acdConfig, argoClientWrapperServiceImpl, pipelineStatusTimelineServiceImpl, chartTemplateServiceImpl, workflowEventPublishServiceImpl, manifestCreationServiceImpl, deployedConfigurationHistoryServiceImpl, argoUserServiceImpl, pipelineStageServiceImpl, globalPluginServiceImpl, customTagServiceImpl, pluginInputVariableParserImpl, prePostCdScriptHistoryServiceImpl, scopedVariableCMCSManagerImpl, workflowServiceImpl, imageDigestPolicyServiceImpl, userServiceImpl, clientImpl, helmAppServiceImpl, enforcerUtilImpl, userDeploymentRequestServiceImpl, helmAppClientImpl, eventSimpleFactoryImpl, eventRESTClientImpl, environmentVariables, appRepositoryImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, pipelineRepositoryImpl, pipelineOverrideRepositoryImpl, manifestPushConfigRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, cdWorkflowRepositoryImpl, ciWorkflowRepositoryImpl, ciArtifactRepositoryImpl, ciTemplateServiceImpl, materialRepositoryImpl, appLabelRepositoryImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, dockerArtifactStoreRepositoryImpl, imageScanServiceImpl, k8sServiceImpl, transactionUtilImpl, deploymentConfigServiceImpl, ciCdPipelineOrchestratorImpl, gitOperationServiceImpl, attributesServiceImpl) if err != nil { return nil, err } From c8b3943fcbeb76e2bcca9f8290c794ab73b9772d Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 21 Oct 2024 12:44:54 +0530 Subject: [PATCH 51/65] api error --- pkg/pipeline/WorkflowService.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index 454716724bd..faa5ec4fdfa 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -22,6 +22,7 @@ import ( "errors" v1alpha12 "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/typed/workflow/v1alpha1" "github.com/argoproj/argo-workflows/v3/workflow/util" + "github.com/devtron-labs/common-lib/utils" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/devtron/api/bean" @@ -39,6 +40,8 @@ import ( v12 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/rest" + "net/http" + "strconv" "strings" ) @@ -380,7 +383,7 @@ func (impl *WorkflowServiceImpl) TerminateDanglingWorkflows(cancelWfDtoRequest * var err error workflowExecutor := impl.getWorkflowExecutor(cancelWfDtoRequest.ExecutorType) if workflowExecutor == nil { - return errors.New("workflow executor not found") + return &utils.ApiError{HttpStatusCode: http.StatusNotFound, Code: strconv.Itoa(http.StatusNotFound), InternalMessage: "workflow executor not found", UserMessage: "workflow executor not found"} } if cancelWfDtoRequest.RestConfig == nil { cancelWfDtoRequest.RestConfig = impl.config From 4174f9ce8aeb76ced419a379ac9a67926099285b Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 21 Oct 2024 13:53:12 +0530 Subject: [PATCH 52/65] fix --- pkg/pipeline/WorkflowService.go | 2 -- pkg/pipeline/bean/WorkflowTemplate.go | 22 +++++++++++-------- .../executors/ArgoWorkflowExecutor.go | 2 +- .../executors/SystemWorkflowExecutor.go | 5 ++--- pkg/pipeline/executors/WorkflowUtils.go | 9 ++++++++ pkg/pipeline/types/Workflow.go | 5 ----- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index faa5ec4fdfa..c51b74b0181 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -165,8 +165,6 @@ func (impl *WorkflowServiceImpl) createWorkflowTemplate(workflowRequest *types.W impl.Logger.Errorw("error occurred while getting workflow main container", "err", err) return bean3.WorkflowTemplate{}, err } - // if anyone wants to add extra labels in workflow template then leverage below func. - workflowRequest.AddExtraLabelsInWorkflowTemplate() workflowTemplate.Containers = []v12.Container{workflowMainContainer} impl.updateBlobStorageConfig(workflowRequest, &workflowTemplate) if workflowRequest.Type == bean3.CI_WORKFLOW_PIPELINE_TYPE || workflowRequest.Type == bean3.JOB_WORKFLOW_PIPELINE_TYPE { diff --git a/pkg/pipeline/bean/WorkflowTemplate.go b/pkg/pipeline/bean/WorkflowTemplate.go index 0245dec4697..dc2476ecb3c 100644 --- a/pkg/pipeline/bean/WorkflowTemplate.go +++ b/pkg/pipeline/bean/WorkflowTemplate.go @@ -50,13 +50,14 @@ type WorkflowTemplate struct { } const ( - CI_WORKFLOW_NAME = "ci" - CI_WORKFLOW_WITH_STAGES = "ci-stages-with-env" - CiStage = "CI" - JobStage = "JOB" - CdStage = "CD" - CD_WORKFLOW_NAME = "cd" - CD_WORKFLOW_WITH_STAGES = "cd-stages-with-env" + CI_WORKFLOW_NAME = "ci" + CI_WORKFLOW_WITH_STAGES = "ci-stages-with-env" + CiStage = "CI" + JobStage = "JOB" + CdStage = "CD" + CD_WORKFLOW_NAME = "cd" + CD_WORKFLOW_WITH_STAGES = "cd-stages-with-env" + WorkflowGenerateNamePrefix = "devtron.ai/generate-name-prefix" ) func (workflowTemplate *WorkflowTemplate) GetEntrypoint() string { @@ -72,17 +73,20 @@ func (workflowTemplate *WorkflowTemplate) GetEntrypoint() string { func (workflowTemplate *WorkflowTemplate) CreateObjectMetadata() *v12.ObjectMeta { + workflowLabels := map[string]string{WorkflowGenerateNamePrefix: workflowTemplate.WorkflowNamePrefix} switch workflowTemplate.WorkflowType { case CI_WORKFLOW_NAME: + workflowLabels["devtron.ai/workflow-purpose"] = "ci" return &v12.ObjectMeta{ GenerateName: workflowTemplate.WorkflowNamePrefix + "-", - Labels: map[string]string{"devtron.ai/workflow-purpose": "ci"}, + Labels: workflowLabels, } case CD_WORKFLOW_NAME: + workflowLabels["devtron.ai/workflow-purpose"] = "cd" return &v12.ObjectMeta{ GenerateName: workflowTemplate.WorkflowNamePrefix + "-", Annotations: map[string]string{"workflows.argoproj.io/controller-instanceid": workflowTemplate.WfControllerInstanceID}, - Labels: map[string]string{"devtron.ai/workflow-purpose": "cd"}, + Labels: workflowLabels, } default: return nil diff --git a/pkg/pipeline/executors/ArgoWorkflowExecutor.go b/pkg/pipeline/executors/ArgoWorkflowExecutor.go index 7b6997900db..c84a903e06d 100644 --- a/pkg/pipeline/executors/ArgoWorkflowExecutor.go +++ b/pkg/pipeline/executors/ArgoWorkflowExecutor.go @@ -97,7 +97,7 @@ func (impl *ArgoWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenerate impl.logger.Errorw("cannot build wf client", "workflowGenerateName", workflowGenerateName, "err", err) return err } - jobSelectorLabel := fmt.Sprintf("%s=%s", types.WorkflowGenerateNamePrefix, workflowGenerateName) + jobSelectorLabel := fmt.Sprintf("%s=%s", bean.WorkflowGenerateNamePrefix, workflowGenerateName) wfList, err := wfClient.List(context.Background(), v1.ListOptions{LabelSelector: jobSelectorLabel}) if err != nil { impl.logger.Errorw("error in fetching list of workflows", "namespace", namespace, "err", err) diff --git a/pkg/pipeline/executors/SystemWorkflowExecutor.go b/pkg/pipeline/executors/SystemWorkflowExecutor.go index a26c05f6940..6d587384678 100644 --- a/pkg/pipeline/executors/SystemWorkflowExecutor.go +++ b/pkg/pipeline/executors/SystemWorkflowExecutor.go @@ -120,7 +120,7 @@ func (impl *SystemWorkflowExecutorImpl) TerminateDanglingWorkflow(workflowGenera impl.logger.Errorw("error occurred while creating k8s client", "workflowGenerateName", workflowGenerateName, "namespace", namespace, "err", err) return err } - jobSelectorLabel := fmt.Sprintf("%s=%s", types2.WorkflowGenerateNamePrefix, workflowGenerateName) + jobSelectorLabel := fmt.Sprintf("%s=%s", bean.WorkflowGenerateNamePrefix, workflowGenerateName) jobList, err := clientset.BatchV1().Jobs(namespace).List(context.Background(), v12.ListOptions{LabelSelector: jobSelectorLabel}) if err != nil { impl.logger.Errorw("error occurred while fetching jobs list for terminating dangling workflows", "namespace", namespace, "err", err) @@ -185,8 +185,7 @@ func (impl *SystemWorkflowExecutorImpl) GetWorkflowStatus(workflowName string, n } func (impl *SystemWorkflowExecutorImpl) getJobTemplate(workflowTemplate bean.WorkflowTemplate) *v1.Job { - - workflowLabels := map[string]string{DEVTRON_WORKFLOW_LABEL_KEY: DEVTRON_WORKFLOW_LABEL_VALUE, "devtron.ai/purpose": "workflow", "workflowType": workflowTemplate.WorkflowType} + workflowLabels := GetWorkflowLabelsForSystemExecutor(workflowTemplate) //setting TerminationGracePeriodSeconds in PodSpec //which ensures Pod has enough time to execute cleanup on SIGTERM event diff --git a/pkg/pipeline/executors/WorkflowUtils.go b/pkg/pipeline/executors/WorkflowUtils.go index 6593658255b..2933356f295 100644 --- a/pkg/pipeline/executors/WorkflowUtils.go +++ b/pkg/pipeline/executors/WorkflowUtils.go @@ -256,3 +256,12 @@ func CheckIfReTriggerRequired(status, message, workflowRunnerStatus string) bool const WorkflowCancel = "CANCELLED" const POD_DELETED_MESSAGE = "pod deleted" + +func GetWorkflowLabelsForSystemExecutor(workflowTemplate bean.WorkflowTemplate) map[string]string { + return map[string]string{ + DEVTRON_WORKFLOW_LABEL_KEY: DEVTRON_WORKFLOW_LABEL_VALUE, + "devtron.ai/purpose": "workflow", + "workflowType": workflowTemplate.WorkflowType, + bean.WorkflowGenerateNamePrefix: workflowTemplate.WorkflowNamePrefix, + } +} diff --git a/pkg/pipeline/types/Workflow.go b/pkg/pipeline/types/Workflow.go index ef6014351a1..1f9f3704b6b 100644 --- a/pkg/pipeline/types/Workflow.go +++ b/pkg/pipeline/types/Workflow.go @@ -151,10 +151,6 @@ type WorkflowRequest struct { HostUrl string `json:"hostUrl"` } -func (workflowRequest *WorkflowRequest) AddExtraLabelsInWorkflowTemplate() { - workflowRequest.AppLabels[WorkflowGenerateNamePrefix] = workflowRequest.WorkflowNamePrefix -} - func (workflowRequest *WorkflowRequest) updateExternalRunMetadata() { pipeline := workflowRequest.Pipeline env := workflowRequest.Env @@ -598,7 +594,6 @@ const ( POST = "POST" CI_NODE_PVC_ALL_ENV = "devtron.ai/ci-pvc-all" CI_NODE_PVC_PIPELINE_PREFIX = "devtron.ai/ci-pvc" - WorkflowGenerateNamePrefix = "devtron.ai/generate-name-prefix" ) type CiArtifactDTO struct { From 92b080b18c5c540322ed2ff6e00f0a0aa40de1ad Mon Sep 17 00:00:00 2001 From: iamayushm <32041961+iamayushm@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:29:18 +0900 Subject: [PATCH 53/65] fix: custom tag (#5999) * fix image getting deactivated * wip * wip * wip * wip * wip * wip * wip * removing deactivate function --- pkg/workflow/dag/WorkflowDagExecutor.go | 49 ------------------------- 1 file changed, 49 deletions(-) diff --git a/pkg/workflow/dag/WorkflowDagExecutor.go b/pkg/workflow/dag/WorkflowDagExecutor.go index d174bf6029f..849c5d9e1b3 100644 --- a/pkg/workflow/dag/WorkflowDagExecutor.go +++ b/pkg/workflow/dag/WorkflowDagExecutor.go @@ -549,12 +549,6 @@ func (impl *WorkflowDagExecutorImpl) HandlePreStageSuccessEvent(triggerContext t } util4.MergeMaps(pluginArtifacts, cdStageCompleteEvent.PluginRegistryArtifactDetails) - err = impl.deactivateUnusedPaths(wfRunner.ImagePathReservationIds, pluginArtifacts) - if err != nil { - impl.logger.Errorw("error in deactiving unusedImagePaths", "err", err) - return err - } - pipeline, err := impl.pipelineRepository.FindById(cdStageCompleteEvent.CdPipelineId) if err != nil { return err @@ -657,13 +651,6 @@ func (impl *WorkflowDagExecutorImpl) HandlePostStageSuccessEvent(triggerContext return err } if len(pluginRegistryImageDetails) > 0 { - if wfr != nil { - err = impl.deactivateUnusedPaths(wfr.ImagePathReservationIds, pluginRegistryImageDetails) - if err != nil { - impl.logger.Errorw("error in deactivation images", "err", err) - return err - } - } PostCDArtifacts, err := impl.commonArtifactService.SavePluginArtifacts(ciArtifact, pluginRegistryImageDetails, cdPipelineId, repository.POST_CD, triggeredBy) if err != nil { impl.logger.Errorw("error in saving plugin artifacts", "err", err) @@ -719,11 +706,6 @@ func (impl *WorkflowDagExecutorImpl) UpdateCiWorkflowForCiSuccess(request *bean2 return err } - err = impl.deactivateUnusedPaths(savedWorkflow.ImagePathReservationIds, request.PluginRegistryArtifactDetails) - if err != nil { - impl.logger.Errorw("error in deactivation images", "err", err) - return err - } return nil } @@ -894,37 +876,6 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger return buildArtifact.Id, err } -func (impl *WorkflowDagExecutorImpl) deactivateUnusedPaths(reserveImagePathIds []int, pluginRegistryArtifactDetails map[string][]string) error { - // for copy container image plugin if images reserved are not equal to actual copird - reservedImagePaths, err := impl.customTagService.GetImagePathsByIds(reserveImagePathIds) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting imagePaths by ids", "ImagePathReservationIds", reserveImagePathIds, "err", err) - return err - } - - copiedImagesMapping := make(map[string]bool) - for _, savedImages := range pluginRegistryArtifactDetails { - for _, image := range savedImages { - copiedImagesMapping[image] = true - } - } - - unusedPaths := make([]string, 0, len(reservedImagePaths)) - for _, reservedImage := range reservedImagePaths { - if _, ok := copiedImagesMapping[reservedImage.ImagePath]; !ok { - unusedPaths = append(unusedPaths, reservedImage.ImagePath) - } - } - - err = impl.customTagService.DeactivateImagePathReservationByImagePath(unusedPaths) - if err != nil { - impl.logger.Errorw("error in deactivating unused image paths", "imagePathReservationIds", reserveImagePathIds, "err", err) - return err - } - - return nil -} - func (impl *WorkflowDagExecutorImpl) WriteCiSuccessEvent(request *bean2.CiArtifactWebhookRequest, pipeline *pipelineConfig.CiPipeline, artifact *repository.CiArtifact) { event, _ := impl.eventFactory.Build(util2.Success, &pipeline.Id, pipeline.AppId, nil, util2.CI) event.CiArtifactId = artifact.Id From 507ea4fef3000b8954c4040780a092e61afc81f7 Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 21 Oct 2024 14:25:51 +0530 Subject: [PATCH 54/65] fix --- .../pipeline/configure/BuildPipelineRestHandler.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go index 5d89f39da56..0a1115a44c0 100644 --- a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go @@ -1562,12 +1562,16 @@ func (handler *PipelineConfigRestHandlerImpl) CancelWorkflow(w http.ResponseWrit return } var forceAbort bool - forceAbort, err = strconv.ParseBool(queryVars.Get("forceAbort")) - if err != nil { - handler.Logger.Errorw("request err, CancelWorkflow", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return + forceAbortQueryParam := queryVars.Get("forceAbort") + if len(forceAbortQueryParam) > 0 { + forceAbort, err = strconv.ParseBool(forceAbortQueryParam) + if err != nil { + handler.Logger.Errorw("request err, CancelWorkflow", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } } + handler.Logger.Infow("request payload, CancelWorkflow", "workflowId", workflowId, "pipelineId", pipelineId) ciPipeline, err := handler.ciPipelineRepository.FindById(pipelineId) From f7b5e61ac572456770dcdd49b10dbd188597eb6e Mon Sep 17 00:00:00 2001 From: Prakash Kumar Date: Mon, 21 Oct 2024 15:14:45 +0530 Subject: [PATCH 55/65] fix --- .../configure/DeploymentPipelineRestHandler.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go index abf07d80794..c25ede47b05 100644 --- a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go @@ -2072,11 +2072,14 @@ func (handler *PipelineConfigRestHandlerImpl) CancelStage(w http.ResponseWriter, return } var forceAbort bool - forceAbort, err = strconv.ParseBool(r.URL.Query().Get("forceAbort")) - if err != nil { - handler.Logger.Errorw("request err, CancelWorkflow", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return + forceAbortQueryParam := r.URL.Query().Get("forceAbort") + if len(forceAbortQueryParam) > 0 { + forceAbort, err = strconv.ParseBool(forceAbortQueryParam) + if err != nil { + handler.Logger.Errorw("request err, CancelWorkflow", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } } handler.Logger.Infow("request payload, CancelStage", "pipelineId", pipelineId, "workflowRunnerId", workflowRunnerId) From df7f2753519731186052800b06597d8c7cce4a26 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:22:22 +0530 Subject: [PATCH 56/65] chore: Cluster terminal images migration (#6006) * cluster terminal images updated * migration seq num modified for cluster terminal images --- scripts/sql/029800_021_cluster_terminal_images.down.sql | 4 ++++ scripts/sql/029800_021_cluster_terminal_images.up.sql | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 scripts/sql/029800_021_cluster_terminal_images.down.sql create mode 100644 scripts/sql/029800_021_cluster_terminal_images.up.sql diff --git a/scripts/sql/029800_021_cluster_terminal_images.down.sql b/scripts/sql/029800_021_cluster_terminal_images.down.sql new file mode 100644 index 00000000000..afa080f1f03 --- /dev/null +++ b/scripts/sql/029800_021_cluster_terminal_images.down.sql @@ -0,0 +1,4 @@ +UPDATE "public"."attributes" +SET value = '[{"groupId":"latest","groupRegex":"v1\\.2[4-8]\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', + updated_on = NOW() +WHERE key = 'DEFAULT_TERMINAL_IMAGE_LIST'; \ No newline at end of file diff --git a/scripts/sql/029800_021_cluster_terminal_images.up.sql b/scripts/sql/029800_021_cluster_terminal_images.up.sql new file mode 100644 index 00000000000..7e43cdaa7d3 --- /dev/null +++ b/scripts/sql/029800_021_cluster_terminal_images.up.sql @@ -0,0 +1,4 @@ +UPDATE "public"."attributes" +SET value = '[{"groupId":"latest","groupRegex":"v1\\.(30|31|32)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} {"groupId":"v1.28","groupRegex":"v1\\.(27|28|29)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.28","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.28","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.28","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.25","groupRegex":"v1\\.(24|25|26)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.25","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.25","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.25","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', + updated_on = NOW() +WHERE key = 'DEFAULT_TERMINAL_IMAGE_LIST'; \ No newline at end of file From b6cf6e854a564e7f25cd3cccae3ada2e0cc899a9 Mon Sep 17 00:00:00 2001 From: Badal Kumar <130441461+badal773@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:05:53 +0530 Subject: [PATCH 57/65] chore: adding refchart migration (#6007) * adding refchart migration * added helm chart templates --------- Co-authored-by: Badal Kumar Prusty --- .../deployment-chart_4-20-0/.helmignore | 22 + .../.image_descriptor_template.json | 1 + .../deployment-chart_4-20-0/Chart.yaml | 5 + .../deployment-chart_4-20-0/README.md | 991 ++++++++++++ .../deployment-chart_4-20-0/app-values.yaml | 530 +++++++ .../deployment-chart_4-20-0/env-values.yaml | 66 + .../pipeline-values.yaml | 6 + .../release-values.yaml | 14 + .../deployment-chart_4-20-0/schema.json | 1368 +++++++++++++++++ .../secrets-test-values.yaml | 1 + .../templates/NOTES.txt | 19 + .../templates/_helpers.tpl | 150 ++ .../templates/ambassador.yaml | 83 + .../templates/configmap.yaml | 17 + .../templates/deployment.yaml | 638 ++++++++ .../templates/externalsecrets.yaml | 66 + .../templates/flagger.yaml | 164 ++ .../templates/generic.yaml | 4 + .../templates/hpa.yaml | 81 + .../templates/ingress.yaml | 177 +++ .../templates/istio-authorizationpolicy.yaml | 37 + .../templates/istio-destinationrule.yaml | 34 + .../templates/istio-gateway.yaml | 50 + .../templates/istio-peerauthentication.yaml | 36 + .../istio-requestauthentication.yaml | 34 + .../templates/istio-virtualservice.yaml | 50 + .../templates/keda-autoscaling.yaml | 64 + .../templates/metrics-service-monitor.yaml | 35 + .../templates/networkpolicy.yaml | 50 + .../templates/persistent-volume-claim.yaml | 24 + .../templates/poddisruptionbudget.yaml | 25 + .../templates/pre-sync-job.yaml | 23 + .../templates/prometheusrules.yaml | 22 + .../templates/secret.yaml | 69 + .../templates/service.yaml | 90 ++ .../templates/serviceaccount.yaml | 16 + .../templates/servicemonitor.yaml | 48 + .../templates/sidecar-configmap.yaml | 169 ++ .../templates/vertical-pod-autoscaler.yaml | 27 + .../templates/winter-soldier.yaml | 41 + .../deployment-chart_4-20-0/test-values.json | 292 ++++ .../deployment-chart_4-20-0/test_values.yaml | 766 +++++++++ .../deployment-chart_4-20-0/values.yaml | 722 +++++++++ .../reference-chart_4-19-0/.helmignore | 22 + .../.image_descriptor_template.json | 1 + .../reference-chart_4-19-0/Chart.yaml | 5 + .../reference-chart_4-19-0/README.md | 866 +++++++++++ .../reference-chart_4-19-0/app-values.yaml | 428 ++++++ .../reference-chart_4-19-0/env-values.yaml | 66 + .../pipeline-values.yaml | 24 + .../release-values.yaml | 14 + .../reference-chart_4-19-0/schema.json | 1363 ++++++++++++++++ .../secrets-test-values.yaml | 1 + .../templates/NOTES.txt | 19 + .../templates/_helpers.tpl | 142 ++ .../templates/ambassador.yaml | 86 ++ .../templates/configmap.yaml | 17 + .../templates/deployment.yaml | 556 +++++++ .../templates/externalsecrets.yaml | 57 + .../templates/generic.yaml | 4 + .../reference-chart_4-19-0/templates/hpa.yaml | 59 + .../templates/ingress.yaml | 177 +++ .../templates/istio-authorizationpolicy.yaml | 37 + .../templates/istio-destinationrule.yaml | 34 + .../templates/istio-gateway.yaml | 50 + .../templates/istio-peerauthentication.yaml | 36 + .../istio-requestauthentication.yaml | 34 + .../templates/istio-virtualservice.yaml | 50 + .../templates/keda-autoscaling.yaml | 64 + .../templates/metrics-service-monitor.yaml | 35 + .../templates/networkpolicy.yaml | 50 + .../templates/poddisruptionbudget.yaml | 25 + .../templates/pre-sync-job.yaml | 23 + .../templates/prometheusrules.yaml | 22 + .../templates/secret.yaml | 69 + .../templates/service.yaml | 83 + .../templates/serviceaccount.yaml | 16 + .../templates/servicemonitor.yaml | 48 + .../templates/sidecar-configmap.yaml | 169 ++ .../templates/winter-soldier.yaml | 41 + .../reference-chart_4-19-0/test_values.yaml | 628 ++++++++ .../reference-chart_4-19-0/values.yaml | 613 ++++++++ .../reference-chart_4-20-0/.helmignore | 22 + .../.image_descriptor_template.json | 1 + .../reference-chart_4-20-0/Chart.yaml | 5 + .../reference-chart_4-20-0/README.md | 911 +++++++++++ .../reference-chart_4-20-0/app-values.yaml | 443 ++++++ .../reference-chart_4-20-0/env-values.yaml | 66 + .../pipeline-values.yaml | 24 + .../release-values.yaml | 14 + .../reference-chart_4-20-0/schema.json | 1363 ++++++++++++++++ .../secrets-test-values.yaml | 1 + .../templates/NOTES.txt | 19 + .../templates/_helpers.tpl | 150 ++ .../templates/ambassador.yaml | 86 ++ .../templates/configmap.yaml | 17 + .../templates/deployment.yaml | 612 ++++++++ .../templates/externalsecrets.yaml | 66 + .../templates/generic.yaml | 4 + .../reference-chart_4-20-0/templates/hpa.yaml | 81 + .../templates/ingress.yaml | 177 +++ .../templates/istio-authorizationpolicy.yaml | 37 + .../templates/istio-destinationrule.yaml | 34 + .../templates/istio-gateway.yaml | 50 + .../templates/istio-peerauthentication.yaml | 36 + .../istio-requestauthentication.yaml | 34 + .../templates/istio-virtualservice.yaml | 50 + .../templates/keda-autoscaling.yaml | 48 + .../templates/metrics-service-monitor.yaml | 35 + .../templates/networkpolicy.yaml | 50 + .../templates/persistent-volume-claim.yaml | 24 + .../templates/poddisruptionbudget.yaml | 25 + .../templates/pre-sync-job.yaml | 23 + .../templates/prometheusrules.yaml | 22 + .../templates/secret.yaml | 69 + .../templates/service.yaml | 93 ++ .../templates/serviceaccount.yaml | 16 + .../templates/servicemonitor.yaml | 48 + .../templates/sidecar-configmap.yaml | 169 ++ .../templates/vertical-pod-autoscaler.yaml | 27 + .../templates/winter-soldier.yaml | 41 + .../reference-chart_4-20-0/test_values.yaml | 648 ++++++++ .../reference-chart_4-20-0/values.yaml | 635 ++++++++ ...500_021_refrence-chart-ref_4-19-0.down.sql | 5 + ...29500_021_refrence-chart-ref_4-19-0.up.sql | 9 + ...600_021_refrence-chart-ref_4-20-0.down.sql | 5 + ...29600_021_refrence-chart-ref_4-20-0.up.sql | 9 + ...0_021_deployment-chart-ref_4-20-0.down.sql | 3 + ...700_021_deployment-chart-ref_4-20-0.up.sql | 7 + 129 files changed, 19475 insertions(+) create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.helmignore create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.image_descriptor_template.json create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/Chart.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/README.md create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/app-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/env-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/pipeline-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/release-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/secrets-test-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/NOTES.txt create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/_helpers.tpl create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/flagger.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/generic.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-authorizationpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-destinationrule.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-gateway.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-peerauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-requestauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-virtualservice.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/metrics-service-monitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/networkpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/persistent-volume-claim.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/sidecar-configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/vertical-pod-autoscaler.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test-values.json create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml create mode 100644 scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.helmignore create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.image_descriptor_template.json create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/Chart.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/README.md create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/app-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/env-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/pipeline-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/release-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/schema.json create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/secrets-test-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/NOTES.txt create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/_helpers.tpl create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ambassador.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/deployment.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/externalsecrets.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/generic.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/hpa.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ingress.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-authorizationpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-destinationrule.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-gateway.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-peerauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-requestauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-virtualservice.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/keda-autoscaling.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/metrics-service-monitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/networkpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/poddisruptionbudget.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/pre-sync-job.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/prometheusrules.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/secret.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/service.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/serviceaccount.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/servicemonitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/sidecar-configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/winter-soldier.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/test_values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-19-0/values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.helmignore create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.image_descriptor_template.json create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/Chart.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/README.md create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/app-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/env-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/pipeline-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/release-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/schema.json create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/secrets-test-values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/NOTES.txt create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/_helpers.tpl create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/deployment.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/generic.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-authorizationpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-destinationrule.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-gateway.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-peerauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-requestauthentication.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-virtualservice.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/metrics-service-monitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/networkpolicy.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/persistent-volume-claim.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/sidecar-configmap.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/vertical-pod-autoscaler.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/test_values.yaml create mode 100644 scripts/devtron-reference-helm-charts/reference-chart_4-20-0/values.yaml create mode 100644 scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql create mode 100644 scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql create mode 100644 scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql create mode 100644 scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql create mode 100644 scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql create mode 100644 scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.helmignore b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.image_descriptor_template.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.image_descriptor_template.json new file mode 100644 index 00000000000..8a99a95664c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/.image_descriptor_template.json @@ -0,0 +1 @@ +{"server":{"deployment":{"image_tag":"{{.Tag}}","image":"{{.Name}}"}},"pipelineName": "{{.PipelineName}}","releaseVersion":"{{.ReleaseVersion}}","deploymentType": "{{.DeploymentType}}", "app": "{{.App}}", "env": "{{.Env}}", "appMetrics": {{.AppMetrics}}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/Chart.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/Chart.yaml new file mode 100644 index 00000000000..4d7d3386052 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: deployment-chart_4-20-0 +version: 4.20.0 diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/README.md b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/README.md new file mode 100644 index 00000000000..57ee0cefa1c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/README.md @@ -0,0 +1,991 @@ + +# Deployment Chart - v4.20.0 + +## 1. Yaml File - + +### Container Ports + +This defines ports on which application services will be exposed to other services + +```yaml +ContainerPort: + - envoyPort: 8799 + idleTimeout: + name: app + port: 8080 + servicePort: 80 + nodePort: 32056 + supportStreaming: true + useHTTP2: true + protocol: TCP +``` + +| Key | Description | +| :--- | :--- | +| `envoyPort` | envoy port for the container. | +| `idleTimeout` | the duration of time that a connection is idle before the connection is terminated. | +| `name` | name of the port. | +| `port` | port for the container. | +| `servicePort` | port of the corresponding kubernetes service. | +| `nodePort` | nodeport of the corresponding kubernetes service. | +| `supportStreaming` | Used for high performance protocols like grpc where timeout needs to be disabled. | +| `useHTTP2` | Envoy container can accept HTTP2 requests. | +| `protocol` | Protocol for port. Must be UDP, TCP, or SCTP. Defaults to "TCP"| + +### EnvVariables +```yaml +EnvVariables: [] +``` +To set environment variables for the containers that run in the Pod. +### EnvVariablesFromSecretKeys +```yaml +EnvVariablesFromSecretKeys: + - name: ENV_NAME + secretName: SECRET_NAME + keyName: SECRET_KEY + +``` + It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable. + + ### EnvVariablesFromConfigMapKeys +```yaml +EnvVariablesFromConfigMapKeys: + - name: ENV_NAME + configMapName: CONFIG_MAP_NAME + keyName: CONFIG_MAP_KEY + +``` + It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable. + +### Liveness Probe + +If this check fails, kubernetes restarts the pod. This should return error code in case of non-recoverable error. + +```yaml +LivenessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true + grpc: + port: 8080 + service: "" +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the liveness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for liveliness. | +| `periodSeconds` | It defines the time to check a given container for liveness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfil the liveness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as live. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | +| `grpc` | GRPC specifies an action involving a GRPC port. Port is a required field if using gRPC service for health probes. Number must be in the range 1 to 65535. Service (optional) is the name of the service to place in the gRPC HealthCheckRequest. | + + + +### MaxUnavailable + +```yaml + MaxUnavailable: 0 +``` +The maximum number of pods that can be unavailable during the update process. The value of "MaxUnavailable: " can be an absolute number or percentage of the replicas count. The default value of "MaxUnavailable: " is 25%. + +### MaxSurge + +```yaml +MaxSurge: 1 +``` +The maximum number of pods that can be created over the desired number of pods. For "MaxSurge: " also, the value can be an absolute number or percentage of the replicas count. +The default value of "MaxSurge: " is 25%. + +### Min Ready Seconds + +```yaml +MinReadySeconds: 60 +``` +This specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. This defaults to 0 (the Pod will be considered available as soon as it is ready). + +### Readiness Probe + +If this check fails, kubernetes stops sending traffic to the application. This should return error code in case of errors which can be recovered from if traffic is stopped. + +```yaml +ReadinessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true + grpc: + port: 8080 + service: "" +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the readiness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for readiness. | +| `periodSeconds` | It defines the time to check a given container for readiness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfill the readiness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as ready. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | +| `grpc` | GRPC specifies an action involving a GRPC port. Port is a required field if using gRPC service for health probes. Number must be in the range 1 to 65535. Service (optional) is the name of the service to place in the gRPC HealthCheckRequest. | + + +### Pod Disruption Budget + +You can create `PodDisruptionBudget` for each application. A PDB limits the number of pods of a replicated application that are down simultaneously from voluntary disruptions. For example, an application would like to ensure the number of replicas running is never brought below the certain number. + +```yaml +podDisruptionBudget: + minAvailable: 1 +``` + +or + +```yaml +podDisruptionBudget: + maxUnavailable: 50% +``` + +You can specify either `maxUnavailable` or `minAvailable` in a PodDisruptionBudget and it can be expressed as integers or as a percentage + +| Key | Description | +| :--- | :--- | +| `minAvailable` | Evictions are allowed as long as they leave behind 1 or more healthy pods of the total number of desired replicas. | +| `maxUnavailable` | Evictions are allowed as long as at most 1 unhealthy replica among the total number of desired replicas. | + +### Ambassador Mappings + +You can create ambassador mappings to access your applications from outside the cluster. At its core a Mapping resource maps a resource to a service. + +```yaml +ambassadorMapping: + ambassadorId: "prod-emissary" + cors: {} + enabled: true + hostname: devtron.example.com + labels: {} + prefix: / + retryPolicy: {} + rewrite: "" + tls: + context: "devtron-tls-context" + create: false + hosts: [] + secretName: "" +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable ambassador mapping else set false.| +| `ambassadorId` | used to specify id for specific ambassador mappings controller. | +| `cors` | used to specify cors policy to access host for this mapping. | +| `weight` | used to specify weight for canary ambassador mappings. | +| `hostname` | used to specify hostname for ambassador mapping. | +| `prefix` | used to specify path for ambassador mapping. | +| `labels` | used to provide custom labels for ambassador mapping. | +| `retryPolicy` | used to specify retry policy for ambassador mapping. | +| `corsPolicy` | Provide cors headers on flagger resource. | +| `rewrite` | used to specify whether to redirect the path of this mapping and where. | +| `tls` | used to create or define ambassador TLSContext resource. | +| `extraSpec` | used to provide extra spec values which not present in deployment template for ambassador resource. | + +### Autoscaling + +This is connected to HPA and controls scaling up and down in response to request load. + +```yaml +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + containerResource: + enabled: true + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + + extraMetrics: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable autoscaling else set false.| +| `MinReplicas` | Minimum number of replicas allowed for scaling. | +| `MaxReplicas` | Maximum number of replicas allowed for scaling. | +| `TargetCPUUtilizationPercentage` | The target CPU utilization that is expected for a container. | +| `TargetMemoryUtilizationPercentage` | The target memory utilization that is expected for a container. | +| `extraMetrics` | Used to give external metrics for autoscaling. | +| `containerResource` | Used to scale resource as per container resource. | + +### Flagger + +You can use flagger for canary releases with deployment objects. It supports flexible traffic routing with istio service mesh as well. + +```yaml +flaggerCanary: + addOtherGateways: [] + addOtherHosts: [] + analysis: + interval: 15s + maxWeight: 50 + stepWeight: 5 + threshold: 5 + annotations: {} + appProtocol: http + corsPolicy: + allowCredentials: false + allowHeaders: + - x-some-header + allowMethods: + - GET + allowOrigin: + - example.com + maxAge: 24h + createIstioGateway: + annotations: {} + enabled: false + host: example.com + labels: {} + tls: + enabled: false + secretName: example-tls-secret + enabled: false + gatewayRefs: null + headers: + request: + add: + x-some-header: value + labels: {} + loadtest: + enabled: true + url: http://flagger-loadtester.istio-system/ + match: + - uri: + prefix: / + port: 8080 + portDiscovery: true + retries: null + rewriteUri: / + targetPort: 8080 + thresholds: + latency: 500 + successRate: 90 + timeout: null +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable canary releases using flagger else set false.| +| `addOtherGateways` | To provide multiple istio gateways for flagger. | +| `addOtherHosts` | Add multiple hosts for istio service mesh with flagger. | +| `analysis` | Define how the canary release should progresss and at what interval. | +| `annotations` | Annotation to add on flagger resource. | +| `labels` | Labels to add on flagger resource. | +| `appProtocol` | Protocol to use for canary. | +| `corsPolicy` | Provide cors headers on flagger resource. | +| `createIstioGateway` | Set to true if you want to create istio gateway as well with flagger. | +| `headers` | Add headers if any. | +| `loadtest` | Enable load testing for your canary release. | + + + +### Fullname Override + +```yaml +fullnameOverride: app-name +``` +`fullnameOverride` replaces the release fullname created by default by devtron, which is used to construct Kubernetes object names. By default, devtron uses {app-name}-{environment-name} as release fullname. + +### Image + +```yaml +image: + pullPolicy: IfNotPresent +``` + +Image is used to access images in kubernetes, pullpolicy is used to define the instances calling the image, here the image is pulled when the image is not present,it can also be set as "Always". + +### imagePullSecrets + +`imagePullSecrets` contains the docker credentials that are used for accessing a registry. + +```yaml +imagePullSecrets: + - regcred +``` +regcred is the secret that contains the docker credentials that are used for accessing a registry. Devtron will not create this secret automatically, you'll have to create this secret using dt-secrets helm chart in the App store or create one using kubectl. You can follow this documentation Pull an Image from a Private Registry [https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) . + +### Ingress + +This allows public access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + className: nginx + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` +Legacy deployment-template ingress format + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + path: "" + host: "" + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + +### Ingress Internal + +This allows private access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingressInternal: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + +### additionalBackends + +This defines additional backend path in the ingress . + +```yaml + hosts: + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 +``` + +### Init Containers +```yaml +initContainers: + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + args: + - sleep 300 + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate + + - name: nginx + image: nginx:1.14.2 + securityContext: + privileged: true + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] +``` +Specialized containers that run before app containers in a Pod. Init containers can contain utilities or setup scripts not present in an app image. One can use base image inside initContainer by setting the reuseContainerImage flag to `true`. + +### Istio + +Istio is a service mesh which simplifies observability, traffic management, security and much more with it's virtual services and gateways. + +```yaml +istio: + enable: true + gateway: + annotations: {} + enabled: false + host: example.com + labels: {} + tls: + enabled: false + secretName: example-tls-secret + virtualService: + annotations: {} + enabled: false + gateways: [] + hosts: [] + http: + - corsPolicy: + allowCredentials: false + allowHeaders: + - x-some-header + allowMethods: + - GET + allowOrigin: + - example.com + maxAge: 24h + headers: + request: + add: + x-some-header: value + match: + - uri: + prefix: /v1 + - uri: + prefix: /v2 + retries: + attempts: 2 + perTryTimeout: 3s + rewriteUri: / + route: + - destination: + host: service1 + port: 80 + timeout: 12s + - route: + - destination: + host: service2 + labels: {} +``` + +### Pause For Seconds Before Switch Active +```yaml +pauseForSecondsBeforeSwitchActive: 30 +``` +To wait for given period of time before switch active the container. + +### Resources + +These define minimum and maximum RAM and CPU available to the application. + +```yaml +resources: + limits: + cpu: "1" + memory: "200Mi" + requests: + cpu: "0.10" + memory: "100Mi" +``` + +Resources are required to set CPU and memory usage. + +#### Limits + +Limits make sure a container never goes above a certain value. The container is only allowed to go up to the limit, and then it is restricted. + +#### Requests + +Requests are what the container is guaranteed to get. + +### Service + +This defines annotations and the type of service, optionally can define name also. + +Supports "ClientIP" and "None". Used to maintain session affinity. Enable + client IP based session affinity. + +```yaml + service: + type: ClusterIP + annotations: {} + sessionAffinity: + enabled: true + sessionAffinityConfig: {} +``` + +### Volumes + +```yaml +volumes: + - name: log-volume + emptyDir: {} + - name: logpv + persistentVolumeClaim: + claimName: logpvc +``` + +It is required when some values need to be read from or written to an external disk. + +### Volume Mounts + +```yaml +volumeMounts: + - mountPath: /var/log/nginx/ + name: log-volume + - mountPath: /mnt/logs + name: logpvc + subPath: employee +``` + +It is used to provide mounts to the volume. + +### Affinity and anti-affinity + +```yaml +Spec: + Affinity: + Key: + Values: +``` + +Spec is used to define the desire state of the given container. + +Node Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node. + +Inter-pod affinity allow you to constrain which nodes your pod is eligible to be scheduled based on labels on pods. + +#### Key + +Key part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +#### Values + +Value part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +### Tolerations + +```yaml +tolerations: + - key: "key" + operator: "Equal" + value: "value" + effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" +``` + +Taints are the opposite, they allow a node to repel a set of pods. + +A given pod can access the given node and avoid the given taint only if the given pod satisfies a given taint. + +Taints and tolerations are a mechanism which work together that allows you to ensure that pods are not placed on inappropriate nodes. Taints are added to nodes, while tolerations are defined in the pod specification. When you taint a node, it will repel all the pods except those that have a toleration for that taint. A node can have one or many taints associated with it. + +### Arguments + +```yaml +args: + enabled: false + value: [] +``` + +This is used to give arguments to command. + +### Command + +```yaml +command: + enabled: false + value: [] +``` + +It contains the commands for the server. + +| Key | Description | +| :--- | :--- | +| `enabled` | To enable or disable the command. | +| `value` | It contains the commands. | + + +### Containers +Containers section can be used to run side-car containers along with your main container within same pod. Containers running within same pod can share volumes and IP Address and can address each other @localhost. We can use base image inside container by setting the reuseContainerImage flag to `true`. + +```yaml + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate +``` + +### Prometheus + +```yaml + prometheus: + release: monitoring +``` + +It is a kubernetes monitoring tool and the name of the file to be monitored as monitoring in the given case.It describes the state of the prometheus. + +### rawYaml + +```yaml +rawYaml: + - apiVersion: v1 + kind: Service + metadata: + name: my-service + spec: + selector: + app: MyApp + ports: + - protocol: TCP + port: 80 + targetPort: 9376 + type: ClusterIP +``` +Accepts an array of Kubernetes objects. You can specify any kubernetes yaml here and it will be applied when your app gets deployed. + +### Grace Period + +```yaml +GracePeriod: 30 +``` +Kubernetes waits for the specified time called the termination grace period before terminating the pods. By default, this is 30 seconds. If your pod usually takes longer than 30 seconds to shut down gracefully, make sure you increase the `GracePeriod`. + +A Graceful termination in practice means that your application needs to handle the SIGTERM message and begin shutting down when it receives it. This means saving all data that needs to be saved, closing down network connections, finishing any work that is left, and other similar tasks. + +There are many reasons why Kubernetes might terminate a perfectly healthy container. If you update your deployment with a rolling update, Kubernetes slowly terminates old pods while spinning up new ones. If you drain a node, Kubernetes terminates all pods on that node. If a node runs out of resources, Kubernetes terminates pods to free those resources. It’s important that your application handle termination gracefully so that there is minimal impact on the end user and the time-to-recovery is as fast as possible. + + +### Server + +```yaml +server: + deployment: + image_tag: 1-95a53 + image: "" +``` + +It is used for providing server configurations. + +#### Deployment + +It gives the details for deployment. + +| Key | Description | +| :--- | :--- | +| `image_tag` | It is the image tag | +| `image` | It is the URL of the image | + +### Service Monitor + +```yaml +servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace +``` + +It gives the set of targets to be monitored. + +### Db Migration Config + +```yaml +dbMigrationConfig: + enabled: false +``` + +It is used to configure database migration. + + +### KEDA Autoscaling +[KEDA](https://keda.sh) is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed. KEDA can be installed into any Kubernetes cluster and can work alongside standard Kubernetes components like the Horizontal Pod Autoscaler(HPA). + +Example for autosccaling with KEDA using Prometheus metrics is given below: +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: + restoreToOriginalReplicaCount: true + horizontalPodAutoscalerConfig: + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 100 + periodSeconds: 15 + triggers: + - type: prometheus + metadata: + serverAddress: http://:9090 + metricName: http_request_total + query: envoy_cluster_upstream_rq{appId="300", cluster_name="300-0", container="envoy",} + threshold: "50" + triggerAuthentication: + enabled: false + name: + spec: {} + authenticationRef: {} +``` +Example for autosccaling with KEDA based on kafka is given below : +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: {} + triggers: + - type: kafka + metadata: + bootstrapServers: b-2.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-3.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-1.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092 + topic: Orders-Service-ESP.info + lagThreshold: "100" + consumerGroup: oders-remove-delivered-packages + allowIdleConsumers: "true" + triggerAuthentication: + enabled: true + name: keda-trigger-auth-kafka-credential + spec: + secretTargetRef: + - parameter: sasl + name: keda-kafka-secrets + key: sasl + - parameter: username + name: keda-kafka-secrets + key: username + authenticationRef: + name: keda-trigger-auth-kafka-credential +``` + +### Winter-Soldier +Winter Soldier can be used to +- cleans up (delete) Kubernetes resources +- reduce workload pods to 0 + +**_NOTE:_** After deploying this we can create the Hibernator object and provide the custom configuration by which workloads going to delete, sleep and many more. for more information check [the main repo](https://github.com/devtron-labs/winter-soldier) + +Given below is template values you can give in winter-soldier: +```yaml +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + action: sleep + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + targetReplicas: [] + fieldSelector: [] +``` +Here, +| Key | values | Description | +| :--- | :--- | :--- | +| `enabled` | `fasle`,`true` | decide the enabling factor | +| `apiVersion` | `pincher.devtron.ai/v1beta1`, `pincher.devtron.ai/v1alpha1` | specific api version | +| `action` | `sleep`,`delete`, `scale` | This specify the action need to perform. | +| `timeRangesWithZone`:`timeZone` | eg:- `"Asia/Kolkata"`,`"US/Pacific"` | It use to specify the timeZone used. (It uses standard format. please refer [this](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) | +| `timeRangesWithZone`:`timeRanges` | array of [ `timeFrom`, `timeTo`, `weekdayFrom`, `weekdayTo`] | It use to define time period/range on which the user need to perform the specified action. you can have multiple timeRanges.
These settings will take `action` on Sat and Sun from 00:00 to 23:59:59, | +| `targetReplicas` | `[n]` : n - number of replicas to scale. | These is mandatory field when the `action` is `scale`
Defalut value is `[]`. | +| `fieldSelector` | `- AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) ` | These value will take a list of methods to select the resources on which we perform specified `action` . | + + +here is an example, +```yaml +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '10h'), Now()) +``` +Above settings will take action on `Sat` and `Sun` from 00:00 to 23:59:59, and on `Mon`-`Fri` from 00:00 to 08:00 and 20:00 to 23:59:59. If `action:sleep` then runs hibernate at timeFrom and unhibernate at `timeTo`. If `action: delete` then it will delete workloads at `timeFrom` and `timeTo`. Here the `action:scale` thus it scale the number of resource replicas to `targetReplicas: [1,1,1]`. Here each element of `targetReplicas` array is mapped with the corresponding elments of array `timeRangesWithZone/timeRanges`. Thus make sure the length of both array is equal, otherwise the cnages cannot be observed. + +The above example will select the application objects which have been created 10 hours ago across all namespaces excluding application's namespace. Winter soldier exposes following functions to handle time, cpu and memory. + +- ParseTime - This function can be used to parse time. For eg to parse creationTimestamp use ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z') +- AddTime - This can be used to add time. For eg AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '-10h') ll add 10h to the time. Use d for day, h for hour, m for minutes and s for seconds. Use negative number to get earlier time. +- Now - This can be used to get current time. +- CpuToNumber - This can be used to compare CPU. For eg any({{spec.containers.#.resources.requests}}, { MemoryToNumber(.memory) < MemoryToNumber('60Mi')}) will check if any resource.requests is less than 60Mi. + + +### Security Context +A security context defines privilege and access control settings for a Pod or Container. + +To add a security context for main container: +```yaml +containerSecurityContext: + allowPrivilegeEscalation: false +``` + +To add a security context on pod level: +```yaml +podSecurityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 +``` + +### Topology Spread Constraints +You can use topology spread constraints to control how Pods are spread across your cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains. This can help to achieve high availability as well as efficient resource utilization. + +```yaml +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: {} + minDomains: 1 + nodeAffinityPolicy: Ignore +``` + +### Persistent Volume Claim +You can use persistent volume claim to mount volume as per your usecase. + +```yaml +persistentVolumeClaim: + name: my-pvc + storageClassName: default + accessMode: + - ReadWriteOnce + mountPath: /tmp +``` + +### Vertical Pod Autoscaling +This is connected to VPA and controls scaling up and down in response to request load. +```yaml +verticalPodScaling: + enabled: true + resourcePolicy: {} + updatePolicy: {} + ``` + +### Scheduler Name + +You can provide you own custom scheduler to schedule your application + +```yaml +schedulerName: "" +``` + +### Deployment Metrics + +It gives the realtime metrics of the deployed applications + +| Key | Description | +| :--- | :--- | +| `Deployment Frequency` | It shows how often this app is deployed to production | +| `Change Failure Rate` | It shows how often the respective pipeline fails. | +| `Mean Lead Time` | It shows the average time taken to deliver a change to production. | +| `Mean Time to Recovery` | It shows the average time taken to fix a failed pipeline. | + +## 2. Show application metrics + +If you want to see application metrics like different HTTP status codes metrics, application throughput, latency, response time. Enable the Application metrics from below the deployment template Save button. After enabling it, you should be able to see all metrics on App detail page. By default it remains disabled. +![](../../../.gitbook/assets/deployment_application_metrics%20%282%29.png) + +Once all the Deployment template configurations are done, click on `Save` to save your deployment configuration. Now you are ready to create [Workflow](workflow/) to do CI/CD. + +### Helm Chart Json Schema + +Helm Chart [json schema](../../../scripts/devtron-reference-helm-charts/reference-chart_4-11-0/schema.json) is used to validate the deployment template values. + +### Other Validations in Json Schema + +The values of CPU and Memory in limits must be greater than or equal to in requests respectively. Similarly, In case of envoyproxy, the values of limits are greater than or equal to requests as mentioned below. +``` +resources.limits.cpu >= resources.requests.cpu +resources.limits.memory >= resources.requests.memory +envoyproxy.resources.limits.cpu >= envoyproxy.resources.requests.cpu +envoyproxy.resources.limits.memory >= envoyproxy.resources.requests.memory +``` diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/app-values.yaml new file mode 100644 index 00000000000..5f8216c0a71 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/app-values.yaml @@ -0,0 +1,530 @@ +# Mandatory configs + +podDisruptionBudget: {} +deploymentLabels: {} +deploymentAnnotations: {} + +containerSpec: + lifecycle: + enabled: false + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +replicaCount: 1 +MinReadySeconds: 60 +GracePeriod: 30 +image: + pullPolicy: IfNotPresent +restartPolicy: Always +service: + type: ClusterIP + # enabled: true + #name: "service-1234567890" + loadBalancerSourceRanges: [] + # loadBalancerSourceRanges: + # - 1.2.3.4/32 + # - 1.2.5.6/23 + annotations: {} + # test1: test2 + # test3: test4 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + protocol: TCP +# servicemonitor: +# enabled: true +# path: /abc +# scheme: 'http' +# interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +# Optional configs +LivenessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + grpc: {} + + +ReadinessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + grpc: {} + + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + grpc: {} + + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/force-ssl-redirect: 'false' +# nginx.ingress.kubernetes.io/ssl-redirect: 'false' +# kubernetes.io/ingress.class: nginx +# nginx.ingress.kubernetes.io/rewrite-target: /$2 +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: example.com + tls: + enabled: false + secretName: example-secret + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + annotation: {} + labels: {} + type: Deployment + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +flaggerCanary: + enabled: false + labels: {} + annotations: {} + createIstioGateway: + enabled: false + labels: {} + annotations: {} + host: + tls: + enabled: false + secretName: + # Istio gateways (optional) + addOtherGateways: [] + # Istio virtual service host names (optional) + addOtherHosts: [] + # Istio gateway refs (optional) + gatewayRefs: + # - name: istio-gateway + # namespace: istio-system + #service port + serviceport: 8080 + #containerPort + targetPort: 8080 + # discover all port open in container + portDiscovery: true + # application protocol (optional) + appProtocol: http + # Istio retry policy (optional) + retries: + # attempts: 3 + # perTryTimeout: 1s + # retryOn: "gateway-error,connect-failure,refused-stream" + # HTTP match conditions (optional) + match: + - uri: + prefix: / + # HTTP rewrite (optional) + rewriteUri: / + # timeout (optional) + timeout: + # Add headers (optional) + headers: + # request: + # add: + # x-some-header: "value" + # cross-origin resource sharing policy (optional) + corsPolicy: + # allowOrigin: + # - example.com + # allowMethods: + # - GET + # allowCredentials: false + # allowHeaders: + # - x-some-header + # maxAge: 24h + analysis: + # schedule interval (default 60s) + interval: 15s + # max number of failed metric checks before rollback + threshold: 5 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 5 + thresholds: + # minimum req success rate (non 5xx responses) + # percentage (0-100) + successRate: 90 + # maximum req duration P99 + # milliseconds + latency: 500 + loadtest: + enabled: true + # load tester address + url: http://flagger-loadtester.istio-system/ + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +command: + workingDir: {} + enabled: false + value: [] + +args: + enabled: false + value: + - /bin/sh + - -c + - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600 + +#For adding custom labels to pods + +podLabels: {} +# customKey: customValue +podAnnotations: {} +# customKey: customValue + +rawYaml: [] + +topologySpreadConstraints: [] + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +containers: [] + ## Additional containers to run along with application pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + +dbMigrationConfig: + enabled: false + +tolerations: [] + +podSecurityContext: {} + +containerSecurityContext: {} + +Spec: + Affinity: + Key: "" + # Key: kops.k8s.io/instancegroup + Values: "" + +affinity: + enabled: false + values: {} + +ambassadorMapping: + enabled: false + labels: {} + prefix: / + ambassadorId: "" + hostname: devtron.example.com + rewrite: "" + retryPolicy: {} + cors: {} + tls: + context: "" + create: false + secretName: "" + hosts: [] + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 70 + TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} + behavior: {} + containerResource: + enabled: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + minReplicaCount: 1 + maxReplicaCount: 2 + advanced: {} + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +# kedaHttpScaledObject: +# enabled: false +# minReplicaCount: 1 +# maxReplicaCount: 2 +# targetPendingRequests: +# scaledownPeriod: +# servicePort: 80 # port of the service (required) + +prometheus: + release: monitoring + +server: + deployment: + image_tag: 1-95af053 + image: "" + +servicemonitor: + additionalLabels: {} + +envoyproxy: + image: quay.io/devtron/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +imagePullSecrets: [] + # - test1 + # - test2 +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" +# - "bar.local" +# - ip: "10.1.2.3" +# hostnames: +# - "foo.remote" +# - "bar.remote" + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/env-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/env-values.yaml new file mode 100644 index 00000000000..48b794e8f28 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/env-values.yaml @@ -0,0 +1,66 @@ +replicaCount: 1 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 + +Spec: + Affinity: + Key: "" + Values: "" + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# +secret: + enabled: false + data: {} +# my_own_secret: S3ViZXJuZXRlcyBXb3Jrcw== + +EnvVariables: [] +# - name: FLASK_ENV +# value: qa + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: "0.05" + memory: 50Mi + requests: + cpu: "0.01" + memory: 10Mi + + diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/pipeline-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/pipeline-values.yaml new file mode 100644 index 00000000000..dbe4db3e8ec --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/pipeline-values.yaml @@ -0,0 +1,6 @@ +deployment: + strategy: + recreate: {} + rolling: + maxSurge: "25%" + maxUnavailable: 1 diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/release-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/release-values.yaml new file mode 100644 index 00000000000..48eb3f482c1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/release-values.yaml @@ -0,0 +1,14 @@ +server: + deployment: + image_tag: IMAGE_TAG + image: IMAGE_REPO + enabled: false +dbMigrationConfig: + enabled: false + +pauseForSecondsBeforeSwitchActive: 0 +waitForSecondsBeforeScalingDown: 0 +autoPromotionSeconds: 30 + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json new file mode 100644 index 00000000000..6a332631a93 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/schema.json @@ -0,0 +1,1368 @@ + +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "containerExtraSpecs":{ + "type": "object", + "title": "containerExtraSpecs", + "description": "Define container extra specs here" + }, + "ContainerPort": { + "type": "array", + "description": "defines ports on which application services will be exposed to other services", + "title": "Container Port", + "items": { + "type": "object", + "properties": { + "envoyPort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "envoy port for the container", + "title": "Envoy Port" + }, + "idleTimeout": { + "type": "string", + "description": "duration of time for which a connection is idle before the connection is terminated", + "title": "Idle Timeout" + }, + "name": { + "type": "string", + "description": "name of the port", + "title": "Name" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Port", + "title": "port for the container" + }, + "servicePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port of the corresponding kubernetes service", + "title": "Service Port" + }, + "nodePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "nodeport of the corresponding kubernetes service", + "title": "Node Port" + }, + "supportStreaming": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "field to enable/disable timeout for high performance protocols like grpc", + "title": "Support Streaming" + }, + "useHTTP2": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": " field for setting if envoy container can accept(or not) HTTP2 requests", + "title": "Use HTTP2" + } + } + } + }, + "EnvVariables": { + "type": "array", + "items": {}, + "description": "contains environment variables needed by the containers", + "title": "Environment Variables" + }, + "EnvVariablesFromFieldPath":{ + "type": "array", + "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs", + "title": "EnvVariablesFromFieldPath", + "items": [ + { + "type": "object", + "properties": { + "name":{ + "type": "string", + "title": "name", + "description": "Env variable name to be" + }, + "fieldPath":{ + "type": "string", + "title": "fieldPath", + "description": "Path of the field to select in the specified API version" + } + } + } + ] + }, + "EnvVariablesFromSecretKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromSecretKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "secretName": { + "type": "string", + "title": "secretName", + "description": "Name of Secret from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "EnvVariablesFromConfigMapKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromConfigMapKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "configMapName": { + "type": "string", + "title": "configMapName", + "description": "Name of configMap from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "GracePeriod": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "time for which Kubernetes waits before terminating the pods", + "title": "Grace Period" + }, + "LivenessProbe": { + "type": "object", + "description": "used by the kubelet to know when to restart a container", + "title": "Liveness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the liveness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as live", + "title": "Failure Threshold" + }, + "httpHeaders": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for liveness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for liveness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the liveness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "MaxSurge": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be created over the desired number of pods", + "title": "Maximum Surge" + }, + "MaxUnavailable": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be unavailable during the update process", + "title": "Maximum Unavailable" + }, + "MinReadySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available", + "title": "Minimum Ready Seconds" + }, + "ReadinessProbe": { + "type": "object", + "description": "kubelet uses readiness probes to know when a container is ready to start accepting traffic", + "title": "Readiness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the readiness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as ready", + "title": "Failure Threshold" + }, + "httpHeader": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for readiness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for readiness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the readiness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "networkPolicy": { + "type": "object", + "description": "NetworkPolicy describes what network traffic is allowed for a set of Pods", + "title": "Network Policy", + "properties": { + "enabled":{ + "type":"boolean", + "description": "used to enable or disable NetworkPolicy" + }, + "annotations":{ + "type": "object", + "description": "Annotations for NetworkPolicy" + }, + "labels":{ + "type":"object", + "description": "Labels for NetworkPolicy" + }, + "podSelector":{ + "type": "object", + "description": "Selects the pods to which this NetworkPolicy object applies", + "properties": { + "matchExpressions":{ + "type":"array", + "description": "list of label selector" + }, + "matchLabels":{ + "type":"object", + "description": "map of {key,value} pairs" + } + } + }, + "policyTypes":{ + "type":"array", + "description": "List of rule types that the NetworkPolicy relates to. Valid options are Ingress,Egress." + }, + "ingress":{ + "type":"array", + "description": "List of ingress rules to be applied to the selected pods" + }, + "egress":{ + "type":"array", + "description": "List of egress rules to be applied to the selected pods" + } + } + }, + "istio": { + "type": "object", + "description": "Istio Service mesh", + "title": "Istio" + }, + "flaggerCanary":{ + "type": "object", + "description": "Flagger for canary release with istio service mesh", + "title": "Flagger Canary Release" + }, + "Spec": { + "type": "object", + "description": "used to define the desire state of the given container", + "title": "Spec", + "properties": { + "Affinity": { + "type": "object", + "description": "Node/Inter-pod Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node/pods", + "title": "Affinity", + "properties": { + "Key": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string", + "description": "Key part of the label for node/pod selection", + "title": "Key" + } + ] + }, + "Values": { + "type": "string", + "description": "Value part of the label for node/pod selection", + "title": "Values" + }, + "key": { + "type": "string" + } + } + } + } + }, + "ambassadorMapping": { + "type": "object", + "description": "used to create ambassador mapping resource", + "title": "Mapping", + "properties": { + "ambassadorId": { + "type": "string", + "description": "used to specify id for specific ambassador mappings controller", + "title": "Ambassador ID" + }, + "cors": { + "type": "object", + "description": "used to specify cors policy to access host for this mapping", + "title": "CORS" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify whether to create an ambassador mapping or not", + "title": "Enabled" + }, + "weight": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify weight for canary ambassador mappings" + }, + "hostname": { + "type": "string", + "description": "used to specify hostname for ambassador mapping", + "title": "Hostname" + }, + "labels": { + "type": "object", + "description": "used to provide custom labels for ambassador mapping", + "title": "Labels" + }, + "prefix": { + "type": "string", + "description": "used to specify path for ambassador mapping", + "title": "Prefix" + }, + "retryPolicy": { + "type": "object", + "description": "used to specify retry policy for ambassador mapping", + "title": "Retry Policy" + }, + "rewrite": { + "type": "string", + "description": "used to specify whether to redirect the path of this mapping and where", + "title": "Rewrite" + }, + "tls": { + "type": "object", + "description": "used to create or define ambassador TLSContext resource", + "title": "TLS Context" + }, + "extraSpec": { + "type": "object", + "description": "used to provide extra spec values which not present in deployment template for ambassador resource", + "title": "Extra Spec" + } + } + }, + "args": { + "type": "object", + "description": " used to give arguments to command", + "title": "Arguments", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling aruguments", + "title": "Enabled" + }, + "value": { + "type": "array", + "description": "values of the arguments", + "title": "Value", + "items": [ + { + "type": "string" + }, + { + "type": "string" + }, + { + "type": "string" + } + ] + } + } + }, + "autoscaling": { + "type": "object", + "description": "connected to HPA and controls scaling up and down in response to request load", + "title": "Autoscaling", + "properties": { + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling", + "title": "Maximum Replicas" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling", + "title": "Minimum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for a container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for a container", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for that behavior", + "title": "Behavior" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling", + "title": "Enabled" + }, + "labels": { + "type": "object", + "description": "labels for HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "used to configure some options for HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "used to give external metrics for autoscaling", + "title": "Extra Metrics" + } + } + }, + "command": { + "type": "object", + "description": "contains the commands for the server", + "title": "Command", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling commands" + }, + "value": { + "type": "array", + "items": {}, + "description": "contains the commands", + "title": "Value" + }, + "workingDir": { + "type": "object", + "items": {}, + "description": "contains the working directory", + "title": "Working directory" + } + } + }, + "containerSecurityContext": { + "type": "object", + "description": " defines privilege and access control settings for a Container", + "title": "Container Security Context" + }, + "containers": { + "type": "array", + "items": {}, + "description": " used to run side-car containers along with the main container within same pod" + }, + "dbMigrationConfig": { + "type": "object", + "description": "used to configure database migration", + "title": "Db Migration Config", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling the config", + "title": "Enabled" + } + } + }, + "envoyproxy": { + "type": "object", + "description": "envoy is attached as a sidecar to the application container to collect metrics like 4XX, 5XX, throughput and latency", + "title": "Envoy Proxy", + "properties": { + "configMapName": { + "type": "string", + "description": "configMap containing configuration for Envoy", + "title": "ConfigMap" + }, + "lifecycle":{ + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled":{ + "type": "boolean" + }, + "postStart":{ + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created" + }, + "preStop":{ + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + }, + "image": { + "type": "string", + "description": "image of envoy to be used" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + } + } + }, + "hostAliases":{ + "type": "array", + "title": "hostAliases", + "description": "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file", + "items": [ + { + "type": "object", + "properties": { + "ip":{ + "type": "string", + "title": "IP", + "description": "IP address of the host file entry" + }, + "hostnames":{ + "type": "array", + "description": "Hostnames for the above IP address", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "image": { + "type": "object", + "description": "used to access images in kubernetes", + "title": "Image", + "properties": { + "pullPolicy": { + "type": "string", + "description": "used to define the instances calling the image", + "title": "Pull Policy", + "enum": ["IfNotPresent", "Always"] + } + } + }, + "restartPolicy": { + "type": "string", + "description": "It restarts the docker container based on defined conditions.", + "title": "Restart Policy", + "enum": [ + "Always", + "OnFailure", + "Never" + ] + }, + "imagePullSecrets": { + "type": "array", + "items": {}, + "description": "contains the docker credentials that are used for accessing a registry", + "title": "Image PullSecrets" + }, + "winterSoldier": { + "type": "object", + "description": "allows to scale, sleep or delete the resource based on time.", + "title": "winterSoldier", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the winterSoldier controller", + "title": "Annotations" + }, + "labels": { + "type": "object", + "description": "labels for winterSoldier", + "title": "winterSoldier labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "apiVersion": { + "type": "string", + "description": "Api version for winterSoldier", + "title": "winterSoldier apiVersion", + "default": "pincher.devtron.ai/v1alpha1" + }, + "timeRangesWithZone": { + "type": "object", + "description": "describe time zone and time ranges to input in the winterSoldier", + "title": "Time Ranges With Zone", + "timeZone": { + "type": "string", + "description": "describe time zone, and follow standard format", + "title": "Time Zone" + }, + "timeRanges": { + "type": "array", + "items": {}, + "description": "used to take array of time ranges in which each element contains timeFrom, timeTo, weekdayFrom and weekdayTo.", + "title": "Time Ranges" + } + }, + "type": { + "type": "string", + "description": "describe the type of application Rollout/deployment.", + "title": "Type" + }, + "action": { + "type": "string", + "description": "describe the action to be performed by winterSoldier.", + "title": "Action" + }, + "targetReplicas": { + "type": "array", + "description": "describe the number of replicas to which the resource should scale up or down.", + "title": "Target Replicas" + }, + "fieldSelector": { + "type": "array", + "description": "it takes arrays of methods to select specific fields.", + "title": "Field Selector" + } + } + }, + "ingress": { + "type": "object", + "description": "allows public access to URLs", + "title": "Ingress", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx" + }, + "labels": { + "type": "object", + "description": "labels for ingress", + "title": "Ingress labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "ingressInternal": { + "type": "object", + "description": "allows private access to the URLs", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx-internal" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "initContainers": { + "type": "array", + "items": {}, + "description": "specialized containers that run before app containers in a Pod, can contain utilities or setup scripts not present in an app image", + "title": "Init Containers" + }, + "kedaAutoscaling": { + "type": "object", + "description": "Kubernetes-based event driven autoscaler. With KEDA, one can drive the scaling of any container in Kubernetes based on the no. of events needing to be processed", + "title": "KEDA Autoscaling", + "properties": { + "advanced": { + "type": "object" + }, + "authenticationRef": { + "type": "object" + }, + "enabled": { + "type": "boolean" + }, + "envSourceContainerName": { + "type": "string" + }, + "maxReplicaCount": { + "type": "integer" + }, + "minReplicaCount": { + "type": "integer" + }, + "triggerAuthentication": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "spec": { + "type": "object" + } + } + }, + "triggers": { + "type": "array", + "items": {} + } + } + }, + "containerSpec": { + "type":"object", + "description": "define the container specic configuration", + "title": "containerSpec", + "properties": { + "lifecycle": { + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled":{ + "type": "boolean" + }, + "postStart":{ + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created.You could use this event to check that a required API is available before the container’s main work begins" + }, + "preStop":{ + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + } + } + }, + "pauseForSecondsBeforeSwitchActive": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "tell how much to wait for given period of time before switch active the container", + "title": "Pause For Seconds Before SwitchActive" + }, + "podAnnotations": { + "type":"object", + "description": "used to attach metadata and configs in Kubernetes", + "title": "Pod Annotations" + }, + "podDisruptionBudget": { + "type": "object", + "description": "PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods", + "properties": { + "minAvailable":{ + "type": "string", + "title": "minAvailable", + "description": "An eviction is allowed if at least \"minAvailable\" pods selected by \"selector\" will still be available after the eviction, i.e. even in the absence of the evicted pod" + }, + "maxUnavailable":{ + "type": "string", + "title": "maxUnavailable", + "description": "An eviction is allowed if at most \"maxUnavailable\" pods selected by \"selector\" are unavailable after the eviction, i.e. even in absence of the evicted pod." + } + } + }, + "deploymentLabels": { + "type": "object", + "description": "deploymentLabels is an object to define the label on deployment.", + "title": "DeploymentLabels" + }, + "deploymentAnnotations": { + "type": "object", + "description": "deploymentAnnotations is an object to define the annotations on deployment.", + "title": "DeploymentAnnotations" + }, + "podExtraSpecs":{ + "type": "object", + "description": "ExtraSpec for the pods to be configured", + "title": "podExtraSpecs" + }, + "podLabels": { + "type":"object", + "description": "key/value pairs that are attached to pods, are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system", + "title": "Pod Labels" + }, + "podSecurityContext": { + "type":"object", + "description": "defines privilege and access control settings for a Pod or Container", + "title": "Pod Security Context" + }, + "prometheus": { + "type": "object", + "description": "a kubernetes monitoring tool", + "title": "Prometheus", + "properties": { + "release": { + "type": "string", + "description": "name of the file to be monitored, describes the state of prometheus" + } + } + }, + "rawYaml": { + "type": "array", + "items": {}, + "description": "Accepts an array of Kubernetes objects. One can specify any kubernetes yaml here & it will be applied when a app gets deployed.", + "title": "Raw YAML" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "count of Replicas of pod", + "title": "REplica Count" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + }, + "secret": { + "type": "object", + "properties": { + "data": { + "type": "object" + }, + "enabled": { + "type": "boolean" + } + } + }, + "server": { + "type": "object", + "description": "used for providing server configurations.", + "title": "Server", + "properties": { + "deployment": { + "type": "object", + "description": "gives the details for deployment", + "title": "Deployment", + "properties": { + "image": { + "type": "string", + "description": "URL of the image", + "title": "Image" + }, + "image_tag": { + "type": "string", + "description": "tag of the image", + "title": "Image Tag" + } + } + } + } + }, + "service": { + "type": "object", + "description": "defines annotations and the type of service", + "title": "Service", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service" + }, + "type": { + "type": "string", + "description": "type of service", + "title": "Type", + "enum": [ + "ClusterIP", + "LoadBalancer", + "NodePort", + "ExternalName" + ] + } + } + }, + "serviceAccount": { + "type": "object", + "description": "defines service account for pods", + "title": "Service Account", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service account" + }, + "name": { + "type": "string", + "description": "name of service account", + "title": "Name" + }, + "create": { + "type": "boolean" + } + } + }, + "servicemonitor": { + "type": "object", + "description": "gives the set of targets to be monitored", + "title": "Service Monitor", + "properties": { + "additionalLabels": { + "type": "object" + } + } + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "a mechanism which work together with Taints which ensures that pods are not placed on inappropriate nodes", + "title": "Tolerations" + }, + "topologySpreadConstraints": { + "type": "array", + "items": {}, + "description": "used to control how Pods are spread across a cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains", + "title": "Topology Spread Constraints" + }, + "volumeMounts": { + "type": "array", + "items": {}, + "description": "used to provide mounts to the volume", + "title": "Volume Mounts" + }, + "volumes": { + "type": "array", + "items": {}, + "description": "required when some values need to be read from or written to an external disk", + "title": "Volumes" + }, + "waitForSecondsBeforeScalingDown": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Wait for given period of time before scaling down the container", + "title": "Wait For Seconds Before Scaling Down" + } + } +} + diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/secrets-test-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/secrets-test-values.yaml new file mode 100644 index 00000000000..4a20404db87 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/secrets-test-values.yaml @@ -0,0 +1 @@ +{"ConfigSecrets":{"enabled":true,"secrets":[{"data":{"standard_key":"c3RhbmRhcmQtdmFsdWU="},"external":false,"externalType":"","mountPath":"/test","name":"normal-secret","type":"volume"},{"data":{"secret_key":"U0VDUkVUIERBVEE="},"external":true,"externalType":"AWSSecretsManager","mountPath":"","name":"external-secret-3","type":"environment"}]}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/NOTES.txt b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/NOTES.txt new file mode 100644 index 00000000000..2b144781688 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range $.Values.ingress.paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include ".Chart.Name .fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include ".Chart.Name .fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include ".Chart.Name .fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include ".Chart.Name .name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/_helpers.tpl b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/_helpers.tpl new file mode 100644 index 00000000000..8fdc4daa201 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/_helpers.tpl @@ -0,0 +1,150 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define ".Chart.Name .name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create service name +*/}} +{{- define ".servicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 63 | trimSuffix "-" -}} +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 55 | trimSuffix "-" -}}-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create preview service name +*/}} +{{- define ".previewservicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 55 | trimSuffix "-" -}}-preview +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define ".Chart.Name .fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define ".Chart.Name .chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define ".Chart.Name .color" -}} +{{- $active0 := (index .Values.server.deployment 0).enabled -}} +{{/* +{{- $active1 := (index .Values.server.deployment 1).enabled -}} +*/}} +{{- $active1 := include "safeenabledcheck" . -}} +{{- $active := and $active0 $active1 -}} +{{- $active -}} +{{- end -}} + +{{- define "safeenabledcheck" -}} +{{- if (eq (len .Values.server.deployment) 2) -}} + {{- if (index .Values.server.deployment 1).enabled -}} + {{- $active := true -}} + {{- $active -}} + {{- else -}} + {{- $active := false -}} + {{- $active -}} + {{- end -}} +{{- else -}} + {{- $active := false -}} + {{- $active -}} +{{- end -}} +{{- end -}} + + +{{- define "isCMVolumeExists" -}} + {{- $isCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $isCMVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isCMVolumeExists -}} +{{- end -}} + +{{- define "isSecretVolumeExists" -}} + {{- $isSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $isSecretVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isSecretVolumeExists -}} +{{- end -}} + + + + +{{- define "serviceMonitorEnabled" -}} + {{- $SMenabled := false -}} + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if and .servicemonitor.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- end }} + {{- end }} + {{- $SMenabled -}} +{{- end -}} + +{{- define "VerticalPodAutoScalingEnabled" -}} + {{- $SMenabled := false -}} + {{- if and .Values.verticalPodScaling.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- $SMenabled -}} +{{- end -}} + +{{/* Create the name of the service account to use */}} +{{- define "serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include ".Chart.Name .fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml new file mode 100644 index 00000000000..5875da84ba8 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml @@ -0,0 +1,83 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ambassadorMapping.enabled }} +{{- with $.Values.ambassadorMapping }} +apiVersion: getambassador.io/v3alpha1 +kind: Mapping +metadata: + name: {{ include ".Chart.Name .fullname" $ }}-mapping + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .labels }} +{{ toYaml .labels | nindent 4 }} + {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .ambassadorId }} + ambassador_id: {{ .ambassadorId }} + {{- end }} + {{- if .hostname }} + hostname: {{ .hostname | quote }} + {{- end }} + prefix: {{ .prefix }} + {{- if .rewrite }} + rewrite: {{ .rewrite }} + {{- end }} + service: {{ $svcName }}.{{ $.Release.Namespace }}:{{ $svcPort }} + {{- if .retryPolicy }} + retry_policy: +{{ toYaml .retryPolicy | indent 4 }} + {{- end }} + {{- if .cors }} + cors: +{{ toYaml .cors | indent 4 }} + {{- end }} + {{- if .weight }} + weight: {{ .weight }} + {{- end }} + {{- if .method }} + method: {{ .method }} + {{- end }} + {{- if .extraSpec }} +{{ toYaml .extraSpec | indent 2 }} + {{- end }} + {{- if .tls }} + {{- if .tls.context }} + tls: {{ .tls.context }} +{{- if .tls.create }} +--- +apiVersion: getambassador.io/v3alpha1 +kind: TLSContext +metadata: + name: {{ .tls.context }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .tls.labels }} +{{ toYaml .tls.labels | nindent 4 }} + {{- end }} +spec: + {{- if .tls.secretName }} + secret: {{ .tls.secretName }} + {{- end }} + {{- if .tls.hosts }} + hosts: +{{ toYaml .tls.hosts | nindent 4 }} + {{- end }} + {{- if .tls.extraSpec }} +{{ toYaml .tls.extraSpec | indent 2 }} + {{- end }} +{{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml new file mode 100644 index 00000000000..72d5ca84798 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +data: +{{ toYaml .data | trim | indent 2 }} + {{- end}} + {{- end}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml new file mode 100644 index 00000000000..558890a3291 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml @@ -0,0 +1,638 @@ + {{- $hasCMEnvExists := false -}} + {{- $hasCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $hasCMVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasCMEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + {{- $hasPVCExists := false -}} + {{- if .Values.persistentVolumeClaim.name }} + {{- $hasPVCExists = true }} + {{- end }} + + {{- $hasSecretEnvExists := false -}} + {{- $hasSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $hasSecretVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasSecretEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ .Values.pipelineName }} +{{- if .Values.deploymentLabels }} +{{ toYaml .Values.deploymentLabels | indent 4 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + +{{- if .Values.deploymentAnnotations }} + annotations: +{{ toYaml .Values.deploymentAnnotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: +{{- if .Values.customMatchLabels }} +{{ toYaml .Values.customMatchLabels | indent 6 }} +{{- end }} + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + replicas: {{ $.Values.replicaCount }} + minReadySeconds: {{ $.Values.MinReadySeconds }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 8 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | indent 8 }} +{{- end }} + spec: +{{- if $.Values.podExtraSpecs }} +{{ toYaml .Values.podExtraSpecs | indent 6 }} +{{- end }} + terminationGracePeriodSeconds: {{ $.Values.GracePeriod }} + restartPolicy: Always +{{- if $.Values.hostAliases }} + hostAliases: +{{ toYaml .Values.hostAliases | indent 8 }} +{{- end }} +{{- if and $.Values.Spec.Affinity.Key $.Values.Spec.Affinity.Values }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: {{ $.Values.Spec.Affinity.Key }} + operator: In + values: + - {{ $.Values.Spec.Affinity.Values | default "nodes" }} +{{- else if $.Values.affinity.enabled }} + affinity: +{{ toYaml .Values.affinity.values | indent 8 }} +{{- end }} +{{- if $.Values.serviceAccountName }} + serviceAccountName: {{ $.Values.serviceAccountName }} +{{- else }} + serviceAccountName: {{ template "serviceAccountName" . }} +{{- end }} +{{- if $.Values.schedulerName }} + schedulerName: {{ .Values.schedulerName }} +{{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} +{{- if $.Values.imagePullSecrets}} + imagePullSecrets: + {{- range .Values.imagePullSecrets }} + - name: {{ . }} + {{- end }} +{{- end}} +{{- if $.Values.topologySpreadConstraints }} + topologySpreadConstraints: +{{- range $.Values.topologySpreadConstraints }} + - maxSkew: {{ .maxSkew }} + topologyKey: {{ .topologyKey }} + whenUnsatisfiable: {{ .whenUnsatisfiable }} + {{- if semverCompare "<=1.30-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .minDomains }} + minDomains: {{ .minDomains }} + {{- end }} + {{- end }} + {{- if .nodeAffinityPolicy }} + nodeAffinityPolicy: {{ .nodeAffinityPolicy }} + {{- end }} + {{- if .nodeTaintsPolicy }} + nodeTaintsPolicy: {{ .nodeTaintsPolicy }} + {{- end }} + labelSelector: + matchLabels: + {{- if and .autoLabelSelector .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- else if .autoLabelSelector }} + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} + {{- else if .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- end }} +{{- end }} +{{- end }} +{{- if $.Values.topologySpreadConstraint }} + topologySpreadConstraints: +{{ toYaml .Values.topologySpreadConstraint }} +{{- end }} +{{- if $.Values.podSecurityContext }} + securityContext: +{{ toYaml .Values.podSecurityContext | indent 8 }} +{{- end }} +{{- if $.Values.restartPolicy }} + restartPolicy: {{ $.Values.restartPolicy }} +{{- end }} +{{- if $.Values.initContainers}} + initContainers: +{{- range $i, $c := .Values.initContainers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-init-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .args}} + args: +{{ toYaml .args | indent 12 -}} +{{- end}} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + containers: + - name: {{ $.Chart.Name }} + image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + {{- if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- if $.Values.containerSpec.lifecycle.postStart }} + postStart: +{{ toYaml $.Values.containerSpec.lifecycle.postStart | indent 12 -}} + {{- end }} + {{- end }} +{{- if and $.Values.containerSecurityContext $.Values.privileged }} + securityContext: + privileged: true +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- else if $.Values.privileged }} + securityContext: + privileged: true +{{- else if $.Values.containerSecurityContext }} + securityContext: +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- end }} +{{- if $.Values.containerExtraSpecs }} +{{ toYaml .Values.containerExtraSpecs | indent 10 }} +{{- end }} +{{- if $.Values.resizePolicy }} + resizePolicy: +{{ toYaml .Values.resizePolicy | indent 12 }} +{{- end }} + ports: + {{- range $.Values.ContainerPort }} + - name: {{ .name}} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end}} +{{- if and $.Values.command.enabled $.Values.command.workingDir }} + workingDir: {{ $.Values.command.workingDir }} +{{- end}} +{{- if and $.Values.command.value $.Values.command.enabled}} + command: +{{ toYaml $.Values.command.value | indent 12 -}} +{{- end}} +{{- if and $.Values.args.value $.Values.args.enabled}} + args: +{{ toYaml $.Values.args.value | indent 12 -}} +{{- end }} + env: + - name: CONFIG_HASH + value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }} + - name: SECRET_HASH + value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }} + - name: DEVTRON_APP_NAME + value: {{ template ".Chart.Name .name" $ }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: DEVTRON_CONTAINER_REPO + value: "{{ .Values.server.deployment.image }}" + - name: DEVTRON_CONTAINER_TAG + value: "{{ .Values.server.deployment.image_tag }}" + {{- range $.Values.EnvVariablesFromFieldPath }} + - name: {{ .name }} + valueFrom: + fieldRef: + fieldPath: {{ .fieldPath }} + {{- end}} + {{- range $.Values.EnvVariables }} + {{- if and .name .value }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromSecretKeys }} + {{- if and .name .secretName .keyName }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromConfigMapKeys }} + {{- if and .name .configMapName .keyName }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ .configMapName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- if or (and ($hasCMEnvExists) (.Values.ConfigMaps.enabled)) (and ($hasSecretEnvExists) (.Values.ConfigSecrets.enabled)) }} + envFrom: + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "environment" }} + - configMapRef: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "environment" }} + - secretRef: + {{if eq .external true}} + name: {{ .name }} + {{else if eq .external false}} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + +{{- if or $.Values.LivenessProbe.Path $.Values.LivenessProbe.command $.Values.LivenessProbe.tcp $.Values.LivenessProbe.grpc }} + livenessProbe: +{{- if $.Values.LivenessProbe.Path }} + httpGet: + path: {{ $.Values.LivenessProbe.Path }} + port: {{ $.Values.LivenessProbe.port }} + scheme: {{ $.Values.LivenessProbe.scheme }} + {{- if $.Values.LivenessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.LivenessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.LivenessProbe.command }} + exec: + command: +{{ toYaml .Values.LivenessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.LivenessProbe.tcp }} + tcpSocket: + port: {{ $.Values.LivenessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.LivenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.LivenessProbe.periodSeconds }} + successThreshold: {{ $.Values.LivenessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.LivenessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.LivenessProbe.failureThreshold }} + {{- if $.Values.LivenessProbe.grpc }} + grpc: +{{ toYaml .Values.LivenessProbe.grpc | indent 14 }} + {{- end }} +{{- end }} +{{- if or $.Values.ReadinessProbe.Path $.Values.ReadinessProbe.command $.Values.ReadinessProbe.tcp $.Values.ReadinessProbe.grpc }} + readinessProbe: +{{- if $.Values.ReadinessProbe.Path }} + httpGet: + path: {{ $.Values.ReadinessProbe.Path }} + port: {{ $.Values.ReadinessProbe.port }} + scheme: {{ $.Values.ReadinessProbe.scheme }} + {{- if $.Values.ReadinessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.ReadinessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.ReadinessProbe.command }} + exec: + command: +{{ toYaml .Values.ReadinessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.ReadinessProbe.tcp }} + tcpSocket: + port: {{ $.Values.ReadinessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.ReadinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.ReadinessProbe.periodSeconds }} + successThreshold: {{ $.Values.ReadinessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.ReadinessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.ReadinessProbe.failureThreshold }} + {{- if $.Values.ReadinessProbe.grpc }} + grpc: +{{ toYaml .Values.ReadinessProbe.grpc | indent 14 }} + {{- end}} +{{- end }} + resources: +{{ toYaml $.Values.resources | trim | indent 12 }} +{{- if or $.Values.StartupProbe.Path $.Values.StartupProbe.command $.Values.StartupProbe.tcp $.Values.StartupProbe.grpc }} + startupProbe: +{{- if $.Values.StartupProbe.Path }} + httpGet: + path: {{ $.Values.StartupProbe.Path }} + port: {{ $.Values.StartupProbe.port }} + {{- if $.Values.StartupProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.StartupProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.StartupProbe.command }} + exec: + command: +{{ toYaml .Values.StartupProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.StartupProbe.tcp }} + tcpSocket: + port: {{ $.Values.StartupProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.StartupProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.StartupProbe.periodSeconds }} + successThreshold: {{ $.Values.StartupProbe.successThreshold }} + timeoutSeconds: {{ $.Values.StartupProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.StartupProbe.failureThreshold }} + {{- if $.Values.StartupProbe.grpc }} + grpc: +{{ toYaml .Values.StartupProbe.grpc | indent 14 }} + {{- end}} +{{- end }} + volumeMounts: +{{- with .Values.volumeMounts }} +{{ toYaml . | trim | indent 12 }} +{{- end }} +{{- if $.Values.persistentVolumeClaim.name }} + - name: {{ .Values.persistentVolumeClaim.name }}-vol + mountPath: {{ .Values.persistentVolumeClaim.mountPath | default "/tmp" }} +{{- end}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{- range $k, $v := .data }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} + {{- if and (.esoSubPath) (ne (len .esoSubPath) 0) }} + {{- range .esoSubPath }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ . }} + subPath: {{ . }} + {{- end }} + {{- else }} + {{- range .esoSecretData.esoData }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ .secretKey }} + subPath: {{ .secretKey }} + {{- end }} + {{- end }} + {{- else }} + {{- range $k, $v := .data }} # for others secrets the mount path will be .data[i].secretKey + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} +{{- if $.Values.appMetrics }} + - name: envoy + image: {{ $.Values.envoyproxy.image | default "quay.io/devtron/envoy:v1.16.0"}} + {{- if $.Values.envoyproxy.lifecycle }} + lifecycle: +{{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} + {{- else if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- end }} + resources: +{{ toYaml $.Values.envoyproxy.resources | trim | indent 12 }} + ports: + - containerPort: 9901 + protocol: TCP + name: envoy-admin + {{- range $index, $element := .Values.ContainerPort }} + - name: {{ $element.name}} + containerPort: {{ $element.envoyPort | default (add 8790 $index) }} + protocol: TCP + {{- end }} + command: ["/usr/local/bin/envoy"] + args: ["-c", "/etc/envoy-config/envoy-config.json", "-l", "info", "--log-format", "[METADATA][%Y-%m-%d %T.%e][%t][%l][%n] %v"] + volumeMounts: + - name: {{ $.Values.envoyproxy.configMapName | default "envoy-config-volume" }} + mountPath: /etc/envoy-config/ +{{- if $.Values.envoyproxy.readinessProbe}} + readinessProbe: +{{ toYaml $.Values.envoyproxy.readinessProbe | indent 12}} +{{- end }} +{{- if $.Values.envoyproxy.livenessProbe}} + livenessProbe: +{{ toYaml $.Values.envoyproxy.livenessProbe | indent 12}} +{{- end }} +{{- end}} +{{- if $.Values.containers }} +{{- range $i, $c := .Values.containers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-sidecontainer-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .env }} + env: +{{ toYaml .env | indent 12 }} +{{- end }} + {{- if .envFrom }} + envFrom: +{{ toYaml .env | indent 12 }} +{{- end }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resizePolicy }} + resizePolicy: +{{ toYaml .resziePolicy | indent 12}} +{{- end }} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + + + volumes: + {{- if $.Values.appMetrics }} + - name: envoy-config-volume + configMap: + name: sidecar-config-{{ template ".Chart.Name .name" $ }} + {{- end }} +{{- with .Values.volumes }} +{{ toYaml . | trim | indent 8 }} +{{- end }} +{{- if .Values.persistentVolumeClaim.name }} + - name: {{.Values.persistentVolumeClaim.name}}-vol + persistentVolumeClaim: + claimName: {{.Values.persistentVolumeClaim.name }} +{{- end}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + configMap: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + secret: + {{- if eq .external true }} + secretName: {{ .name }} + {{- else if eq .external false }} + secretName: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} + + revisionHistoryLimit: 3 +## pauseForSecondsBeforeSwitchActive: {{ $.Values.pauseForSecondsBeforeSwitchActive }} +# waitForSecondsBeforeScalingDown: {{ $.Values.waitForSecondsBeforeScalingDown }} + strategy: + {{- if eq .Values.deploymentType "ROLLING" }} + type: "RollingUpdate" + rollingUpdate: + maxSurge: {{ $.Values.deployment.strategy.rolling.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.rolling.maxUnavailable }} + {{- end }} + {{- if eq .Values.deploymentType "RECREATE" }} + type: "Recreate" + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml new file mode 100644 index 00000000000..ea0ee9f5dc1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml @@ -0,0 +1,66 @@ +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external true }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} +{{- if .esoSecretData.secretStore }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: SecretStore +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + provider: + {{- toYaml .esoSecretData.secretStore | nindent 4 }} +{{- end }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: {{ .name }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .esoSecretData.refreshInterval }} + refreshInterval: {{ .esoSecretData.refreshInterval }} + {{- else }} + refreshInterval: 1h + {{- end}} + {{- if and .esoSecretData.secretStoreRef (not .esoSecretData.secretStore) }} + secretStoreRef: +{{ toYaml .esoSecretData.secretStoreRef | indent 4 }} + {{- else }} + secretStoreRef: + name: {{ .name}} + kind: SecretStore + {{- end }} + target: + name: {{ .name}} + {{- if .esoSecretData.template }} + template: + {{- toYaml .esoSecretData.template | nindent 6 }} + {{- end }} + creationPolicy: Owner + {{- if .esoSecretData.esoDataFrom }} + dataFrom: + {{- toYaml .esoSecretData.esoDataFrom | nindent 4 }} + {{- else }} + data: + {{- range .esoSecretData.esoData }} + - secretKey: {{ .secretKey }} + remoteRef: + key: {{ .key }} + {{- if .property }} + property: {{ .property }} + {{- end }} + {{- end}} +{{- end}} +{{- end}} +{{- end}} +{{- end}} +{{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/flagger.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/flagger.yaml new file mode 100644 index 00000000000..766098fb618 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/flagger.yaml @@ -0,0 +1,164 @@ +{{- if .Values.flaggerCanary.enabled }} +{{ if .Values.flaggerCanary.createIstioGateway.enabled -}} +{{- with .Values.flaggerCanary.createIstioGateway }} +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .labels }} +{{ toYaml .labels | indent 4 }} + {{- end }} +{{- if .annotations }} + annotations: +{{ toYaml .annotations | indent 4 }} +{{- end }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - {{ .host | quote -}} +{{- if .tls.enabled }} + tls: + httpsRedirect: true + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - {{ .host | quote }} + tls: + mode: SIMPLE + credentialName: {{ .tls.secretName }} +{{ end }} +{{ end }} +{{ end }} +{{ end }} +--- +{{- if .Values.flaggerCanary.enabled }} +{{- with .Values.flaggerCanary }} +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-canary + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .labels }} +{{ toYaml .labels | indent 4 }} + {{- end }} +{{- if .annotations }} + annotations: +{{ toYaml .annotations | indent 4 }} +{{- end }} +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include ".Chart.Name .fullname" $ }} +{{- if $.Values.autoscaling.enabled }} + autoscalerRef: + apiVersion: autoscaling/v1 + kind: HorizontalPodAutoscaler + name: {{ template ".Chart.Name .fullname" $ }}-hpa +{{- end }} + service: + portDiscovery: {{ .portDiscovery }} + port: {{ .serviceport }} + targetPort: {{ .targetPort }} + {{- if .appProtocol }} + appProtocol: {{ .appProtocol }} + {{- end }} +{{- if $.Values.flaggerCanary.gatewayRefs }} + gatewayRefs: +{{ toYaml $.Values.flaggerCanary.gatewayRefs | indent 6 }} +{{- end }} + {{- if or .createIstioGateway.enabled .addOtherGateways }} + gateways: + {{- if .createIstioGateway.enabled }} + - {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} + {{- if .addOtherGateways }} + {{- range .addOtherGateways }} + - {{ . }} + {{- end }} + {{- end }} + {{- end }} + {{- if or .createIstioGateway.enabled .addOtherHosts }} + hosts: + {{- if .createIstioGateway.enabled }} + - {{ .createIstioGateway.host | quote }} + {{- end }} + {{- if .addOtherHosts }} + {{- range .addOtherHosts }} + - {{ . | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- if .retries }} + retries: +{{ toYaml .retries | indent 6 }} + {{- end }} + {{- if .match }} + match: + {{- range .match }} + - uri: + prefix: {{ .uri.prefix }} + {{- end }} + {{- end }} + {{- if .rewriteUri }} + rewrite: + uri: {{ .rewriteUri }} + {{- end }} + {{- if .timeout }} + timeout: {{ .timeout }} + {{- end }} +{{- if $.Values.flaggerCanary.headers }} + headers: +{{ toYaml $.Values.flaggerCanary.headers | indent 6 }} +{{- end }} +{{- if $.Values.flaggerCanary.corsPolicy }} + corsPolicy: +{{ toYaml $.Values.flaggerCanary.corsPolicy | indent 6 }} +{{- end }} + analysis: + interval: {{ .analysis.interval }} + threshold: {{ .analysis.threshold }} + maxWeight: {{ .analysis.maxWeight }} + stepWeight: {{ .analysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .thresholds.successRate }} + interval: 1m + - name: request-duration + threshold: {{ .thresholds.latency }} + interval: 1m + webhooks: + {{- if .loadtest.enabled }} + - name: load-test + url: {{ .loadtest.url }} + timeout: 5s + metadata: + cmd: "hey -z 1m -q 10 -c 2 http://{{ include ".Chart.Name .fullname" $ }}-canary.{{ $.Release.Namespace }}:{{ $.Values.flaggerCanary.targetPort }}/" + {{- end }} +{{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/generic.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/generic.yaml new file mode 100644 index 00000000000..db95e842670 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/generic.yaml @@ -0,0 +1,4 @@ +{{- range .Values.rawYaml }} +--- +{{ toYaml . }} + {{- end -}} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml new file mode 100644 index 00000000000..cad686a0f1f --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml @@ -0,0 +1,81 @@ +{{- if $.Values.autoscaling.enabled }} +{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2 +{{- else if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2beta2 +{{- else }} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- if .Values.autoscaling.annotations }} + annotations: +{{ toYaml .Values.autoscaling.annotations | indent 4 }} + {{- end }} + {{- if .Values.autoscaling.labels }} + labels: +{{ toYaml .Values.autoscaling.labels | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include ".Chart.Name .fullname" $ }} + minReplicas: {{ $.Values.autoscaling.MinReplicas }} + maxReplicas: {{ $.Values.autoscaling.MaxReplicas }} + metrics: + {{- if $.Values.autoscaling.containerResource.enabled }} + {{- with $.Values.autoscaling.containerResource }} + {{- if .TargetCPUUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: cpu + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetCPUUtilizationPercentage }} + {{- end}} + {{- if .TargetMemoryUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: memory + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetMemoryUtilizationPercentage }} + {{- end}} + {{- end }} + {{- end }} + {{- if $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if $.Values.autoscaling.TargetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if and $.Values.autoscaling.extraMetrics (semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $.Values.autoscaling.extraMetrics | nindent 2 }} + {{- end}} + {{- if and $.Values.autoscaling.behavior (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml new file mode 100644 index 00000000000..3a4921f69d2 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml @@ -0,0 +1,177 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ingress.enabled -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- if and .Values.ingressInternal.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingressInternal.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingressInternal.annotations "kubernetes.io/ingress.class" .Values.ingressInternal.className}} + {{- end }} +{{- end }} +{{- end }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.ingress.labels }} +{{ toYaml .Values.ingress.labels | indent 4 }} + {{- end }} +{{- if .Values.ingress.annotations }} + annotations: +{{ toYaml .Values.ingress.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + rules: + {{- if or .Values.ingress.host .Values.ingress.path }} + - host: {{ .Values.ingress.host }} + http: + paths: + - path: {{ .Values.ingress.path }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingress.pathType | default "ImplementationSpecific" }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingress.hosts) (not ($.Values.ingress.host )) }} + {{- range .Values.ingress.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + + {{- end }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end }} +{{- if $.Values.ingressInternal.enabled }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{ else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{ else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress-internal + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.ingressInternal.annotations }} + annotations: +{{ toYaml .Values.ingressInternal.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingressInternal.className }} + {{- end }} + rules: + {{- if or .Values.ingressInternal.host .Values.ingressInternal.path }} + - host: {{ .Values.ingressInternal.host }} + http: + paths: + - path: {{ .Values.ingressInternal.path }} + {{- if and .Values.ingressInternal.pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingressInternal.pathType | default "Prefix" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingressInternal.hosts) (not ($.Values.ingressInternal.host )) }} + {{- range .Values.ingressInternal.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ingressInternal.tls }} + tls: +{{ toYaml .Values.ingressInternal.tls | indent 4 }} + {{- end -}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-authorizationpolicy.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-authorizationpolicy.yaml new file mode 100644 index 00000000000..ac7b456ec5b --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-authorizationpolicy.yaml @@ -0,0 +1,37 @@ +{{- with .Values.istio }} +{{- if and .enable .authorizationPolicy.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .authorizationPolicy.labels }} +{{ toYaml .authorizationPolicy.labels | indent 4 }} + {{- end }} +{{- if .authorizationPolicy.annotations }} + annotations: +{{ toYaml .authorizationPolicy.annotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} + action: {{ .authorizationPolicy.action }} +{{- if $.Values.istio.authorizationPolicy.provider }} + provider: +{{ toYaml $.Values.istio.authorizationPolicy.provider | indent 4 }} +{{- end }} +{{- if $.Values.istio.authorizationPolicy.rules }} + rules: +{{ toYaml $.Values.istio.authorizationPolicy.rules | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-destinationrule.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-destinationrule.yaml new file mode 100644 index 00000000000..47bef9a828e --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-destinationrule.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .destinationRule.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: DestinationRule +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .destinationRule.labels }} +{{ toYaml .destinationRule.labels | indent 4 }} + {{- end }} +{{- if .destinationRule.annotations }} + annotations: +{{ toYaml .destinationRule.annotations | indent 4 }} +{{- end }} +spec: + host: "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- if $.Values.istio.destinationRule.subsets }} + subsets: +{{ toYaml $.Values.istio.destinationRule.subsets | indent 4 }} +{{- end }} +{{- if $.Values.istio.destinationRule.trafficPolicy }} + trafficPolicy: +{{ toYaml $.Values.istio.destinationRule.trafficPolicy | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-gateway.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-gateway.yaml new file mode 100644 index 00000000000..d6579590100 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-gateway.yaml @@ -0,0 +1,50 @@ +{{- if and .Values.istio.enable .Values.istio.gateway.enabled -}} +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.istio.gateway.labels }} +{{ toYaml $.Values.istio.gateway.labels | indent 4 }} + {{- end }} +{{- if $.Values.istio.gateway.annotations }} + annotations: +{{ toYaml $.Values.istio.gateway.annotations | indent 4 }} +{{- end }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - {{ .Values.istio.gateway.host | quote -}} +{{ with .Values.istio.gateway }} +{{- if .tls.enabled }} + tls: + httpsRedirect: true + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - {{ .host | quote }} + tls: + mode: SIMPLE + credentialName: {{ .tls.secretName }} +{{ end }} +{{ end }} +{{ end }} + + + diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-peerauthentication.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-peerauthentication.yaml new file mode 100644 index 00000000000..481f8a96474 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-peerauthentication.yaml @@ -0,0 +1,36 @@ +{{- with .Values.istio }} +{{- if and .enable .peerAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: PeerAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .peerAuthentication.labels }} +{{ toYaml .peerAuthentication.labels | indent 4 }} + {{- end }} +{{- if .peerAuthentication.annotations }} + annotations: +{{ toYaml .peerAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .peerAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} + mtls: + mode: {{ .peerAuthentication.mtls.mode }} +{{- if $.Values.istio.peerAuthentication.portLevelMtls }} + portLevelMtls: +{{ toYaml $.Values.istio.peerAuthentication.portLevelMtls | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-requestauthentication.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-requestauthentication.yaml new file mode 100644 index 00000000000..3429cee1462 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-requestauthentication.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .requestAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: RequestAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .requestAuthentication.labels }} +{{ toYaml .requestAuthentication.labels | indent 4 }} + {{- end }} +{{- if .requestAuthentication.annotations }} + annotations: +{{ toYaml .requestAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .requestAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} +{{- if $.Values.istio.requestAuthentication.jwtRules }} + jwtRules: +{{ toYaml $.Values.istio.requestAuthentication.jwtRules | indent 2 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-virtualservice.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-virtualservice.yaml new file mode 100644 index 00000000000..af61039b8db --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/istio-virtualservice.yaml @@ -0,0 +1,50 @@ +{{- with .Values.istio }} +{{- if and .enable .virtualService.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .virtualService.labels }} +{{ toYaml .virtualService.labels | indent 4 }} + {{- end }} +{{- if .virtualService.annotations }} + annotations: +{{ toYaml .virtualService.annotations | indent 4 }} +{{- end }} +spec: +{{- if or .gateway.enabled .virtualService.gateways }} + gateways: + {{- if .gateway.enabled }} + - {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} + {{- range .virtualService.gateways }} + - {{ . | quote }} + {{- end }} +{{- end }} +{{- if or .gateway.enabled .virtualService.hosts }} + hosts: + {{- if .gateway.enabled }} + - {{ .gateway.host | quote }} + {{- end }} + {{- range .virtualService.hosts }} + - {{ . | quote }} + {{- end }} +{{- else }} + hosts: + - "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- end }} +{{- if $.Values.istio.virtualService.http }} + http: +{{ toYaml $.Values.istio.virtualService.http | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml new file mode 100644 index 00000000000..f92af5924df --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml @@ -0,0 +1,64 @@ +{{- if $.Values.kedaAutoscaling.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-keda + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.labels }} +{{ toYaml .Values.kedaAutoscaling.labels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.annotations }} + annotations: +{{ toYaml .Values.kedaAutoscaling.annotations | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include ".Chart.Name .fullname" $ }} +{{- if $.Values.kedaAutoscaling.envSourceContainerName }} + envSourceContainerName: {{ $.Values.kedaAutoscaling.envSourceContainerName }} +{{- end }} +{{- if $.Values.kedaAutoscaling.pollingInterval }} + pollingInterval: {{ $.Values.kedaAutoscaling.pollingInterval }} +{{- end }} +{{- if $.Values.kedaAutoscaling.cooldownPeriod }} + cooldownPeriod: {{ $.Values.kedaAutoscaling.cooldownPeriod }} +{{- end }} +{{- if $.Values.kedaAutoscaling.idleReplicaCount }} + idleReplicaCount: {{ $.Values.kedaAutoscaling.idleReplicaCount }} +{{- end }} + minReplicaCount: {{ $.Values.kedaAutoscaling.minReplicaCount }} + maxReplicaCount: {{ $.Values.kedaAutoscaling.maxReplicaCount }} +{{- if $.Values.kedaAutoscaling.fallback }} + fallback: +{{ toYaml $.Values.kedaAutoscaling.fallback | indent 4 }} +{{- end }} +{{- if $.Values.kedaAutoscaling.advanced }} + advanced: +{{ toYaml $.Values.kedaAutoscaling.advanced | indent 4 }} +{{- end }} + triggers: +{{ toYaml .Values.kedaAutoscaling.triggers | indent 2}} +{{- if $.Values.kedaAutoscaling.authenticationRef }} + authenticationRef: +{{ toYaml $.Values.kedaAutoscaling.authenticationRef | indent 6 }} +{{- end }} +--- +{{- if $.Values.kedaAutoscaling.triggerAuthentication.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: TriggerAuthentication +metadata: + name: {{ $.Values.kedaAutoscaling.triggerAuthentication.name }} +spec: +{{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/metrics-service-monitor.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/metrics-service-monitor.yaml new file mode 100644 index 00000000000..fa5321d3034 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/metrics-service-monitor.yaml @@ -0,0 +1,35 @@ +{{- if $.Values.appMetrics -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: + jobLabel: {{ template ".Chart.Name .name" $ }} + endpoints: + - port: envoy-admin + interval: 30s + path: /stats/prometheus + relabelings: + - action: replace + sourceLabels: + - __meta_kubernetes_pod_label_pod_template_hash + targetLabel: devtron_app_hash + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + namespaceSelector: + matchNames: + - {{.Release.Namespace}} + podTargetLabels: + - appId + - envId + - devtron_app_hash +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/networkpolicy.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/networkpolicy.yaml new file mode 100644 index 00000000000..350232a23b6 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/networkpolicy.yaml @@ -0,0 +1,50 @@ +{{- if .Values.networkPolicy.enabled -}} +{{- with .Values.networkPolicy }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.networkPolicy.labels }} +{{ toYaml $.Values.networkPolicy.labels | indent 4 }} + {{- end }} +{{- if $.Values.networkPolicy.annotations }} + annotations: +{{ toYaml $.Values.networkPolicy.annotations | indent 4 }} +{{- end }} +spec: + podSelector: +{{- if .podSelector.matchExpressions }} + matchExpressions: +{{ toYaml $.Values.networkPolicy.podSelector.matchExpressions | indent 6 }} +{{- end }} +{{- if .podSelector.matchLabels }} + matchLabels: +{{ toYaml $.Values.networkPolicy.podSelector.matchLabels | indent 6 }} +{{- else }} + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} +{{- end }} +{{- if .policyTypes }} + policyTypes: +{{ toYaml $.Values.networkPolicy.policyTypes | indent 4 }} +{{- end }} +{{- if .ingress }} + ingress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4 }} +{{- end }} +{{- if .egress }} + egress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4}} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/persistent-volume-claim.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/persistent-volume-claim.yaml new file mode 100644 index 00000000000..bf4e6dfb712 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/persistent-volume-claim.yaml @@ -0,0 +1,24 @@ +{{- if .Values.persistentVolumeClaim.name }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{.Values.persistentVolumeClaim.name }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- with .Values.persistentVolumeClaim }} +spec: + accessModes: +{{- range .accessMode }} + - {{ . }} +{{- end }} + resources: + requests: + storage: {{ .storage | default "5Gi" }} + storageClassName: {{ .storageClassName | default "default" }} + volumeMode: {{ .volumeMode | default "Filesystem" }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml new file mode 100644 index 00000000000..c9cbb4162d4 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml @@ -0,0 +1,25 @@ +{{- if .Values.podDisruptionBudget }} +{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: policy/v1 +{{- else -}} +apiVersion: policy/v1beta1 +{{- end }} +kind: PodDisruptionBudget +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + selector: + matchLabels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml new file mode 100644 index 00000000000..cd733d48576 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml @@ -0,0 +1,23 @@ +{{- if $.Values.dbMigrationConfig.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-migrator + annotations: + argocd.argoproj.io/hook: PreSync +# argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + containers: + - name: migrator + image: 686244538589.dkr.ecr.us-east-2.amazonaws.com/migrator:0.0.1-rc14 + env: + {{- range $.Values.dbMigrationConfig.envValues }} + - name: {{ .key}} + value: {{ .value | quote }} + {{- end}} + restartPolicy: Never + backoffLimit: 0 +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml new file mode 100644 index 00000000000..90f398bff4c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml @@ -0,0 +1,22 @@ +{{- if .Values.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template ".Chart.Name .fullname" . }} + {{- if .Values.prometheusRule.namespace }} + namespace: {{ .Values.prometheusRule.namespace }} + {{- end }} + labels: + kind: Prometheus + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.prometheusRule.additionalLabels }} +{{ toYaml .Values.prometheusRule.additionalLabels | indent 4 }} + {{- end }} +spec: + {{- with .Values.prometheusRule.rules }} + groups: + - name: {{ template ".Chart.Name .fullname" $ }} + rules: {{- toYaml . | nindent 6 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml new file mode 100644 index 00000000000..26a17b968ca --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml @@ -0,0 +1,69 @@ +{{- if $.Values.secret.enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: app-secret +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml $.Values.secret.data | indent 2 }} +{{- end }} + + +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml .data | trim | indent 2 }} +{{- end}} + {{if eq .external true }} + {{if (or (eq .externalType "AWSSecretsManager") (eq .externalType "AWSSystemManager") (eq .externalType "HashiCorpVault"))}} +--- +apiVersion: kubernetes-client.io/v1 +kind: ExternalSecret +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .roleARN }} + roleArn: .roleARN + {{- end}} + {{- if eq .externalType "AWSSecretsManager"}} + backendType: secretsManager + {{- end}} + {{- if eq .externalType "AWSSystemManager"}} + backendType: systemManager + {{- end}} + {{- if eq .externalType "HashiCorpVault"}} + backendType: vault + {{- end}} + data: + {{- range .secretData }} + - key: {{.key}} + name: {{.name}} + {{- if .property }} + property: {{.property}} + {{- end}} + isBinary: {{.isBinary}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml new file mode 100644 index 00000000000..03bbbc7c950 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml @@ -0,0 +1,90 @@ +{{- if .Values.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".servicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end}} +spec: + type: {{ .Values.service.type | default "ClusterIP" }} +{{- if (and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges )}} + loadBalancerSourceRanges: + {{- range .Values.service.loadBalancerSourceRanges }} + - {{ . }} + {{- end }} +{{- end }} + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + {{- if .targetPort }} + targetPort: {{ .targetPort }} + {{- else }} + targetPort: {{ .name }} + {{- end }} + protocol: {{ .protocol }} + {{- if (and (eq $.Values.service.type "NodePort") .nodePort ) }} + nodePort: {{ .nodePort }} + {{- end }} + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- if .Values.service.sessionAffinity.enabled }} + sessionAffinity: ClientIP +{{- end }} +{{- if .Values.service.sessionAffinityConfig }} + sessionAffinityConfig: +{{ toYaml .Values.service.sessionAffinityConfig | indent 4 }} +{{- end }} +{{- if eq .Values.deploymentType "BLUE-GREEN" }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".previewservicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +spec: + type: ClusterIP + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + targetPort: {{ .name }} + protocol: TCP + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml new file mode 100644 index 00000000000..ac258610fa8 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if $.Values.serviceAccount }} +{{- if $.Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "serviceAccountName" . }} + {{- if .Values.podLabels }} + labels: +{{ toYaml .Values.podLabels | indent 4 }} + {{- end }} + {{- if .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml new file mode 100644 index 00000000000..1f90c722cb1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml @@ -0,0 +1,48 @@ +{{ $serviceMonitorEnabled := include "serviceMonitorEnabled" . }} +{{- if eq "true" $serviceMonitorEnabled -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" . }}-sm + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.servicemonitor.additionalLabels }} +{{ toYaml .Values.servicemonitor.additionalLabels | indent 4 }} + {{- end }} +spec: + endpoints: + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if .servicemonitor.enabled}} + {{- if .servicePort }} + - port: {{ .name }} + {{- if .servicemonitor.path }} + path: {{ .servicemonitor.path}} + {{- end }} + {{- if .servicemonitor.scheme }} + scheme: {{ .servicemonitor.scheme}} + {{- end }} + {{- if .servicemonitor.interval }} + interval: {{ .servicemonitor.interval}} + {{- end }} + {{- if .servicemonitor.scrapeTimeout }} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} + {{- end }} + {{- if .servicemonitor.metricRelabelings}} + metricRelabelings: +{{toYaml .servicemonitor.metricRelabelings | indent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/sidecar-configmap.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/sidecar-configmap.yaml new file mode 100644 index 00000000000..cf32679409a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/sidecar-configmap.yaml @@ -0,0 +1,169 @@ +{{- if .Values.appMetrics }} +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2019-08-12T18:38:34Z + name: sidecar-config-{{ template ".Chart.Name .name" $ }} +data: + envoy-config.json: | + { + "stats_config": { + "use_all_default_tags": false, + "stats_tags": [ + { + "tag_name": "cluster_name", + "regex": "^cluster\\.((.+?(\\..+?\\.svc\\.cluster\\.local)?)\\.)" + }, + { + "tag_name": "tcp_prefix", + "regex": "^tcp\\.((.*?)\\.)\\w+?$" + }, + { + "tag_name": "response_code", + "regex": "_rq(_(\\d{3}))$" + }, + { + "tag_name": "response_code_class", + "regex": ".*_rq(_(\\dxx))$" + }, + { + "tag_name": "http_conn_manager_listener_prefix", + "regex": "^listener(?=\\.).*?\\.http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "http_conn_manager_prefix", + "regex": "^http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "listener_address", + "regex": "^listener\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "mongo_prefix", + "regex": "^mongo\\.(.+?)\\.(collection|cmd|cx_|op_|delays_|decoding_)(.*?)$" + } + ], + "stats_matcher": { + "inclusion_list": { + "patterns": [ + { + "regex": ".*_rq_\\dxx$" + }, + { + "regex": ".*_rq_time$" + }, + { + "regex": "cluster.*" + }, + ] + } + } + }, + "admin": { + "access_log_path": "/dev/null", + "address": { + "socket_address": { + "address": "0.0.0.0", + "port_value": 9901 + } + } + }, + "static_resources": { + "clusters": [ + {{- range $index, $element := .Values.ContainerPort }} + { + "name": "{{ $.Values.app }}-{{ $index }}", + "type": "STATIC", + "connect_timeout": "0.250s", + "lb_policy": "ROUND_ROBIN", +{{- if $element.idleTimeout }} + "common_http_protocol_options": { + "idle_timeout": {{ $element.idleTimeout | quote }} + }, +{{- end }} +{{- if or $element.useHTTP2 $element.useGRPC }} + "http2_protocol_options": {}, +{{- end }} +{{- if and (not $element.useGRPC) (not $element.supportStreaming) }} + "max_requests_per_connection": "1", +{{- end }} + "load_assignment": { + "cluster_name": "9", + "endpoints": { + "lb_endpoints": [ + { + "endpoint": { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "127.0.0.1", + "port_value": {{ $element.port }} + } + } + } + } + ] + } + } + }, + {{- end }} + ], + "listeners":[ + {{- range $index, $element := .Values.ContainerPort }} + { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "0.0.0.0", + "port_value": {{ $element.envoyPort | default (add 8790 $index) }} + } + }, + "filter_chains": [ + { + "filters": [ + { + "name": "envoy.filters.network.http_connection_manager", + "config": { + "codec_type": "AUTO", + "stat_prefix": "stats", + "route_config": { + "virtual_hosts": [ + { + "name": "backend", + "domains": [ + "*" + ], + "routes": [ + { + "match": { + "prefix": "/" + }, + "route": { +{{- if $element.supportStreaming }} + "timeout": "0s", +{{- end }} +{{- if and ($element.envoyTimeout) (not $element.supportStreaming) }} + "timeout": "{{ $element.envoyTimeout }}", +{{- end }} + "cluster": "{{ $.Values.app }}-{{ $index }}" + } + } + ] + } + ] + }, + "http_filters": { + "name": "envoy.filters.http.router" + } + } + } + ] + } + ] + }, + {{- end }} + ] + } + } +--- +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/vertical-pod-autoscaler.yaml new file mode 100644 index 00000000000..16933579793 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/vertical-pod-autoscaler.yaml @@ -0,0 +1,27 @@ +{{ $VerticalPodAutoScalingEnabled := include "VerticalPodAutoScalingEnabled" . }} +{{- if eq "true" $VerticalPodAutoScalingEnabled -}} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" . }}-vpa + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: +{{- if .Values.verticalPodScaling.resourcePolicy }} + resourcePolicy: +{{ toYaml .Values.verticalPodScaling.resourcePolicy}} +{{- end }} +{{- if .Values.verticalPodScaling.updatePolicy }} + updatePolicy: +{{ toYaml .Values.verticalPodScaling.updatePolicy}} +{{- end }} + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include ".Chart.Name .fullname" $ }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml new file mode 100644 index 00000000000..b09b2533c05 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml @@ -0,0 +1,41 @@ +{{- if .Values.winterSoldier.enabled }} +apiVersion: {{ $.Values.winterSoldier.apiVersion }} +kind: Hibernator +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hibernator + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.winterSoldier.labels }} +{{ toYaml .Values.winterSoldier.labels | indent 4 }} + {{- end }} +{{- if .Values.winterSoldier.annotations }} + annotations: +{{ toYaml .Values.winterSoldier.annotations | indent 4 }} +{{- end }} +spec: + timeRangesWithZone: +{{ toYaml $.Values.winterSoldier.timeRangesWithZone | indent 4}} + selectors: + - inclusions: + - objectSelector: + name: {{ include ".Chart.Name .fullname" $ }} + type: {{ .Values.winterSoldier.type | quote }} + fieldSelector: +{{toYaml $.Values.winterSoldier.fieldSelector | indent 14 }} + namespaceSelector: + name: {{ $.Release.Namespace }} + exclusions: [] + action: {{ $.Values.winterSoldier.action }} + {{- if eq .Values.winterSoldier.action "scale" }} + {{- if .Values.winterSoldier.targetReplicas }} + targetReplicas: {{ $.Values.winterSoldier.targetReplicas }} + {{- end }} + {{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test-values.json b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test-values.json new file mode 100644 index 00000000000..a26806cb912 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test-values.json @@ -0,0 +1,292 @@ +{ + "ConfigMaps": { + "enabled": true, + "maps": [ + { + "data": { + "a": "b" + }, + "esoSecretData": {}, + "external": false, + "externalType": "", + "filePermission": "", + "mountPath": "", + "name": "abc", + "roleARN": "", + "subPath": false, + "type": "environment" + } + ] + }, + "ConfigSecrets": { + "enabled": true, + "secrets": [ + { + "data": { + "access-key": "QUtJQVdQVENFV0w1Wk4zVFBSRzY=", + "secret-access-key": "dkJ1bXRJL1YyZFUrQmVrSnM4QkVsblJnQzlRbEZueVZqL0dEdUc4Ng==" + }, + "esoSecretData": {}, + "external": false, + "externalType": "", + "filePermission": "", + "mountPath": "", + "name": "auth-aws", + "roleARN": "", + "subPath": false, + "type": "environment" + }, + { + "esoSecretData": { + "esoData": [ + { + "key": "ajay-secret-aws", + "property": "mob", + "secretKey": "mymob" + }, + { + "key": "ajay-secret-aws", + "property": "pin", + "secretKey": "mypin" + } + ], + "secretStore": { + "aws": { + "auth": { + "secretRef": { + "accessKeyIDSecretRef": { + "key": "access-key", + "name": "auth-aws-1" + }, + "secretAccessKeySecretRef": { + "key": "secret-access-key", + "name": "auth-aws-1" + } + } + }, + "region": "ap-south-1", + "service": "SecretsManager" + } + } + }, + "external": true, + "externalType": "ESO_AWSSecretsManager", + "filePermission": "", + "mountPath": "", + "name": "external-secret-aws", + "roleARN": "", + "subPath": false, + "type": "environment" + } + ] + }, + "ContainerPort": [ + { + "envoyPort": 8799, + "idleTimeout": "1800s", + "name": "app", + "port": 80, + "servicePort": 80, + "supportStreaming": false, + "useHTTP2": false + } + ], + "EnvVariables": [], + "GracePeriod": 30, + "LivenessProbe": { + "Path": "", + "command": [], + "failureThreshold": 3, + "httpHeaders": [], + "initialDelaySeconds": 20, + "periodSeconds": 10, + "port": 8080, + "scheme": "", + "successThreshold": 1, + "tcp": false, + "timeoutSeconds": 5 + }, + "MaxSurge": 1, + "MaxUnavailable": 0, + "MinReadySeconds": 60, + "ReadinessProbe": { + "Path": "", + "command": [], + "failureThreshold": 3, + "httpHeaders": [], + "initialDelaySeconds": 20, + "periodSeconds": 10, + "port": 8080, + "scheme": "", + "successThreshold": 1, + "tcp": false, + "timeoutSeconds": 5 + }, + "Spec": { + "Affinity": { + "Values": "nodes", + "key": "" + } + }, + "app": "1", + "appLabels": {}, + "appMetrics": false, + "args": { + "enabled": false, + "value": [ + "/bin/sh", + "-c", + "touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600" + ] + }, + "autoscaling": { + "MaxReplicas": 2, + "MinReplicas": 1, + "TargetCPUUtilizationPercentage": 90, + "TargetMemoryUtilizationPercentage": 80, + "annotations": {}, + "behavior": {}, + "enabled": false, + "extraMetrics": [], + "labels": {} + }, + "command": { + "enabled": false, + "value": [], + "workingDir": {} + }, + "containerSecurityContext": {}, + "containers": [], + "dbMigrationConfig": { + "enabled": false + }, + "deployment": { + "strategy": { + "blueGreen": { + "autoPromotionEnabled": false, + "autoPromotionSeconds": 30, + "previewReplicaCount": 1, + "scaleDownDelaySeconds": 30 + } + } + }, + "deploymentType": "BLUE-GREEN", + "env": "1", + "envoyproxy": { + "configMapName": "", + "image": "quay.io/devtron/envoy:v1.14.1", + "resources": { + "limits": { + "cpu": "50m", + "memory": "50Mi" + }, + "requests": { + "cpu": "50m", + "memory": "50Mi" + } + } + }, + "hostAliases": [], + "image": { + "pullPolicy": "IfNotPresent" + }, + "imagePullSecrets": [], + "ingress": { + "annotations": {}, + "className": "", + "enabled": false, + "hosts": [ + { + "host": "chart-example1.local", + "pathType": "ImplementationSpecific", + "paths": [ + "/example1" + ] + } + ], + "labels": {}, + "tls": [] + }, + "ingressInternal": { + "annotations": {}, + "className": "", + "enabled": false, + "hosts": [ + { + "host": "chart-example1.internal", + "pathType": "ImplementationSpecific", + "paths": [ + "/example1" + ] + }, + { + "host": "chart-example2.internal", + "pathType": "ImplementationSpecific", + "paths": [ + "/example2", + "/example2/healthz" + ] + } + ], + "tls": [] + }, + "initContainers": [], + "kedaAutoscaling": { + "advanced": {}, + "authenticationRef": {}, + "enabled": false, + "envSourceContainerName": "", + "maxReplicaCount": 2, + "minReplicaCount": 1, + "triggerAuthentication": { + "enabled": false, + "name": "", + "spec": {} + }, + "triggers": [] + }, + "pauseForSecondsBeforeSwitchActive": 30, + "pipelineName": "cd-1-fpji", + "podAnnotations": {}, + "podLabels": {}, + "podSecurityContext": {}, + "prometheus": { + "release": "monitoring" + }, + "rawYaml": [], + "releaseVersion": "6", + "replicaCount": 1, + "resources": { + "limits": { + "cpu": "0.05", + "memory": "50Mi" + }, + "requests": { + "cpu": "0.01", + "memory": "10Mi" + } + }, + "secret": { + "data": {}, + "enabled": false + }, + "server": { + "deployment": { + "image": "aju121/test12", + "image_tag": "63118bf2-1-1" + } + }, + "service": { + "annotations": {}, + "loadBalancerSourceRanges": [], + "type": "ClusterIP" + }, + "servicemonitor": { + "additionalLabels": {} + }, + "tolerations": [], + "topologySpreadConstraints": [], + "volumeMounts": [], + "volumes": [], + "waitForSecondsBeforeScalingDown": 30 +} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml new file mode 100644 index 00000000000..78df2f31416 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml @@ -0,0 +1,766 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +kedaAutoscaling: + enabled: true + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + cooldownPeriod: 300 # Optional. Default: 300 seconds + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 # Optional. Must be less than minReplicaCount + pollingInterval: 30 # Optional. Default: 30 seconds + # The fallback section is optional. It defines a number of replicas to fallback to if a scaler is in an error state. + fallback: {} # Optional. Section to specify fallback options + # failureThreshold: 3 # Mandatory if fallback section is included + # replicas: 6 + advanced: {} + # horizontalPodAutoscalerConfig: # Optional. Section to specify HPA related options + # behavior: # Optional. Use to modify HPA's scaling behavior + # scaleDown: + # stabilizationWindowSeconds: 300 + # policies: + # - type: Percent + # value: 100 + # periodSeconds: 15 + triggers: + - type: kubernetes-workload + name: trig_one + metadata: + podSelector: 'pod=workload-test' + - type: metrics-api + name: trig_two + metadata: + url: "https://mockbin.org/bin/336a8d99-9e09-4f1f-979d-851a6d1b1423" + valueLocation: "tasks" + + triggerAuthentication: + enabled: true + name: "trigger-test" + spec: {} + authenticationRef: {} + +deploymentLabels: + name: kunalverma + Company: Devtron + Job: DevRel + +deploymentAnnotations: + name: kunalverma + Company: Devtron + Job: DevRel + +containerSpec: + lifecycle: + enabled: true + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +imagePullSecrets: + - test1 + - test2 +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyTimeout: 15 + targetPort: 8080 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace + + - name: app1 + port: 8090 + targetPort: 1234 + servicePort: 8080 + useGRPC: true + servicemonitor: + enabled: true + - name: app2 + port: 8091 + servicePort: 8081 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: + Key: + # Key: kops.k8s.io/instancegroup + Values: + + +image: + pullPolicy: IfNotPresent + +autoscaling: + enabled: true + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +secret: + enabled: false + +service: + type: ClusterIP + # name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: example.com + tls: + enabled: false + secretName: example-tls-secret + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # rewriteUri: / + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + # route: + # - destination: + # host: service1 + # port: 80 + # - route: + # - destination: + # host: service2 + +flaggerCanary: + enabled: false + labels: {} + annotations: {} + createIstioGateway: + enabled: false + labels: {} + annotations: {} + host: example.com + tls: + enabled: false + secretName: example-tls-secret + # Istio gateways (optional) + addOtherGateways: [] + # Istio virtual service host names (optional) + addOtherHosts: [] + # Istio gateway refs (optional) + gatewayRefs: + # - name: istio-gateway + # namespace: istio-system + #service port + port: 80 + #containerPort + targetPort: 8080 + # discover all port open in container + portDiscovery: false + # application protocol (optional) + appProtocol: + # Istio retry policy (optional) + retries: + # attempts: 3 + # perTryTimeout: 1s + # retryOn: "gateway-error,connect-failure,refused-stream" + # HTTP match conditions (optional) + match: + - uri: + prefix: / + # HTTP rewrite (optional) + rewriteUri: + # timeout (optional) + timeout: + # Add headers (optional) + headers: + # request: + # add: + # x-some-header: "value" + # cross-origin resource sharing policy (optional) + corsPolicy: + # allowOrigin: + # - example.com + # allowMethods: + # - GET + # allowCredentials: false + # allowHeaders: + # - x-some-header + # maxAge: 24h + analysis: + # schedule interval (default 60s) + interval: 5s + # max number of failed metric checks before rollback + threshold: 10 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 5 + thresholds: + # minimum req success rate (non 5xx responses) + # percentage (0-100) + successRate: 90 + # maximum req duration P99 + # milliseconds + latency: 500 + loadtest: + enabled: true + # load tester address + url: http://flagger-loadtester.test/ + +server: + deployment: + image_tag: 1-95af053 + image: "" +deploymentType: "RECREATE" + +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: + foo: bar + +EnvVariables: + - name: FLASK_ENV + value: qa + +LivenessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + - name: Custom-Header2 + value: xyz + +ReadinessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + +StartupProbe: + Path: "/" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + +prometheusRule: + enabled: true + additionalLabels: {} + namespace: "" + rules: + # These are just examples rules, please adapt them to your needs + - alert: TooMany500s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 5XXs + summary: More than 5% of the all requests did return 5XX, this require your attention + - alert: TooMany400s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 4XXs + summary: More than 5% of the all requests did return 4XX, this require your attention + + +ingress: + enabled: true + className: nginx + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" +# Old Ingress Format +# host: "ingress-example.com" +# path: "/app" + +# New Ingress Format + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 + + tls: [] +### Legacy Ingress Format ## +# host: abc.com +# path: "/" +# pathType: "ImplementationSpecific" + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: true + className: nginx-internal + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + additionalBackends: + - path: /internal + pathType: "ImplementationSpecific" + backend: + service: + name: test-service-internal + port: + number: 80 + - path: /internal-01 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service-internal + port: + number: 80 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + type: Deployment + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + + +dbMigrationConfig: + enabled: false + +command: + workingDir: /app + enabled: false + value: ["ls"] + +args: + enabled: false + value: [] + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# filePermission: 0400 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: true + secrets: + - name: config-secret-1 + type: environment + external: false + externalType: AWSSecretsManager + esoSecretData: + secretStore: + aws: + service: SecretsManager + region: us-east-1 + auth: + secretRef: + accessKeyIDSecretRef: + name: awssm-secret + key: access-key + secretAccessKeySecretRef: + name: awssm-secret + key: secret-access-key + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + data: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + - name: config-secret-2 + type: environment + external: false + externalType: ESO_HashiCorpVault + esoSecretData: + secretStore: + vault: + server: "http://my.vault.server:8200" + path: "secret" + version: "v2" + auth: + tokenSecretRef: + name: vault-token + key: token + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + date: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + - command: ["sh", "-c", "chown -R 1000:1000 logs"] + reuseContainerImage: true + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + privileged: true + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + - name: init-migrate + image: busybox:latest + command: ["sh", "-c", "chown -R 1000:1000 logs"] + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + capabilities: + drop: + - ALL + +containers: + # Additional init containers to run before the Scheduler pods. + # for example, be used to run a sidecar that chown Logs storage . + - name: volume-mount-hack + image: busybox + command: ["sh", "-c", "chown -R 1000:1000 logs"] + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + + +rawYaml: + - apiVersion: v1 + kind: Service + metadata: + annotations: + labels: + app: sample-metrics-app + name: sample-metrics-app + namespace: default + spec: + ports: + - name: web + port: 80 + protocol: TCP + targetPort: 8080 + selector: + app: sample-metrics-app + sessionAffinity: None + type: ClusterIP + - apiVersion: v1 + kind: Service + metadata: + annotations: + labels: + app: sample-metrics-app + name: sample-metrics-app + namespace: default + spec: + ports: + - name: web + port: 80 + protocol: TCP + targetPort: 8080 + selector: + app: sample-metrics-app + sessionAffinity: None + type: ClusterIP + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +podDisruptionBudget: + minAvailable: 1 + maxUnavailable: 1 + + # Node tolerations for server scheduling to nodes with taints + # Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +# + +tolerations: + - key: "key" + operator: "Equal|Exists" + value: "value" + effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +appMetrics: true +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "test1" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: + kubernetes.io/service-account.name: build-robot +containerSecurityContext: + allowPrivilegeEscalation: false +privileged: true +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" + + +affinity: + enabled: false + values: + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: topology.kubernetes.io/zone \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml new file mode 100644 index 00000000000..c5dd74b354d --- /dev/null +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml @@ -0,0 +1,722 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + envoyTimeout: 15s + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + protocol: TCP +# servicemonitor: +# enabled: true +# path: /abc +# scheme: 'http' +# interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace + + - name: app1 + port: 8090 + servicePort: 8080 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: + Key: "" +# Key: kops.k8s.io/instancegroup + Values: "" + +affinity: {} + +image: + pullPolicy: IfNotPresent + +restartPolicy: Always + +ambassadorMapping: + enabled: false + # labels: + # key1: value1 + # prefix: / + # ambassadorId: 1234 + # hostname: devtron.example.com + # rewrite: /foo/ + # retryPolicy: + # retry_on: "5xx" + # num_retries: 10 + # cors: + # origins: http://foo.example,http://bar.example + # methods: POST, GET, OPTIONS + # headers: Content-Type + # credentials: true + # exposed_headers: X-Custom-Header + # max_age: "86400" + # weight: 10 + # method: GET + # extraSpec: + # method_regex: true + # headers: + # x-quote-mode: backend + # x-random-header: devtron + # tls: + # context: httpd-context + # create: true + # secretName: httpd-secret + # hosts: + # - anything.example.info + # - devtron.example.com + # extraSpec: + # min_tls_version: v1.2 + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + annotations: {} + labels: {} + behavior: {} + containerResource: + enabled: false +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + cooldownPeriod: 300 # Optional. Default: 300 seconds + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 # Optional. Must be less than minReplicaCount + pollingInterval: 30 # Optional. Default: 30 seconds + # The fallback section is optional. It defines a number of replicas to fallback to if a scaler is in an error state. + fallback: {} # Optional. Section to specify fallback options + # failureThreshold: 3 # Mandatory if fallback section is included + # replicas: 6 + advanced: {} + # horizontalPodAutoscalerConfig: # Optional. Section to specify HPA related options + # behavior: # Optional. Use to modify HPA's scaling behavior + # scaleDown: + # stabilizationWindowSeconds: 300 + # policies: + # - type: Percent + # value: 100 + # periodSeconds: 15 + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +# kedaHttpScaledObject: +# enabled: false +# minReplicaCount: 1 +# maxReplicaCount: 2 +# targetPendingRequests: +# scaledownPeriod: +# servicePort: 80 # port of the service (required) + +secret: + enabled: false + +service: + type: ClusterIP + enabled: true +# name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + sessionAffinity: + enabled: false + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: "" + tls: + enabled: false + secretName: "" + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +flaggerCanary: + enabled: false + labels: {} + annotations: {} + createIstioGateway: + enabled: false + labels: {} + annotations: {} + host: "" + tls: + enabled: false + secretName: "" + # Istio gateways (optional) + addOtherGateways: [] + # Istio virtual service host names (optional) + addOtherHosts: [] + # Istio gateway refs (optional) + gatewayRefs: + # - name: istio-gateway + # namespace: istio-system + #service port + serviceport: 8080 + #containerPort + targetPort: 8080 + # discover all port open in container + portDiscovery: true + # application protocol (optional) + appProtocol: + # Istio retry policy (optional) + retries: + attempts: 3 + perTryTimeout: 1s + retryOn: "gateway-error,connect-failure,refused-stream" + # HTTP match conditions (optional) + match: + - uri: + prefix: / + # HTTP rewrite (optional) + rewriteUri: / + # timeout (optional) + timeout: + # Add headers (optional) + headers: + # request: + # add: + # x-some-header: "value" + # cross-origin resource sharing policy (optional) + corsPolicy: + # allowOrigin: + # - example.com + # allowMethods: + # - GET + # allowCredentials: false + # allowHeaders: + # - x-some-header + # maxAge: 24h + analysis: + # schedule interval (default 60s) + interval: 15s + # max number of failed metric checks before rollback + threshold: 5 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 5 + thresholds: + # minimum req success rate (non 5xx responses) + # percentage (0-100) + successRate: 90 + # maximum req duration P99 + # milliseconds + latency: 500 + loadtest: + enabled: true + # load tester address + url: http://flagger-loadtester.istio-system/ + + +server: + deployment: + image_tag: 1-95af053 + image: "" + +EnvVariablesFromFieldPath: [] +# - name: POD_NAME +# fieldPath: metadata.name + +EnvVariables: [] + # - name: FLASK_ENV + # value: qa + +EnvVariablesFromSecretKeys: [] + # - name: ENV_NAME + # secretName: SECRET_NAME + # keyName: SECRET_KEY + +EnvVariablesFromConfigMapKeys: [] + # - name: ENV_NAME + # configMapName: CONFIG_MAP_NAME + # keyName: CONFIG_MAP_KEY + +LivenessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + grpc: {} + + +ReadinessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + grpc: {} + + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + grpc: {} + + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + + +prometheusRule: + enabled: false + additionalLabels: {} + namespace: "" +# rules: +# # These are just examples rules, please adapt them to your needs +# - alert: TooMany500s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 5XXs +# summary: More than 5% of the all requests did return 5XX, this require your attention +# - alert: TooMany400s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 4XXs +# summary: More than 5% of the all requests did return 4XX, this require your attention +# + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + labels: {} + annotations: {} + type: Deployment + timeRangesWithZone: {} + # timeZone: "Asia/Kolkata" + # timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: [] + # - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +dbMigrationConfig: + enabled: false + +command: + enabled: false + value: [] + +args: + enabled: false + value: [] + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: true + secrets: + - name: config-secret-1 + type: volume + filePermission: "420" + externalType: ESO_GoogleSecretsManager + mountPath: /etc/config/2 + esoSecretData: + esoData: + - key": kushagra-test + property: test1 + secretKey: SECRET_KUSHAGRA + # data: + # key1: key1value-1 + # key2: key2value-1 + # key3: key3value-1 +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + # # Uncomment below line ONLY IF you want to reuse the container image. + # # This will assign your application's docker image to init container. + # reuseContainerImage: true + +containers: + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + - name: volume-mount-hack + image: busybox + command: ["sh", "-c", "chown -R 1000:1000 logs"] + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + envFrom: + - configMapRef: + name: kamal + + +rawYaml: [] +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP + +topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: zone + # whenUnsatisfiable: DoNotSchedule + # autoLabelSelector: true + # minDomain: 1 + # nodeTaintsPolicy: Honor + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + lifecycle: {} + configMapName: "" + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +containerSpec: + lifecycle: + enabled: false + preStop: {} +# exec: +# command: ["sleep","10"] + postStart: {} +# httpGet: +# host: example.com +# path: /example +# port: 90 + +podDisruptionBudget: {} +# minAvailable: 1 +# maxUnavailable: 1 + + ## Node tolerations for server scheduling to nodes with taints + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + ## + +podSecurityContext: {} + # runAsUser: 1000 + # runAsGroup: 3000 + # fsGroup: 2000 + +containerSecurityContext: {} + # allowPrivilegeEscalation: false +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +imagePullSecrets: [] + # - test1 + # - test2 +persistentVolumeClaim: {} + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.helmignore b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.image_descriptor_template.json b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.image_descriptor_template.json new file mode 100644 index 00000000000..bd2472da075 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/.image_descriptor_template.json @@ -0,0 +1 @@ +{"server":{"deployment":{"image_tag":"{{.Tag}}","image":"{{.Name}}"}},"pipelineName": "{{.PipelineName}}","releaseVersion":"{{.ReleaseVersion}}","deploymentType": "{{.DeploymentType}}", "app": "{{.App}}", "env": "{{.Env}}", "appMetrics": {{.AppMetrics}}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/Chart.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/Chart.yaml new file mode 100644 index 00000000000..5335b9923f4 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: reference-chart_4-19-0 +version: 4.19.0 diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/README.md b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/README.md new file mode 100644 index 00000000000..968eac6bb5a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/README.md @@ -0,0 +1,866 @@ + +# Rollout Deployment Chart - v4.19.0 + +## 1. Yaml File - + +### Container Ports + +This defines ports on which application services will be exposed to other services + +```yaml +ContainerPort: + - envoyPort: 8799 + idleTimeout: + name: app + port: 8080 + servicePort: 80 + nodePort: 32056 + supportStreaming: true + useHTTP2: true +``` + +| Key | Description | +| :--- | :--- | +| `envoyPort` | envoy port for the container. | +| `idleTimeout` | the duration of time that a connection is idle before the connection is terminated. | +| `name` | name of the port. | +| `port` | port for the container. | +| `servicePort` | port of the corresponding kubernetes service. | +| `nodePort` | nodeport of the corresponding kubernetes service. | +| `supportStreaming` | Used for high performance protocols like grpc where timeout needs to be disabled. | +| `useHTTP2` | Envoy container can accept HTTP2 requests. | + +### EnvVariables +```yaml +EnvVariables: [] +``` +To set environment variables for the containers that run in the Pod. + +### EnvVariablesFromSecretKeys +```yaml +EnvVariablesFromSecretKeys: + - name: ENV_NAME + secretName: SECRET_NAME + keyName: SECRET_KEY + +``` + It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable. + + ### EnvVariablesFromConfigMapKeys +```yaml +EnvVariablesFromConfigMapKeys: + - name: ENV_NAME + configMapName: CONFIG_MAP_NAME + keyName: CONFIG_MAP_KEY + +``` + It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable. + +### Liveness Probe + +If this check fails, kubernetes restarts the pod. This should return error code in case of non-recoverable error. + +```yaml +LivenessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the liveness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for liveliness. | +| `periodSeconds` | It defines the time to check a given container for liveness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfil the liveness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as live. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | + + +### MaxUnavailable + +```yaml + MaxUnavailable: 0 +``` +The maximum number of pods that can be unavailable during the update process. The value of "MaxUnavailable: " can be an absolute number or percentage of the replicas count. The default value of "MaxUnavailable: " is 25%. + +### MaxSurge + +```yaml +MaxSurge: 1 +``` +The maximum number of pods that can be created over the desired number of pods. For "MaxSurge: " also, the value can be an absolute number or percentage of the replicas count. +The default value of "MaxSurge: " is 25%. + +### Min Ready Seconds + +```yaml +MinReadySeconds: 60 +``` +This specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. This defaults to 0 (the Pod will be considered available as soon as it is ready). + +### Readiness Probe + +If this check fails, kubernetes stops sending traffic to the application. This should return error code in case of errors which can be recovered from if traffic is stopped. + +```yaml +ReadinessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the readiness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for readiness. | +| `periodSeconds` | It defines the time to check a given container for readiness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfill the readiness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as ready. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | + +### Pod Disruption Budget + +You can create `PodDisruptionBudget` for each application. A PDB limits the number of pods of a replicated application that are down simultaneously from voluntary disruptions. For example, an application would like to ensure the number of replicas running is never brought below the certain number. + +```yaml +podDisruptionBudget: + minAvailable: 1 +``` + +or + +```yaml +podDisruptionBudget: + maxUnavailable: 50% +``` + +You can specify either `maxUnavailable` or `minAvailable` in a PodDisruptionBudget and it can be expressed as integers or as a percentage + +| Key | Description | +| :--- | :--- | +| `minAvailable` | Evictions are allowed as long as they leave behind 1 or more healthy pods of the total number of desired replicas. | +| `maxUnavailable` | Evictions are allowed as long as at most 1 unhealthy replica among the total number of desired replicas. | + +### Ambassador Mappings + +You can create ambassador mappings to access your applications from outside the cluster. At its core a Mapping resource maps a resource to a service. + +```yaml +ambassadorMapping: + ambassadorId: "prod-emissary" + cors: {} + enabled: true + hostname: devtron.example.com + labels: {} + prefix: / + retryPolicy: {} + rewrite: "" + tls: + context: "devtron-tls-context" + create: false + hosts: [] + secretName: "" +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable ambassador mapping else set false.| +| `ambassadorId` | used to specify id for specific ambassador mappings controller. | +| `cors` | used to specify cors policy to access host for this mapping. | +| `weight` | used to specify weight for canary ambassador mappings. | +| `hostname` | used to specify hostname for ambassador mapping. | +| `prefix` | used to specify path for ambassador mapping. | +| `labels` | used to provide custom labels for ambassador mapping. | +| `retryPolicy` | used to specify retry policy for ambassador mapping. | +| `corsPolicy` | Provide cors headers on flagger resource. | +| `rewrite` | used to specify whether to redirect the path of this mapping and where. | +| `tls` | used to create or define ambassador TLSContext resource. | +| `extraSpec` | used to provide extra spec values which not present in deployment template for ambassador resource. | + +### Autoscaling + +This is connected to HPA and controls scaling up and down in response to request load. + +```yaml +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + extraMetrics: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable autoscaling else set false.| +| `MinReplicas` | Minimum number of replicas allowed for scaling. | +| `MaxReplicas` | Maximum number of replicas allowed for scaling. | +| `TargetCPUUtilizationPercentage` | The target CPU utilization that is expected for a container. | +| `TargetMemoryUtilizationPercentage` | The target memory utilization that is expected for a container. | +| `extraMetrics` | Used to give external metrics for autoscaling. | + +### Fullname Override + +```yaml +fullnameOverride: app-name +``` +`fullnameOverride` replaces the release fullname created by default by devtron, which is used to construct Kubernetes object names. By default, devtron uses {app-name}-{environment-name} as release fullname. + +### Image + +```yaml +image: + pullPolicy: IfNotPresent +``` + +Image is used to access images in kubernetes, pullpolicy is used to define the instances calling the image, here the image is pulled when the image is not present,it can also be set as "Always". + +### imagePullSecrets + +`imagePullSecrets` contains the docker credentials that are used for accessing a registry. + +```yaml +imagePullSecrets: + - regcred +``` +regcred is the secret that contains the docker credentials that are used for accessing a registry. Devtron will not create this secret automatically, you'll have to create this secret using dt-secrets helm chart in the App store or create one using kubectl. You can follow this documentation Pull an Image from a Private Registry [https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) . + +### Ingress + +This allows public access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + className: nginx + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` +Legacy deployment-template ingress format + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + path: "" + host: "" + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + +### Ingress Internal + +This allows private access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingressInternal: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + + +### additionalBackends + +This defines additional backend path in the ingress . + +```yaml + hosts: + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 +``` + +### Init Containers +```yaml +initContainers: + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate + + - name: nginx + image: nginx:1.14.2 + securityContext: + privileged: true + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] +``` +Specialized containers that run before app containers in a Pod. Init containers can contain utilities or setup scripts not present in an app image. One can use base image inside initContainer by setting the reuseContainerImage flag to `true`. + +### Istio + +Istio is a service mesh which simplifies observability, traffic management, security and much more with it's virtual services and gateways. + +```yaml +istio: + enable: true + gateway: + annotations: {} + enabled: false + host: example.com + labels: {} + tls: + enabled: false + secretName: example-tls-secret + virtualService: + annotations: {} + enabled: false + gateways: [] + hosts: [] + http: + - corsPolicy: + allowCredentials: false + allowHeaders: + - x-some-header + allowMethods: + - GET + allowOrigin: + - example.com + maxAge: 24h + headers: + request: + add: + x-some-header: value + match: + - uri: + prefix: /v1 + - uri: + prefix: /v2 + retries: + attempts: 2 + perTryTimeout: 3s + rewriteUri: / + route: + - destination: + host: service1 + port: 80 + timeout: 12s + - route: + - destination: + host: service2 + labels: {} +``` + +### Pause For Seconds Before Switch Active +```yaml +pauseForSecondsBeforeSwitchActive: 30 +``` +To wait for given period of time before switch active the container. + + +### Winter-Soldier +Winter Soldier can be used to +- cleans up (delete) Kubernetes resources +- reduce workload pods to 0 + +**_NOTE:_** After deploying this we can create the Hibernator object and provide the custom configuration by which workloads going to delete, sleep and many more. for more information check [the main repo](https://github.com/devtron-labs/winter-soldier) + +Given below is template values you can give in winter-soldier: +```yaml +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + action: sleep + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + targetReplicas: [] + fieldSelector: [] +``` +Here, +| Key | values | Description | +| :--- | :--- | :--- | +| `enabled` | `fasle`,`true` | decide the enabling factor | +| `apiVersion` | `pincher.devtron.ai/v1beta1`, `pincher.devtron.ai/v1alpha1` | specific api version | +| `action` | `sleep`,`delete`, `scale` | This specify the action need to perform. | +| `timeRangesWithZone`:`timeZone` | eg:- `"Asia/Kolkata"`,`"US/Pacific"` | It use to specify the timeZone used. (It uses standard format. please refer [this](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) | +| `timeRangesWithZone`:`timeRanges` | array of [ `timeFrom`, `timeTo`, `weekdayFrom`, `weekdayTo`] | It use to define time period/range on which the user need to perform the specified action. you can have multiple timeRanges.
These settings will take `action` on Sat and Sun from 00:00 to 23:59:59, | +| `targetReplicas` | `[n]` : n - number of replicas to scale. | These is mandatory field when the `action` is `scale`
Defalut value is `[]`. | +| `fieldSelector` | `- AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) ` | These value will take a list of methods to select the resources on which we perform specified `action` . | + + +here is an example, +```yaml +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '10h'), Now()) +``` +Above settings will take action on `Sat` and `Sun` from 00:00 to 23:59:59, and on `Mon`-`Fri` from 00:00 to 08:00 and 20:00 to 23:59:59. If `action:sleep` then runs hibernate at timeFrom and unhibernate at `timeTo`. If `action: delete` then it will delete workloads at `timeFrom` and `timeTo`. Here the `action:scale` thus it scale the number of resource replicas to `targetReplicas: [1,1,1]`. Here each element of `targetReplicas` array is mapped with the corresponding elments of array `timeRangesWithZone/timeRanges`. Thus make sure the length of both array is equal, otherwise the cnages cannot be observed. + +The above example will select the application objects which have been created 10 hours ago across all namespaces excluding application's namespace. Winter soldier exposes following functions to handle time, cpu and memory. + +- ParseTime - This function can be used to parse time. For eg to parse creationTimestamp use ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z') +- AddTime - This can be used to add time. For eg AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '-10h') ll add 10h to the time. Use d for day, h for hour, m for minutes and s for seconds. Use negative number to get earlier time. +- Now - This can be used to get current time. +- CpuToNumber - This can be used to compare CPU. For eg any({{spec.containers.#.resources.requests}}, { MemoryToNumber(.memory) < MemoryToNumber('60Mi')}) will check if any resource.requests is less than 60Mi. + + + +### Resources + +These define minimum and maximum RAM and CPU available to the application. + +```yaml +resources: + limits: + cpu: "1" + memory: "200Mi" + requests: + cpu: "0.10" + memory: "100Mi" +``` + +Resources are required to set CPU and memory usage. + +#### Limits + +Limits make sure a container never goes above a certain value. The container is only allowed to go up to the limit, and then it is restricted. + +#### Requests + +Requests are what the container is guaranteed to get. + +### Service + +This defines annotations and the type of service, optionally can define name also. + +```yaml + service: + type: ClusterIP + annotations: {} +``` + +### Volumes + +```yaml +volumes: + - name: log-volume + emptyDir: {} + - name: logpv + persistentVolumeClaim: + claimName: logpvc +``` + +It is required when some values need to be read from or written to an external disk. + +### Volume Mounts + +```yaml +volumeMounts: + - mountPath: /var/log/nginx/ + name: log-volume + - mountPath: /mnt/logs + name: logpvc + subPath: employee +``` + +It is used to provide mounts to the volume. + +### Affinity and anti-affinity + +```yaml +Spec: + Affinity: + Key: + Values: +``` + +Spec is used to define the desire state of the given container. + +Node Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node. + +Inter-pod affinity allow you to constrain which nodes your pod is eligible to be scheduled based on labels on pods. + +#### Key + +Key part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +#### Values + +Value part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +### Tolerations + +```yaml +tolerations: + - key: "key" + operator: "Equal" + value: "value" + effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" +``` + +Taints are the opposite, they allow a node to repel a set of pods. + +A given pod can access the given node and avoid the given taint only if the given pod satisfies a given taint. + +Taints and tolerations are a mechanism which work together that allows you to ensure that pods are not placed on inappropriate nodes. Taints are added to nodes, while tolerations are defined in the pod specification. When you taint a node, it will repel all the pods except those that have a toleration for that taint. A node can have one or many taints associated with it. + +### Arguments + +```yaml +args: + enabled: false + value: [] +``` + +This is used to give arguments to command. + +### Command + +```yaml +command: + enabled: false + value: [] +``` + +It contains the commands for the server. + +| Key | Description | +| :--- | :--- | +| `enabled` | To enable or disable the command. | +| `value` | It contains the commands. | + + +### Containers +Containers section can be used to run side-car containers along with your main container within same pod. Containers running within same pod can share volumes and IP Address and can address each other @localhost. We can use base image inside container by setting the reuseContainerImage flag to `true`. + +```yaml + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate +``` + +### Prometheus + +```yaml + prometheus: + release: monitoring +``` + +It is a kubernetes monitoring tool and the name of the file to be monitored as monitoring in the given case.It describes the state of the prometheus. + +### rawYaml + +```yaml +rawYaml: + - apiVersion: v1 + kind: Service + metadata: + name: my-service + spec: + selector: + app: MyApp + ports: + - protocol: TCP + port: 80 + targetPort: 9376 + type: ClusterIP +``` +Accepts an array of Kubernetes objects. You can specify any kubernetes yaml here and it will be applied when your app gets deployed. + +### Grace Period + +```yaml +GracePeriod: 30 +``` +Kubernetes waits for the specified time called the termination grace period before terminating the pods. By default, this is 30 seconds. If your pod usually takes longer than 30 seconds to shut down gracefully, make sure you increase the `GracePeriod`. + +A Graceful termination in practice means that your application needs to handle the SIGTERM message and begin shutting down when it receives it. This means saving all data that needs to be saved, closing down network connections, finishing any work that is left, and other similar tasks. + +There are many reasons why Kubernetes might terminate a perfectly healthy container. If you update your deployment with a rolling update, Kubernetes slowly terminates old pods while spinning up new ones. If you drain a node, Kubernetes terminates all pods on that node. If a node runs out of resources, Kubernetes terminates pods to free those resources. It’s important that your application handle termination gracefully so that there is minimal impact on the end user and the time-to-recovery is as fast as possible. + + +### Server + +```yaml +server: + deployment: + image_tag: 1-95a53 + image: "" +``` + +It is used for providing server configurations. + +#### Deployment + +It gives the details for deployment. + +| Key | Description | +| :--- | :--- | +| `image_tag` | It is the image tag | +| `image` | It is the URL of the image | + +### Service Monitor + +```yaml +servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace +``` + +It gives the set of targets to be monitored. + +### Db Migration Config + +```yaml +dbMigrationConfig: + enabled: false +``` + +It is used to configure database migration. + + +### KEDA Autoscaling +[KEDA](https://keda.sh) is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed. KEDA can be installed into any Kubernetes cluster and can work alongside standard Kubernetes components like the Horizontal Pod Autoscaler(HPA). + +Example for autosccaling with KEDA using Prometheus metrics is given below: +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: + restoreToOriginalReplicaCount: true + horizontalPodAutoscalerConfig: + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 100 + periodSeconds: 15 + triggers: + - type: prometheus + metadata: + serverAddress: http://:9090 + metricName: http_request_total + query: envoy_cluster_upstream_rq{appId="300", cluster_name="300-0", container="envoy",} + threshold: "50" + triggerAuthentication: + enabled: false + name: + spec: {} + authenticationRef: {} +``` +Example for autosccaling with KEDA based on kafka is given below : +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: {} + triggers: + - type: kafka + metadata: + bootstrapServers: b-2.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-3.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-1.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092 + topic: Orders-Service-ESP.info + lagThreshold: "100" + consumerGroup: oders-remove-delivered-packages + allowIdleConsumers: "true" + triggerAuthentication: + enabled: true + name: keda-trigger-auth-kafka-credential + spec: + secretTargetRef: + - parameter: sasl + name: keda-kafka-secrets + key: sasl + - parameter: username + name: keda-kafka-secrets + key: username + authenticationRef: + name: keda-trigger-auth-kafka-credential +``` + +### Security Context +A security context defines privilege and access control settings for a Pod or Container. + +To add a security context for main container: +```yaml +containerSecurityContext: + allowPrivilegeEscalation: false +``` + +To add a security context on pod level: +```yaml +podSecurityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 +``` + +### Topology Spread Constraints +You can use topology spread constraints to control how Pods are spread across your cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains. This can help to achieve high availability as well as efficient resource utilization. + +```yaml +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: {} +``` + +### Deployment Metrics + +It gives the realtime metrics of the deployed applications + +| Key | Description | +| :--- | :--- | +| `Deployment Frequency` | It shows how often this app is deployed to production | +| `Change Failure Rate` | It shows how often the respective pipeline fails. | +| `Mean Lead Time` | It shows the average time taken to deliver a change to production. | +| `Mean Time to Recovery` | It shows the average time taken to fix a failed pipeline. | + +## 2. Show application metrics + +If you want to see application metrics like different HTTP status codes metrics, application throughput, latency, response time. Enable the Application metrics from below the deployment template Save button. After enabling it, you should be able to see all metrics on App detail page. By default it remains disabled. +![](../../../.gitbook/assets/deployment_application_metrics%20%282%29.png) + +Once all the Deployment template configurations are done, click on `Save` to save your deployment configuration. Now you are ready to create [Workflow](workflow/) to do CI/CD. + +### Helm Chart Json Schema + +Helm Chart [json schema](../../../scripts/devtron-reference-helm-charts/reference-chart_4-11-0/schema.json) is used to validate the deployment template values. + +### Other Validations in Json Schema + +The values of CPU and Memory in limits must be greater than or equal to in requests respectively. Similarly, In case of envoyproxy, the values of limits are greater than or equal to requests as mentioned below. +``` +resources.limits.cpu >= resources.requests.cpu +resources.limits.memory >= resources.requests.memory +envoyproxy.resources.limits.cpu >= envoyproxy.resources.requests.cpu +envoyproxy.resources.limits.memory >= envoyproxy.resources.requests.memory +``` diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/app-values.yaml new file mode 100644 index 00000000000..f4c8cef663c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/app-values.yaml @@ -0,0 +1,428 @@ +# Mandatory configs +podDisruptionBudget: {} + +rolloutLabels: {} +rolloutAnnotations: {} + +containerSpec: + lifecycle: + enabled: false + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +replicaCount: 1 +MinReadySeconds: 60 +GracePeriod: 30 +image: + pullPolicy: IfNotPresent +restartPolicy: Always +service: + # enabled: true + type: ClusterIP + #name: "service-1234567890" + loadBalancerSourceRanges: [] + # loadBalancerSourceRanges: + # - 1.2.3.4/32 + # - 1.2.5.6/23 + annotations: {} + # test1: test2 + # test3: test4 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s +# servicemonitor: +# enabled: true +# path: /abc +# scheme: 'http' +# interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +# Optional configs +LivenessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + +ReadinessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/force-ssl-redirect: 'false' +# nginx.ingress.kubernetes.io/ssl-redirect: 'false' +# kubernetes.io/ingress.class: nginx +# nginx.ingress.kubernetes.io/rewrite-target: /$2 +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +command: + workingDir: {} + enabled: false + value: [] + +args: + enabled: false + value: + - /bin/sh + - -c + - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600 + +#For adding custom labels to pods + +podLabels: {} +# customKey: customValue +podAnnotations: {} +# customKey: customValue + +rawYaml: [] + +topologySpreadConstraints: [] + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +containers: [] + ## Additional containers to run along with application pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + +dbMigrationConfig: + enabled: false + +tolerations: [] + +podSecurityContext: {} + +containerSecurityContext: {} + +Spec: + Affinity: + Key: + # Key: kops.k8s.io/instancegroup + Values: + +ambassadorMapping: + enabled: false + labels: {} + prefix: / + ambassadorId: "" + hostname: devtron.example.com + rewrite: "" + retryPolicy: {} + cors: {} + tls: + context: "" + create: false + secretName: "" + hosts: [] + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 70 + TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + minReplicaCount: 1 + maxReplicaCount: 2 + advanced: {} + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +prometheus: + release: monitoring + +server: + deployment: + image_tag: 1-95af053 + image: "" + +servicemonitor: + additionalLabels: {} + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: "example.com" + tls: + enabled: false + secretName: secret-name + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + annotation: {} + labels: {} + type: Rollout + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + + + + +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +imagePullSecrets: [] + # - test1 + # - test2 +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" +# - "bar.local" +# - ip: "10.1.2.3" +# hostnames: +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/env-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/env-values.yaml new file mode 100644 index 00000000000..5cd07c0269e --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/env-values.yaml @@ -0,0 +1,66 @@ +replicaCount: 1 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 + +Spec: + Affinity: + key: "" + Values: nodes + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# +secret: + enabled: false + data: {} +# my_own_secret: S3ViZXJuZXRlcyBXb3Jrcw== + +EnvVariables: [] +# - name: FLASK_ENV +# value: qa + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: "0.05" + memory: 50Mi + requests: + cpu: "0.01" + memory: 10Mi + + diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/pipeline-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/pipeline-values.yaml new file mode 100644 index 00000000000..40a5ec633dd --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/pipeline-values.yaml @@ -0,0 +1,24 @@ +deployment: + strategy: + blueGreen: + autoPromotionSeconds: 30 + scaleDownDelaySeconds: 30 + previewReplicaCount: 1 + autoPromotionEnabled: false + rolling: + maxSurge: "25%" + maxUnavailable: 1 + canary: + maxSurge: "25%" + maxUnavailable: 1 + steps: + - setWeight: 25 + - pause: + duration: 15 # 1 min + - setWeight: 50 + - pause: + duration: 15 # 1 min + - setWeight: 75 + - pause: + duration: 15 # 1 min + recreate: {} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/release-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/release-values.yaml new file mode 100644 index 00000000000..48eb3f482c1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/release-values.yaml @@ -0,0 +1,14 @@ +server: + deployment: + image_tag: IMAGE_TAG + image: IMAGE_REPO + enabled: false +dbMigrationConfig: + enabled: false + +pauseForSecondsBeforeSwitchActive: 0 +waitForSecondsBeforeScalingDown: 0 +autoPromotionSeconds: 30 + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/schema.json b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/schema.json new file mode 100644 index 00000000000..da5cce59eab --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/schema.json @@ -0,0 +1,1363 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "containerExtraSpecs": { + "type": "object", + "title": "containerExtraSpecs", + "description": "Define container extra specs here" + }, + "ContainerPort": { + "type": "array", + "description": "defines ports on which application services will be exposed to other services", + "title": "Container Port", + "items": { + "type": "object", + "properties": { + "envoyPort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "envoy port for the container", + "title": "Envoy Port" + }, + "idleTimeout": { + "type": "string", + "description": "duration of time for which a connection is idle before the connection is terminated", + "title": "Idle Timeout" + }, + "name": { + "type": "string", + "description": "name of the port", + "title": "Name" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Port", + "title": "port for the container" + }, + "servicePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port of the corresponding kubernetes service", + "title": "Service Port" + }, + "nodePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "nodeport of the corresponding kubernetes service", + "title": "Node Port" + }, + "supportStreaming": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "field to enable/disable timeout for high performance protocols like grpc", + "title": "Support Streaming" + }, + "useHTTP2": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": " field for setting if envoy container can accept(or not) HTTP2 requests", + "title": "Use HTTP2" + } + } + } + }, + "EnvVariables": { + "type": "array", + "items": {}, + "description": "contains environment variables needed by the containers", + "title": "Environment Variables" + }, + "EnvVariablesFromFieldPath": { + "type": "array", + "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs", + "title": "EnvVariablesFromFieldPath", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be" + }, + "fieldPath": { + "type": "string", + "title": "fieldPath", + "description": "Path of the field to select in the specified API version" + } + } + } + ] + }, + "EnvVariablesFromSecretKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromSecretKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "secretName": { + "type": "string", + "title": "secretName", + "description": "Name of Secret from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "EnvVariablesFromConfigMapKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromConfigMapKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "configMapName": { + "type": "string", + "title": "configMapName", + "description": "Name of configMap from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "GracePeriod": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "time for which Kubernetes waits before terminating the pods", + "title": "Grace Period" + }, + "LivenessProbe": { + "type": "object", + "description": "used by the kubelet to know when to restart a container", + "title": "Liveness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the liveness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as live", + "title": "Failure Threshold" + }, + "httpHeaders": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for liveness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for liveness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the liveness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "MaxSurge": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be created over the desired number of pods", + "title": "Maximum Surge" + }, + "MaxUnavailable": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be unavailable during the update process", + "title": "Maximum Unavailable" + }, + "MinReadySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available", + "title": "Minimum Ready Seconds" + }, + "ReadinessProbe": { + "type": "object", + "description": "kubelet uses readiness probes to know when a container is ready to start accepting traffic", + "title": "Readiness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the readiness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as ready", + "title": "Failure Threshold" + }, + "httpHeader": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for readiness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for readiness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the readiness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "Spec": { + "type": "object", + "description": "used to define the desire state of the given container", + "title": "Spec", + "properties": { + "Affinity": { + "type": "object", + "description": "Node/Inter-pod Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node/pods", + "title": "Affinity", + "properties": { + "Key": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string", + "description": "Key part of the label for node/pod selection", + "title": "Key" + } + ] + }, + "Values": { + "type": "string", + "description": "Value part of the label for node/pod selection", + "title": "Values" + }, + "key": { + "type": "string" + } + } + } + } + }, + "ambassadorMapping": { + "type": "object", + "description": "used to create ambassador mapping resource", + "title": "Mapping", + "properties": { + "ambassadorId": { + "type": "string", + "description": "used to specify id for specific ambassador mappings controller", + "title": "Ambassador ID" + }, + "cors": { + "type": "object", + "description": "used to specify cors policy to access host for this mapping", + "title": "CORS" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify whether to create an ambassador mapping or not", + "title": "Enabled" + }, + "weight": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify weight for canary ambassador mappings" + }, + "hostname": { + "type": "string", + "description": "used to specify hostname for ambassador mapping", + "title": "Hostname" + }, + "labels": { + "type": "object", + "description": "used to provide custom labels for ambassador mapping", + "title": "Labels" + }, + "prefix": { + "type": "string", + "description": "used to specify path for ambassador mapping", + "title": "Prefix" + }, + "retryPolicy": { + "type": "object", + "description": "used to specify retry policy for ambassador mapping", + "title": "Retry Policy" + }, + "rewrite": { + "type": "string", + "description": "used to specify whether to redirect the path of this mapping and where", + "title": "Rewrite" + }, + "tls": { + "type": "object", + "description": "used to create or define ambassador TLSContext resource", + "title": "TLS Context" + }, + "extraSpec": { + "type": "object", + "description": "used to provide extra spec values which not present in deployment template for ambassador resource", + "title": "Extra Spec" + } + } + }, + "args": { + "type": "object", + "description": " used to give arguments to command", + "title": "Arguments", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling aruguments", + "title": "Enabled" + }, + "value": { + "type": "array", + "description": "values of the arguments", + "title": "Value", + "items": [ + { + "type": "string" + }, + { + "type": "string" + }, + { + "type": "string" + } + ] + } + } + }, + "autoscaling": { + "type": "object", + "description": "connected to HPA and controls scaling up and down in response to request load", + "title": "Autoscaling", + "properties": { + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling", + "title": "Maximum Replicas" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling", + "title": "Minimum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for a container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for a container", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for that behavior", + "title": "Behavior" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling", + "title": "Enabled" + }, + "labels": { + "type": "object", + "description": "labels for HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "used to configure some options for HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "used to give external metrics for autoscaling", + "title": "Extra Metrics" + } + } + }, + "command": { + "type": "object", + "description": "contains the commands for the server", + "title": "Command", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling commands" + }, + "value": { + "type": "array", + "items": {}, + "description": "contains the commands", + "title": "Value" + }, + "workingDir": { + "type": "object", + "items": {}, + "description": "contains the working directory", + "title": "Working directory" + } + } + }, + "containerSecurityContext": { + "type": "object", + "description": " defines privilege and access control settings for a Container", + "title": "Container Security Context" + }, + "containers": { + "type": "array", + "items": {}, + "description": " used to run side-car containers along with the main container within same pod" + }, + "dbMigrationConfig": { + "type": "object", + "description": "used to configure database migration", + "title": "Db Migration Config", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling the config", + "title": "Enabled" + } + } + }, + "envoyproxy": { + "type": "object", + "description": "envoy is attached as a sidecar to the application container to collect metrics like 4XX, 5XX, throughput and latency", + "title": "Envoy Proxy", + "properties": { + "configMapName": { + "type": "string", + "description": "configMap containing configuration for Envoy", + "title": "ConfigMap" + }, + "lifecycle": { + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled": { + "type": "boolean" + }, + "postStart": { + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created" + }, + "preStop": { + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + }, + "image": { + "type": "string", + "description": "image of envoy to be used" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + } + } + }, + "hostAliases": { + "type": "array", + "title": "hostAliases", + "description": "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file", + "items": [ + { + "type": "object", + "properties": { + "ip": { + "type": "string", + "title": "IP", + "description": "IP address of the host file entry" + }, + "hostnames": { + "type": "array", + "description": "Hostnames for the above IP address", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "image": { + "type": "object", + "description": "used to access images in kubernetes", + "title": "Image", + "properties": { + "pullPolicy": { + "type": "string", + "description": "used to define the instances calling the image", + "title": "Pull Policy", + "enum": [ + "IfNotPresent", + "Always" + ] + } + } + }, + "restartPolicy": { + "type": "string", + "description": "It restarts the docker container based on defined conditions.", + "title": "Restart Policy", + "enum": [ + "Always", + "OnFailure", + "Never" + ] + }, + "imagePullSecrets": { + "type": "array", + "items": {}, + "description": "contains the docker credentials that are used for accessing a registry", + "title": "Image PullSecrets" + }, + "winterSoldier": { + "type": "object", + "description": "allows to scale, sleep or delete the resource based on time.", + "title": "winterSoldier", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the winterSoldier controller", + "title": "Annotations" + }, + "labels": { + "type": "object", + "description": "labels for winterSoldier", + "title": "winterSoldier labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "apiVersion": { + "type": "string", + "description": "Api version for winterSoldier", + "title": "winterSoldier apiVersion", + "default": "pincher.devtron.ai/v1alpha1" + }, + "timeRangesWithZone": { + "type": "object", + "description": "describe time zone and time ranges to input in the winterSoldier", + "title": "Time Ranges With Zone", + "timeZone": { + "type": "string", + "description": "describe time zone, and follow standard format", + "title": "Time Zone" + }, + "timeRanges": { + "type": "array", + "items": {}, + "description": "used to take array of time ranges in which each element contains timeFrom, timeTo, weekdayFrom and weekdayTo.", + "title": "Time Ranges" + } + }, + "type": { + "type": "string", + "description": "describe the type of application Rollout/deployment.", + "title": "Type" + }, + "action": { + "type": "string", + "description": "describe the action to be performed by winterSoldier.", + "title": "Action" + }, + "targetReplicas": { + "type": "array", + "description": "describe the number of replicas to which the resource should scale up or down.", + "title": "Target Replicas" + }, + "fieldSelector": { + "type": "array", + "description": "it takes arrays of methods to select specific fields.", + "title": "Field Selector" + } + } + }, + "ingress": { + "type": "object", + "description": "allows public access to URLs", + "title": "Ingress", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx" + }, + "labels": { + "type": "object", + "description": "labels for ingress", + "title": "Ingress labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "ingressInternal": { + "type": "object", + "description": "allows private access to the URLs", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx-internal" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "networkPolicy":{ + "type": "object", + "description": "NetworkPolicy describes what network traffic is allowed for a set of Pods", + "title": "Network Policy", + "properties": { + "enabled":{ + "type":"boolean", + "description": "used to enable or disable NetworkPolicy" + }, + "annotations":{ + "type": "object", + "description": "Annotations for NetworkPolicy" + }, + "labels":{ + "type":"object", + "description": "Labels for NetworkPolicy" + }, + "podSelector":{ + "type": "object", + "description": "Selects the pods to which this NetworkPolicy object applies", + "properties": { + "matchExpressions":{ + "type":"array", + "description": "list of label selector" + }, + "matchLabels":{ + "type":"object", + "description": "map of {key,value} pairs" + } + } + }, + "policyTypes":{ + "type":"array", + "description": "List of rule types that the NetworkPolicy relates to. Valid options are Ingress,Egress." + }, + "ingress":{ + "type":"array", + "description": "List of ingress rules to be applied to the selected pods" + }, + "egress":{ + "type":"array", + "description": "List of egress rules to be applied to the selected pods" + } + } + }, + "istio":{ + "type": "object", + "description": "Istio Service mesh", + "title": "Istio" + }, + "initContainers": { + "type": "array", + "items": {}, + "description": "specialized containers that run before app containers in a Pod, can contain utilities or setup scripts not present in an app image", + "title": "Init Containers" + }, + "kedaAutoscaling": { + "type": "object", + "description": "Kubernetes-based event driven autoscaler. With KEDA, one can drive the scaling of any container in Kubernetes based on the no. of events needing to be processed", + "title": "KEDA Autoscaling", + "properties": { + "advanced": { + "type": "object" + }, + "authenticationRef": { + "type": "object" + }, + "enabled": { + "type": "boolean" + }, + "envSourceContainerName": { + "type": "string" + }, + "maxReplicaCount": { + "type": "integer" + }, + "minReplicaCount": { + "type": "integer" + }, + "triggerAuthentication": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "spec": { + "type": "object" + } + } + }, + "triggers": { + "type": "array", + "items": {} + } + } + }, + "containerSpec": { + "type": "object", + "description": "define the container specic configuration", + "title": "containerSpec", + "properties": { + "lifecycle": { + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled": { + "type": "boolean" + }, + "postStart": { + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created.You could use this event to check that a required API is available before the container’s main work begins" + }, + "preStop": { + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + } + } + }, + "pauseForSecondsBeforeSwitchActive": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "tell how much to wait for given period of time before switch active the container", + "title": "Pause For Seconds Before SwitchActive" + }, + "podAnnotations": { + "type": "object", + "description": "used to attach metadata and configs in Kubernetes", + "title": "Pod Annotations" + }, + "podDisruptionBudget": { + "type": "object", + "description": "PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods", + "properties": { + "minAvailable": { + "type": "string", + "title": "minAvailable", + "description": "An eviction is allowed if at least \"minAvailable\" pods selected by \"selector\" will still be available after the eviction, i.e. even in the absence of the evicted pod" + }, + "maxUnavailable": { + "type": "string", + "title": "maxUnavailable", + "description": "An eviction is allowed if at most \"maxUnavailable\" pods selected by \"selector\" are unavailable after the eviction, i.e. even in absence of the evicted pod." + } + } + }, + "podExtraSpecs": { + "type": "object", + "description": "ExtraSpec for the pods to be configured", + "title": "podExtraSpecs" + }, + "podLabels": { + "type": "object", + "description": "key/value pairs that are attached to pods, are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system", + "title": "Pod Labels" + }, + "podSecurityContext": { + "type": "object", + "description": "defines privilege and access control settings for a Pod or Container", + "title": "Pod Security Context" + }, + "prometheus": { + "type": "object", + "description": "a kubernetes monitoring tool", + "title": "Prometheus", + "properties": { + "release": { + "type": "string", + "description": "name of the file to be monitored, describes the state of prometheus" + } + } + }, + "rawYaml": { + "type": "array", + "items": {}, + "description": "Accepts an array of Kubernetes objects. One can specify any kubernetes yaml here & it will be applied when a app gets deployed.", + "title": "Raw YAML" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "count of Replicas of pod", + "title": "REplica Count" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + }, + "secret": { + "type": "object", + "properties": { + "data": { + "type": "object" + }, + "enabled": { + "type": "boolean" + } + } + }, + "server": { + "type": "object", + "description": "used for providing server configurations.", + "title": "Server", + "properties": { + "deployment": { + "type": "object", + "description": "gives the details for deployment", + "title": "Deployment", + "properties": { + "image": { + "type": "string", + "description": "URL of the image", + "title": "Image" + }, + "image_tag": { + "type": "string", + "description": "tag of the image", + "title": "Image Tag" + } + } + } + } + }, + "service": { + "type": "object", + "description": "defines annotations and the type of service", + "title": "Service", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service" + }, + "type": { + "type": "string", + "description": "type of service", + "title": "Type", + "enum": [ + "ClusterIP", + "LoadBalancer", + "NodePort", + "ExternalName" + ] + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable service", + "title": "Enabled" + } + } + }, + "serviceAccount": { + "type": "object", + "description": "defines service account for pods", + "title": "Service Account", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service account" + }, + "name": { + "type": "string", + "description": "name of service account", + "title": "Name" + }, + "create": { + "type": "boolean" + } + } + }, + "servicemonitor": { + "type": "object", + "description": "gives the set of targets to be monitored", + "title": "Service Monitor", + "properties": { + "additionalLabels": { + "type": "object" + } + } + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "a mechanism which work together with Taints which ensures that pods are not placed on inappropriate nodes", + "title": "Tolerations" + }, + "topologySpreadConstraints": { + "type": "array", + "items": {}, + "description": "used to control how Pods are spread across a cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains", + "title": "Topology Spread Constraints" + }, + "volumeMounts": { + "type": "array", + "items": {}, + "description": "used to provide mounts to the volume", + "title": "Volume Mounts" + }, + "volumes": { + "type": "array", + "items": {}, + "description": "required when some values need to be read from or written to an external disk", + "title": "Volumes" + }, + "waitForSecondsBeforeScalingDown": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Wait for given period of time before scaling down the container", + "title": "Wait For Seconds Before Scaling Down" + } + } +} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/secrets-test-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/secrets-test-values.yaml new file mode 100644 index 00000000000..4a20404db87 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/secrets-test-values.yaml @@ -0,0 +1 @@ +{"ConfigSecrets":{"enabled":true,"secrets":[{"data":{"standard_key":"c3RhbmRhcmQtdmFsdWU="},"external":false,"externalType":"","mountPath":"/test","name":"normal-secret","type":"volume"},{"data":{"secret_key":"U0VDUkVUIERBVEE="},"external":true,"externalType":"AWSSecretsManager","mountPath":"","name":"external-secret-3","type":"environment"}]}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/NOTES.txt b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/NOTES.txt new file mode 100644 index 00000000000..2b144781688 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range $.Values.ingress.paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include ".Chart.Name .fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include ".Chart.Name .fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include ".Chart.Name .fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include ".Chart.Name .name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/_helpers.tpl b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/_helpers.tpl new file mode 100644 index 00000000000..ada78dad51a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/_helpers.tpl @@ -0,0 +1,142 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define ".Chart.Name .name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create service name +*/}} +{{- define ".servicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 63 | trimSuffix "-" -}} +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 55 | trimSuffix "-" -}}-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create preview service name +*/}} +{{- define ".previewservicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 55 | trimSuffix "-" -}}-preview +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define ".Chart.Name .fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define ".Chart.Name .chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define ".Chart.Name .color" -}} +{{- $active0 := (index .Values.server.deployment 0).enabled -}} +{{/* +{{- $active1 := (index .Values.server.deployment 1).enabled -}} +*/}} +{{- $active1 := include "safeenabledcheck" . -}} +{{- $active := and $active0 $active1 -}} +{{- $active -}} +{{- end -}} + +{{- define "safeenabledcheck" -}} +{{- if (eq (len .Values.server.deployment) 2) -}} + {{- if (index .Values.server.deployment 1).enabled -}} + {{- $active := true -}} + {{- $active -}} + {{- else -}} + {{- $active := false -}} + {{- $active -}} + {{- end -}} +{{- else -}} + {{- $active := false -}} + {{- $active -}} +{{- end -}} +{{- end -}} + + +{{- define "isCMVolumeExists" -}} + {{- $isCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $isCMVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isCMVolumeExists -}} +{{- end -}} + +{{- define "isSecretVolumeExists" -}} + {{- $isSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $isSecretVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isSecretVolumeExists -}} +{{- end -}} + + + + +{{- define "serviceMonitorEnabled" -}} + {{- $SMenabled := false -}} + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if and .servicemonitor.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- end }} + {{- end }} + {{- $SMenabled -}} +{{- end -}} + +{{/* Create the name of the service account to use */}} +{{- define "serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include ".Chart.Name .fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ambassador.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ambassador.yaml new file mode 100644 index 00000000000..7c374a70e8b --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ambassador.yaml @@ -0,0 +1,86 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ambassadorMapping.enabled }} +{{- with $.Values.ambassadorMapping }} +apiVersion: getambassador.io/v3alpha1 +kind: Mapping +metadata: + name: {{ include ".Chart.Name .fullname" $ }}-mapping + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .labels }} +{{ toYaml .labels | nindent 4 }} + {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .ambassadorId }} + ambassador_id: {{ .ambassadorId }} + {{- end }} + {{- if .hostname }} + hostname: {{ .hostname | quote }} + {{- end }} + prefix: {{ .prefix }} + {{- if .rewrite }} + rewrite: {{ .rewrite }} + {{- end }} + service: {{ $svcName }}.{{ $.Release.Namespace }}:{{ $svcPort }} + {{- if .retryPolicy }} + retry_policy: +{{ toYaml .retryPolicy | indent 4 }} + {{- end }} + {{- if .cors }} + cors: +{{ toYaml .cors | indent 4 }} + {{- end }} + {{- if .weight }} + weight: {{ .weight }} + {{- end }} + {{- if .method }} + method: {{ .method }} + {{- end }} + {{- if .extraSpec }} +{{ toYaml .extraSpec | indent 2 }} + {{- end }} + {{- if .tls }} + {{- if .tls.context }} + tls: {{ .tls.context }} +{{- if .tls.create }} +--- +apiVersion: getambassador.io/v3alpha1 +kind: TLSContext +metadata: + name: {{ .tls.context }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .tls.labels }} +{{ toYaml .tls.labels | nindent 4 }} + {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .tls.secretName }} + secret: {{ .tls.secretName }} + {{- end }} + {{- if .tls.hosts }} + hosts: +{{ toYaml .tls.hosts | nindent 4 }} + {{- end }} + {{- if .tls.extraSpec }} +{{ toYaml .tls.extraSpec | indent 2 }} + {{- end }} +{{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/configmap.yaml new file mode 100644 index 00000000000..72d5ca84798 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/configmap.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +data: +{{ toYaml .data | trim | indent 2 }} + {{- end}} + {{- end}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/deployment.yaml new file mode 100644 index 00000000000..317b3f992b7 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/deployment.yaml @@ -0,0 +1,556 @@ + {{- $hasCMEnvExists := false -}} + {{- $hasCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $hasCMVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasCMEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + {{- $hasSecretEnvExists := false -}} + {{- $hasSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $hasSecretVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasSecretEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + +apiVersion: argoproj.io/v1alpha1 +kind: Rollout +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ .Values.pipelineName }} +{{- if .Values.rolloutLabels }} +{{ toYaml .Values.rolloutLabels | indent 4 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + +{{- if .Values.rolloutAnnotations }} + annotations: +{{ toYaml .Values.rolloutAnnotations | indent 4 }} +{{- end }} + +spec: + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + replicas: {{ $.Values.replicaCount }} + minReadySeconds: {{ $.Values.MinReadySeconds }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | indent 8 }} +{{- end }} + spec: +{{- if $.Values.podExtraSpecs }} +{{ toYaml .Values.podExtraSpecs | indent 6 }} +{{- end }} + terminationGracePeriodSeconds: {{ $.Values.GracePeriod }} + restartPolicy: Always +{{- if $.Values.hostAliases }} + hostAliases: +{{ toYaml .Values.hostAliases | indent 8 }} +{{- end }} +{{- if and $.Values.Spec.Affinity.Key $.Values.Spec.Affinity.Values }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: {{ $.Values.Spec.Affinity.Key }} + operator: In + values: + - {{ $.Values.Spec.Affinity.Values | default "nodes" }} +{{- end }} +{{- if $.Values.serviceAccountName }} + serviceAccountName: {{ $.Values.serviceAccountName }} +{{- else }} + serviceAccountName: {{ template "serviceAccountName" . }} +{{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} +{{- if $.Values.imagePullSecrets}} + imagePullSecrets: + {{- range .Values.imagePullSecrets }} + - name: {{ . }} + {{- end }} +{{- end}} +{{- if $.Values.topologySpreadConstraints }} + topologySpreadConstraints: +{{- range $.Values.topologySpreadConstraints }} + - maxSkew: {{ .maxSkew }} + topologyKey: {{ .topologyKey }} + whenUnsatisfiable: {{ .whenUnsatisfiable }} + labelSelector: + matchLabels: + {{- if and .autoLabelSelector .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- else if .autoLabelSelector }} + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} + {{- else if .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- end }} +{{- end }} +{{- end }} +{{- if $.Values.podSecurityContext }} + securityContext: +{{ toYaml .Values.podSecurityContext | indent 8 }} +{{- end }} +{{- if $.Values.restartPolicy }} + restartPolicy: {{ $.Values.restartPolicy }} +{{- end }} +{{- if $.Values.initContainers}} + initContainers: +{{- range $i, $c := .Values.initContainers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-init-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + containers: +{{- if $.Values.appMetrics }} + - name: envoy + image: {{ $.Values.envoyproxy.image | default "envoyproxy/envoy:v1.14.1"}} + {{- if $.Values.envoyproxy.lifecycle }} + lifecycle: +{{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} + {{- else if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- end }} + resources: +{{ toYaml $.Values.envoyproxy.resources | trim | indent 12 }} + ports: + - containerPort: 9901 + protocol: TCP + name: envoy-admin + {{- range $index, $element := .Values.ContainerPort }} + - name: {{ $element.name}} + containerPort: {{ $element.envoyPort | default (add 8790 $index) }} + protocol: TCP + {{- end }} + command: ["/usr/local/bin/envoy"] + args: ["-c", "/etc/envoy-config/envoy-config.json", "-l", "info", "--log-format", "[METADATA][%Y-%m-%d %T.%e][%t][%l][%n] %v"] + volumeMounts: + - name: {{ $.Values.envoyproxy.configMapName | default "envoy-config-volume" }} + mountPath: /etc/envoy-config/ +{{- end}} +{{- if $.Values.containers }} +{{- range $i, $c := .Values.containers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-sidecontainer-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + - name: {{ $.Chart.Name }} + image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + {{- if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- if $.Values.containerSpec.lifecycle.postStart }} + postStart: +{{ toYaml $.Values.containerSpec.lifecycle.postStart | indent 12 -}} + {{- end }} + {{- end }} +{{- if and $.Values.containerSecurityContext $.Values.privileged }} + securityContext: + privileged: true +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- else if $.Values.privileged }} + securityContext: + privileged: true +{{- else if $.Values.containerSecurityContext }} + securityContext: +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- end }} +{{- if $.Values.containerExtraSpecs }} +{{ toYaml .Values.containerExtraSpecs | indent 10 }} +{{- end }} + ports: + {{- range $.Values.ContainerPort }} + - name: {{ .name}} + containerPort: {{ .port }} + protocol: TCP + {{- end}} +{{- if and $.Values.command.enabled $.Values.command.workingDir }} + workingDir: {{ $.Values.command.workingDir }} +{{- end}} +{{- if and $.Values.command.value $.Values.command.enabled}} + command: +{{ toYaml $.Values.command.value | indent 12 -}} +{{- end}} +{{- if and $.Values.args.value $.Values.args.enabled}} + args: +{{ toYaml $.Values.args.value | indent 12 -}} +{{- end }} + env: + - name: CONFIG_HASH + value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }} + - name: SECRET_HASH + value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }} + - name: DEVTRON_APP_NAME + value: {{ template ".Chart.Name .name" $ }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: DEVTRON_CONTAINER_REPO + value: "{{ .Values.server.deployment.image }}" + - name: DEVTRON_CONTAINER_TAG + value: "{{ .Values.server.deployment.image_tag }}" + {{- range $.Values.EnvVariablesFromFieldPath }} + {{- if and .name .fieldPath }} + - name: {{ .name }} + valueFrom: + fieldRef: + fieldPath: {{ .fieldPath }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariables }} + {{- if and .name .value }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromSecretKeys }} + {{- if and .name .secretName .keyName }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromConfigMapKeys }} + {{- if and .name .configMapName .keyName }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ .configMapName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- if or (and ($hasCMEnvExists) (.Values.ConfigMaps.enabled)) (and ($hasSecretEnvExists) (.Values.ConfigSecrets.enabled)) }} + envFrom: + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "environment" }} + - configMapRef: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "environment" }} + - secretRef: + {{if eq .external true}} + name: {{ .name }} + {{else if eq .external false}} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + +{{- if or $.Values.LivenessProbe.Path $.Values.LivenessProbe.command $.Values.LivenessProbe.tcp }} + livenessProbe: +{{- if $.Values.LivenessProbe.Path }} + httpGet: + path: {{ $.Values.LivenessProbe.Path }} + port: {{ $.Values.LivenessProbe.port }} + {{- if $.Values.LivenessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.LivenessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.LivenessProbe.command }} + exec: + command: +{{ toYaml .Values.LivenessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.LivenessProbe.tcp }} + tcpSocket: + port: {{ $.Values.LivenessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.LivenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.LivenessProbe.periodSeconds }} + successThreshold: {{ $.Values.LivenessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.LivenessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.LivenessProbe.failureThreshold }} +{{- end }} +{{- if or $.Values.ReadinessProbe.Path $.Values.ReadinessProbe.command $.Values.ReadinessProbe.tcp }} + readinessProbe: +{{- if $.Values.ReadinessProbe.Path }} + httpGet: + path: {{ $.Values.ReadinessProbe.Path }} + port: {{ $.Values.ReadinessProbe.port }} + {{- if $.Values.ReadinessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.ReadinessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.ReadinessProbe.command }} + exec: + command: +{{ toYaml .Values.ReadinessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.ReadinessProbe.tcp }} + tcpSocket: + port: {{ $.Values.ReadinessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.ReadinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.ReadinessProbe.periodSeconds }} + successThreshold: {{ $.Values.ReadinessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.ReadinessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.ReadinessProbe.failureThreshold }} +{{- end }} + resources: +{{ toYaml $.Values.resources | trim | indent 12 }} +{{- if or $.Values.StartupProbe.Path $.Values.StartupProbe.command $.Values.StartupProbe.tcp }} + startupProbe: +{{- if $.Values.StartupProbe.Path }} + httpGet: + path: {{ $.Values.StartupProbe.Path }} + port: {{ $.Values.StartupProbe.port }} + {{- if $.Values.StartupProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.StartupProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.StartupProbe.command }} + exec: + command: +{{ toYaml .Values.StartupProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.StartupProbe.tcp }} + tcpSocket: + port: {{ $.Values.StartupProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.StartupProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.StartupProbe.periodSeconds }} + successThreshold: {{ $.Values.StartupProbe.successThreshold }} + timeoutSeconds: {{ $.Values.StartupProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.StartupProbe.failureThreshold }} +{{- end }} + volumeMounts: +{{- with .Values.volumeMounts }} +{{ toYaml . | trim | indent 12 }} +{{- end }} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{- range $k, $v := .data }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{- range $k, $v := .data }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} []{{- end }} + + volumes: + {{- if $.Values.appMetrics }} + - name: envoy-config-volume + configMap: + name: sidecar-config-{{ template ".Chart.Name .name" $ }} + {{- end }} +{{- with .Values.volumes }} +{{ toYaml . | trim | indent 8 }} +{{- end }} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + configMap: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + secret: + {{- if eq .external true }} + secretName: {{ .name }} + {{- else if eq .external false }} + secretName: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) (eq (.Values.appMetrics) false) }} []{{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) (eq (.Values.appMetrics) false) }} []{{- end }} + + revisionHistoryLimit: 3 +## pauseForSecondsBeforeSwitchActive: {{ $.Values.pauseForSecondsBeforeSwitchActive }} +# waitForSecondsBeforeScalingDown: {{ $.Values.waitForSecondsBeforeScalingDown }} + strategy: + {{- if eq .Values.deploymentType "BLUE-GREEN" }} + blueGreen: # A new field that used to provide configurable options for a BlueGreenUpdate strategy + previewService: {{ template ".previewservicename" . }} # Reference to a service that can serve traffic to a new image before it receives the active traffic + activeService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + autoPromotionSeconds: {{ $.Values.deployment.strategy.blueGreen.autoPromotionSeconds }} + scaleDownDelaySeconds: {{ $.Values.deployment.strategy.blueGreen.scaleDownDelaySeconds }} + previewReplicaCount: {{ $.Values.deployment.strategy.blueGreen.previewReplicaCount }} + autoPromotionEnabled: {{ $.Values.deployment.strategy.blueGreen.autoPromotionEnabled }} + {{- else if eq .Values.deploymentType "ROLLING" }} + canary: + stableService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + maxSurge: {{ $.Values.deployment.strategy.rolling.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.rolling.maxUnavailable }} + {{- else if eq .Values.deploymentType "RECREATE" }} + recreate: + activeService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + {{- else if eq .Values.deploymentType "CANARY" }} + canary: + stableService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + maxSurge: {{ $.Values.deployment.strategy.canary.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.canary.maxUnavailable }} + steps: +{{ toYaml .Values.deployment.strategy.canary.steps | indent 8 }} + {{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/externalsecrets.yaml new file mode 100644 index 00000000000..bdb4223cc0c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/externalsecrets.yaml @@ -0,0 +1,57 @@ +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external true }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} +{{- if .esoSecretData.secretStore }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: SecretStore +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + provider: + {{- toYaml .esoSecretData.secretStore | nindent 4 }} +{{- end }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: {{ .name }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .esoSecretData.refreshInterval }} + refreshInterval: {{ .esoSecretData.refreshInterval }} + {{- else }} + refreshInterval: 1h + {{- end}} + {{- if and .esoSecretData.secretStoreRef (not .esoSecretData.secretStore) }} + secretStoreRef: +{{ toYaml .esoSecretData.secretStoreRef | indent 4 }} + {{- else }} + secretStoreRef: + name: {{ .name}} + kind: SecretStore + {{- end }} + target: + name: {{ .name}} + creationPolicy: Owner + data: + {{- range .esoSecretData.esoData }} + - secretKey: {{ .secretKey }} + remoteRef: + key: {{ .key }} + {{- if .property }} + property: {{ .property }} + {{- end }} + {{- end}} +{{- end}} +{{- end}} +{{- end}} +{{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/generic.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/generic.yaml new file mode 100644 index 00000000000..db95e842670 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/generic.yaml @@ -0,0 +1,4 @@ +{{- range .Values.rawYaml }} +--- +{{ toYaml . }} + {{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/hpa.yaml new file mode 100644 index 00000000000..a0e15155766 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/hpa.yaml @@ -0,0 +1,59 @@ +{{- if $.Values.autoscaling.enabled }} +{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2 +{{- else if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2beta2 +{{- else }} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- if .Values.autoscaling.annotations }} + annotations: +{{ toYaml .Values.autoscaling.annotations | indent 4 }} + {{- end }} + {{- if .Values.autoscaling.labels }} + labels: +{{ toYaml .Values.autoscaling.labels | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: argoproj.io/v1alpha1 + kind: Rollout + name: {{ include ".Chart.Name .fullname" $ }} + minReplicas: {{ $.Values.autoscaling.MinReplicas }} + maxReplicas: {{ $.Values.autoscaling.MaxReplicas }} + metrics: + {{- if $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if $.Values.autoscaling.TargetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if and $.Values.autoscaling.extraMetrics (semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $.Values.autoscaling.extraMetrics | nindent 2 }} + {{- end}} + {{- if and $.Values.autoscaling.behavior (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ingress.yaml new file mode 100644 index 00000000000..1f231966b16 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/ingress.yaml @@ -0,0 +1,177 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ingress.enabled -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- if and .Values.ingressInternal.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingressInternal.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingressInternal.annotations "kubernetes.io/ingress.class" .Values.ingressInternal.className}} + {{- end }} +{{- end }} +{{- end }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.ingress.labels }} +{{ toYaml .Values.ingress.labels | indent 4 }} + {{- end }} +{{- if .Values.ingress.annotations }} + annotations: +{{ toYaml .Values.ingress.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + rules: + {{- if or .Values.ingress.host .Values.ingress.path }} + - host: {{ .Values.ingress.host }} + http: + paths: + - path: {{ .Values.ingress.path }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingress.pathType | default "ImplementationSpecific" }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingress.hosts) (not ($.Values.ingress.host )) }} + {{- range .Values.ingress.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end }} +{{- if $.Values.ingressInternal.enabled }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{ else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{ else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress-internal + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.ingressInternal.annotations }} + annotations: +{{ toYaml .Values.ingressInternal.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingressInternal.className }} + {{- end }} + rules: + {{- if or .Values.ingressInternal.host .Values.ingressInternal.path }} + - host: {{ .Values.ingressInternal.host }} + http: + paths: + - path: {{ .Values.ingressInternal.path }} + {{- if and .Values.ingressInternal.pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingressInternal.pathType | default "Prefix" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingressInternal.hosts) (not ($.Values.ingressInternal.host )) }} + {{- range .Values.ingressInternal.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + + {{- end }} + {{- end }} + {{- if .Values.ingressInternal.tls }} + tls: +{{ toYaml .Values.ingressInternal.tls | indent 4 }} + {{- end -}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-authorizationpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-authorizationpolicy.yaml new file mode 100644 index 00000000000..ac7b456ec5b --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-authorizationpolicy.yaml @@ -0,0 +1,37 @@ +{{- with .Values.istio }} +{{- if and .enable .authorizationPolicy.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .authorizationPolicy.labels }} +{{ toYaml .authorizationPolicy.labels | indent 4 }} + {{- end }} +{{- if .authorizationPolicy.annotations }} + annotations: +{{ toYaml .authorizationPolicy.annotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} + action: {{ .authorizationPolicy.action }} +{{- if $.Values.istio.authorizationPolicy.provider }} + provider: +{{ toYaml $.Values.istio.authorizationPolicy.provider | indent 4 }} +{{- end }} +{{- if $.Values.istio.authorizationPolicy.rules }} + rules: +{{ toYaml $.Values.istio.authorizationPolicy.rules | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-destinationrule.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-destinationrule.yaml new file mode 100644 index 00000000000..47bef9a828e --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-destinationrule.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .destinationRule.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: DestinationRule +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .destinationRule.labels }} +{{ toYaml .destinationRule.labels | indent 4 }} + {{- end }} +{{- if .destinationRule.annotations }} + annotations: +{{ toYaml .destinationRule.annotations | indent 4 }} +{{- end }} +spec: + host: "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- if $.Values.istio.destinationRule.subsets }} + subsets: +{{ toYaml $.Values.istio.destinationRule.subsets | indent 4 }} +{{- end }} +{{- if $.Values.istio.destinationRule.trafficPolicy }} + trafficPolicy: +{{ toYaml $.Values.istio.destinationRule.trafficPolicy | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-gateway.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-gateway.yaml new file mode 100644 index 00000000000..d6579590100 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-gateway.yaml @@ -0,0 +1,50 @@ +{{- if and .Values.istio.enable .Values.istio.gateway.enabled -}} +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.istio.gateway.labels }} +{{ toYaml $.Values.istio.gateway.labels | indent 4 }} + {{- end }} +{{- if $.Values.istio.gateway.annotations }} + annotations: +{{ toYaml $.Values.istio.gateway.annotations | indent 4 }} +{{- end }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - {{ .Values.istio.gateway.host | quote -}} +{{ with .Values.istio.gateway }} +{{- if .tls.enabled }} + tls: + httpsRedirect: true + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - {{ .host | quote }} + tls: + mode: SIMPLE + credentialName: {{ .tls.secretName }} +{{ end }} +{{ end }} +{{ end }} + + + diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-peerauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-peerauthentication.yaml new file mode 100644 index 00000000000..481f8a96474 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-peerauthentication.yaml @@ -0,0 +1,36 @@ +{{- with .Values.istio }} +{{- if and .enable .peerAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: PeerAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .peerAuthentication.labels }} +{{ toYaml .peerAuthentication.labels | indent 4 }} + {{- end }} +{{- if .peerAuthentication.annotations }} + annotations: +{{ toYaml .peerAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .peerAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} + mtls: + mode: {{ .peerAuthentication.mtls.mode }} +{{- if $.Values.istio.peerAuthentication.portLevelMtls }} + portLevelMtls: +{{ toYaml $.Values.istio.peerAuthentication.portLevelMtls | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-requestauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-requestauthentication.yaml new file mode 100644 index 00000000000..3429cee1462 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-requestauthentication.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .requestAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: RequestAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .requestAuthentication.labels }} +{{ toYaml .requestAuthentication.labels | indent 4 }} + {{- end }} +{{- if .requestAuthentication.annotations }} + annotations: +{{ toYaml .requestAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .requestAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} +{{- if $.Values.istio.requestAuthentication.jwtRules }} + jwtRules: +{{ toYaml $.Values.istio.requestAuthentication.jwtRules | indent 2 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-virtualservice.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-virtualservice.yaml new file mode 100644 index 00000000000..af61039b8db --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/istio-virtualservice.yaml @@ -0,0 +1,50 @@ +{{- with .Values.istio }} +{{- if and .enable .virtualService.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .virtualService.labels }} +{{ toYaml .virtualService.labels | indent 4 }} + {{- end }} +{{- if .virtualService.annotations }} + annotations: +{{ toYaml .virtualService.annotations | indent 4 }} +{{- end }} +spec: +{{- if or .gateway.enabled .virtualService.gateways }} + gateways: + {{- if .gateway.enabled }} + - {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} + {{- range .virtualService.gateways }} + - {{ . | quote }} + {{- end }} +{{- end }} +{{- if or .gateway.enabled .virtualService.hosts }} + hosts: + {{- if .gateway.enabled }} + - {{ .gateway.host | quote }} + {{- end }} + {{- range .virtualService.hosts }} + - {{ . | quote }} + {{- end }} +{{- else }} + hosts: + - "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- end }} +{{- if $.Values.istio.virtualService.http }} + http: +{{ toYaml $.Values.istio.virtualService.http | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/keda-autoscaling.yaml new file mode 100644 index 00000000000..7eb999bb486 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/keda-autoscaling.yaml @@ -0,0 +1,64 @@ +{{- if $.Values.kedaAutoscaling.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-keda + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.labels }} +{{ toYaml .Values.kedaAutoscaling.labels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.annotations }} + annotations: +{{ toYaml .Values.kedaAutoscaling.annotations | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: argoproj.io/v1alpha1 + kind: Rollout + name: {{ include ".Chart.Name .fullname" $ }} +{{- if $.Values.kedaAutoscaling.envSourceContainerName }} + envSourceContainerName: {{ $.Values.kedaAutoscaling.envSourceContainerName }} +{{- end }} +{{- if $.Values.kedaAutoscaling.pollingInterval }} + pollingInterval: {{ $.Values.kedaAutoscaling.pollingInterval }} +{{- end }} +{{- if $.Values.kedaAutoscaling.cooldownPeriod }} + cooldownPeriod: {{ $.Values.kedaAutoscaling.cooldownPeriod }} +{{- end }} +{{- if $.Values.kedaAutoscaling.idleReplicaCount }} + idleReplicaCount: {{ $.Values.kedaAutoscaling.idleReplicaCount }} +{{- end }} + minReplicaCount: {{ $.Values.kedaAutoscaling.minReplicaCount }} + maxReplicaCount: {{ $.Values.kedaAutoscaling.maxReplicaCount }} +{{- if $.Values.kedaAutoscaling.fallback }} + fallback: +{{ toYaml $.Values.kedaAutoscaling.fallback | indent 4 }} +{{- end }} +{{- if $.Values.kedaAutoscaling.advanced }} + advanced: +{{ toYaml $.Values.kedaAutoscaling.advanced | indent 4 }} +{{- end }} + triggers: +{{ toYaml .Values.kedaAutoscaling.triggers | indent 2}} +{{- if $.Values.kedaAutoscaling.authenticationRef }} + authenticationRef: +{{ toYaml $.Values.kedaAutoscaling.authenticationRef | indent 6 }} +{{- end }} +--- +{{- if $.Values.kedaAutoscaling.triggerAuthentication.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: TriggerAuthentication +metadata: + name: {{ $.Values.kedaAutoscaling.triggerAuthentication.name }} +spec: +{{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/metrics-service-monitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/metrics-service-monitor.yaml new file mode 100644 index 00000000000..4e9e544f508 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/metrics-service-monitor.yaml @@ -0,0 +1,35 @@ +{{- if $.Values.appMetrics -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: + jobLabel: {{ template ".Chart.Name .name" $ }} + endpoints: + - port: envoy-admin + interval: 30s + path: /stats/prometheus + relabelings: + - action: replace + sourceLabels: + - __meta_kubernetes_pod_label_rollouts_pod_template_hash + targetLabel: devtron_app_hash + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + namespaceSelector: + matchNames: + - {{.Release.Namespace}} + podTargetLabels: + - appId + - envId + - devtron_app_hash +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/networkpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/networkpolicy.yaml new file mode 100644 index 00000000000..350232a23b6 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/networkpolicy.yaml @@ -0,0 +1,50 @@ +{{- if .Values.networkPolicy.enabled -}} +{{- with .Values.networkPolicy }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.networkPolicy.labels }} +{{ toYaml $.Values.networkPolicy.labels | indent 4 }} + {{- end }} +{{- if $.Values.networkPolicy.annotations }} + annotations: +{{ toYaml $.Values.networkPolicy.annotations | indent 4 }} +{{- end }} +spec: + podSelector: +{{- if .podSelector.matchExpressions }} + matchExpressions: +{{ toYaml $.Values.networkPolicy.podSelector.matchExpressions | indent 6 }} +{{- end }} +{{- if .podSelector.matchLabels }} + matchLabels: +{{ toYaml $.Values.networkPolicy.podSelector.matchLabels | indent 6 }} +{{- else }} + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} +{{- end }} +{{- if .policyTypes }} + policyTypes: +{{ toYaml $.Values.networkPolicy.policyTypes | indent 4 }} +{{- end }} +{{- if .ingress }} + ingress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4 }} +{{- end }} +{{- if .egress }} + egress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4}} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/poddisruptionbudget.yaml new file mode 100644 index 00000000000..c9cbb4162d4 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/poddisruptionbudget.yaml @@ -0,0 +1,25 @@ +{{- if .Values.podDisruptionBudget }} +{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: policy/v1 +{{- else -}} +apiVersion: policy/v1beta1 +{{- end }} +kind: PodDisruptionBudget +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + selector: + matchLabels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/pre-sync-job.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/pre-sync-job.yaml new file mode 100644 index 00000000000..cd733d48576 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/pre-sync-job.yaml @@ -0,0 +1,23 @@ +{{- if $.Values.dbMigrationConfig.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-migrator + annotations: + argocd.argoproj.io/hook: PreSync +# argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + containers: + - name: migrator + image: 686244538589.dkr.ecr.us-east-2.amazonaws.com/migrator:0.0.1-rc14 + env: + {{- range $.Values.dbMigrationConfig.envValues }} + - name: {{ .key}} + value: {{ .value | quote }} + {{- end}} + restartPolicy: Never + backoffLimit: 0 +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/prometheusrules.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/prometheusrules.yaml new file mode 100644 index 00000000000..90f398bff4c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/prometheusrules.yaml @@ -0,0 +1,22 @@ +{{- if .Values.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template ".Chart.Name .fullname" . }} + {{- if .Values.prometheusRule.namespace }} + namespace: {{ .Values.prometheusRule.namespace }} + {{- end }} + labels: + kind: Prometheus + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.prometheusRule.additionalLabels }} +{{ toYaml .Values.prometheusRule.additionalLabels | indent 4 }} + {{- end }} +spec: + {{- with .Values.prometheusRule.rules }} + groups: + - name: {{ template ".Chart.Name .fullname" $ }} + rules: {{- toYaml . | nindent 6 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/secret.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/secret.yaml new file mode 100644 index 00000000000..26a17b968ca --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/secret.yaml @@ -0,0 +1,69 @@ +{{- if $.Values.secret.enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: app-secret +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml $.Values.secret.data | indent 2 }} +{{- end }} + + +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml .data | trim | indent 2 }} +{{- end}} + {{if eq .external true }} + {{if (or (eq .externalType "AWSSecretsManager") (eq .externalType "AWSSystemManager") (eq .externalType "HashiCorpVault"))}} +--- +apiVersion: kubernetes-client.io/v1 +kind: ExternalSecret +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .roleARN }} + roleArn: .roleARN + {{- end}} + {{- if eq .externalType "AWSSecretsManager"}} + backendType: secretsManager + {{- end}} + {{- if eq .externalType "AWSSystemManager"}} + backendType: systemManager + {{- end}} + {{- if eq .externalType "HashiCorpVault"}} + backendType: vault + {{- end}} + data: + {{- range .secretData }} + - key: {{.key}} + name: {{.name}} + {{- if .property }} + property: {{.property}} + {{- end}} + isBinary: {{.isBinary}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/service.yaml new file mode 100644 index 00000000000..da6917be6d1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/service.yaml @@ -0,0 +1,83 @@ +{{- if .Values.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".servicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end}} +spec: + type: {{ .Values.service.type | default "ClusterIP" }} +{{- if (and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges )}} + loadBalancerSourceRanges: + {{- range .Values.service.loadBalancerSourceRanges }} + - {{ . }} + {{- end }} +{{- end }} + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + {{- if .targetPort }} + targetPort: {{ .targetPort }} + {{- else }} + targetPort: {{ .name }} + {{- end }} + {{- if (and (eq $.Values.service.type "NodePort") .nodePort )}} + nodePort: {{ .nodePort }} + {{- end }} + protocol: TCP + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- if eq .Values.deploymentType "BLUE-GREEN" }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".previewservicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +spec: + type: ClusterIP + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + targetPort: {{ .name }} + protocol: TCP + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/serviceaccount.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/serviceaccount.yaml new file mode 100644 index 00000000000..ac258610fa8 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if $.Values.serviceAccount }} +{{- if $.Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "serviceAccountName" . }} + {{- if .Values.podLabels }} + labels: +{{ toYaml .Values.podLabels | indent 4 }} + {{- end }} + {{- if .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/servicemonitor.yaml new file mode 100644 index 00000000000..1f90c722cb1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/servicemonitor.yaml @@ -0,0 +1,48 @@ +{{ $serviceMonitorEnabled := include "serviceMonitorEnabled" . }} +{{- if eq "true" $serviceMonitorEnabled -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" . }}-sm + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.servicemonitor.additionalLabels }} +{{ toYaml .Values.servicemonitor.additionalLabels | indent 4 }} + {{- end }} +spec: + endpoints: + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if .servicemonitor.enabled}} + {{- if .servicePort }} + - port: {{ .name }} + {{- if .servicemonitor.path }} + path: {{ .servicemonitor.path}} + {{- end }} + {{- if .servicemonitor.scheme }} + scheme: {{ .servicemonitor.scheme}} + {{- end }} + {{- if .servicemonitor.interval }} + interval: {{ .servicemonitor.interval}} + {{- end }} + {{- if .servicemonitor.scrapeTimeout }} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} + {{- end }} + {{- if .servicemonitor.metricRelabelings}} + metricRelabelings: +{{toYaml .servicemonitor.metricRelabelings | indent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/sidecar-configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/sidecar-configmap.yaml new file mode 100644 index 00000000000..cf32679409a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/sidecar-configmap.yaml @@ -0,0 +1,169 @@ +{{- if .Values.appMetrics }} +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2019-08-12T18:38:34Z + name: sidecar-config-{{ template ".Chart.Name .name" $ }} +data: + envoy-config.json: | + { + "stats_config": { + "use_all_default_tags": false, + "stats_tags": [ + { + "tag_name": "cluster_name", + "regex": "^cluster\\.((.+?(\\..+?\\.svc\\.cluster\\.local)?)\\.)" + }, + { + "tag_name": "tcp_prefix", + "regex": "^tcp\\.((.*?)\\.)\\w+?$" + }, + { + "tag_name": "response_code", + "regex": "_rq(_(\\d{3}))$" + }, + { + "tag_name": "response_code_class", + "regex": ".*_rq(_(\\dxx))$" + }, + { + "tag_name": "http_conn_manager_listener_prefix", + "regex": "^listener(?=\\.).*?\\.http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "http_conn_manager_prefix", + "regex": "^http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "listener_address", + "regex": "^listener\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "mongo_prefix", + "regex": "^mongo\\.(.+?)\\.(collection|cmd|cx_|op_|delays_|decoding_)(.*?)$" + } + ], + "stats_matcher": { + "inclusion_list": { + "patterns": [ + { + "regex": ".*_rq_\\dxx$" + }, + { + "regex": ".*_rq_time$" + }, + { + "regex": "cluster.*" + }, + ] + } + } + }, + "admin": { + "access_log_path": "/dev/null", + "address": { + "socket_address": { + "address": "0.0.0.0", + "port_value": 9901 + } + } + }, + "static_resources": { + "clusters": [ + {{- range $index, $element := .Values.ContainerPort }} + { + "name": "{{ $.Values.app }}-{{ $index }}", + "type": "STATIC", + "connect_timeout": "0.250s", + "lb_policy": "ROUND_ROBIN", +{{- if $element.idleTimeout }} + "common_http_protocol_options": { + "idle_timeout": {{ $element.idleTimeout | quote }} + }, +{{- end }} +{{- if or $element.useHTTP2 $element.useGRPC }} + "http2_protocol_options": {}, +{{- end }} +{{- if and (not $element.useGRPC) (not $element.supportStreaming) }} + "max_requests_per_connection": "1", +{{- end }} + "load_assignment": { + "cluster_name": "9", + "endpoints": { + "lb_endpoints": [ + { + "endpoint": { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "127.0.0.1", + "port_value": {{ $element.port }} + } + } + } + } + ] + } + } + }, + {{- end }} + ], + "listeners":[ + {{- range $index, $element := .Values.ContainerPort }} + { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "0.0.0.0", + "port_value": {{ $element.envoyPort | default (add 8790 $index) }} + } + }, + "filter_chains": [ + { + "filters": [ + { + "name": "envoy.filters.network.http_connection_manager", + "config": { + "codec_type": "AUTO", + "stat_prefix": "stats", + "route_config": { + "virtual_hosts": [ + { + "name": "backend", + "domains": [ + "*" + ], + "routes": [ + { + "match": { + "prefix": "/" + }, + "route": { +{{- if $element.supportStreaming }} + "timeout": "0s", +{{- end }} +{{- if and ($element.envoyTimeout) (not $element.supportStreaming) }} + "timeout": "{{ $element.envoyTimeout }}", +{{- end }} + "cluster": "{{ $.Values.app }}-{{ $index }}" + } + } + ] + } + ] + }, + "http_filters": { + "name": "envoy.filters.http.router" + } + } + } + ] + } + ] + }, + {{- end }} + ] + } + } +--- +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/winter-soldier.yaml new file mode 100644 index 00000000000..2d3e7bae0fe --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/templates/winter-soldier.yaml @@ -0,0 +1,41 @@ +{{- if .Values.winterSoldier.enabled }} +apiVersion: {{ $.Values.winterSoldier.apiVersion }} +kind: Hibernator +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hibernator + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.winterSoldier.labels }} +{{ toYaml .Values.winterSoldier.labels | indent 4 }} + {{- end }} +{{- if .Values.winterSoldier.annotations }} + annotations: +{{ toYaml .Values.winterSoldier.annotations | indent 4 }} +{{- end }} +spec: + timeRangesWithZone: +{{ toYaml $.Values.winterSoldier.timeRangesWithZone | indent 4}} + selectors: + - inclusions: + - objectSelector: + name: {{ include ".Chart.Name .fullname" $ }} + type: {{ .Values.winterSoldier.type | quote }} + fieldSelector: +{{toYaml $.Values.winterSoldier.fieldSelector | indent 14}} + namespaceSelector: + name: {{ $.Release.Namespace }} + exclusions: [] + action: {{ $.Values.winterSoldier.action }} + {{- if eq .Values.winterSoldier.action "scale" }} + {{- if .Values.winterSoldier.targetReplicas }} + targetReplicas: {{ $.Values.winterSoldier.targetReplicas }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/test_values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/test_values.yaml new file mode 100644 index 00000000000..aa0f16d568a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/test_values.yaml @@ -0,0 +1,628 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +rolloutLabels: + name: abhinav + Company: Devtron + Job: DevOps + +rolloutAnnotations: + name: abhinav + Company: Devtron + Job: DevOps + +containerSpec: + lifecycle: + enabled: true + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +imagePullSecrets: + - test1 + - test2 +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyTimeout: 15 + targetPort: 8080 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace + + - name: app1 + port: 8090 + targetPort: 1234 + servicePort: 8080 + useGRPC: true + servicemonitor: + enabled: true + - name: app2 + port: 8091 + servicePort: 8081 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: + Key: + # Key: kops.k8s.io/instancegroup + Values: + + +image: + pullPolicy: IfNotPresent + +autoscaling: + enabled: true + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +secret: + enabled: false + +service: + enabled: true + type: ClusterIP + # name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + +server: + deployment: + image_tag: 1-95af053 + image: "" +deploymentType: "RECREATE" + +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: + foo: bar + +EnvVariables: + - name: FLASK_ENV + value: qa + +EnvVariablesFromSecretKeys: [] + # - name: ENV_NAME + # secretName: SECRET_NAME + # keyName: SECRET_KEY + +EnvVariablesFromCongigMapKeys: [] + # - name: ENV_NAME + # configMapName: CONFIG_MAP_NAME + # keyName: CONFIG_MAP_KEY + +LivenessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + - name: Custom-Header2 + value: xyz + + +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + + +ReadinessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + +StartupProbe: + Path: "/" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + + +prometheusRule: + enabled: true + additionalLabels: {} + namespace: "" + rules: + # These are just examples rules, please adapt them to your needs + - alert: TooMany500s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 5XXs + summary: More than 5% of the all requests did return 5XX, this require your attention + - alert: TooMany400s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 4XXs + summary: More than 5% of the all requests did return 4XX, this require your attention + + +ingress: + enabled: true + className: nginx + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" +# Old Ingress Format +# host: "ingress-example.com" +# path: "/app" + +# New Ingress Format + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 + + tls: [] +### Legacy Ingress Format ## +# host: abc.com +# path: "/" +# pathType: "ImplementationSpecific" + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: nginx-internal + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + additionalBackends: + - path: /internal + pathType: "ImplementationSpecific" + backend: + service: + name: test-service-internal + port: + number: 80 + + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +dbMigrationConfig: + enabled: false + +command: + workingDir: /app + enabled: false + value: ["ls"] + +args: + enabled: false + value: [] + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: false + secrets: + - name: config-secret-1 + type: environment + external: false + externalType: AWSSecretsManager + esoSecretData: + secretStore: + aws: + service: SecretsManager + region: us-east-1 + auth: + secretRef: + accessKeyIDSecretRef: + name: awssm-secret + key: access-key + secretAccessKeySecretRef: + name: awssm-secret + key: secret-access-key + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + data: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + - name: config-secret-2 + type: environment + external: false + externalType: ESO_HashiCorpVault + esoSecretData: + secretStore: + vault: + server: "http://my.vault.server:8200" + path: "secret" + version: "v2" + auth: + tokenSecretRef: + name: vault-token + key: token + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + date: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + - command: ["sh", "-c", "chown -R 1000:1000 logs"] + reuseContainerImage: true + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + privileged: true + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + - name: init-migrate + image: busybox:latest + command: ["sh", "-c", "chown -R 1000:1000 logs"] + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + capabilities: + drop: + - ALL + +containers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs +# name: logs-data + + +rawYaml: [] +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +podDisruptionBudget: {} + # minAvailable: 1 + # maxUnavailable: 1 + + ## Node tolerations for server scheduling to nodes with taints + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +## + +tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" +# effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +appMetrics: false +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "test1" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: + kubernetes.io/service-account.name: build-robot +containerSecurityContext: + allowPrivilegeEscalation: false +privileged: true +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" + +deployment: + strategy: + blueGreen: + autoPromotionSeconds: 30 + scaleDownDelaySeconds: 30 + previewReplicaCount: 1 + autoPromotionEnabled: false + rolling: + maxSurge: "25%" + maxUnavailable: 1 + canary: + maxSurge: "25%" + maxUnavailable: 1 + steps: + - setWeight: 25 + - pause: + duration: 15 # 1 min + - setWeight: 50 + - pause: + duration: 15 # 1 min + - setWeight: 75 + - pause: + duration: 15 # 1 min + recreate: {} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/values.yaml new file mode 100644 index 00000000000..97d1ddee937 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-19-0/values.yaml @@ -0,0 +1,613 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + envoyTimeout: 15s + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s +# servicemonitor: +# enabled: true +# path: /abc +# scheme: 'http' +# interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace + + - name: app1 + port: 8090 + servicePort: 8080 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: + Key: +# Key: kops.k8s.io/instancegroup + Values: + + +image: + pullPolicy: IfNotPresent + +restartPolicy: Always + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + # TargetCPUUtilizationPercentage: 90 + # TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + cooldownPeriod: 300 # Optional. Default: 300 seconds + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 # Optional. Must be less than minReplicaCount + pollingInterval: 30 # Optional. Default: 30 seconds + # The fallback section is optional. It defines a number of replicas to fallback to if a scaler is in an error state. + fallback: {} # Optional. Section to specify fallback options + # failureThreshold: 3 # Mandatory if fallback section is included + # replicas: 6 + advanced: {} + # horizontalPodAutoscalerConfig: # Optional. Section to specify HPA related options + # behavior: # Optional. Use to modify HPA's scaling behavior + # scaleDown: + # stabilizationWindowSeconds: 300 + # policies: + # - type: Percent + # value: 100 + # periodSeconds: 15 + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +secret: + enabled: false + +service: + enabled: true + type: ClusterIP +# name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + +server: + deployment: + image_tag: 1-95af053 + image: "" + +EnvVariablesFromFieldPath: [] +# - name: POD_NAME +# fieldPath: metadata.name + +EnvVariables: [] + # - name: FLASK_ENV + # value: qa + +EnvVariablesFromSecretKeys: [] + # - name: ENV_NAME + # secretName: SECRET_NAME + # keyName: SECRET_KEY + +EnvVariablesFromConfigMapKeys: [] + # - name: ENV_NAME + # configMapName: CONFIG_MAP_NAME + # keyName: CONFIG_MAP_KEY + +LivenessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] +# - name: Custom-Header +# value: abc + +ReadinessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] +# - name: Custom-Header +# value: abc + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + + +prometheusRule: + enabled: false + additionalLabels: {} + namespace: "" +# rules: +# # These are just examples rules, please adapt them to your needs +# - alert: TooMany500s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 5XXs +# summary: More than 5% of the all requests did return 5XX, this require your attention +# - alert: TooMany400s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 4XXs +# summary: More than 5% of the all requests did return 4XX, this require your attention +# + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: "" + tls: + enabled: false + secretName: "" + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +hibernator: + enable: false + +dbMigrationConfig: + enabled: false + +command: + enabled: false + value: [] + +args: + enabled: false + value: [] + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: false + secrets: [] +# - name: config-secret-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + # - name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + # # Uncomment below line ONLY IF you want to reuse the container image. + # # This will assign your application's docker image to init container. + # reuseContainerImage: true + +containers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + + +rawYaml: [] +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + labels: {} + annotations: {} + timeRangesWithZone: {} + # timeZone: "Asia/Kolkata" + # timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: [] + type: Rollout + # - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + +topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: zone + # whenUnsatisfiable: DoNotSchedule + # autoLabelSelector: true + # customLabelSelector: {} + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + lifecycle: {} + configMapName: "" + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +ambassadorMapping: + enabled: false + # labels: + # key1: value1 + # prefix: / + # ambassadorId: 1234 + # hostname: devtron.example.com + # rewrite: /foo/ + # retryPolicy: + # retry_on: "5xx" + # num_retries: 10 + # cors: + # origins: http://foo.example,http://bar.example + # methods: POST, GET, OPTIONS + # headers: Content-Type + # credentials: true + # exposed_headers: X-Custom-Header + # max_age: "86400" + # weight: 10 + # method: GET + # extraSpec: + # method_regex: true + # headers: + # x-quote-mode: backend + # x-random-header: devtron + # tls: + # context: httpd-context + # create: true + # secretName: httpd-secret + # hosts: + # - anything.example.info + # - devtron.example.com + # extraSpec: + # min_tls_version: v1.2 + +containerSpec: + lifecycle: + enabled: false + preStop: {} +# exec: +# command: ["sleep","10"] + postStart: {} +# httpGet: +# host: example.com +# path: /example +# port: 90 + +podDisruptionBudget: {} +# minAvailable: 1 +# maxUnavailable: 1 + + ## Node tolerations for server scheduling to nodes with taints + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + ## + +podSecurityContext: {} + # runAsUser: 1000 + # runAsGroup: 3000 + # fsGroup: 2000 + +containerSecurityContext: {} + # allowPrivilegeEscalation: false +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +imagePullSecrets: [] + # - test1 + # - test2 diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.helmignore b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.image_descriptor_template.json b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.image_descriptor_template.json new file mode 100644 index 00000000000..bd2472da075 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/.image_descriptor_template.json @@ -0,0 +1 @@ +{"server":{"deployment":{"image_tag":"{{.Tag}}","image":"{{.Name}}"}},"pipelineName": "{{.PipelineName}}","releaseVersion":"{{.ReleaseVersion}}","deploymentType": "{{.DeploymentType}}", "app": "{{.App}}", "env": "{{.Env}}", "appMetrics": {{.AppMetrics}}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/Chart.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/Chart.yaml new file mode 100644 index 00000000000..69ce8a7da83 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: reference-chart_4-20-0 +version: 4.20.0 diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/README.md b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/README.md new file mode 100644 index 00000000000..dc967d598dd --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/README.md @@ -0,0 +1,911 @@ + +# Rollout Deployment Chart - v4.20.0 + +## 1. Yaml File - + +### Container Ports + +This defines ports on which application services will be exposed to other services + +```yaml +ContainerPort: + - envoyPort: 8799 + idleTimeout: + name: app + port: 8080 + servicePort: 80 + nodePort: 32056 + supportStreaming: true + useHTTP2: true + protocol: TCP +``` + +| Key | Description | +| :--- | :--- | +| `envoyPort` | envoy port for the container. | +| `idleTimeout` | the duration of time that a connection is idle before the connection is terminated. | +| `name` | name of the port. | +| `port` | port for the container. | +| `servicePort` | port of the corresponding kubernetes service. | +| `nodePort` | nodeport of the corresponding kubernetes service. | +| `supportStreaming` | Used for high performance protocols like grpc where timeout needs to be disabled. | +| `useHTTP2` | Envoy container can accept HTTP2 requests. | +|`protocol`| Protocol for port. Must be UDP, TCP, or SCTP. Defaults to "TCP". | + +### EnvVariables +```yaml +EnvVariables: [] +``` +To set environment variables for the containers that run in the Pod. + +### EnvVariablesFromSecretKeys +```yaml +EnvVariablesFromSecretKeys: + - name: ENV_NAME + secretName: SECRET_NAME + keyName: SECRET_KEY + +``` + It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable. + + ### EnvVariablesFromConfigMapKeys +```yaml +EnvVariablesFromConfigMapKeys: + - name: ENV_NAME + configMapName: CONFIG_MAP_NAME + keyName: CONFIG_MAP_KEY + +``` + It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable. + +### Liveness Probe + +If this check fails, kubernetes restarts the pod. This should return error code in case of non-recoverable error. + +```yaml +LivenessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the liveness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for liveliness. | +| `periodSeconds` | It defines the time to check a given container for liveness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfil the liveness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as live. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | + + +### MaxUnavailable + +```yaml + MaxUnavailable: 0 +``` +The maximum number of pods that can be unavailable during the update process. The value of "MaxUnavailable: " can be an absolute number or percentage of the replicas count. The default value of "MaxUnavailable: " is 25%. + +### MaxSurge + +```yaml +MaxSurge: 1 +``` +The maximum number of pods that can be created over the desired number of pods. For "MaxSurge: " also, the value can be an absolute number or percentage of the replicas count. +The default value of "MaxSurge: " is 25%. + +### Min Ready Seconds + +```yaml +MinReadySeconds: 60 +``` +This specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. This defaults to 0 (the Pod will be considered available as soon as it is ready). + +### Readiness Probe + +If this check fails, kubernetes stops sending traffic to the application. This should return error code in case of errors which can be recovered from if traffic is stopped. + +```yaml +ReadinessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + scheme: "" + tcp: true +``` + +| Key | Description | +| :--- | :--- | +| `Path` | It define the path where the readiness needs to be checked. | +| `initialDelaySeconds` | It defines the time to wait before a given container is checked for readiness. | +| `periodSeconds` | It defines the time to check a given container for readiness. | +| `successThreshold` | It defines the number of successes required before a given container is said to fulfill the readiness probe. | +| `timeoutSeconds` | It defines the time for checking timeout. | +| `failureThreshold` | It defines the maximum number of failures that are acceptable before a given container is not considered as ready. | +| `httpHeaders` | Custom headers to set in the request. HTTP allows repeated headers,You can override the default headers by defining .httpHeaders for the probe. | +| `scheme` | Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. +| `tcp` | The kubelet will attempt to open a socket to your container on the specified port. If it can establish a connection, the container is considered healthy. | + +### Pod Disruption Budget + +You can create `PodDisruptionBudget` for each application. A PDB limits the number of pods of a replicated application that are down simultaneously from voluntary disruptions. For example, an application would like to ensure the number of replicas running is never brought below the certain number. + +```yaml +podDisruptionBudget: + minAvailable: 1 +``` + +or + +```yaml +podDisruptionBudget: + maxUnavailable: 50% +``` + +You can specify either `maxUnavailable` or `minAvailable` in a PodDisruptionBudget and it can be expressed as integers or as a percentage + +| Key | Description | +| :--- | :--- | +| `minAvailable` | Evictions are allowed as long as they leave behind 1 or more healthy pods of the total number of desired replicas. | +| `maxUnavailable` | Evictions are allowed as long as at most 1 unhealthy replica among the total number of desired replicas. | + +### Ambassador Mappings + +You can create ambassador mappings to access your applications from outside the cluster. At its core a Mapping resource maps a resource to a service. + +```yaml +ambassadorMapping: + ambassadorId: "prod-emissary" + cors: {} + enabled: true + hostname: devtron.example.com + labels: {} + prefix: / + retryPolicy: {} + rewrite: "" + tls: + context: "devtron-tls-context" + create: false + hosts: [] + secretName: "" +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable ambassador mapping else set false.| +| `ambassadorId` | used to specify id for specific ambassador mappings controller. | +| `cors` | used to specify cors policy to access host for this mapping. | +| `weight` | used to specify weight for canary ambassador mappings. | +| `hostname` | used to specify hostname for ambassador mapping. | +| `prefix` | used to specify path for ambassador mapping. | +| `labels` | used to provide custom labels for ambassador mapping. | +| `retryPolicy` | used to specify retry policy for ambassador mapping. | +| `corsPolicy` | Provide cors headers on flagger resource. | +| `rewrite` | used to specify whether to redirect the path of this mapping and where. | +| `tls` | used to create or define ambassador TLSContext resource. | +| `extraSpec` | used to provide extra spec values which not present in deployment template for ambassador resource. | + +### Autoscaling + +This is connected to HPA and controls scaling up and down in response to request load. + +```yaml +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + containerResource: + enabled: true + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + extraMetrics: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Set true to enable autoscaling else set false.| +| `MinReplicas` | Minimum number of replicas allowed for scaling. | +| `MaxReplicas` | Maximum number of replicas allowed for scaling. | +| `TargetCPUUtilizationPercentage` | The target CPU utilization that is expected for a container. | +| `TargetMemoryUtilizationPercentage` | The target memory utilization that is expected for a container. | +| `extraMetrics` | Used to give external metrics for autoscaling. | +| `containerResource` | Used to scale resource as per container resource. | + +### Fullname Override + +```yaml +fullnameOverride: app-name +``` +`fullnameOverride` replaces the release fullname created by default by devtron, which is used to construct Kubernetes object names. By default, devtron uses {app-name}-{environment-name} as release fullname. + +### Image + +```yaml +image: + pullPolicy: IfNotPresent +``` + +Image is used to access images in kubernetes, pullpolicy is used to define the instances calling the image, here the image is pulled when the image is not present,it can also be set as "Always". + +### imagePullSecrets + +`imagePullSecrets` contains the docker credentials that are used for accessing a registry. + +```yaml +imagePullSecrets: + - regcred +``` +regcred is the secret that contains the docker credentials that are used for accessing a registry. Devtron will not create this secret automatically, you'll have to create this secret using dt-secrets helm chart in the App store or create one using kubectl. You can follow this documentation Pull an Image from a Private Registry [https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) . + +### Ingress + +This allows public access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + className: nginx + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` +Legacy deployment-template ingress format + +```yaml +ingress: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + path: "" + host: "" + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + +### Ingress Internal + +This allows private access to the url, please ensure you are using right nginx annotation for nginx class, its default value is nginx + +```yaml +ingressInternal: + enabled: false + # For K8s 1.19 and above use ingressClassName instead of annotation kubernetes.io/ingress.class: + ingressClassName: nginx-internal + annotations: {} + hosts: + - host: example1.com + paths: + - /example + - host: example2.com + paths: + - /example2 + - /example2/healthz + tls: [] +``` + +| Key | Description | +| :--- | :--- | +| `enabled` | Enable or disable ingress | +| `annotations` | To configure some options depending on the Ingress controller | +| `path` | Path name | +| `host` | Host name | +| `tls` | It contains security details | + + +### additionalBackends + +This defines additional backend path in the ingress . + +```yaml + hosts: + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 +``` + +### Init Containers +```yaml +initContainers: + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + args: + - sleep 300 + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate + + - name: nginx + image: nginx:1.14.2 + securityContext: + privileged: true + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] +``` +Specialized containers that run before app containers in a Pod. Init containers can contain utilities or setup scripts not present in an app image. One can use base image inside initContainer by setting the reuseContainerImage flag to `true`. + +### Istio + +Istio is a service mesh which simplifies observability, traffic management, security and much more with it's virtual services and gateways. + +```yaml +istio: + enable: true + gateway: + annotations: {} + enabled: false + host: example.com + labels: {} + tls: + enabled: false + secretName: example-tls-secret + virtualService: + annotations: {} + enabled: false + gateways: [] + hosts: [] + http: + - corsPolicy: + allowCredentials: false + allowHeaders: + - x-some-header + allowMethods: + - GET + allowOrigin: + - example.com + maxAge: 24h + headers: + request: + add: + x-some-header: value + match: + - uri: + prefix: /v1 + - uri: + prefix: /v2 + retries: + attempts: 2 + perTryTimeout: 3s + rewriteUri: / + route: + - destination: + host: service1 + port: 80 + timeout: 12s + - route: + - destination: + host: service2 + labels: {} +``` + +### Pause For Seconds Before Switch Active +```yaml +pauseForSecondsBeforeSwitchActive: 30 +``` +To wait for given period of time before switch active the container. + + +### Winter-Soldier +Winter Soldier can be used to +- cleans up (delete) Kubernetes resources +- reduce workload pods to 0 + +**_NOTE:_** After deploying this we can create the Hibernator object and provide the custom configuration by which workloads going to delete, sleep and many more. for more information check [the main repo](https://github.com/devtron-labs/winter-soldier) + +Given below is template values you can give in winter-soldier: +```yaml +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + action: sleep + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + targetReplicas: [] + fieldSelector: [] +``` +Here, +| Key | values | Description | +| :--- | :--- | :--- | +| `enabled` | `fasle`,`true` | decide the enabling factor | +| `apiVersion` | `pincher.devtron.ai/v1beta1`, `pincher.devtron.ai/v1alpha1` | specific api version | +| `action` | `sleep`,`delete`, `scale` | This specify the action need to perform. | +| `timeRangesWithZone`:`timeZone` | eg:- `"Asia/Kolkata"`,`"US/Pacific"` | It use to specify the timeZone used. (It uses standard format. please refer [this](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) | +| `timeRangesWithZone`:`timeRanges` | array of [ `timeFrom`, `timeTo`, `weekdayFrom`, `weekdayTo`] | It use to define time period/range on which the user need to perform the specified action. you can have multiple timeRanges.
These settings will take `action` on Sat and Sun from 00:00 to 23:59:59, | +| `targetReplicas` | `[n]` : n - number of replicas to scale. | These is mandatory field when the `action` is `scale`
Defalut value is `[]`. | +| `fieldSelector` | `- AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) ` | These value will take a list of methods to select the resources on which we perform specified `action` . | + + +here is an example, +```yaml +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime( ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '10h'), Now()) +``` +Above settings will take action on `Sat` and `Sun` from 00:00 to 23:59:59, and on `Mon`-`Fri` from 00:00 to 08:00 and 20:00 to 23:59:59. If `action:sleep` then runs hibernate at timeFrom and unhibernate at `timeTo`. If `action: delete` then it will delete workloads at `timeFrom` and `timeTo`. Here the `action:scale` thus it scale the number of resource replicas to `targetReplicas: [1,1,1]`. Here each element of `targetReplicas` array is mapped with the corresponding elments of array `timeRangesWithZone/timeRanges`. Thus make sure the length of both array is equal, otherwise the cnages cannot be observed. + +The above example will select the application objects which have been created 10 hours ago across all namespaces excluding application's namespace. Winter soldier exposes following functions to handle time, cpu and memory. + +- ParseTime - This function can be used to parse time. For eg to parse creationTimestamp use ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z') +- AddTime - This can be used to add time. For eg AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '-10h') ll add 10h to the time. Use d for day, h for hour, m for minutes and s for seconds. Use negative number to get earlier time. +- Now - This can be used to get current time. +- CpuToNumber - This can be used to compare CPU. For eg any({{spec.containers.#.resources.requests}}, { MemoryToNumber(.memory) < MemoryToNumber('60Mi')}) will check if any resource.requests is less than 60Mi. + + + +### Resources + +These define minimum and maximum RAM and CPU available to the application. + +```yaml +resources: + limits: + cpu: "1" + memory: "200Mi" + requests: + cpu: "0.10" + memory: "100Mi" +``` + +Resources are required to set CPU and memory usage. + +#### Limits + +Limits make sure a container never goes above a certain value. The container is only allowed to go up to the limit, and then it is restricted. + +#### Requests + +Requests are what the container is guaranteed to get. + +### Service + +This defines annotations and the type of service, optionally can define name also. + +```yaml + service: + type: ClusterIP + annotations: {} + sessionAffinity: + enabled: true + sessionAffinityConfig: {} +``` + +### Volumes + +```yaml +volumes: + - name: log-volume + emptyDir: {} + - name: logpv + persistentVolumeClaim: + claimName: logpvc +``` + +It is required when some values need to be read from or written to an external disk. + +### Volume Mounts + +```yaml +volumeMounts: + - mountPath: /var/log/nginx/ + name: log-volume + - mountPath: /mnt/logs + name: logpvc + subPath: employee +``` + +It is used to provide mounts to the volume. + +### Affinity and anti-affinity + +```yaml +Spec: + Affinity: + Key: + Values: +``` + +Spec is used to define the desire state of the given container. + +Node Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node. + +Inter-pod affinity allow you to constrain which nodes your pod is eligible to be scheduled based on labels on pods. + +#### Key + +Key part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +#### Values + +Value part of the label for node selection, this should be same as that on node. Please confirm with devops team. + +### Tolerations + +```yaml +tolerations: + - key: "key" + operator: "Equal" + value: "value" + effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" +``` + +Taints are the opposite, they allow a node to repel a set of pods. + +A given pod can access the given node and avoid the given taint only if the given pod satisfies a given taint. + +Taints and tolerations are a mechanism which work together that allows you to ensure that pods are not placed on inappropriate nodes. Taints are added to nodes, while tolerations are defined in the pod specification. When you taint a node, it will repel all the pods except those that have a toleration for that taint. A node can have one or many taints associated with it. + +### Arguments + +```yaml +args: + enabled: false + value: [] +``` + +This is used to give arguments to command. + +### Command + +```yaml +command: + enabled: false + value: [] +``` + +It contains the commands for the server. + +| Key | Description | +| :--- | :--- | +| `enabled` | To enable or disable the command. | +| `value` | It contains the commands. | + + +### Containers +Containers section can be used to run side-car containers along with your main container within same pod. Containers running within same pod can share volumes and IP Address and can address each other @localhost. We can use base image inside container by setting the reuseContainerImage flag to `true`. + +```yaml + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + command: ["/usr/local/bin/nginx"] + args: ["-g", "daemon off;"] + - reuseContainerImage: true + securityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + volumeMounts: + - mountPath: /etc/ls-oms + name: ls-oms-cm-vol + command: + - flyway + - -configFiles=/etc/ls-oms/flyway.conf + - migrate +``` + +### Prometheus + +```yaml + prometheus: + release: monitoring +``` + +It is a kubernetes monitoring tool and the name of the file to be monitored as monitoring in the given case.It describes the state of the prometheus. + +### rawYaml + +```yaml +rawYaml: + - apiVersion: v1 + kind: Service + metadata: + name: my-service + spec: + selector: + app: MyApp + ports: + - protocol: TCP + port: 80 + targetPort: 9376 + type: ClusterIP +``` +Accepts an array of Kubernetes objects. You can specify any kubernetes yaml here and it will be applied when your app gets deployed. + +### Grace Period + +```yaml +GracePeriod: 30 +``` +Kubernetes waits for the specified time called the termination grace period before terminating the pods. By default, this is 30 seconds. If your pod usually takes longer than 30 seconds to shut down gracefully, make sure you increase the `GracePeriod`. + +A Graceful termination in practice means that your application needs to handle the SIGTERM message and begin shutting down when it receives it. This means saving all data that needs to be saved, closing down network connections, finishing any work that is left, and other similar tasks. + +There are many reasons why Kubernetes might terminate a perfectly healthy container. If you update your deployment with a rolling update, Kubernetes slowly terminates old pods while spinning up new ones. If you drain a node, Kubernetes terminates all pods on that node. If a node runs out of resources, Kubernetes terminates pods to free those resources. It’s important that your application handle termination gracefully so that there is minimal impact on the end user and the time-to-recovery is as fast as possible. + + +### Server + +```yaml +server: + deployment: + image_tag: 1-95a53 + image: "" +``` + +It is used for providing server configurations. + +#### Deployment + +It gives the details for deployment. + +| Key | Description | +| :--- | :--- | +| `image_tag` | It is the image tag | +| `image` | It is the URL of the image | + +### Service Monitor + +```yaml +servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace +``` + +It gives the set of targets to be monitored. + +### Db Migration Config + +```yaml +dbMigrationConfig: + enabled: false +``` + +It is used to configure database migration. + + +### KEDA Autoscaling +[KEDA](https://keda.sh) is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed. KEDA can be installed into any Kubernetes cluster and can work alongside standard Kubernetes components like the Horizontal Pod Autoscaler(HPA). + +Example for autosccaling with KEDA using Prometheus metrics is given below: +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: + restoreToOriginalReplicaCount: true + horizontalPodAutoscalerConfig: + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 100 + periodSeconds: 15 + triggers: + - type: prometheus + metadata: + serverAddress: http://:9090 + metricName: http_request_total + query: envoy_cluster_upstream_rq{appId="300", cluster_name="300-0", container="envoy",} + threshold: "50" + triggerAuthentication: + enabled: false + name: + spec: {} + authenticationRef: {} +``` +Example for autosccaling with KEDA based on kafka is given below : +```yaml +kedaAutoscaling: + enabled: true + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 + pollingInterval: 30 + advanced: {} + triggers: + - type: kafka + metadata: + bootstrapServers: b-2.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-3.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092,b-1.kafka-msk-dev.example.c2.kafka.ap-southeast-1.amazonaws.com:9092 + topic: Orders-Service-ESP.info + lagThreshold: "100" + consumerGroup: oders-remove-delivered-packages + allowIdleConsumers: "true" + triggerAuthentication: + enabled: true + name: keda-trigger-auth-kafka-credential + spec: + secretTargetRef: + - parameter: sasl + name: keda-kafka-secrets + key: sasl + - parameter: username + name: keda-kafka-secrets + key: username + authenticationRef: + name: keda-trigger-auth-kafka-credential +``` + +### Security Context +A security context defines privilege and access control settings for a Pod or Container. + +To add a security context for main container: +```yaml +containerSecurityContext: + allowPrivilegeEscalation: false +``` + +To add a security context on pod level: +```yaml +podSecurityContext: + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 +``` + +### Topology Spread Constraints +You can use topology spread constraints to control how Pods are spread across your cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains. This can help to achieve high availability as well as efficient resource utilization. + +```yaml +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: {} + minDomains: 1 + nodeAffinityPolicy: Ignore +``` + +### Persistent Volume Claim +You can use persistent volume in your stateless application + +```yaml +persistentVolumeClaim: + name: my-pvc + storageClassName: default + accessMode: + - ReadWriteOnce + mountPath: /tmp + +``` + +### Vertical Pod Autoscaling +This is connected to VPA and controls scaling up and down in response to request load. +```yaml +verticalPodScaling: + enabled: true + resourcePolicy: {} + updatePolicy: {} + ``` + +### Scheduler Name + +You can provide you own custom scheduler to schedule your application + +```yaml +schedulerName: "" +``` + + +### Deployment Metrics + +It gives the realtime metrics of the deployed applications + +| Key | Description | +| :--- | :--- | +| `Deployment Frequency` | It shows how often this app is deployed to production | +| `Change Failure Rate` | It shows how often the respective pipeline fails. | +| `Mean Lead Time` | It shows the average time taken to deliver a change to production. | +| `Mean Time to Recovery` | It shows the average time taken to fix a failed pipeline. | + +## 2. Show application metrics + +If you want to see application metrics like different HTTP status codes metrics, application throughput, latency, response time. Enable the Application metrics from below the deployment template Save button. After enabling it, you should be able to see all metrics on App detail page. By default it remains disabled. +![](../../../.gitbook/assets/deployment_application_metrics%20%282%29.png) + +Once all the Deployment template configurations are done, click on `Save` to save your deployment configuration. Now you are ready to create [Workflow](workflow/) to do CI/CD. + +### Helm Chart Json Schema + +Helm Chart [json schema](../../../scripts/devtron-reference-helm-charts/reference-chart_4-11-0/schema.json) is used to validate the deployment template values. + +### Other Validations in Json Schema + +The values of CPU and Memory in limits must be greater than or equal to in requests respectively. Similarly, In case of envoyproxy, the values of limits are greater than or equal to requests as mentioned below. +``` +resources.limits.cpu >= resources.requests.cpu +resources.limits.memory >= resources.requests.memory +envoyproxy.resources.limits.cpu >= envoyproxy.resources.requests.cpu +envoyproxy.resources.limits.memory >= envoyproxy.resources.requests.memory +``` diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/app-values.yaml new file mode 100644 index 00000000000..6ef81ac0779 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/app-values.yaml @@ -0,0 +1,443 @@ +# Mandatory configs +podDisruptionBudget: {} + +rolloutLabels: {} +rolloutAnnotations: {} + +containerSpec: + lifecycle: + enabled: false + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +replicaCount: 1 +MinReadySeconds: 60 +GracePeriod: 30 +image: + pullPolicy: IfNotPresent +restartPolicy: Always +service: + # enabled: true + type: ClusterIP + #name: "service-1234567890" + loadBalancerSourceRanges: [] + # loadBalancerSourceRanges: + # - 1.2.3.4/32 + # - 1.2.5.6/23 + annotations: {} + # test1: test2 + # test3: test4 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + protocol: TCP + resizePolicy: [] +# servicemonitor: +# enabled: true +# path: /abc +# scheme: 'http' +# interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +# Optional configs +LivenessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + +ReadinessProbe: + Path: "" + port: 8080 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + tcp: false + command: [] + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/force-ssl-redirect: 'false' +# nginx.ingress.kubernetes.io/ssl-redirect: 'false' +# kubernetes.io/ingress.class: nginx +# nginx.ingress.kubernetes.io/rewrite-target: /$2 +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +command: + workingDir: {} + enabled: false + value: [] + +args: + enabled: false + value: + - /bin/sh + - -c + - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600 + +#For adding custom labels to pods + +podLabels: {} +# customKey: customValue +podAnnotations: {} +# customKey: customValue + +rawYaml: [] + +topologySpreadConstraints: [] + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +containers: [] + ## Additional containers to run along with application pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + +dbMigrationConfig: + enabled: false + +tolerations: [] + +podSecurityContext: {} + +containerSecurityContext: {} + +Spec: + Affinity: + Key: + # Key: kops.k8s.io/instancegroup + Values: + +affinity: + enabled: false + values: {} + +ambassadorMapping: + enabled: false + labels: {} + prefix: / + ambassadorId: "" + hostname: devtron.example.com + rewrite: "" + retryPolicy: {} + cors: {} + tls: + context: "" + create: false + secretName: "" + hosts: [] + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 70 + TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} + behavior: {} + containerResource: + enabled: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + minReplicaCount: 1 + maxReplicaCount: 2 + advanced: {} + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +prometheus: + release: monitoring + +server: + deployment: + image_tag: 1-95af053 + image: "" + +servicemonitor: + additionalLabels: {} + +envoyproxy: + image: quay.io/devtron/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: "example.com" + tls: + enabled: false + secretName: secret-name + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + annotation: {} + labels: {} + type: Rollout + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + + + + +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +imagePullSecrets: [] + # - test1 + # - test2 +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" +# - "bar.local" +# - ip: "10.1.2.3" +# hostnames: +# - "foo.remote" +# - "bar.remote" +peristentVolumeClaim: {} + + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/env-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/env-values.yaml new file mode 100644 index 00000000000..5cd07c0269e --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/env-values.yaml @@ -0,0 +1,66 @@ +replicaCount: 1 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 + +Spec: + Affinity: + key: "" + Values: nodes + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# +secret: + enabled: false + data: {} +# my_own_secret: S3ViZXJuZXRlcyBXb3Jrcw== + +EnvVariables: [] +# - name: FLASK_ENV +# value: qa + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: "0.05" + memory: 50Mi + requests: + cpu: "0.01" + memory: 10Mi + + diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/pipeline-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/pipeline-values.yaml new file mode 100644 index 00000000000..40a5ec633dd --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/pipeline-values.yaml @@ -0,0 +1,24 @@ +deployment: + strategy: + blueGreen: + autoPromotionSeconds: 30 + scaleDownDelaySeconds: 30 + previewReplicaCount: 1 + autoPromotionEnabled: false + rolling: + maxSurge: "25%" + maxUnavailable: 1 + canary: + maxSurge: "25%" + maxUnavailable: 1 + steps: + - setWeight: 25 + - pause: + duration: 15 # 1 min + - setWeight: 50 + - pause: + duration: 15 # 1 min + - setWeight: 75 + - pause: + duration: 15 # 1 min + recreate: {} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/release-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/release-values.yaml new file mode 100644 index 00000000000..48eb3f482c1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/release-values.yaml @@ -0,0 +1,14 @@ +server: + deployment: + image_tag: IMAGE_TAG + image: IMAGE_REPO + enabled: false +dbMigrationConfig: + enabled: false + +pauseForSecondsBeforeSwitchActive: 0 +waitForSecondsBeforeScalingDown: 0 +autoPromotionSeconds: 30 + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/schema.json b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/schema.json new file mode 100644 index 00000000000..da5cce59eab --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/schema.json @@ -0,0 +1,1363 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "containerExtraSpecs": { + "type": "object", + "title": "containerExtraSpecs", + "description": "Define container extra specs here" + }, + "ContainerPort": { + "type": "array", + "description": "defines ports on which application services will be exposed to other services", + "title": "Container Port", + "items": { + "type": "object", + "properties": { + "envoyPort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "envoy port for the container", + "title": "Envoy Port" + }, + "idleTimeout": { + "type": "string", + "description": "duration of time for which a connection is idle before the connection is terminated", + "title": "Idle Timeout" + }, + "name": { + "type": "string", + "description": "name of the port", + "title": "Name" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Port", + "title": "port for the container" + }, + "servicePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port of the corresponding kubernetes service", + "title": "Service Port" + }, + "nodePort": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "nodeport of the corresponding kubernetes service", + "title": "Node Port" + }, + "supportStreaming": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "field to enable/disable timeout for high performance protocols like grpc", + "title": "Support Streaming" + }, + "useHTTP2": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": " field for setting if envoy container can accept(or not) HTTP2 requests", + "title": "Use HTTP2" + } + } + } + }, + "EnvVariables": { + "type": "array", + "items": {}, + "description": "contains environment variables needed by the containers", + "title": "Environment Variables" + }, + "EnvVariablesFromFieldPath": { + "type": "array", + "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs", + "title": "EnvVariablesFromFieldPath", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be" + }, + "fieldPath": { + "type": "string", + "title": "fieldPath", + "description": "Path of the field to select in the specified API version" + } + } + } + ] + }, + "EnvVariablesFromSecretKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Secret name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromSecretKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "secretName": { + "type": "string", + "title": "secretName", + "description": "Name of Secret from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "EnvVariablesFromConfigMapKeys": { + "type": "array", + "description": "Selects a field of the deployment: It is use to get the name of Environment Variable name, Config Map name and the Key name from which we are using the value in that corresponding Environment Variable.", + "title": "EnvVariablesFromConfigMapKeys", + "items": [ + { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "name", + "description": "Env variable name to be used." + }, + "configMapName": { + "type": "string", + "title": "configMapName", + "description": "Name of configMap from which we are taking the value." + }, + "keyName": { + "type": "string", + "title": "keyName", + "description": "Name of The Key Where the value is mapped with." + } + } + } + ] + }, + "GracePeriod": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "time for which Kubernetes waits before terminating the pods", + "title": "Grace Period" + }, + "LivenessProbe": { + "type": "object", + "description": "used by the kubelet to know when to restart a container", + "title": "Liveness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the liveness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as live", + "title": "Failure Threshold" + }, + "httpHeaders": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for liveness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for liveness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the liveness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "MaxSurge": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be created over the desired number of pods", + "title": "Maximum Surge" + }, + "MaxUnavailable": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "maximum number of pods that can be unavailable during the update process", + "title": "Maximum Unavailable" + }, + "MinReadySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available", + "title": "Minimum Ready Seconds" + }, + "ReadinessProbe": { + "type": "object", + "description": "kubelet uses readiness probes to know when a container is ready to start accepting traffic", + "title": "Readiness Probe", + "properties": { + "Path": { + "type": "string", + "description": "defines the path where the readiness needs to be checked", + "title": "Path" + }, + "command": { + "type": "array", + "items": {}, + "description": "commands executed to perform a probe", + "title": "Command" + }, + "failureThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the maximum number of failures that are acceptable before a given container is not considered as ready", + "title": "Failure Threshold" + }, + "httpHeader": { + "type": "array", + "items": {}, + "description": "used to override the default headers by defining .httpHeaders for the probe", + "title": "HTTP headers" + }, + "initialDelaySeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to wait before a given container is checked for readiness", + "title": "Initial Delay Seconds" + }, + "periodSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time to check a given container for readiness", + "title": "Period Seconds" + }, + "port": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "port to access on the container", + "title": "Port" + }, + "scheme": { + "type": "string", + "description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.", + "title": "Scheme" + }, + "successThreshold": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the number of successes required before a given container is said to fulfil the readiness probe", + "title": "Success Threshold" + }, + "tcp": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "If enabled, the kubelet will attempt to open a socket to container. If connection is established, the container is considered healthy", + "title": "TCP" + }, + "timeoutSeconds": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "defines the time for checking timeout", + "title": "Timeout Seconds" + } + } + }, + "Spec": { + "type": "object", + "description": "used to define the desire state of the given container", + "title": "Spec", + "properties": { + "Affinity": { + "type": "object", + "description": "Node/Inter-pod Affinity allows you to constrain which nodes your pod is eligible to schedule on, based on labels of the node/pods", + "title": "Affinity", + "properties": { + "Key": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string", + "description": "Key part of the label for node/pod selection", + "title": "Key" + } + ] + }, + "Values": { + "type": "string", + "description": "Value part of the label for node/pod selection", + "title": "Values" + }, + "key": { + "type": "string" + } + } + } + } + }, + "ambassadorMapping": { + "type": "object", + "description": "used to create ambassador mapping resource", + "title": "Mapping", + "properties": { + "ambassadorId": { + "type": "string", + "description": "used to specify id for specific ambassador mappings controller", + "title": "Ambassador ID" + }, + "cors": { + "type": "object", + "description": "used to specify cors policy to access host for this mapping", + "title": "CORS" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify whether to create an ambassador mapping or not", + "title": "Enabled" + }, + "weight": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to specify weight for canary ambassador mappings" + }, + "hostname": { + "type": "string", + "description": "used to specify hostname for ambassador mapping", + "title": "Hostname" + }, + "labels": { + "type": "object", + "description": "used to provide custom labels for ambassador mapping", + "title": "Labels" + }, + "prefix": { + "type": "string", + "description": "used to specify path for ambassador mapping", + "title": "Prefix" + }, + "retryPolicy": { + "type": "object", + "description": "used to specify retry policy for ambassador mapping", + "title": "Retry Policy" + }, + "rewrite": { + "type": "string", + "description": "used to specify whether to redirect the path of this mapping and where", + "title": "Rewrite" + }, + "tls": { + "type": "object", + "description": "used to create or define ambassador TLSContext resource", + "title": "TLS Context" + }, + "extraSpec": { + "type": "object", + "description": "used to provide extra spec values which not present in deployment template for ambassador resource", + "title": "Extra Spec" + } + } + }, + "args": { + "type": "object", + "description": " used to give arguments to command", + "title": "Arguments", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling aruguments", + "title": "Enabled" + }, + "value": { + "type": "array", + "description": "values of the arguments", + "title": "Value", + "items": [ + { + "type": "string" + }, + { + "type": "string" + }, + { + "type": "string" + } + ] + } + } + }, + "autoscaling": { + "type": "object", + "description": "connected to HPA and controls scaling up and down in response to request load", + "title": "Autoscaling", + "properties": { + "MaxReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Maximum number of replicas allowed for scaling", + "title": "Maximum Replicas" + }, + "MinReplicas": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Minimum number of replicas allowed for scaling", + "title": "Minimum Replicas" + }, + "TargetCPUUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target CPU utilization that is expected for a container", + "title": "TargetCPUUtilizationPercentage" + }, + "TargetMemoryUtilizationPercentage": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "The target memory utilization that is expected for a container", + "title": "TargetMemoryUtilizationPercentage" + }, + "behavior": { + "type": "object", + "description": "describes behavior and scaling policies for that behavior", + "title": "Behavior" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling autoscaling", + "title": "Enabled" + }, + "labels": { + "type": "object", + "description": "labels for HPA", + "title": "labels" + }, + "annotations": { + "type": "object", + "description": "used to configure some options for HPA", + "title": "annotations" + }, + "extraMetrics": { + "type": "array", + "items": {}, + "description": "used to give external metrics for autoscaling", + "title": "Extra Metrics" + } + } + }, + "command": { + "type": "object", + "description": "contains the commands for the server", + "title": "Command", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling commands" + }, + "value": { + "type": "array", + "items": {}, + "description": "contains the commands", + "title": "Value" + }, + "workingDir": { + "type": "object", + "items": {}, + "description": "contains the working directory", + "title": "Working directory" + } + } + }, + "containerSecurityContext": { + "type": "object", + "description": " defines privilege and access control settings for a Container", + "title": "Container Security Context" + }, + "containers": { + "type": "array", + "items": {}, + "description": " used to run side-car containers along with the main container within same pod" + }, + "dbMigrationConfig": { + "type": "object", + "description": "used to configure database migration", + "title": "Db Migration Config", + "properties": { + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used for enabling/disabling the config", + "title": "Enabled" + } + } + }, + "envoyproxy": { + "type": "object", + "description": "envoy is attached as a sidecar to the application container to collect metrics like 4XX, 5XX, throughput and latency", + "title": "Envoy Proxy", + "properties": { + "configMapName": { + "type": "string", + "description": "configMap containing configuration for Envoy", + "title": "ConfigMap" + }, + "lifecycle": { + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled": { + "type": "boolean" + }, + "postStart": { + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created" + }, + "preStop": { + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + }, + "image": { + "type": "string", + "description": "image of envoy to be used" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + } + } + }, + "hostAliases": { + "type": "array", + "title": "hostAliases", + "description": "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file", + "items": [ + { + "type": "object", + "properties": { + "ip": { + "type": "string", + "title": "IP", + "description": "IP address of the host file entry" + }, + "hostnames": { + "type": "array", + "description": "Hostnames for the above IP address", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "image": { + "type": "object", + "description": "used to access images in kubernetes", + "title": "Image", + "properties": { + "pullPolicy": { + "type": "string", + "description": "used to define the instances calling the image", + "title": "Pull Policy", + "enum": [ + "IfNotPresent", + "Always" + ] + } + } + }, + "restartPolicy": { + "type": "string", + "description": "It restarts the docker container based on defined conditions.", + "title": "Restart Policy", + "enum": [ + "Always", + "OnFailure", + "Never" + ] + }, + "imagePullSecrets": { + "type": "array", + "items": {}, + "description": "contains the docker credentials that are used for accessing a registry", + "title": "Image PullSecrets" + }, + "winterSoldier": { + "type": "object", + "description": "allows to scale, sleep or delete the resource based on time.", + "title": "winterSoldier", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the winterSoldier controller", + "title": "Annotations" + }, + "labels": { + "type": "object", + "description": "labels for winterSoldier", + "title": "winterSoldier labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "apiVersion": { + "type": "string", + "description": "Api version for winterSoldier", + "title": "winterSoldier apiVersion", + "default": "pincher.devtron.ai/v1alpha1" + }, + "timeRangesWithZone": { + "type": "object", + "description": "describe time zone and time ranges to input in the winterSoldier", + "title": "Time Ranges With Zone", + "timeZone": { + "type": "string", + "description": "describe time zone, and follow standard format", + "title": "Time Zone" + }, + "timeRanges": { + "type": "array", + "items": {}, + "description": "used to take array of time ranges in which each element contains timeFrom, timeTo, weekdayFrom and weekdayTo.", + "title": "Time Ranges" + } + }, + "type": { + "type": "string", + "description": "describe the type of application Rollout/deployment.", + "title": "Type" + }, + "action": { + "type": "string", + "description": "describe the action to be performed by winterSoldier.", + "title": "Action" + }, + "targetReplicas": { + "type": "array", + "description": "describe the number of replicas to which the resource should scale up or down.", + "title": "Target Replicas" + }, + "fieldSelector": { + "type": "array", + "description": "it takes arrays of methods to select specific fields.", + "title": "Field Selector" + } + } + }, + "ingress": { + "type": "object", + "description": "allows public access to URLs", + "title": "Ingress", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx" + }, + "labels": { + "type": "object", + "description": "labels for ingress", + "title": "Ingress labels", + "default": "" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "ingressInternal": { + "type": "object", + "description": "allows private access to the URLs", + "properties": { + "annotations": { + "type": "object", + "description": "used to configure some options depending on the Ingress controller", + "title": "Annotations" + }, + "className": { + "type": "string", + "description": "name of ingress class, a reference to an IngressClass resource that contains additional configuration including the name of the controller", + "title": "Ingress class name", + "default": "nginx-internal" + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable ingress", + "title": "Enabled" + }, + "hosts": { + "type": "array", + "description": "list of hosts in ingress", + "title": "Hosts", + "items": [ + { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "host URL", + "title": "Host" + }, + "pathType": { + "type": "string", + "description": "type of path", + "title": "PathType" + }, + "paths": { + "type": "array", + "description": "list of paths for a given host", + "title": "Paths", + "items": [ + { + "type": "string" + } + ] + } + } + } + ] + }, + "tls": { + "type": "array", + "items": {}, + "description": "contains security details - private key and certificate", + "title": "TLS" + } + } + }, + "networkPolicy":{ + "type": "object", + "description": "NetworkPolicy describes what network traffic is allowed for a set of Pods", + "title": "Network Policy", + "properties": { + "enabled":{ + "type":"boolean", + "description": "used to enable or disable NetworkPolicy" + }, + "annotations":{ + "type": "object", + "description": "Annotations for NetworkPolicy" + }, + "labels":{ + "type":"object", + "description": "Labels for NetworkPolicy" + }, + "podSelector":{ + "type": "object", + "description": "Selects the pods to which this NetworkPolicy object applies", + "properties": { + "matchExpressions":{ + "type":"array", + "description": "list of label selector" + }, + "matchLabels":{ + "type":"object", + "description": "map of {key,value} pairs" + } + } + }, + "policyTypes":{ + "type":"array", + "description": "List of rule types that the NetworkPolicy relates to. Valid options are Ingress,Egress." + }, + "ingress":{ + "type":"array", + "description": "List of ingress rules to be applied to the selected pods" + }, + "egress":{ + "type":"array", + "description": "List of egress rules to be applied to the selected pods" + } + } + }, + "istio":{ + "type": "object", + "description": "Istio Service mesh", + "title": "Istio" + }, + "initContainers": { + "type": "array", + "items": {}, + "description": "specialized containers that run before app containers in a Pod, can contain utilities or setup scripts not present in an app image", + "title": "Init Containers" + }, + "kedaAutoscaling": { + "type": "object", + "description": "Kubernetes-based event driven autoscaler. With KEDA, one can drive the scaling of any container in Kubernetes based on the no. of events needing to be processed", + "title": "KEDA Autoscaling", + "properties": { + "advanced": { + "type": "object" + }, + "authenticationRef": { + "type": "object" + }, + "enabled": { + "type": "boolean" + }, + "envSourceContainerName": { + "type": "string" + }, + "maxReplicaCount": { + "type": "integer" + }, + "minReplicaCount": { + "type": "integer" + }, + "triggerAuthentication": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "spec": { + "type": "object" + } + } + }, + "triggers": { + "type": "array", + "items": {} + } + } + }, + "containerSpec": { + "type": "object", + "description": "define the container specic configuration", + "title": "containerSpec", + "properties": { + "lifecycle": { + "type": "object", + "description": "Actions that the management system should take in response to container lifecycle events", + "title": "lifecycle", + "properties": { + "enabled": { + "type": "boolean" + }, + "postStart": { + "type": "object", + "title": "postStart", + "description": "PostStart is called immediately after a container is created.You could use this event to check that a required API is available before the container’s main work begins" + }, + "preStop": { + "type": "object", + "title": "preStop", + "description": "PreStop is called immediately before a container is terminated" + } + } + } + } + }, + "pauseForSecondsBeforeSwitchActive": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "tell how much to wait for given period of time before switch active the container", + "title": "Pause For Seconds Before SwitchActive" + }, + "podAnnotations": { + "type": "object", + "description": "used to attach metadata and configs in Kubernetes", + "title": "Pod Annotations" + }, + "podDisruptionBudget": { + "type": "object", + "description": "PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods", + "properties": { + "minAvailable": { + "type": "string", + "title": "minAvailable", + "description": "An eviction is allowed if at least \"minAvailable\" pods selected by \"selector\" will still be available after the eviction, i.e. even in the absence of the evicted pod" + }, + "maxUnavailable": { + "type": "string", + "title": "maxUnavailable", + "description": "An eviction is allowed if at most \"maxUnavailable\" pods selected by \"selector\" are unavailable after the eviction, i.e. even in absence of the evicted pod." + } + } + }, + "podExtraSpecs": { + "type": "object", + "description": "ExtraSpec for the pods to be configured", + "title": "podExtraSpecs" + }, + "podLabels": { + "type": "object", + "description": "key/value pairs that are attached to pods, are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system", + "title": "Pod Labels" + }, + "podSecurityContext": { + "type": "object", + "description": "defines privilege and access control settings for a Pod or Container", + "title": "Pod Security Context" + }, + "prometheus": { + "type": "object", + "description": "a kubernetes monitoring tool", + "title": "Prometheus", + "properties": { + "release": { + "type": "string", + "description": "name of the file to be monitored, describes the state of prometheus" + } + } + }, + "rawYaml": { + "type": "array", + "items": {}, + "description": "Accepts an array of Kubernetes objects. One can specify any kubernetes yaml here & it will be applied when a app gets deployed.", + "title": "Raw YAML" + }, + "replicaCount": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "count of Replicas of pod", + "title": "REplica Count" + }, + "resources": { + "type": "object", + "description": "minimum and maximum RAM and CPU available to the application", + "title": "Resources", + "properties": { + "limits": { + "type": "object", + "description": "the maximum values a container can reach", + "title": "Limits", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "limit of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "limit of memory", + "title": "Memory" + } + } + }, + "requests": { + "type": "object", + "description": "request is what the container is guaranteed to get", + "title": "Requests", + "properties": { + "cpu": { + "type": "string", + "format": "cpu", + "description": "request value of CPU", + "title": "CPU" + }, + "memory": { + "type": "string", + "format": "memory", + "description": "request value of memory", + "title": "Memory" + } + } + } + } + }, + "secret": { + "type": "object", + "properties": { + "data": { + "type": "object" + }, + "enabled": { + "type": "boolean" + } + } + }, + "server": { + "type": "object", + "description": "used for providing server configurations.", + "title": "Server", + "properties": { + "deployment": { + "type": "object", + "description": "gives the details for deployment", + "title": "Deployment", + "properties": { + "image": { + "type": "string", + "description": "URL of the image", + "title": "Image" + }, + "image_tag": { + "type": "string", + "description": "tag of the image", + "title": "Image Tag" + } + } + } + } + }, + "service": { + "type": "object", + "description": "defines annotations and the type of service", + "title": "Service", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service" + }, + "type": { + "type": "string", + "description": "type of service", + "title": "Type", + "enum": [ + "ClusterIP", + "LoadBalancer", + "NodePort", + "ExternalName" + ] + }, + "enabled": { + "type": [ + "boolean", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "used to enable or disable service", + "title": "Enabled" + } + } + }, + "serviceAccount": { + "type": "object", + "description": "defines service account for pods", + "title": "Service Account", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations", + "description": "annotations of service account" + }, + "name": { + "type": "string", + "description": "name of service account", + "title": "Name" + }, + "create": { + "type": "boolean" + } + } + }, + "servicemonitor": { + "type": "object", + "description": "gives the set of targets to be monitored", + "title": "Service Monitor", + "properties": { + "additionalLabels": { + "type": "object" + } + } + }, + "tolerations": { + "type": "array", + "items": {}, + "description": "a mechanism which work together with Taints which ensures that pods are not placed on inappropriate nodes", + "title": "Tolerations" + }, + "topologySpreadConstraints": { + "type": "array", + "items": {}, + "description": "used to control how Pods are spread across a cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains", + "title": "Topology Spread Constraints" + }, + "volumeMounts": { + "type": "array", + "items": {}, + "description": "used to provide mounts to the volume", + "title": "Volume Mounts" + }, + "volumes": { + "type": "array", + "items": {}, + "description": "required when some values need to be read from or written to an external disk", + "title": "Volumes" + }, + "waitForSecondsBeforeScalingDown": { + "type": [ + "integer", + "string" + ], + "pattern": "^@{{[a-zA-Z0-9-+/*%_\\s]+}}$", + "description": "Wait for given period of time before scaling down the container", + "title": "Wait For Seconds Before Scaling Down" + } + } +} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/secrets-test-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/secrets-test-values.yaml new file mode 100644 index 00000000000..4a20404db87 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/secrets-test-values.yaml @@ -0,0 +1 @@ +{"ConfigSecrets":{"enabled":true,"secrets":[{"data":{"standard_key":"c3RhbmRhcmQtdmFsdWU="},"external":false,"externalType":"","mountPath":"/test","name":"normal-secret","type":"volume"},{"data":{"secret_key":"U0VDUkVUIERBVEE="},"external":true,"externalType":"AWSSecretsManager","mountPath":"","name":"external-secret-3","type":"environment"}]}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/NOTES.txt b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/NOTES.txt new file mode 100644 index 00000000000..2b144781688 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range $.Values.ingress.paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include ".Chart.Name .fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include ".Chart.Name .fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include ".Chart.Name .fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include ".Chart.Name .name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/_helpers.tpl b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/_helpers.tpl new file mode 100644 index 00000000000..170e5fb2739 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/_helpers.tpl @@ -0,0 +1,150 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define ".Chart.Name .name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create service name +*/}} +{{- define ".servicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 63 | trimSuffix "-" -}} +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 55 | trimSuffix "-" -}}-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 55 | trimSuffix "-" -}}-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create preview service name +*/}} +{{- define ".previewservicename" -}} +{{- if .Values.service.name -}} +{{- .Values.service.name | trunc 55 | trimSuffix "-" -}}-preview +{{- else if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 47 | trimSuffix "-" -}}-preview-service +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define ".Chart.Name .fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define ".Chart.Name .chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define ".Chart.Name .color" -}} +{{- $active0 := (index .Values.server.deployment 0).enabled -}} +{{/* +{{- $active1 := (index .Values.server.deployment 1).enabled -}} +*/}} +{{- $active1 := include "safeenabledcheck" . -}} +{{- $active := and $active0 $active1 -}} +{{- $active -}} +{{- end -}} + +{{- define "safeenabledcheck" -}} +{{- if (eq (len .Values.server.deployment) 2) -}} + {{- if (index .Values.server.deployment 1).enabled -}} + {{- $active := true -}} + {{- $active -}} + {{- else -}} + {{- $active := false -}} + {{- $active -}} + {{- end -}} +{{- else -}} + {{- $active := false -}} + {{- $active -}} +{{- end -}} +{{- end -}} + + +{{- define "isCMVolumeExists" -}} + {{- $isCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $isCMVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isCMVolumeExists -}} +{{- end -}} + +{{- define "isSecretVolumeExists" -}} + {{- $isSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $isSecretVolumeExists = true}} + {{- end }} + {{- end }} + {{- end }} + {{- $isSecretVolumeExists -}} +{{- end -}} + + + + +{{- define "serviceMonitorEnabled" -}} + {{- $SMenabled := false -}} + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if and .servicemonitor.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- end }} + {{- end }} + {{- $SMenabled -}} +{{- end -}} + +{{/* Create the name of the service account to use */}} +{{- define "serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include ".Chart.Name .fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{- define "VerticalPodAutoScalingEnabled" -}} + {{- $SMenabled := false -}} + {{- if and .Values.verticalPodScaling.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- $SMenabled -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml new file mode 100644 index 00000000000..7c374a70e8b --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml @@ -0,0 +1,86 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ambassadorMapping.enabled }} +{{- with $.Values.ambassadorMapping }} +apiVersion: getambassador.io/v3alpha1 +kind: Mapping +metadata: + name: {{ include ".Chart.Name .fullname" $ }}-mapping + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .labels }} +{{ toYaml .labels | nindent 4 }} + {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .ambassadorId }} + ambassador_id: {{ .ambassadorId }} + {{- end }} + {{- if .hostname }} + hostname: {{ .hostname | quote }} + {{- end }} + prefix: {{ .prefix }} + {{- if .rewrite }} + rewrite: {{ .rewrite }} + {{- end }} + service: {{ $svcName }}.{{ $.Release.Namespace }}:{{ $svcPort }} + {{- if .retryPolicy }} + retry_policy: +{{ toYaml .retryPolicy | indent 4 }} + {{- end }} + {{- if .cors }} + cors: +{{ toYaml .cors | indent 4 }} + {{- end }} + {{- if .weight }} + weight: {{ .weight }} + {{- end }} + {{- if .method }} + method: {{ .method }} + {{- end }} + {{- if .extraSpec }} +{{ toYaml .extraSpec | indent 2 }} + {{- end }} + {{- if .tls }} + {{- if .tls.context }} + tls: {{ .tls.context }} +{{- if .tls.create }} +--- +apiVersion: getambassador.io/v3alpha1 +kind: TLSContext +metadata: + name: {{ .tls.context }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ $.Values.pipelineName }} + {{- if .tls.labels }} +{{ toYaml .tls.labels | nindent 4 }} + {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .tls.secretName }} + secret: {{ .tls.secretName }} + {{- end }} + {{- if .tls.hosts }} + hosts: +{{ toYaml .tls.hosts | nindent 4 }} + {{- end }} + {{- if .tls.extraSpec }} +{{ toYaml .tls.extraSpec | indent 2 }} + {{- end }} +{{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml new file mode 100644 index 00000000000..72d5ca84798 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +data: +{{ toYaml .data | trim | indent 2 }} + {{- end}} + {{- end}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/deployment.yaml new file mode 100644 index 00000000000..4a115fc563c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/deployment.yaml @@ -0,0 +1,612 @@ + {{- $hasCMEnvExists := false -}} + {{- $hasCMVolumeExists := false -}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $hasCMVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasCMEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + {{- $hasPVCExists := false -}} + {{- if .Values.persistentVolumeClaim.name }} + {{- $hasPVCExists = true }} + {{- end }} + + {{- $hasSecretEnvExists := false -}} + {{- $hasSecretVolumeExists := false -}} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $hasSecretVolumeExists = true}} + {{- end }} + {{- if eq .type "environment"}} + {{- $hasSecretEnvExists = true}} + {{- end }} + {{- end }} + {{- end }} + + +apiVersion: argoproj.io/v1alpha1 +kind: Rollout +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ .Values.pipelineName }} +{{- if .Values.rolloutLabels }} +{{ toYaml .Values.rolloutLabels | indent 4 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- if .Values.rolloutAnnotations }} + annotations: +{{ toYaml .Values.rolloutAnnotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + replicas: {{ $.Values.replicaCount }} + minReadySeconds: {{ $.Values.MinReadySeconds }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 8 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | indent 8 }} +{{- end }} + spec: +{{- if $.Values.podExtraSpecs }} +{{ toYaml .Values.podExtraSpecs | indent 6 }} +{{- end }} + terminationGracePeriodSeconds: {{ $.Values.GracePeriod }} + restartPolicy: Always +{{- if $.Values.hostAliases }} + hostAliases: +{{ toYaml .Values.hostAliases | indent 8 }} +{{- end }} +{{- if and $.Values.Spec.Affinity.Key $.Values.Spec.Affinity.Values }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: {{ $.Values.Spec.Affinity.Key }} + operator: In + values: + - {{ $.Values.Spec.Affinity.Values | default "nodes" }} +{{- else if $.Values.affinity.enabled }} + affinity: +{{ toYaml .Values.affinity.values | indent 8 }} +{{- end }} +{{- if $.Values.serviceAccountName }} + serviceAccountName: {{ $.Values.serviceAccountName }} +{{- else }} + serviceAccountName: {{ template "serviceAccountName" . }} +{{- end }} +{{- if $.Values.schedulerName }} + schedulerName: {{ .Values.schedulerName }} +{{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} +{{- if $.Values.imagePullSecrets}} + imagePullSecrets: + {{- range .Values.imagePullSecrets }} + - name: {{ . }} + {{- end }} +{{- end}} +{{- if $.Values.topologySpreadConstraints }} + topologySpreadConstraints: +{{- range $.Values.topologySpreadConstraints }} + - maxSkew: {{ .maxSkew }} + topologyKey: {{ .topologyKey }} + whenUnsatisfiable: {{ .whenUnsatisfiable }} + labelSelector: + matchLabels: + {{- if and .autoLabelSelector .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- else if .autoLabelSelector }} + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} + {{- else if .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- end }} +{{- end }} +{{- end }} +{{- if $.Values.podSecurityContext }} + securityContext: +{{ toYaml .Values.podSecurityContext | indent 8 }} +{{- end }} +{{- if $.Values.restartPolicy }} + restartPolicy: {{ $.Values.restartPolicy }} +{{- end }} +{{- if $.Values.initContainers}} + initContainers: +{{- range $i, $c := .Values.initContainers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-init-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .args}} + args: +{{ toYaml .args | indent 12 -}} +{{- end}} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + containers: + - name: {{ $.Chart.Name }} + image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + {{- if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- if $.Values.containerSpec.lifecycle.postStart }} + postStart: +{{ toYaml $.Values.containerSpec.lifecycle.postStart | indent 12 -}} + {{- end }} + {{- end }} +{{- if and $.Values.containerSecurityContext $.Values.privileged }} + securityContext: + privileged: true +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- else if $.Values.privileged }} + securityContext: + privileged: true +{{- else if $.Values.containerSecurityContext }} + securityContext: +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- end }} +{{- if $.Values.containerExtraSpecs }} +{{ toYaml .Values.containerExtraSpecs | indent 10 }} +{{- end }} +{{- if $.Values.resizePolicy }} + resizePolicy: +{{ toYaml .Values.resizePolicy | indent 12 }} +{{- end }} + ports: + {{- range $.Values.ContainerPort }} + - name: {{ .name}} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end}} +{{- if and $.Values.command.enabled $.Values.command.workingDir }} + workingDir: {{ $.Values.command.workingDir }} +{{- end}} +{{- if and $.Values.command.value $.Values.command.enabled}} + command: +{{ toYaml $.Values.command.value | indent 12 -}} +{{- end}} +{{- if and $.Values.args.value $.Values.args.enabled}} + args: +{{ toYaml $.Values.args.value | indent 12 -}} +{{- end }} + env: + - name: CONFIG_HASH + value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }} + - name: SECRET_HASH + value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }} + - name: DEVTRON_APP_NAME + value: {{ template ".Chart.Name .name" $ }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: DEVTRON_CONTAINER_REPO + value: "{{ .Values.server.deployment.image }}" + - name: DEVTRON_CONTAINER_TAG + value: "{{ .Values.server.deployment.image_tag }}" + {{- range $.Values.EnvVariablesFromFieldPath }} + {{- if and .name .fieldPath }} + - name: {{ .name }} + valueFrom: + fieldRef: + fieldPath: {{ .fieldPath }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariables }} + {{- if and .name .value }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromSecretKeys }} + {{- if and .name .secretName .keyName }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromConfigMapKeys }} + {{- if and .name .configMapName .keyName }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ .configMapName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- if or (and ($hasCMEnvExists) (.Values.ConfigMaps.enabled)) (and ($hasSecretEnvExists) (.Values.ConfigSecrets.enabled)) }} + envFrom: + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "environment" }} + - configMapRef: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "environment" }} + - secretRef: + {{if eq .external true}} + name: {{ .name }} + {{else if eq .external false}} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + +{{- if or $.Values.LivenessProbe.Path $.Values.LivenessProbe.command $.Values.LivenessProbe.tcp }} + livenessProbe: +{{- if $.Values.LivenessProbe.Path }} + httpGet: + path: {{ $.Values.LivenessProbe.Path }} + port: {{ $.Values.LivenessProbe.port }} + scheme: {{ $.Values.LivenessProbe.scheme }} + {{- if $.Values.LivenessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.LivenessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.LivenessProbe.command }} + exec: + command: +{{ toYaml .Values.LivenessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.LivenessProbe.tcp }} + tcpSocket: + port: {{ $.Values.LivenessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.LivenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.LivenessProbe.periodSeconds }} + successThreshold: {{ $.Values.LivenessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.LivenessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.LivenessProbe.failureThreshold }} +{{- end }} +{{- if or $.Values.ReadinessProbe.Path $.Values.ReadinessProbe.command $.Values.ReadinessProbe.tcp }} + readinessProbe: +{{- if $.Values.ReadinessProbe.Path }} + httpGet: + path: {{ $.Values.ReadinessProbe.Path }} + port: {{ $.Values.ReadinessProbe.port }} + scheme: {{ $.Values.ReadinessProbe.scheme }} + {{- if $.Values.ReadinessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.ReadinessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.ReadinessProbe.command }} + exec: + command: +{{ toYaml .Values.ReadinessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.ReadinessProbe.tcp }} + tcpSocket: + port: {{ $.Values.ReadinessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.ReadinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.ReadinessProbe.periodSeconds }} + successThreshold: {{ $.Values.ReadinessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.ReadinessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.ReadinessProbe.failureThreshold }} +{{- end }} + resources: +{{ toYaml $.Values.resources | trim | indent 12 }} +{{- if or $.Values.StartupProbe.Path $.Values.StartupProbe.command $.Values.StartupProbe.tcp }} + startupProbe: +{{- if $.Values.StartupProbe.Path }} + httpGet: + path: {{ $.Values.StartupProbe.Path }} + port: {{ $.Values.StartupProbe.port }} + {{- if $.Values.StartupProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.StartupProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.StartupProbe.command }} + exec: + command: +{{ toYaml .Values.StartupProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.StartupProbe.tcp }} + tcpSocket: + port: {{ $.Values.StartupProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.StartupProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.StartupProbe.periodSeconds }} + successThreshold: {{ $.Values.StartupProbe.successThreshold }} + timeoutSeconds: {{ $.Values.StartupProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.StartupProbe.failureThreshold }} +{{- end }} + volumeMounts: +{{- with .Values.volumeMounts }} +{{ toYaml . | trim | indent 12 }} +{{- end }} +{{- if $.Values.persistentVolumeClaim.name }} + - name: {{ .Values.persistentVolumeClaim.name }}-vol + mountPath: {{ .Values.persistentVolumeClaim.mountPath | default "/tmp" }} +{{- end}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{- range $k, $v := .data }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} + {{- if and (.esoSubPath) (ne (len .esoSubPath) 0) }} + {{- range .esoSubPath }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ . }} + subPath: {{ . }} + {{- end }} + {{- else }} + {{- range .esoSecretData.esoData }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ .secretKey }} + subPath: {{ .secretKey }} + {{- end }} + {{- end }} + {{- else }} + {{- range $k, $v := .data }} # for others secrets the mount path will be .data[i].secretKey + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} +{{- if $.Values.appMetrics }} + - name: envoy + image: {{ $.Values.envoyproxy.image | default "quay.io/devtron/envoy:v1.16.0"}} + {{- if $.Values.envoyproxy.lifecycle }} + lifecycle: +{{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} + {{- else if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- end }} + resources: +{{ toYaml $.Values.envoyproxy.resources | trim | indent 12 }} + ports: + - containerPort: 9901 + protocol: TCP + name: envoy-admin + {{- range $index, $element := .Values.ContainerPort }} + - name: {{ $element.name}} + containerPort: {{ $element.envoyPort | default (add 8790 $index) }} + protocol: TCP + {{- end }} + command: ["/usr/local/bin/envoy"] + args: ["-c", "/etc/envoy-config/envoy-config.json", "-l", "info", "--log-format", "[METADATA][%Y-%m-%d %T.%e][%t][%l][%n] %v"] + volumeMounts: + - name: {{ $.Values.envoyproxy.configMapName | default "envoy-config-volume" }} + mountPath: /etc/envoy-config/envoy-config-volume +{{- if $.Values.envoyproxy.readinessProbe}} + readinessProbe: +{{ toYaml $.Values.envoyproxy.readinessProbe | indent 12}} +{{- end }} +{{- if $.Values.envoyproxy.livenessProbe}} + readinessProbe: +{{ toYaml $.Values.envoyproxy.livenessProbe | indent 12}} +{{- end }} +{{- end}} +{{- if $.Values.containers }} +{{- range $i, $c := .Values.containers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-sidecontainer-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resizePolicy }} + resizePolicy: +{{ toYaml .resziePolicy | indent 12}} +{{- end }} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + volumes: + {{- if $.Values.appMetrics }} + - name: envoy-config-volume + configMap: + name: sidecar-config-{{ template ".Chart.Name .name" $ }} + {{- end }} +{{- if .Values.persistentVolumeClaim.name }} + - name: {{.Values.persistentVolumeClaim.name}}-vol + persistentVolumeClaim: + claimName: {{.Values.persistentVolumeClaim.name }} +{{- end}} +{{- with .Values.volumes }} +{{ toYaml . | trim | indent 8 }} +{{- end }} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + configMap: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + secret: + {{- if eq .external true }} + secretName: {{ .name }} + {{- else if eq .external false }} + secretName: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) (eq (.Values.appMetrics) false) }} []{{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) (eq (.Values.appMetrics) false) }} []{{- end }} + revisionHistoryLimit: 3 +## pauseForSecondsBeforeSwitchActive: {{ $.Values.pauseForSecondsBeforeSwitchActive }} +# waitForSecondsBeforeScalingDown: {{ $.Values.waitForSecondsBeforeScalingDown }} + strategy: + {{- if eq .Values.deploymentType "BLUE-GREEN" }} + blueGreen: # A new field that used to provide configurable options for a BlueGreenUpdate strategy + previewService: {{ template ".previewservicename" . }} # Reference to a service that can serve traffic to a new image before it receives the active traffic + activeService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + autoPromotionSeconds: {{ $.Values.deployment.strategy.blueGreen.autoPromotionSeconds }} + scaleDownDelaySeconds: {{ $.Values.deployment.strategy.blueGreen.scaleDownDelaySeconds }} + previewReplicaCount: {{ $.Values.deployment.strategy.blueGreen.previewReplicaCount }} + autoPromotionEnabled: {{ $.Values.deployment.strategy.blueGreen.autoPromotionEnabled }} + {{- else if eq .Values.deploymentType "ROLLING" }} + canary: + stableService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + maxSurge: {{ $.Values.deployment.strategy.rolling.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.rolling.maxUnavailable }} + {{- else if eq .Values.deploymentType "RECREATE" }} + recreate: + activeService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + {{- else if eq .Values.deploymentType "CANARY" }} + canary: + stableService: {{ template ".servicename" . }} # Reference to a service that serves end-user traffic to the replica set + maxSurge: {{ $.Values.deployment.strategy.canary.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.canary.maxUnavailable }} + steps: +{{ toYaml .Values.deployment.strategy.canary.steps | indent 8 }} + {{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml new file mode 100644 index 00000000000..ea0ee9f5dc1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml @@ -0,0 +1,66 @@ +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external true }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} +{{- if .esoSecretData.secretStore }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: SecretStore +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + provider: + {{- toYaml .esoSecretData.secretStore | nindent 4 }} +{{- end }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: {{ .name }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .esoSecretData.refreshInterval }} + refreshInterval: {{ .esoSecretData.refreshInterval }} + {{- else }} + refreshInterval: 1h + {{- end}} + {{- if and .esoSecretData.secretStoreRef (not .esoSecretData.secretStore) }} + secretStoreRef: +{{ toYaml .esoSecretData.secretStoreRef | indent 4 }} + {{- else }} + secretStoreRef: + name: {{ .name}} + kind: SecretStore + {{- end }} + target: + name: {{ .name}} + {{- if .esoSecretData.template }} + template: + {{- toYaml .esoSecretData.template | nindent 6 }} + {{- end }} + creationPolicy: Owner + {{- if .esoSecretData.esoDataFrom }} + dataFrom: + {{- toYaml .esoSecretData.esoDataFrom | nindent 4 }} + {{- else }} + data: + {{- range .esoSecretData.esoData }} + - secretKey: {{ .secretKey }} + remoteRef: + key: {{ .key }} + {{- if .property }} + property: {{ .property }} + {{- end }} + {{- end}} +{{- end}} +{{- end}} +{{- end}} +{{- end}} +{{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/generic.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/generic.yaml new file mode 100644 index 00000000000..db95e842670 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/generic.yaml @@ -0,0 +1,4 @@ +{{- range .Values.rawYaml }} +--- +{{ toYaml . }} + {{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml new file mode 100644 index 00000000000..8f424d15fde --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml @@ -0,0 +1,81 @@ +{{- if $.Values.autoscaling.enabled }} +{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2 +{{- else if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2beta2 +{{- else }} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- if .Values.autoscaling.annotations }} + annotations: +{{ toYaml .Values.autoscaling.annotations | indent 4 }} + {{- end }} + {{- if .Values.autoscaling.labels }} + labels: +{{ toYaml .Values.autoscaling.labels | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: argoproj.io/v1alpha1 + kind: Rollout + name: {{ include ".Chart.Name .fullname" $ }} + minReplicas: {{ $.Values.autoscaling.MinReplicas }} + maxReplicas: {{ $.Values.autoscaling.MaxReplicas }} + metrics: + {{- if $.Values.autoscaling.containerResource.enabled }} + {{- with $.Values.autoscaling.containerResource }} + {{- if .TargetCPUUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: cpu + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetCPUUtilizationPercentage }} + {{- end}} + {{- if .TargetMemoryUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: memory + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetMemoryUtilizationPercentage }} + {{- end}} + {{- end }} + {{- end }} + {{- if $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if $.Values.autoscaling.TargetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if and $.Values.autoscaling.extraMetrics (semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion) }} + {{- toYaml $.Values.autoscaling.extraMetrics | nindent 2 }} + {{- end}} + {{- if and $.Values.autoscaling.behavior (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml new file mode 100644 index 00000000000..1f231966b16 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml @@ -0,0 +1,177 @@ +{{ $svcName := include ".servicename" . }} +{{ $svcPort := (index .Values.ContainerPort 0).servicePort }} +{{- if $.Values.ingress.enabled -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- if and .Values.ingressInternal.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingressInternal.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingressInternal.annotations "kubernetes.io/ingress.class" .Values.ingressInternal.className}} + {{- end }} +{{- end }} +{{- end }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.ingress.labels }} +{{ toYaml .Values.ingress.labels | indent 4 }} + {{- end }} +{{- if .Values.ingress.annotations }} + annotations: +{{ toYaml .Values.ingress.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + rules: + {{- if or .Values.ingress.host .Values.ingress.path }} + - host: {{ .Values.ingress.host }} + http: + paths: + - path: {{ .Values.ingress.path }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingress.pathType | default "ImplementationSpecific" }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingress.hosts) (not ($.Values.ingress.host )) }} + {{- range .Values.ingress.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end }} +{{- if $.Values.ingressInternal.enabled }} +--- +{{ if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{ else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{ else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ template ".Chart.Name .fullname" . }}-ingress-internal + namespace: {{ $.Values.NameSpace }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.ingressInternal.annotations }} + annotations: +{{ toYaml .Values.ingressInternal.annotations | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingressInternal.className }} + {{- end }} + rules: + {{- if or .Values.ingressInternal.host .Values.ingressInternal.path }} + - host: {{ .Values.ingressInternal.host }} + http: + paths: + - path: {{ .Values.ingressInternal.path }} + {{- if and .Values.ingressInternal.pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $.Values.ingressInternal.pathType | default "Prefix" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if and ($.Values.ingressInternal.hosts) (not ($.Values.ingressInternal.host )) }} + {{- range .Values.ingressInternal.hosts }} + {{ $outer := . -}} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ $outer.pathType | default "ImplementationSpecific" | quote }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $svcName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $svcName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- if .additionalBackends }} +{{ toYaml .additionalBackends | indent 10 }} + {{- end }} + + {{- end }} + {{- end }} + {{- if .Values.ingressInternal.tls }} + tls: +{{ toYaml .Values.ingressInternal.tls | indent 4 }} + {{- end -}} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-authorizationpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-authorizationpolicy.yaml new file mode 100644 index 00000000000..ac7b456ec5b --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-authorizationpolicy.yaml @@ -0,0 +1,37 @@ +{{- with .Values.istio }} +{{- if and .enable .authorizationPolicy.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .authorizationPolicy.labels }} +{{ toYaml .authorizationPolicy.labels | indent 4 }} + {{- end }} +{{- if .authorizationPolicy.annotations }} + annotations: +{{ toYaml .authorizationPolicy.annotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} + action: {{ .authorizationPolicy.action }} +{{- if $.Values.istio.authorizationPolicy.provider }} + provider: +{{ toYaml $.Values.istio.authorizationPolicy.provider | indent 4 }} +{{- end }} +{{- if $.Values.istio.authorizationPolicy.rules }} + rules: +{{ toYaml $.Values.istio.authorizationPolicy.rules | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-destinationrule.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-destinationrule.yaml new file mode 100644 index 00000000000..47bef9a828e --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-destinationrule.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .destinationRule.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: DestinationRule +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .destinationRule.labels }} +{{ toYaml .destinationRule.labels | indent 4 }} + {{- end }} +{{- if .destinationRule.annotations }} + annotations: +{{ toYaml .destinationRule.annotations | indent 4 }} +{{- end }} +spec: + host: "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- if $.Values.istio.destinationRule.subsets }} + subsets: +{{ toYaml $.Values.istio.destinationRule.subsets | indent 4 }} +{{- end }} +{{- if $.Values.istio.destinationRule.trafficPolicy }} + trafficPolicy: +{{ toYaml $.Values.istio.destinationRule.trafficPolicy | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-gateway.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-gateway.yaml new file mode 100644 index 00000000000..d6579590100 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-gateway.yaml @@ -0,0 +1,50 @@ +{{- if and .Values.istio.enable .Values.istio.gateway.enabled -}} +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.istio.gateway.labels }} +{{ toYaml $.Values.istio.gateway.labels | indent 4 }} + {{- end }} +{{- if $.Values.istio.gateway.annotations }} + annotations: +{{ toYaml $.Values.istio.gateway.annotations | indent 4 }} +{{- end }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - {{ .Values.istio.gateway.host | quote -}} +{{ with .Values.istio.gateway }} +{{- if .tls.enabled }} + tls: + httpsRedirect: true + - port: + number: 443 + name: https + protocol: HTTPS + hosts: + - {{ .host | quote }} + tls: + mode: SIMPLE + credentialName: {{ .tls.secretName }} +{{ end }} +{{ end }} +{{ end }} + + + diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-peerauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-peerauthentication.yaml new file mode 100644 index 00000000000..481f8a96474 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-peerauthentication.yaml @@ -0,0 +1,36 @@ +{{- with .Values.istio }} +{{- if and .enable .peerAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: PeerAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .peerAuthentication.labels }} +{{ toYaml .peerAuthentication.labels | indent 4 }} + {{- end }} +{{- if .peerAuthentication.annotations }} + annotations: +{{ toYaml .peerAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .peerAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} + mtls: + mode: {{ .peerAuthentication.mtls.mode }} +{{- if $.Values.istio.peerAuthentication.portLevelMtls }} + portLevelMtls: +{{ toYaml $.Values.istio.peerAuthentication.portLevelMtls | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-requestauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-requestauthentication.yaml new file mode 100644 index 00000000000..3429cee1462 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-requestauthentication.yaml @@ -0,0 +1,34 @@ +{{- with .Values.istio }} +{{- if and .enable .requestAuthentication.enabled }} +apiVersion: security.istio.io/v1beta1 +kind: RequestAuthentication +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .requestAuthentication.labels }} +{{ toYaml .requestAuthentication.labels | indent 4 }} + {{- end }} +{{- if .requestAuthentication.annotations }} + annotations: +{{ toYaml .requestAuthentication.annotations | indent 4 }} +{{- end }} +spec: +{{- if .requestAuthentication.selector.enabled }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template ".Chart.Name .fullname" $ }} +{{- end }} +{{- if $.Values.istio.requestAuthentication.jwtRules }} + jwtRules: +{{ toYaml $.Values.istio.requestAuthentication.jwtRules | indent 2 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-virtualservice.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-virtualservice.yaml new file mode 100644 index 00000000000..af61039b8db --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/istio-virtualservice.yaml @@ -0,0 +1,50 @@ +{{- with .Values.istio }} +{{- if and .enable .virtualService.enabled }} +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if .virtualService.labels }} +{{ toYaml .virtualService.labels | indent 4 }} + {{- end }} +{{- if .virtualService.annotations }} + annotations: +{{ toYaml .virtualService.annotations | indent 4 }} +{{- end }} +spec: +{{- if or .gateway.enabled .virtualService.gateways }} + gateways: + {{- if .gateway.enabled }} + - {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} + {{- range .virtualService.gateways }} + - {{ . | quote }} + {{- end }} +{{- end }} +{{- if or .gateway.enabled .virtualService.hosts }} + hosts: + {{- if .gateway.enabled }} + - {{ .gateway.host | quote }} + {{- end }} + {{- range .virtualService.hosts }} + - {{ . | quote }} + {{- end }} +{{- else }} + hosts: + - "{{ include ".servicename" $ }}.{{ $.Release.Namespace }}.svc.cluster.local" +{{- end }} +{{- if $.Values.istio.virtualService.http }} + http: +{{ toYaml $.Values.istio.virtualService.http | indent 4 }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml new file mode 100644 index 00000000000..8c703a56474 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml @@ -0,0 +1,48 @@ +{{- if $.Values.kedaAutoscaling.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-keda +spec: + scaleTargetRef: + apiVersion: argoproj.io/v1alpha1 + kind: Rollout + name: {{ include ".Chart.Name .fullname" $ }} +{{- if $.Values.kedaAutoscaling.envSourceContainerName }} + envSourceContainerName: {{ $.Values.kedaAutoscaling.envSourceContainerName }} +{{- end }} +{{- if $.Values.kedaAutoscaling.pollingInterval }} + pollingInterval: {{ $.Values.kedaAutoscaling.pollingInterval }} +{{- end }} +{{- if $.Values.kedaAutoscaling.cooldownPeriod }} + cooldownPeriod: {{ $.Values.kedaAutoscaling.cooldownPeriod }} +{{- end }} +{{- if $.Values.kedaAutoscaling.idleReplicaCount }} + idleReplicaCount: {{ $.Values.kedaAutoscaling.idleReplicaCount }} +{{- end }} + minReplicaCount: {{ $.Values.kedaAutoscaling.minReplicaCount }} + maxReplicaCount: {{ $.Values.kedaAutoscaling.maxReplicaCount }} +{{- if $.Values.kedaAutoscaling.fallback }} + fallback: +{{ toYaml $.Values.kedaAutoscaling.fallback | indent 4 }} +{{- end }} +{{- if $.Values.kedaAutoscaling.advanced }} + advanced: +{{ toYaml $.Values.kedaAutoscaling.advanced | indent 4 }} +{{- end }} + triggers: +{{ toYaml .Values.kedaAutoscaling.triggers | indent 2}} +{{- if $.Values.kedaAutoscaling.authenticationRef }} + authenticationRef: +{{ toYaml $.Values.kedaAutoscaling.authenticationRef | indent 6 }} +{{- end }} +--- +{{- if $.Values.kedaAutoscaling.triggerAuthentication.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: TriggerAuthentication +metadata: + name: {{ $.Values.kedaAutoscaling.triggerAuthentication.name }} +spec: +{{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/metrics-service-monitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/metrics-service-monitor.yaml new file mode 100644 index 00000000000..4e9e544f508 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/metrics-service-monitor.yaml @@ -0,0 +1,35 @@ +{{- if $.Values.appMetrics -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: + jobLabel: {{ template ".Chart.Name .name" $ }} + endpoints: + - port: envoy-admin + interval: 30s + path: /stats/prometheus + relabelings: + - action: replace + sourceLabels: + - __meta_kubernetes_pod_label_rollouts_pod_template_hash + targetLabel: devtron_app_hash + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + namespaceSelector: + matchNames: + - {{.Release.Namespace}} + podTargetLabels: + - appId + - envId + - devtron_app_hash +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/networkpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/networkpolicy.yaml new file mode 100644 index 00000000000..350232a23b6 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/networkpolicy.yaml @@ -0,0 +1,50 @@ +{{- if .Values.networkPolicy.enabled -}} +{{- with .Values.networkPolicy }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} + {{- if $.Values.networkPolicy.labels }} +{{ toYaml $.Values.networkPolicy.labels | indent 4 }} + {{- end }} +{{- if $.Values.networkPolicy.annotations }} + annotations: +{{ toYaml $.Values.networkPolicy.annotations | indent 4 }} +{{- end }} +spec: + podSelector: +{{- if .podSelector.matchExpressions }} + matchExpressions: +{{ toYaml $.Values.networkPolicy.podSelector.matchExpressions | indent 6 }} +{{- end }} +{{- if .podSelector.matchLabels }} + matchLabels: +{{ toYaml $.Values.networkPolicy.podSelector.matchLabels | indent 6 }} +{{- else }} + matchLabels: + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} +{{- end }} +{{- if .policyTypes }} + policyTypes: +{{ toYaml $.Values.networkPolicy.policyTypes | indent 4 }} +{{- end }} +{{- if .ingress }} + ingress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4 }} +{{- end }} +{{- if .egress }} + egress: +{{ toYaml $.Values.networkPolicy.ingress | indent 4}} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/persistent-volume-claim.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/persistent-volume-claim.yaml new file mode 100644 index 00000000000..bf4e6dfb712 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/persistent-volume-claim.yaml @@ -0,0 +1,24 @@ +{{- if .Values.persistentVolumeClaim.name }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{.Values.persistentVolumeClaim.name }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- with .Values.persistentVolumeClaim }} +spec: + accessModes: +{{- range .accessMode }} + - {{ . }} +{{- end }} + resources: + requests: + storage: {{ .storage | default "5Gi" }} + storageClassName: {{ .storageClassName | default "default" }} + volumeMode: {{ .volumeMode | default "Filesystem" }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml new file mode 100644 index 00000000000..c9cbb4162d4 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml @@ -0,0 +1,25 @@ +{{- if .Values.podDisruptionBudget }} +{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: policy/v1 +{{- else -}} +apiVersion: policy/v1beta1 +{{- end }} +kind: PodDisruptionBudget +metadata: + name: {{ include ".Chart.Name .fullname" $ }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + selector: + matchLabels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml new file mode 100644 index 00000000000..cd733d48576 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml @@ -0,0 +1,23 @@ +{{- if $.Values.dbMigrationConfig.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-migrator + annotations: + argocd.argoproj.io/hook: PreSync +# argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + containers: + - name: migrator + image: 686244538589.dkr.ecr.us-east-2.amazonaws.com/migrator:0.0.1-rc14 + env: + {{- range $.Values.dbMigrationConfig.envValues }} + - name: {{ .key}} + value: {{ .value | quote }} + {{- end}} + restartPolicy: Never + backoffLimit: 0 +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml new file mode 100644 index 00000000000..90f398bff4c --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml @@ -0,0 +1,22 @@ +{{- if .Values.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template ".Chart.Name .fullname" . }} + {{- if .Values.prometheusRule.namespace }} + namespace: {{ .Values.prometheusRule.namespace }} + {{- end }} + labels: + kind: Prometheus + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.prometheusRule.additionalLabels }} +{{ toYaml .Values.prometheusRule.additionalLabels | indent 4 }} + {{- end }} +spec: + {{- with .Values.prometheusRule.rules }} + groups: + - name: {{ template ".Chart.Name .fullname" $ }} + rules: {{- toYaml . | nindent 6 }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml new file mode 100644 index 00000000000..26a17b968ca --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml @@ -0,0 +1,69 @@ +{{- if $.Values.secret.enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: app-secret +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml $.Values.secret.data | indent 2 }} +{{- end }} + + +{{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{if eq .external false}} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .name}}-{{ $.Values.app }} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +type: Opaque +data: +{{ toYaml .data | trim | indent 2 }} +{{- end}} + {{if eq .external true }} + {{if (or (eq .externalType "AWSSecretsManager") (eq .externalType "AWSSystemManager") (eq .externalType "HashiCorpVault"))}} +--- +apiVersion: kubernetes-client.io/v1 +kind: ExternalSecret +metadata: + name: {{ .name}} +{{- if $.Values.appLabels }} + labels: +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} +spec: + {{- if .roleARN }} + roleArn: .roleARN + {{- end}} + {{- if eq .externalType "AWSSecretsManager"}} + backendType: secretsManager + {{- end}} + {{- if eq .externalType "AWSSystemManager"}} + backendType: systemManager + {{- end}} + {{- if eq .externalType "HashiCorpVault"}} + backendType: vault + {{- end}} + data: + {{- range .secretData }} + - key: {{.key}} + name: {{.name}} + {{- if .property }} + property: {{.property}} + {{- end}} + isBinary: {{.isBinary}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} + {{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml new file mode 100644 index 00000000000..f943af00ae1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml @@ -0,0 +1,93 @@ +{{- if .Values.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".servicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end}} +spec: + type: {{ .Values.service.type | default "ClusterIP" }} +{{- if (and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges )}} + loadBalancerSourceRanges: + {{- range .Values.service.loadBalancerSourceRanges }} + - {{ . }} + {{- end }} +{{- end }} + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + {{- if .targetPort }} + targetPort: {{ .targetPort }} + {{- else }} + targetPort: {{ .name }} + {{- end }} + {{- if (and (eq $.Values.service.type "NodePort") .nodePort )}} + nodePort: {{ .nodePort }} + {{- end }} + protocol: {{ .protocol }} + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- if .Values.service.sessionAffinity.enabled }} + sessionAffinity: ClientIP +{{- end }} +{{- if .Values.service.sessionAffinityConfig }} + sessionAffinityConfig: +{{ toYaml .Values.service.sessionAffinityConfig | indent 4 }} +{{- end }} + + + +{{- if eq .Values.deploymentType "BLUE-GREEN" }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template ".previewservicename" . }} + labels: + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Release.Name }} +spec: + type: ClusterIP + ports: + {{- range .Values.ContainerPort }} + {{- if .servicePort }} + - port: {{ .servicePort }} + {{- else }} + - port: {{ .port }} + {{- end }} + targetPort: {{ .name }} + protocol: TCP + name: {{ .name }} + {{- end }} + {{- if $.Values.appMetrics }} + - port: 9901 + name: envoy-admin + {{- end }} + selector: + app: {{ template ".Chart.Name .name" . }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml new file mode 100644 index 00000000000..ac258610fa8 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if $.Values.serviceAccount }} +{{- if $.Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "serviceAccountName" . }} + {{- if .Values.podLabels }} + labels: +{{ toYaml .Values.podLabels | indent 4 }} + {{- end }} + {{- if .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml new file mode 100644 index 00000000000..1f90c722cb1 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml @@ -0,0 +1,48 @@ +{{ $serviceMonitorEnabled := include "serviceMonitorEnabled" . }} +{{- if eq "true" $serviceMonitorEnabled -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template ".Chart.Name .fullname" . }}-sm + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} + {{- if .Values.servicemonitor.additionalLabels }} +{{ toYaml .Values.servicemonitor.additionalLabels | indent 4 }} + {{- end }} +spec: + endpoints: + {{- range .Values.ContainerPort }} + {{- if .servicemonitor }} + {{- if .servicemonitor.enabled}} + {{- if .servicePort }} + - port: {{ .name }} + {{- if .servicemonitor.path }} + path: {{ .servicemonitor.path}} + {{- end }} + {{- if .servicemonitor.scheme }} + scheme: {{ .servicemonitor.scheme}} + {{- end }} + {{- if .servicemonitor.interval }} + interval: {{ .servicemonitor.interval}} + {{- end }} + {{- if .servicemonitor.scrapeTimeout }} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} + {{- end }} + {{- if .servicemonitor.metricRelabelings}} + metricRelabelings: +{{toYaml .servicemonitor.metricRelabelings | indent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + selector: + matchLabels: + app: {{ template ".Chart.Name .name" $ }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/sidecar-configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/sidecar-configmap.yaml new file mode 100644 index 00000000000..cf32679409a --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/sidecar-configmap.yaml @@ -0,0 +1,169 @@ +{{- if .Values.appMetrics }} +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: 2019-08-12T18:38:34Z + name: sidecar-config-{{ template ".Chart.Name .name" $ }} +data: + envoy-config.json: | + { + "stats_config": { + "use_all_default_tags": false, + "stats_tags": [ + { + "tag_name": "cluster_name", + "regex": "^cluster\\.((.+?(\\..+?\\.svc\\.cluster\\.local)?)\\.)" + }, + { + "tag_name": "tcp_prefix", + "regex": "^tcp\\.((.*?)\\.)\\w+?$" + }, + { + "tag_name": "response_code", + "regex": "_rq(_(\\d{3}))$" + }, + { + "tag_name": "response_code_class", + "regex": ".*_rq(_(\\dxx))$" + }, + { + "tag_name": "http_conn_manager_listener_prefix", + "regex": "^listener(?=\\.).*?\\.http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "http_conn_manager_prefix", + "regex": "^http\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "listener_address", + "regex": "^listener\\.(((?:[_.[:digit:]]*|[_\\[\\]aAbBcCdDeEfF[:digit:]]*))\\.)" + }, + { + "tag_name": "mongo_prefix", + "regex": "^mongo\\.(.+?)\\.(collection|cmd|cx_|op_|delays_|decoding_)(.*?)$" + } + ], + "stats_matcher": { + "inclusion_list": { + "patterns": [ + { + "regex": ".*_rq_\\dxx$" + }, + { + "regex": ".*_rq_time$" + }, + { + "regex": "cluster.*" + }, + ] + } + } + }, + "admin": { + "access_log_path": "/dev/null", + "address": { + "socket_address": { + "address": "0.0.0.0", + "port_value": 9901 + } + } + }, + "static_resources": { + "clusters": [ + {{- range $index, $element := .Values.ContainerPort }} + { + "name": "{{ $.Values.app }}-{{ $index }}", + "type": "STATIC", + "connect_timeout": "0.250s", + "lb_policy": "ROUND_ROBIN", +{{- if $element.idleTimeout }} + "common_http_protocol_options": { + "idle_timeout": {{ $element.idleTimeout | quote }} + }, +{{- end }} +{{- if or $element.useHTTP2 $element.useGRPC }} + "http2_protocol_options": {}, +{{- end }} +{{- if and (not $element.useGRPC) (not $element.supportStreaming) }} + "max_requests_per_connection": "1", +{{- end }} + "load_assignment": { + "cluster_name": "9", + "endpoints": { + "lb_endpoints": [ + { + "endpoint": { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "127.0.0.1", + "port_value": {{ $element.port }} + } + } + } + } + ] + } + } + }, + {{- end }} + ], + "listeners":[ + {{- range $index, $element := .Values.ContainerPort }} + { + "address": { + "socket_address": { + "protocol": "TCP", + "address": "0.0.0.0", + "port_value": {{ $element.envoyPort | default (add 8790 $index) }} + } + }, + "filter_chains": [ + { + "filters": [ + { + "name": "envoy.filters.network.http_connection_manager", + "config": { + "codec_type": "AUTO", + "stat_prefix": "stats", + "route_config": { + "virtual_hosts": [ + { + "name": "backend", + "domains": [ + "*" + ], + "routes": [ + { + "match": { + "prefix": "/" + }, + "route": { +{{- if $element.supportStreaming }} + "timeout": "0s", +{{- end }} +{{- if and ($element.envoyTimeout) (not $element.supportStreaming) }} + "timeout": "{{ $element.envoyTimeout }}", +{{- end }} + "cluster": "{{ $.Values.app }}-{{ $index }}" + } + } + ] + } + ] + }, + "http_filters": { + "name": "envoy.filters.http.router" + } + } + } + ] + } + ] + }, + {{- end }} + ] + } + } +--- +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/vertical-pod-autoscaler.yaml new file mode 100644 index 00000000000..9591354bdc2 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/vertical-pod-autoscaler.yaml @@ -0,0 +1,27 @@ +{{ $VerticalPodAutoScalingEnabled := include "VerticalPodAutoScalingEnabled" . }} +{{- if eq "true" $VerticalPodAutoScalingEnabled -}} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" . }}-vpa + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: +{{- if .Values.verticalPodScaling.resourcePolicy }} + resourcePolicy: +{{ toYaml .Values.verticalPodScaling.resourcePolicy}} +{{- end }} +{{- if .Values.verticalPodScaling.updatePolicy }} + updatePolicy: +{{ toYaml .Values.verticalPodScaling.updatePolicy}} +{{- end }} + targetRef: + apiVersion: argoproj.io/v1alpha1 + kind: Rollout + name: {{ include ".Chart.Name .fullname" $ }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml new file mode 100644 index 00000000000..2d3e7bae0fe --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml @@ -0,0 +1,41 @@ +{{- if .Values.winterSoldier.enabled }} +apiVersion: {{ $.Values.winterSoldier.apiVersion }} +kind: Hibernator +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-hibernator + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + {{- if .Values.winterSoldier.labels }} +{{ toYaml .Values.winterSoldier.labels | indent 4 }} + {{- end }} +{{- if .Values.winterSoldier.annotations }} + annotations: +{{ toYaml .Values.winterSoldier.annotations | indent 4 }} +{{- end }} +spec: + timeRangesWithZone: +{{ toYaml $.Values.winterSoldier.timeRangesWithZone | indent 4}} + selectors: + - inclusions: + - objectSelector: + name: {{ include ".Chart.Name .fullname" $ }} + type: {{ .Values.winterSoldier.type | quote }} + fieldSelector: +{{toYaml $.Values.winterSoldier.fieldSelector | indent 14}} + namespaceSelector: + name: {{ $.Release.Namespace }} + exclusions: [] + action: {{ $.Values.winterSoldier.action }} + {{- if eq .Values.winterSoldier.action "scale" }} + {{- if .Values.winterSoldier.targetReplicas }} + targetReplicas: {{ $.Values.winterSoldier.targetReplicas }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/test_values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/test_values.yaml new file mode 100644 index 00000000000..7077cd43276 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/test_values.yaml @@ -0,0 +1,648 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +rolloutLabels: + name: abhinav + Company: Devtron + Job: DevOps + +rolloutAnnotations: + name: abhinav + Company: Devtron + Job: DevOps + +containerSpec: + lifecycle: + enabled: true + preStop: + exec: + command: ["sleep","10"] + postStart: + httpGet: + host: example.com + path: /example + port: 90 + +imagePullSecrets: + - test1 + - test2 +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyTimeout: 15 + targetPort: 8080 + envoyPort: 8799 + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + servicemonitor: + enabled: true + path: /abc + scheme: 'http' + interval: 30s + scrapeTimeout: 20s + metricRelabelings: + - sourceLabels: [namespace] + regex: '(.*)' + replacement: myapp + targetLabel: target_namespace + + - name: app1 + port: 8090 + targetPort: 1234 + servicePort: 8080 + useGRPC: true + servicemonitor: + enabled: true + - name: app2 + port: 8091 + servicePort: 8081 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: + Key: + # Key: kops.k8s.io/instancegroup + Values: + + +image: + pullPolicy: IfNotPresent + +autoscaling: + enabled: true + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 + behavior: {} +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +secret: + enabled: false + +service: + enabled: true + type: ClusterIP + # name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + +server: + deployment: + image_tag: 1-95af053 + image: "" +deploymentType: "RECREATE" + +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + autoLabelSelector: true + customLabelSelector: + foo: bar + +EnvVariables: + - name: FLASK_ENV + value: qa + +EnvVariablesFromSecretKeys: [] + # - name: ENV_NAME + # secretName: SECRET_NAME + # keyName: SECRET_KEY + +EnvVariablesFromCongigMapKeys: [] + # - name: ENV_NAME + # configMapName: CONFIG_MAP_NAME + # keyName: CONFIG_MAP_KEY + +LivenessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + - name: Custom-Header2 + value: xyz + + +winterSoldier: + apiVersion: pincher.devtron.ai/v1alpha1 + enabled: true + annotations: {} + labels: {} + timeRangesWithZone: + timeZone: "Asia/Kolkata" + timeRanges: + - timeFrom: 00:00 + timeTo: 23:59:59 + weekdayFrom: Sat + weekdayTo: Sun + - timeFrom: 00:00 + timeTo: 08:00 + weekdayFrom: Mon + weekdayTo: Fri + - timeFrom: 20:00 + timeTo: 23:59:59 + weekdayFrom: Mon + weekdayTo: Fri + action: scale + targetReplicas: [1,1,1] + fieldSelector: + - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + + +ReadinessProbe: + Path: / + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: + - name: Custom-Header + value: abc + +StartupProbe: + Path: "/" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + + +prometheusRule: + enabled: true + additionalLabels: {} + namespace: "" + rules: + # These are just examples rules, please adapt them to your needs + - alert: TooMany500s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 5XXs + summary: More than 5% of the all requests did return 5XX, this require your attention + - alert: TooMany400s + expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + for: 1m + labels: + severity: critical + annotations: + description: Too many 4XXs + summary: More than 5% of the all requests did return 4XX, this require your attention + + +ingress: + enabled: true + className: nginx + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" +# Old Ingress Format +# host: "ingress-example.com" +# path: "/app" + +# New Ingress Format + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + additionalBackends: + - path: /example1 + pathType: "ImplementationSpecific" + backend: + service: + name: test-service + port: + number: 80 + + tls: [] +### Legacy Ingress Format ## +# host: abc.com +# path: "/" +# pathType: "ImplementationSpecific" + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: nginx-internal + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + additionalBackends: + - path: /internal + pathType: "ImplementationSpecific" + backend: + service: + name: test-service-internal + port: + number: 80 + + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +dbMigrationConfig: + enabled: false + +command: + workingDir: /app + enabled: false + value: ["ls"] + +args: + enabled: false + value: [] + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 1 + memory: 200Mi + requests: + cpu: 0.10 + memory: 100Mi + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: false + secrets: + - name: config-secret-1 + type: environment + external: false + externalType: AWSSecretsManager + esoSecretData: + secretStore: + aws: + service: SecretsManager + region: us-east-1 + auth: + secretRef: + accessKeyIDSecretRef: + name: awssm-secret + key: access-key + secretAccessKeySecretRef: + name: awssm-secret + key: secret-access-key + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + data: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + - name: config-secret-2 + type: environment + external: false + externalType: ESO_HashiCorpVault + esoSecretData: + secretStore: + vault: + server: "http://my.vault.server:8200" + path: "secret" + version: "v2" + auth: + tokenSecretRef: + name: vault-token + key: token + esoData: + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + - secretKey: prod-mysql-password + key: secrets/prod-mysql-secrets + property: prodPassword + date: + key1: key1value-1 + key2: key2value-1 + key3: key3value-1 + +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + - command: ["sh", "-c", "chown -R 1000:1000 logs"] + reuseContainerImage: true + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + privileged: true + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + - name: init-migrate + image: busybox:latest + command: ["sh", "-c", "chown -R 1000:1000 logs"] + volumeMounts: + - mountPath: /usr/local/airflow/logs + name: logs-data + securityContext: + capabilities: + drop: + - ALL + +containers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + #- name: volume-mount-hack + # image: busybox + # command: ["sh", "-c", "chown -R 1000:1000 logs"] + # volumeMounts: + # - mountPath: /usr/local/airflow/logs +# name: logs-data + + +rawYaml: [] +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + configMapName: "" + lifecycle: {} + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +podDisruptionBudget: {} + # minAvailable: 1 + # maxUnavailable: 1 + + ## Node tolerations for server scheduling to nodes with taints + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +## + +tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" +# effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +appMetrics: false +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "test1" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: + kubernetes.io/service-account.name: build-robot +containerSecurityContext: + allowPrivilegeEscalation: false +privileged: true +hostAliases: [] +# - ip: "127.0.0.1" +# hostnames: +# - "foo.local" + +deployment: + strategy: + blueGreen: + autoPromotionSeconds: 30 + scaleDownDelaySeconds: 30 + previewReplicaCount: 1 + autoPromotionEnabled: false + rolling: + maxSurge: "25%" + maxUnavailable: 1 + canary: + maxSurge: "25%" + maxUnavailable: 1 + steps: + - setWeight: 25 + - pause: + duration: 15 # 1 min + - setWeight: 50 + - pause: + duration: 15 # 1 min + - setWeight: 75 + - pause: + duration: 15 # 1 min + recreate: {} + +persistentVolumeClaim: + name: kamal-pvc + resources: + requests: + storage: 5Gi + storageClassName: my-storage-class + +affinity: + enabled: false + values: + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: topology.kubernetes.io/zone diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/values.yaml new file mode 100644 index 00000000000..bd87d4fc2ec --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/values.yaml @@ -0,0 +1,635 @@ +# Default values for myapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +MinReadySeconds: 5 +MaxSurge: 1 +MaxUnavailable: 0 +GracePeriod: 30 +ContainerPort: + - name: app + port: 8080 + servicePort: 80 + envoyPort: 8799 + envoyTimeout: 15s + useHTTP2: false + supportStreaming: false + idleTimeout: 1800s + protocol: TCP + # servicemonitor: + # enabled: true + # path: /abc + # scheme: 'http' + # interval: 30s +# scrapeTimeout: 20s +# metricRelabelings: +# - sourceLabels: [namespace] +# regex: '(.*)' +# replacement: myapp +# targetLabel: target_namespace + + - name: app1 + port: 8090 + servicePort: 8080 + useGRPC: true + +pauseForSecondsBeforeSwitchActive: 30 +waitForSecondsBeforeScalingDown: 30 +autoPromotionSeconds: 30 + +Spec: + Affinity: #required/preferred + Key: +# Key: kops.k8s.io/instancegroup + Values: + + +affinity: + enabled: false + values: {} + + +image: + pullPolicy: IfNotPresent + +restartPolicy: Always + +autoscaling: + enabled: false + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 70 + TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} + behavior: {} + containerResource: + enable: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# scaleUp: +# stabilizationWindowSeconds: 0 +# policies: +# - type: Percent +# value: 100 +# periodSeconds: 15 +# - type: Pods +# value: 4 +# periodSeconds: 15 +# selectPolicy: Max + extraMetrics: [] +# - external: +# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages +# metricSelector: +# matchLabels: +# resource.labels.subscription_id: echo-read +# targetAverageValue: "2" +# type: External +# + +kedaAutoscaling: + enabled: false + envSourceContainerName: "" # Optional. Default: .spec.template.spec.containers[0] + cooldownPeriod: 300 # Optional. Default: 300 seconds + minReplicaCount: 1 + maxReplicaCount: 2 + idleReplicaCount: 0 # Optional. Must be less than minReplicaCount + pollingInterval: 30 # Optional. Default: 30 seconds + # The fallback section is optional. It defines a number of replicas to fallback to if a scaler is in an error state. + fallback: {} # Optional. Section to specify fallback options + # failureThreshold: 3 # Mandatory if fallback section is included + # replicas: 6 + advanced: {} + # horizontalPodAutoscalerConfig: # Optional. Section to specify HPA related options + # behavior: # Optional. Use to modify HPA's scaling behavior + # scaleDown: + # stabilizationWindowSeconds: 300 + # policies: + # - type: Percent + # value: 100 + # periodSeconds: 15 + triggers: [] + triggerAuthentication: + enabled: false + name: "" + spec: {} + authenticationRef: {} + +secret: + enabled: false + +service: + enabled: true + type: ClusterIP +# name: "1234567890123456789012345678901234567890123456789012345678901234567890" + annotations: {} + # test1: test2 + # test3: test4 + sessionAffinity: + enabled: false + sessionAffinityConfig: {} + + +server: + deployment: + image_tag: 1-95af053 + image: "" + +EnvVariablesFromFieldPath: [] +# - name: POD_NAME +# fieldPath: metadata.name + +EnvVariables: [] + # - name: FLASK_ENV + # value: qa + +EnvVariablesFromSecretKeys: [] + # - name: ENV_NAME + # secretName: SECRET_NAME + # keyName: SECRET_KEY + +EnvVariablesFromConfigMapKeys: [] + # - name: ENV_NAME + # configMapName: CONFIG_MAP_NAME + # keyName: CONFIG_MAP_KEY + +LivenessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + +ReadinessProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + scheme: "" + httpHeaders: [] +# - name: Custom-Header +# value: abc + +StartupProbe: + Path: "" + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + failureThreshold: 3 + httpHeaders: [] + command: [] + tcp: false + +prometheus: + release: monitoring + +servicemonitor: + additionalLabels: {} + + +prometheusRule: + enabled: false + additionalLabels: {} + namespace: "" +# rules: +# # These are just examples rules, please adapt them to your needs +# - alert: TooMany500s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 5XXs +# summary: More than 5% of the all requests did return 5XX, this require your attention +# - alert: TooMany400s +# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 +# for: 1m +# labels: +# severity: critical +# annotations: +# description: Too many 4XXs +# summary: More than 5% of the all requests did return 4XX, this require your attention +# + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} +# nginx.ingress.kubernetes.io/rewrite-target: / +# nginx.ingress.kubernetes.io/ssl-redirect: "false" +# kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# nginx.ingress.kubernetes.io/canary: "true" +# nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.local + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.local + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressInternal: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # nginx.ingress.kubernetes.io/canary: "true" + # nginx.ingress.kubernetes.io/canary-weight: "10" + + hosts: + - host: chart-example1.internal + pathType: "ImplementationSpecific" + paths: + - /example1 + - host: chart-example2.internal + pathType: "ImplementationSpecific" + paths: + - /example2 + - /example2/healthz + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +istio: + enable: false + gateway: + enabled: false + labels: {} + annotations: {} + host: "" + tls: + enabled: false + secretName: "" + virtualService: + enabled: false + labels: {} + annotations: {} + gateways: [] + hosts: [] + http: [] + # - match: + # - uri: + # prefix: /v1 + # - uri: + # prefix: /v2 + # timeout: 12 + # headers: + # request: + # add: + # x-some-header: "value" + # retries: + # attempts: 2 + # perTryTimeout: 3s + destinationRule: + enabled: false + labels: {} + annotations: {} + subsets: [] + trafficPolicy: {} + peerAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + mtls: + mode: "" + portLevelMtls: {} + requestAuthentication: + enabled: false + labels: {} + annotations: {} + selector: + enabled: false + jwtRules: [] + authorizationPolicy: + enabled: false + labels: {} + annotations: {} + action: + provider: {} + rules: [] + +networkPolicy: + enabled: false + annotations: {} + labels: {} + podSelector: + matchExpressions: [] + matchLabels: {} + policyTypes: [] + ingress: [] + egress: [] + +hibernator: + enable: false + +dbMigrationConfig: + enabled: false + +command: + enabled: false + value: [] + +args: + enabled: false + value: [] + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + +volumeMounts: [] +# - name: log-volume +# mountPath: /var/log + +volumes: [] +# - name: log-volume +# emptyDir: {} + + +nodeSelector: {} + +# If you need to provide some extra specs for pod which are not included by default in deployment template +# then provide them here +podExtraSpecs: {} + +# If you need to provide some extra specs for main container which are not included by default in deployment template +# then provide them here +containerExtraSpecs: {} + +#used for deployment algo selection +orchestrator.deploymant.algo: 1 + +ConfigMaps: + enabled: false + maps: [] +# - name: config-map-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-map-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 +# key3: abc-2 +# - name: config-map-3 +# type: environment +# external: true +# mountPath: /etc/config/3 +# data: [] +# - name: config-map-4 +# type: volume +# external: true +# mountPath: /etc/config/4 +# data: [] + + +ConfigSecrets: + enabled: false + secrets: [] +# - name: config-secret-1 +# type: environment +# external: false +# data: +# key1: key1value-1 +# key2: key2value-1 +# key3: key3value-1 +# - name: config-secret-2 +# type: volume +# external: false +# mountPath: /etc/config/2 +# data: +# key1: | +# club : manchester utd +# nation : england +# key2: abc-2 + + +initContainers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . + # volumeMounts: + # - mountPath: /usr/local/airflow/logs + # name: logs-data + # # Uncomment below line ONLY IF you want to reuse the container image. + # # This will assign your application's docker image to init container. + # reuseContainerImage: true + +containers: [] + ## Additional init containers to run before the Scheduler pods. + ## for example, be used to run a sidecar that chown Logs storage . +# - name: volume-mount-hack +# image: busybox +# command: ["sh", "-c", "chown -R 1000:1000 logs"] +# volumeMounts: +# - mountPath: /usr/local/airflow/logs +# name: logs-data +# resizePolicy: +# - resourceName: cpu +# restartPolicy: NotRequired +# - resourceName: memory +# restartPolicy: RestartContainer + + +rawYaml: [] +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP +# - apiVersion: v1 +# kind: Service +# metadata: +# annotations: +# labels: +# app: sample-metrics-app +# name: sample-metrics-app +# namespace: default +# spec: +# ports: +# - name: web +# port: 80 +# protocol: TCP +# targetPort: 8080 +# selector: +# app: sample-metrics-app +# sessionAffinity: None +# type: ClusterIP + +winterSoldier: + enabled: false + apiVersion: pincher.devtron.ai/v1alpha1 + labels: {} + annotations: {} + timeRangesWithZone: {} + # timeZone: "Asia/Kolkata" + # timeRanges: [] + action: sleep + targetReplicas: [] + fieldSelector: [] + type: Rollout + # - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) + +topologySpreadConstraints: [] + +schedulerName: "" + +envoyproxy: + image: docker.io/envoyproxy/envoy:v1.16.0 + lifecycle: {} + configMapName: "" + resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +ambassadorMapping: + enabled: false + # labels: + # key1: value1 + # prefix: / + # ambassadorId: 1234 + # hostname: devtron.example.com + # rewrite: /foo/ + # retryPolicy: + # retry_on: "5xx" + # num_retries: 10 + # cors: + # origins: http://foo.example,http://bar.example + # methods: POST, GET, OPTIONS + # headers: Content-Type + # credentials: true + # exposed_headers: X-Custom-Header + # max_age: "86400" + # weight: 10 + # method: GET + # extraSpec: + # method_regex: true + # headers: + # x-quote-mode: backend + # x-random-header: devtron + # tls: + # context: httpd-context + # create: true + # secretName: httpd-secret + # hosts: + # - anything.example.info + # - devtron.example.com + # extraSpec: + # min_tls_version: v1.2 + +containerSpec: + lifecycle: + enabled: false + preStop: {} +# exec: +# command: ["sleep","10"] + postStart: {} +# httpGet: +# host: example.com +# path: /example +# port: 90 + +podDisruptionBudget: {} +# minAvailable: 1 +# maxUnavailable: 1 + + ## Node tolerations for server scheduling to nodes with taints + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + ## + +podSecurityContext: {} + # runAsUser: 1000 + # runAsGroup: 3000 + # fsGroup: 2000 + +containerSecurityContext: {} + # allowPrivilegeEscalation: false +## Pods Service Account +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## +serviceAccount: + ## @param serviceAccount.create Enable creation of ServiceAccount for pods + ## + create: false + ## @param serviceAccount.name The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the `.Chart.Name .fullname` template + name: "" + ## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. + ## Only used if `create` is `true`. + ## + annotations: {} + +tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + +imagePullSecrets: [] + # - test1 + # - test2 + + +persistentVolumeClaim: {} + + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql b/scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql new file mode 100644 index 00000000000..858040b89e2 --- /dev/null +++ b/scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql @@ -0,0 +1,5 @@ +DELETE FROM global_strategy_metadata_chart_ref_mapping WHERE chart_ref_id=(select id from chart_ref where version='4.19.0' and name is null); + +DELETE FROM "public"."chart_ref" WHERE ("location" = 'reference-chart_4-19-0' AND "version" = '4.19.0'); + +UPDATE "public"."chart_ref" SET "is_default" = 't' WHERE "location" = 'reference-chart_4-19-0' AND "version" = '4.19.0'; \ No newline at end of file diff --git a/scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql b/scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql new file mode 100644 index 00000000000..370ecd61eed --- /dev/null +++ b/scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql @@ -0,0 +1,9 @@ +INSERT INTO "public"."chart_ref" ("location", "version","deployment_strategy_path", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by") VALUES + ('reference-chart_4-19-0', '4.19.0','pipeline-values.yaml', 'f', 't', 'now()', 1, 'now()', 1); + + +INSERT INTO global_strategy_metadata_chart_ref_mapping ("global_strategy_metadata_id", "chart_ref_id", "active", "created_on", "created_by", "updated_on", "updated_by","default") +VALUES (1,(select id from chart_ref where version='4.19.0' and name is null), true, now(), 1, now(), 1,true), +(2,(select id from chart_ref where version='4.19.0' and name is null), true, now(), 1, now(), 1,false), +(3,(select id from chart_ref where version='4.19.0' and name is null), true, now(), 1, now(), 1,false), +(4,(select id from chart_ref where version='4.19.0' and name is null), true, now(), 1, now(), 1,false); \ No newline at end of file diff --git a/scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql b/scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql new file mode 100644 index 00000000000..95b64648047 --- /dev/null +++ b/scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql @@ -0,0 +1,5 @@ +DELETE FROM global_strategy_metadata_chart_ref_mapping WHERE chart_ref_id=(select id from chart_ref where version='4.20.0' and name is null); + +DELETE FROM "public"."chart_ref" WHERE ("location" = 'reference-chart_4-20-0' AND "version" = '4.20.0'); + +UPDATE "public"."chart_ref" SET "is_default" = 't' WHERE "location" = 'reference-chart_4-20-0' AND "version" = '4.20.0'; \ No newline at end of file diff --git a/scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql b/scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql new file mode 100644 index 00000000000..4b3f818cab7 --- /dev/null +++ b/scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql @@ -0,0 +1,9 @@ +INSERT INTO "public"."chart_ref" ("location", "version","deployment_strategy_path", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by") VALUES + ('reference-chart_4-20-0', '4.20.0','pipeline-values.yaml', 'f', 't', 'now()', 1, 'now()', 1); + + +INSERT INTO global_strategy_metadata_chart_ref_mapping ("global_strategy_metadata_id", "chart_ref_id", "active", "created_on", "created_by", "updated_on", "updated_by","default") +VALUES (1,(select id from chart_ref where version='4.20.0' and name is null), true, now(), 1, now(), 1,true), +(2,(select id from chart_ref where version='4.20.0' and name is null), true, now(), 1, now(), 1,false), +(3,(select id from chart_ref where version='4.20.0' and name is null), true, now(), 1, now(), 1,false), +(4,(select id from chart_ref where version='4.20.0' and name is null), true, now(), 1, now(), 1,false); \ No newline at end of file diff --git a/scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql b/scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql new file mode 100644 index 00000000000..0d23e81af2c --- /dev/null +++ b/scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql @@ -0,0 +1,3 @@ +DELETE FROM global_strategy_metadata_chart_ref_mapping WHERE chart_ref_id=(select id from chart_ref where version='4.20.0' and name='Deployment'); + +DELETE FROM "public"."chart_ref" WHERE ("location" = 'deployment-chart_4-18-0' AND "version" = '4.20.0'); \ No newline at end of file diff --git a/scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql b/scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql new file mode 100644 index 00000000000..3a4b09171d1 --- /dev/null +++ b/scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql @@ -0,0 +1,7 @@ +UPDATE chart_ref SET is_default=false; +INSERT INTO "public"."chart_ref" ("name","location", "version", "deployment_strategy_path","is_default", "active", "created_on", "created_by", "updated_on", "updated_by") VALUES + ('Deployment','deployment-chart_4-20-0', '4.20.0','pipeline-values.yaml','t', 't', 'now()', 1, 'now()', 1); + +INSERT INTO global_strategy_metadata_chart_ref_mapping ("global_strategy_metadata_id", "chart_ref_id", "active", "created_on", "created_by", "updated_on", "updated_by","default") +VALUES (1,(select id from chart_ref where version='4.20.0' and name='Deployment'), true, now(), 1, now(), 1,true), +(4,(select id from chart_ref where version='4.20.0' and name='Deployment'), true, now(), 1, now(), 1,false); \ No newline at end of file From fba47c9e429dd40b87713fc90eac4e1ca3f05500 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:44:39 +0530 Subject: [PATCH 58/65] migration fix (#6010) --- scripts/sql/029800_021_cluster_terminal_images.down.sql | 4 +++- scripts/sql/029800_021_cluster_terminal_images.up.sql | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/sql/029800_021_cluster_terminal_images.down.sql b/scripts/sql/029800_021_cluster_terminal_images.down.sql index afa080f1f03..2699a0e08d5 100644 --- a/scripts/sql/029800_021_cluster_terminal_images.down.sql +++ b/scripts/sql/029800_021_cluster_terminal_images.down.sql @@ -1,4 +1,6 @@ UPDATE "public"."attributes" SET value = '[{"groupId":"latest","groupRegex":"v1\\.2[4-8]\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', updated_on = NOW() -WHERE key = 'DEFAULT_TERMINAL_IMAGE_LIST'; \ No newline at end of file +WHERE key = 'DEFAULT_TERMINAL_IMAGE_LIST'; + +ALTER TABLE attributes ALTER COLUMN value TYPE VARCHAR(5000); \ No newline at end of file diff --git a/scripts/sql/029800_021_cluster_terminal_images.up.sql b/scripts/sql/029800_021_cluster_terminal_images.up.sql index 7e43cdaa7d3..ff23c1f9219 100644 --- a/scripts/sql/029800_021_cluster_terminal_images.up.sql +++ b/scripts/sql/029800_021_cluster_terminal_images.up.sql @@ -1,3 +1,5 @@ +ALTER TABLE attributes ALTER COLUMN value TYPE VARCHAR(10000); + UPDATE "public"."attributes" SET value = '[{"groupId":"latest","groupRegex":"v1\\.(30|31|32)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} {"groupId":"v1.28","groupRegex":"v1\\.(27|28|29)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.28","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.28","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.28","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.25","groupRegex":"v1\\.(24|25|26)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.25","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.25","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.25","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', updated_on = NOW() From d125a9557a0a623556cba60a7f39099959fd23b4 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:55:55 +0530 Subject: [PATCH 59/65] migration fix (#6015) --- scripts/sql/029800_021_cluster_terminal_images.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sql/029800_021_cluster_terminal_images.up.sql b/scripts/sql/029800_021_cluster_terminal_images.up.sql index ff23c1f9219..688067af392 100644 --- a/scripts/sql/029800_021_cluster_terminal_images.up.sql +++ b/scripts/sql/029800_021_cluster_terminal_images.up.sql @@ -1,6 +1,6 @@ ALTER TABLE attributes ALTER COLUMN value TYPE VARCHAR(10000); UPDATE "public"."attributes" -SET value = '[{"groupId":"latest","groupRegex":"v1\\.(30|31|32)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} {"groupId":"v1.28","groupRegex":"v1\\.(27|28|29)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.28","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.28","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.28","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.25","groupRegex":"v1\\.(24|25|26)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.25","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.25","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.25","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', +SET value = '[{"groupId":"latest","groupRegex":"v1\\.(30|31|32)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:latest","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:latest","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:latest","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.28","groupRegex":"v1\\.(27|28|29)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.28","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.28","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.28","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.25","groupRegex":"v1\\.(24|25|26)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.25","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.25","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.25","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]} ,{"groupId":"v1.22","groupRegex":"v1\\.(21|22|23)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.22","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.22","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.22","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."}]},{"groupId":"v1.19","groupRegex":"v1\\.(18|19|20)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.19","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"},{"image":"quay.io/devtron/alpine-k8s-utils:1.19","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.19","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]},{"groupId":"v1.16","groupRegex":"v1\\.(15|16|17)\\..+","imageList":[{"image":"quay.io/devtron/ubuntu-k8s-utils:1.16","name":"Ubuntu: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on ubuntu OS"}, {"image":"quay.io/devtron/alpine-k8s-utils:1.16","name":"Alpine: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on alpine OS"},{"image":"quay.io/devtron/centos-k8s-utils:1.16","name":"CentOS: Kubernetes utilites","description":"Contains kubectl, helm, curl, git, busybox, wget, jq, nslookup, telnet on Cent OS"},{"image":"quay.io/devtron/alpine-netshoot:latest","name":"Alpine: Netshoot","description":"Contains Docker + Kubernetes network troubleshooting utilities."},{"image":"quay.io/devtron/k9s-k8s-utils:latest","name":"K9s: Kubernetes CLI","description": " Kubernetes CLI To Manage Your Clusters In Style!"}]}]', updated_on = NOW() WHERE key = 'DEFAULT_TERMINAL_IMAGE_LIST'; \ No newline at end of file From dc012c093969dd6d0d406bcbc4a8289fc96d5e82 Mon Sep 17 00:00:00 2001 From: kamal-devtron <128121299+kamal-devtron@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:54:55 +0530 Subject: [PATCH 60/65] Charts hotfix (#1992) (#6018) * Synced all chart changes * Updated VPA in sts chart * chnages in sts SM --- .../templates/ambassador.yaml | 13 +- .../templates/configmap.yaml | 7 +- .../templates/deployment.yaml | 611 ++++++++++++++++++ .../templates/externalsecrets.yaml | 14 +- .../templates/hpa.yaml | 91 ++- .../templates/ingress.yaml | 11 + .../templates/keda-autoscaling.yaml | 16 +- .../templates/poddisruptionbudget.yaml | 10 + .../templates/pre-sync-job.yaml | 6 + .../templates/prometheusrules.yaml | 15 +- .../templates/secret.yaml | 19 +- .../templates/service.yaml | 8 + .../templates/serviceaccount.yaml | 7 +- .../templates/servicemonitor.yaml | 68 +- .../templates/winter-soldier.yaml | 4 + .../deployment-chart_4-20-0/test_values.yaml | 15 +- .../deployment-chart_4-20-0/values.yaml | 16 +- .../templates/ambassador.yaml | 10 +- .../templates/configmap.yaml | 7 +- .../templates/externalsecrets.yaml | 14 +- .../reference-chart_4-20-0/templates/hpa.yaml | 7 +- .../templates/ingress.yaml | 11 + .../templates/keda-autoscaling.yaml | 28 + .../templates/poddisruptionbudget.yaml | 10 + .../templates/pre-sync-job.yaml | 6 + .../templates/prometheusrules.yaml | 15 +- .../templates/secret.yaml | 19 +- .../templates/service.yaml | 8 + .../templates/serviceaccount.yaml | 7 +- .../templates/servicemonitor.yaml | 68 +- .../templates/winter-soldier.yaml | 4 + .../statefulset-chart_5-1-0/app-values.yaml | 12 +- .../templates/_helpers.tpl | 8 + .../templates/externalsecrets.yaml | 9 + .../templates/hpa.yaml | 22 + .../templates/keda-autoscaling.yaml | 11 + .../templates/service.yaml | 18 +- .../templates/servicemonitor.yaml | 2 +- .../templates/statefulset.yaml | 132 +++- .../templates/vertical-pod-autoscaler.yaml | 27 + .../statefulset-chart_5-1-0/values.yaml | 13 +- 41 files changed, 1361 insertions(+), 38 deletions(-) create mode 100644 scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/vertical-pod-autoscaler.yaml diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml index 5875da84ba8..9d4a431c26d 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ambassador.yaml @@ -5,10 +5,16 @@ apiVersion: getambassador.io/v3alpha1 kind: Mapping metadata: - name: {{ include ".Chart.Name .fullname" $ }}-mapping + {{- if .name }} + name: {{ .name }} + {{- else }} + name: {{ include ".Chart.Name .fullname" $ }}-mapping + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} release: {{ $.Release.Name }} releaseVersion: {{ $.Values.releaseVersion | quote }} pipelineName: {{ $.Values.pipelineName }} @@ -57,6 +63,8 @@ kind: TLSContext metadata: name: {{ .tls.context }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} app: {{ template ".Chart.Name .name" $ }} chart: {{ template ".Chart.Name .chart" $ }} release: {{ $.Release.Name }} @@ -65,6 +73,9 @@ metadata: {{- if .tls.labels }} {{ toYaml .tls.labels | nindent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: {{- if .tls.secretName }} secret: {{ .tls.secretName }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml index 72d5ca84798..4e7879665e4 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/configmap.yaml @@ -6,8 +6,13 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ .name}}-{{ $.Values.app }} -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} data: diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml index 558890a3291..95f796b3398 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/deployment.yaml @@ -636,3 +636,614 @@ spec: {{- if eq .Values.deploymentType "RECREATE" }} type: "Recreate" {{- end }} +{{- if $.Values.secondaryWorkload.enabled }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + releaseVersion: {{ $.Values.releaseVersion | quote }} + pipelineName: {{ .Values.pipelineName }} +{{- if .Values.deploymentLabels }} +{{ toYaml .Values.deploymentLabels | indent 4 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} + +{{- if .Values.deploymentAnnotations }} + annotations: +{{ toYaml .Values.deploymentAnnotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: +{{- if .Values.customMatchLabels }} +{{ toYaml .Values.customMatchLabels | indent 6 }} +{{- end }} + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + replicas: {{ $.Values.secondaryWorkload.replicaCount | default 1 }} + minReadySeconds: {{ $.Values.MinReadySeconds }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + labels: + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 8 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | indent 8 }} +{{- end }} + spec: +{{- if $.Values.podExtraSpecs }} +{{ toYaml .Values.podExtraSpecs | indent 6 }} +{{- end }} + terminationGracePeriodSeconds: {{ $.Values.GracePeriod }} + restartPolicy: Always +{{- if $.Values.hostAliases }} + hostAliases: +{{ toYaml .Values.hostAliases | indent 8 }} +{{- end }} +{{- with $.Values.secondaryWorkload }} +{{- if and .Spec.Affinity.Key .Spec.Affinity.Values }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: {{ .Spec.Affinity.Key }} + operator: In + values: + - {{ .Spec.Affinity.Values | default "nodes" }} +{{- else if .affinity.enabled }} + affinity: +{{ toYaml .affinity.values | indent 8 }} +{{- end }} +{{- end }} +{{- if $.Values.serviceAccountName }} + serviceAccountName: {{ $.Values.serviceAccountName }} +{{- else }} + serviceAccountName: {{ template "serviceAccountName" . }} +{{- end }} +{{- if $.Values.schedulerName }} + schedulerName: {{ .Values.schedulerName }} +{{- end }} + {{- if $.Values.secondaryWorkload.tolerations }} + tolerations: +{{ toYaml $.Values.secondaryWorkload.tolerations | indent 8 }} + {{- end }} +{{- if $.Values.imagePullSecrets}} + imagePullSecrets: + {{- range .Values.imagePullSecrets }} + - name: {{ . }} + {{- end }} +{{- end}} +{{- if $.Values.topologySpreadConstraints }} + topologySpreadConstraints: +{{- range $.Values.topologySpreadConstraints }} + - maxSkew: {{ .maxSkew }} + topologyKey: {{ .topologyKey }} + whenUnsatisfiable: {{ .whenUnsatisfiable }} + {{- if semverCompare "<=1.30-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .minDomains }} + minDomains: {{ .minDomains }} + {{- end }} + {{- end }} + {{- if .nodeAffinityPolicy }} + nodeAffinityPolicy: {{ .nodeAffinityPolicy }} + {{- end }} + {{- if .nodeTaintsPolicy }} + nodeTaintsPolicy: {{ .nodeTaintsPolicy }} + {{- end }} + labelSelector: + matchLabels: + {{- if and .autoLabelSelector .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- else if .autoLabelSelector }} + app: {{ template ".Chart.Name .name" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} + {{- else if .customLabelSelector }} +{{ toYaml .customLabelSelector | indent 12 }} + {{- end }} +{{- end }} +{{- end }} +{{- if $.Values.topologySpreadConstraint }} + topologySpreadConstraints: +{{ toYaml .Values.topologySpreadConstraint }} +{{- end }} +{{- if $.Values.podSecurityContext }} + securityContext: +{{ toYaml .Values.podSecurityContext | indent 8 }} +{{- end }} +{{- if $.Values.restartPolicy }} + restartPolicy: {{ $.Values.restartPolicy }} +{{- end }} +{{- if $.Values.initContainers}} + initContainers: +{{- range $i, $c := .Values.initContainers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-init-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .args}} + args: +{{ toYaml .args | indent 12 -}} +{{- end}} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + containers: + - name: {{ $.Chart.Name }} + image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + {{- if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- if $.Values.containerSpec.lifecycle.postStart }} + postStart: +{{ toYaml $.Values.containerSpec.lifecycle.postStart | indent 12 -}} + {{- end }} + {{- end }} +{{- if and $.Values.containerSecurityContext $.Values.privileged }} + securityContext: + privileged: true +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- else if $.Values.privileged }} + securityContext: + privileged: true +{{- else if $.Values.containerSecurityContext }} + securityContext: +{{ toYaml .Values.containerSecurityContext | indent 12 }} +{{- end }} +{{- if $.Values.containerExtraSpecs }} +{{ toYaml .Values.containerExtraSpecs | indent 10 }} +{{- end }} +{{- if $.Values.resizePolicy }} + resizePolicy: +{{ toYaml .Values.resizePolicy | indent 12 }} +{{- end }} + ports: + {{- range $.Values.ContainerPort }} + - name: {{ .name}} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end}} +{{- if and $.Values.command.enabled $.Values.command.workingDir }} + workingDir: {{ $.Values.command.workingDir }} +{{- end}} +{{- if and $.Values.command.value $.Values.command.enabled}} + command: +{{ toYaml $.Values.command.value | indent 12 -}} +{{- end}} +{{- if and $.Values.args.value $.Values.args.enabled}} + args: +{{ toYaml $.Values.args.value | indent 12 -}} +{{- end }} + env: + - name: CONFIG_HASH + value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }} + - name: SECRET_HASH + value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }} + - name: DEVTRON_APP_NAME + value: {{ template ".Chart.Name .name" $ }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: DEVTRON_CONTAINER_REPO + value: "{{ .Values.server.deployment.image }}" + - name: DEVTRON_CONTAINER_TAG + value: "{{ .Values.server.deployment.image_tag }}" + {{- range $.Values.EnvVariablesFromFieldPath }} + - name: {{ .name }} + valueFrom: + fieldRef: + fieldPath: {{ .fieldPath }} + {{- end}} + {{- range $.Values.EnvVariables }} + {{- if and .name .value }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromSecretKeys }} + {{- if and .name .secretName .keyName }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- range $.Values.EnvVariablesFromConfigMapKeys }} + {{- if and .name .configMapName .keyName }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ .configMapName }} + key: {{ .keyName }} + {{- end }} + {{- end }} + {{- if or (and ($hasCMEnvExists) (.Values.ConfigMaps.enabled)) (and ($hasSecretEnvExists) (.Values.ConfigSecrets.enabled)) }} + envFrom: + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "environment" }} + - configMapRef: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "environment" }} + - secretRef: + {{if eq .external true}} + name: {{ .name }} + {{else if eq .external false}} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + +{{- if or $.Values.LivenessProbe.Path $.Values.LivenessProbe.command $.Values.LivenessProbe.tcp $.Values.LivenessProbe.grpc }} + livenessProbe: +{{- if $.Values.LivenessProbe.Path }} + httpGet: + path: {{ $.Values.LivenessProbe.Path }} + port: {{ $.Values.LivenessProbe.port }} + scheme: {{ $.Values.LivenessProbe.scheme }} + {{- if $.Values.LivenessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.LivenessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.LivenessProbe.command }} + exec: + command: +{{ toYaml .Values.LivenessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.LivenessProbe.tcp }} + tcpSocket: + port: {{ $.Values.LivenessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.LivenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.LivenessProbe.periodSeconds }} + successThreshold: {{ $.Values.LivenessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.LivenessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.LivenessProbe.failureThreshold }} + {{- if $.Values.LivenessProbe.grpc }} + grpc: +{{ toYaml .Values.LivenessProbe.grpc | indent 14 }} + {{- end }} +{{- end }} +{{- if or $.Values.ReadinessProbe.Path $.Values.ReadinessProbe.command $.Values.ReadinessProbe.tcp $.Values.ReadinessProbe.grpc }} + readinessProbe: +{{- if $.Values.ReadinessProbe.Path }} + httpGet: + path: {{ $.Values.ReadinessProbe.Path }} + port: {{ $.Values.ReadinessProbe.port }} + scheme: {{ $.Values.ReadinessProbe.scheme }} + {{- if $.Values.ReadinessProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.ReadinessProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.ReadinessProbe.command }} + exec: + command: +{{ toYaml .Values.ReadinessProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.ReadinessProbe.tcp }} + tcpSocket: + port: {{ $.Values.ReadinessProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.ReadinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.ReadinessProbe.periodSeconds }} + successThreshold: {{ $.Values.ReadinessProbe.successThreshold }} + timeoutSeconds: {{ $.Values.ReadinessProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.ReadinessProbe.failureThreshold }} + {{- if $.Values.ReadinessProbe.grpc }} + grpc: +{{ toYaml .Values.ReadinessProbe.grpc | indent 14 }} + {{- end}} +{{- end }} + resources: +{{ toYaml $.Values.resources | trim | indent 12 }} +{{- if or $.Values.StartupProbe.Path $.Values.StartupProbe.command $.Values.StartupProbe.tcp $.Values.StartupProbe.grpc }} + startupProbe: +{{- if $.Values.StartupProbe.Path }} + httpGet: + path: {{ $.Values.StartupProbe.Path }} + port: {{ $.Values.StartupProbe.port }} + {{- if $.Values.StartupProbe.httpHeaders }} + httpHeaders: + {{- range $.Values.StartupProbe.httpHeaders}} + - name: {{.name}} + value: {{.value}} + {{- end}} + {{- end }} +{{- end }} +{{- if $.Values.StartupProbe.command }} + exec: + command: +{{ toYaml .Values.StartupProbe.command | indent 16 }} +{{- end}} +{{- if and $.Values.StartupProbe.tcp }} + tcpSocket: + port: {{ $.Values.StartupProbe.port }} +{{- end}} + initialDelaySeconds: {{ $.Values.StartupProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.StartupProbe.periodSeconds }} + successThreshold: {{ $.Values.StartupProbe.successThreshold }} + timeoutSeconds: {{ $.Values.StartupProbe.timeoutSeconds }} + failureThreshold: {{ $.Values.StartupProbe.failureThreshold }} + {{- if $.Values.StartupProbe.grpc }} + grpc: +{{ toYaml .Values.StartupProbe.grpc | indent 14 }} + {{- end}} +{{- end }} + volumeMounts: +{{- with .Values.volumeMounts }} +{{ toYaml . | trim | indent 12 }} +{{- end }} +{{- if $.Values.persistentVolumeClaim.name }} + - name: {{ .Values.persistentVolumeClaim.name }}-vol + mountPath: {{ .Values.persistentVolumeClaim.mountPath | default "/tmp" }} +{{- end}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{- range $k, $v := .data }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + {{- $cmName := .name -}} + {{- $cmMountPath := .mountPath -}} + {{- if eq .subPath false }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath }} + + {{- else }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} + {{- if and (.esoSubPath) (ne (len .esoSubPath) 0) }} + {{- range .esoSubPath }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ . }} + subPath: {{ . }} + {{- end }} + {{- else }} + {{- range .esoSecretData.esoData }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ .secretKey }} + subPath: {{ .secretKey }} + {{- end }} + {{- end }} + {{- else }} + {{- range $k, $v := .data }} # for others secrets the mount path will be .data[i].secretKey + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ $k}} + subPath: {{ $k}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} +{{- if $.Values.appMetrics }} + - name: envoy + image: {{ $.Values.envoyproxy.image | default "quay.io/devtron/envoy:v1.16.0"}} + {{- if $.Values.envoyproxy.lifecycle }} + lifecycle: +{{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} + {{- else if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- end }} + resources: +{{ toYaml $.Values.envoyproxy.resources | trim | indent 12 }} + ports: + - containerPort: 9901 + protocol: TCP + name: envoy-admin + {{- range $index, $element := .Values.ContainerPort }} + - name: {{ $element.name}} + containerPort: {{ $element.envoyPort | default (add 8790 $index) }} + protocol: TCP + {{- end }} + command: ["/usr/local/bin/envoy"] + args: ["-c", "/etc/envoy-config/envoy-config.json", "-l", "info", "--log-format", "[METADATA][%Y-%m-%d %T.%e][%t][%l][%n] %v"] + volumeMounts: + - name: {{ $.Values.envoyproxy.configMapName | default "envoy-config-volume" }} + mountPath: /etc/envoy-config/ +{{- if $.Values.envoyproxy.readinessProbe}} + readinessProbe: +{{ toYaml $.Values.envoyproxy.readinessProbe | indent 12}} +{{- end }} +{{- if $.Values.envoyproxy.livenessProbe}} + livenessProbe: +{{ toYaml $.Values.envoyproxy.livenessProbe | indent 12}} +{{- end }} +{{- end}} +{{- if $.Values.containers }} +{{- range $i, $c := .Values.containers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-sidecontainer-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .env }} + env: +{{ toYaml .env | indent 12 }} +{{- end }} + {{- if .envFrom }} + envFrom: +{{ toYaml .env | indent 12 }} +{{- end }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resizePolicy }} + resizePolicy: +{{ toYaml .resziePolicy | indent 12}} +{{- end }} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + + + volumes: + {{- if $.Values.appMetrics }} + - name: envoy-config-volume + configMap: + name: sidecar-config-{{ template ".Chart.Name .name" $ }} + {{- end }} +{{- with .Values.volumes }} +{{ toYaml . | trim | indent 8 }} +{{- end }} +{{- if .Values.persistentVolumeClaim.name }} + - name: {{.Values.persistentVolumeClaim.name}}-vol + persistentVolumeClaim: + claimName: {{.Values.persistentVolumeClaim.name }} +{{- end}} + {{- if .Values.ConfigMaps.enabled }} + {{- range .Values.ConfigMaps.maps }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + configMap: + {{- if eq .external true }} + name: {{ .name }} + {{- else if eq .external false }} + name: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- if .Values.ConfigSecrets.enabled }} + {{- range .Values.ConfigSecrets.secrets }} + {{- if eq .type "volume"}} + - name: {{ .name | replace "." "-"}}-vol + secret: + {{- if eq .external true }} + secretName: {{ .name }} + {{- else if eq .external false }} + secretName: {{ .name}}-{{ $.Values.app }} + {{- end }} + {{- if eq (len .filePermission) 0 }} + {{- else }} + defaultMode: {{ .filePermission}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (eq ($hasPVCExists) false) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq ($hasPVCExists) false) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} + + revisionHistoryLimit: 3 +## pauseForSecondsBeforeSwitchActive: {{ $.Values.pauseForSecondsBeforeSwitchActive }} +# waitForSecondsBeforeScalingDown: {{ $.Values.waitForSecondsBeforeScalingDown }} + strategy: + {{- if eq .Values.deploymentType "ROLLING" }} + type: "RollingUpdate" + rollingUpdate: + maxSurge: {{ $.Values.deployment.strategy.rolling.maxSurge }} + maxUnavailable: {{ $.Values.deployment.strategy.rolling.maxUnavailable }} + {{- end }} + {{- if eq .Values.deploymentType "RECREATE" }} + type: "Recreate" + {{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml index ea0ee9f5dc1..efd291af5d2 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/externalsecrets.yaml @@ -8,8 +8,13 @@ apiVersion: external-secrets.io/v1beta1 kind: SecretStore metadata: name: {{ .name}} -{{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: @@ -21,8 +26,13 @@ apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: {{ .name }} -{{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml index cad686a0f1f..91553a09f57 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/hpa.yaml @@ -13,8 +13,13 @@ metadata: annotations: {{ toYaml .Values.autoscaling.annotations | indent 4 }} {{- end }} - {{- if .Values.autoscaling.labels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + {{- if .Values.autoscaling.labels }} {{ toYaml .Values.autoscaling.labels | indent 4 }} {{- end }} spec: @@ -79,3 +84,87 @@ spec: {{- toYaml $.Values.autoscaling.behavior | nindent 4 }} {{- end }} {{- end }} +{{- if and $.Values.secondaryWorkload.enabled $.Values.secondaryWorkload.autoscaling.enabled }} +--- +{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2 +{{- else if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2beta2 +{{- else }} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }}-hpa + {{- if .Values.autoscaling.annotations }} + annotations: +{{ toYaml .Values.autoscaling.annotations | indent 4 }} + {{- end }} + {{- if .Values.autoscaling.labels }} + labels: +{{ toYaml .Values.autoscaling.labels | indent 4 }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include ".Chart.Name .fullname" $ }}-{{ $.Values.secondaryWorkload.postfix | default "sec" }} + {{- with $.Values.secondaryWorkload }} + minReplicas: {{ .autoscaling.MinReplicas }} + maxReplicas: {{ .autoscaling.MaxReplicas }} + metrics: + {{- if .autoscaling.containerResource.enabled }} + {{- with .autoscaling.containerResource }} + {{- if .TargetCPUUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: cpu + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetCPUUtilizationPercentage }} + {{- end}} + {{- if .TargetMemoryUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: memory + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetMemoryUtilizationPercentage }} + {{- end}} + {{- end }} + {{- end }} + {{- if .autoscaling.TargetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ .autoscaling.TargetMemoryUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if .autoscaling.TargetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + {{- if semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion }} + target: + type: Utilization + averageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + {{- else }} + targetAverageUtilization: {{ .autoscaling.TargetCPUUtilizationPercentage }} + {{- end }} + {{- end }} + {{- if and .autoscaling.extraMetrics (semverCompare ">=1.16-0" $.Capabilities.KubeVersion.GitVersion) }} + {{- toYaml .autoscaling.extraMetrics | nindent 2 }} + {{- end}} + {{- if and .autoscaling.behavior (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + behavior: + {{- toYaml .autoscaling.behavior | nindent 4 }} + {{- end }} + {{- end }} + {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml index 3a4921f69d2..d9a2543e98d 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/ingress.yaml @@ -21,7 +21,11 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: + {{- if $.Values.ingress.name }} + name: {{ $.Values.ingress.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-ingress + {{- end }} namespace: {{ $.Values.NameSpace }} labels: app: {{ template ".Chart.Name .name" . }} @@ -107,7 +111,11 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: + {{- if $.Values.ingressInternal.name }} + name: {{ $.Values.ingressInternal.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-ingress-internal + {{- end }} namespace: {{ $.Values.NameSpace }} labels: app: {{ template ".Chart.Name .name" . }} @@ -115,6 +123,9 @@ metadata: envId: {{ $.Values.env | quote }} chart: {{ template ".Chart.Name .chart" . }} release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} {{- if .Values.ingressInternal.annotations }} annotations: {{ toYaml .Values.ingressInternal.annotations | indent 4 }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml index f92af5924df..371363ab1a8 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/keda-autoscaling.yaml @@ -2,12 +2,17 @@ apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: + {{- if $.Values.kedaAutoscaling.name }} + name: {{ $.Values.kedaAutoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-keda + {{- end }} labels: - app: {{ template ".Chart.Name .name" . }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} - chart: {{ template ".Chart.Name .chart" . }} release: {{ .Release.Name }} {{- if .Values.appLabels }} {{ toYaml .Values.appLabels | indent 4 }} @@ -58,6 +63,13 @@ apiVersion: keda.sh/v1alpha1 kind: TriggerAuthentication metadata: name: {{ $.Values.kedaAutoscaling.triggerAuthentication.name }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + spec: {{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml index c9cbb4162d4..2736332531c 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/poddisruptionbudget.yaml @@ -6,11 +6,17 @@ apiVersion: policy/v1beta1 {{- end }} kind: PodDisruptionBudget metadata: + {{- if .Values.podDisruptionBudget.name }} + name: {{ .Values.podDisruptionBudget.name }} + {{- else }} name: {{ include ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} spec: {{- if .Values.podDisruptionBudget.minAvailable }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} @@ -20,6 +26,10 @@ spec: {{- end }} selector: matchLabels: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 6 }} + {{- else }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} + {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml index cd733d48576..54c9f636eed 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/pre-sync-job.yaml @@ -4,6 +4,12 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ template ".Chart.Name .fullname" $ }}-migrator + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} annotations: argocd.argoproj.io/hook: PreSync # argocd.argoproj.io/hook-delete-policy: HookSucceeded diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml index 90f398bff4c..c285de13883 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/prometheusrules.yaml @@ -2,13 +2,20 @@ apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: - name: {{ template ".Chart.Name .fullname" . }} + {{- if .Values.prometheusRule.name }} + name: {{ .Values.prometheusRule.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" . }} + {{- end }} {{- if .Values.prometheusRule.namespace }} namespace: {{ .Values.prometheusRule.namespace }} {{- end }} labels: kind: Prometheus - chart: {{ template ".Chart.Name .chart" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} release: {{ .Values.prometheus.release }} {{- if .Values.prometheusRule.additionalLabels }} {{ toYaml .Values.prometheusRule.additionalLabels | indent 4 }} @@ -16,7 +23,11 @@ metadata: spec: {{- with .Values.prometheusRule.rules }} groups: + {{- if $.Values.prometheusRule.name }} + - name: {{ $.Values.prometheusRule.name }} + {{- else }} - name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} rules: {{- toYaml . | nindent 6 }} {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml index 26a17b968ca..5ac3ae14101 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/secret.yaml @@ -4,8 +4,13 @@ apiVersion: v1 kind: Secret metadata: name: app-secret -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} type: Opaque @@ -22,8 +27,13 @@ apiVersion: v1 kind: Secret metadata: name: {{ .name}}-{{ $.Values.app }} -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + chart: {{ template ".Chart.Name .chart" $ }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} type: Opaque @@ -39,6 +49,11 @@ metadata: name: {{ .name}} {{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml index 03bbbc7c950..17c96b2ec72 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/service.yaml @@ -47,7 +47,11 @@ spec: name: envoy-admin {{- end }} selector: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 4 }} + {{- else }} app: {{ template ".Chart.Name .name" . }} + {{- end }} {{- if .Values.service.sessionAffinity.enabled }} sessionAffinity: ClientIP {{- end }} @@ -85,6 +89,10 @@ spec: name: envoy-admin {{- end }} selector: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 4 }} + {{- else }} app: {{ template ".Chart.Name .name" . }} + {{- end }} {{- end }} {{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml index ac258610fa8..f337548e942 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/serviceaccount.yaml @@ -4,8 +4,13 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "serviceAccountName" . }} - {{- if .Values.podLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if .Values.podLabels }} {{ toYaml .Values.podLabels | indent 4 }} {{- end }} {{- if .Values.serviceAccount.annotations }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml index 1f90c722cb1..3cdacf236d5 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/servicemonitor.yaml @@ -4,7 +4,11 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: + {{- if .Values.servicemonitor.name }} + name: {{ .Values.servicemonitor.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-sm + {{- end }} labels: kind: Prometheus app: {{ template ".Chart.Name .name" . }} @@ -20,8 +24,50 @@ spec: {{- range .Values.ContainerPort }} {{- if .servicemonitor }} {{- if .servicemonitor.enabled}} - {{- if .servicePort }} + {{- if .servicemonitor.targetPort }} + - targetPort: {{ .servicemonitor.targetPort }} + {{- else if .servicePort }} - port: {{ .name }} + {{- end }} + {{- if .servicemonitor.path }} + path: {{ .servicemonitor.path}} + {{- end }} + {{- if .servicemonitor.scheme }} + scheme: {{ .servicemonitor.scheme}} + {{- end }} + {{- if .servicemonitor.interval }} + interval: {{ .servicemonitor.interval}} + {{- end }} + {{- if .servicemonitor.scrapeTimeout }} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout | quote }} + {{- end }} + {{- if .servicemonitor.basicAuth }} + basicAuth: + {{- toYaml .servicemonitor.basicAuth | nindent 8 }} + {{- end }} + {{- if .servicemonitor.insecureTLS }} + tlsConfig: + insecureSkipVerify: true + {{- else if .servicemonitor.tlsConfig }} + tlsConfig: + {{- toYaml .servicemonitor.tlsConfig | nindent 8 }} + {{- end }} + {{- if .servicemonitor.metricRelabelings}} + metricRelabelings: +{{toYaml .servicemonitor.metricRelabelings | indent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- range .Values.containers }} + {{- range .ports }} + {{- if .servicemonitor }} + {{- if .servicemonitor.enabled}} + {{- if .servicemonitor.targetPort }} + - targetPort: {{ .servicemonitor.targetPort }} + {{- else if .servicePort }} + - port: {{ .name }} + {{- end }} {{- if .servicemonitor.path }} path: {{ .servicemonitor.path}} {{- end }} @@ -34,6 +80,17 @@ spec: {{- if .servicemonitor.scrapeTimeout }} scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} {{- end }} + {{- if .servicemonitor.basicAuth }} + basicAuth: + {{- toYaml .servicemonitor.basicAuth | nindent 8 }} + {{- end }} + {{- if .servicemonitor.insecureTLS }} + tlsConfig: + insecureSkipVerify: true + {{- else if .servicemonitor.tlsConfig }} + tlsConfig: + {{- toYaml .servicemonitor.tlsConfig | nindent 8 }} + {{- end }} {{- if .servicemonitor.metricRelabelings}} metricRelabelings: {{toYaml .servicemonitor.metricRelabelings | indent 8 }} @@ -42,7 +99,16 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.servicemonitor.namespaceSelector }} + namespaceSelector: + matchNames: + {{- toYaml .Values.servicemonitor.namespaceSelector | nindent 6 }} + {{- end }} selector: matchLabels: + {{- if .Values.servicemonitor.matchLabels }} + {{- toYaml .Values.servicemonitor.matchLabels | nindent 6 }} + {{- else }} app: {{ template ".Chart.Name .name" $ }} {{- end }} +{{- end }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml index b09b2533c05..314f0c6db0c 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/winter-soldier.yaml @@ -2,7 +2,11 @@ apiVersion: {{ $.Values.winterSoldier.apiVersion }} kind: Hibernator metadata: + {{- if .Values.winterSoldier.name }} + name: {{ .Values.winterSoldier.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-hibernator + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml index 78df2f31416..dd0395f97f8 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/test_values.yaml @@ -763,4 +763,17 @@ affinity: operator: In values: - S1 - topologyKey: topology.kubernetes.io/zone \ No newline at end of file + topologyKey: topology.kubernetes.io/zone + +secondaryWorkload: + enabled: true + postfix: "od" + replicaCount: 1 + affinity: {} + tolerations: [] + autoscaling: + enabled: true + MinReplicas: 1 + MaxReplicas: 2 + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml index c5dd74b354d..2d5215d050e 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/values.yaml @@ -719,4 +719,18 @@ imagePullSecrets: [] persistentVolumeClaim: {} verticalPodScaling: - enabled: false \ No newline at end of file + enabled: false + +secondaryWorkload: + enabled: false + Spec: + Affinity: + Key: "" + Values: "" + replicaCount: 1 + affinity: {} + tolerations: [] + autoscaling: + enabled: false + containerResource: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml index 7c374a70e8b..9d4a431c26d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ambassador.yaml @@ -5,10 +5,16 @@ apiVersion: getambassador.io/v3alpha1 kind: Mapping metadata: - name: {{ include ".Chart.Name .fullname" $ }}-mapping + {{- if .name }} + name: {{ .name }} + {{- else }} + name: {{ include ".Chart.Name .fullname" $ }}-mapping + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} release: {{ $.Release.Name }} releaseVersion: {{ $.Values.releaseVersion | quote }} pipelineName: {{ $.Values.pipelineName }} @@ -57,6 +63,8 @@ kind: TLSContext metadata: name: {{ .tls.context }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} app: {{ template ".Chart.Name .name" $ }} chart: {{ template ".Chart.Name .chart" $ }} release: {{ $.Release.Name }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml index 72d5ca84798..4e7879665e4 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/configmap.yaml @@ -6,8 +6,13 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ .name}}-{{ $.Values.app }} -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} data: diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml index ea0ee9f5dc1..efd291af5d2 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/externalsecrets.yaml @@ -8,8 +8,13 @@ apiVersion: external-secrets.io/v1beta1 kind: SecretStore metadata: name: {{ .name}} -{{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: @@ -21,8 +26,13 @@ apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: {{ .name }} -{{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml index 8f424d15fde..c7ba46e15b5 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/hpa.yaml @@ -13,8 +13,13 @@ metadata: annotations: {{ toYaml .Values.autoscaling.annotations | indent 4 }} {{- end }} - {{- if .Values.autoscaling.labels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + {{- if .Values.autoscaling.labels }} {{ toYaml .Values.autoscaling.labels | indent 4 }} {{- end }} spec: diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml index 1f231966b16..021d061b734 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/ingress.yaml @@ -21,7 +21,11 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: + {{- if $.Values.ingress.name }} + name: {{ $.Values.ingress.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-ingress + {{- end }} namespace: {{ $.Values.NameSpace }} labels: app: {{ template ".Chart.Name .name" . }} @@ -106,7 +110,11 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: + {{- if $.Values.ingressInternal.name }} + name: {{ $.Values.ingressInternal.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-ingress-internal + {{- end }} namespace: {{ $.Values.NameSpace }} labels: app: {{ template ".Chart.Name .name" . }} @@ -114,6 +122,9 @@ metadata: envId: {{ $.Values.env | quote }} chart: {{ template ".Chart.Name .chart" . }} release: {{ .Release.Name }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} +{{- end }} {{- if .Values.ingressInternal.annotations }} annotations: {{ toYaml .Values.ingressInternal.annotations | indent 4 }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml index 8c703a56474..faf89be1251 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/keda-autoscaling.yaml @@ -2,7 +2,28 @@ apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: + {{- if $.Values.kedaAutoscaling.name }} + name: {{ $.Values.kedaAutoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-keda + {{- end }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + release: {{ .Release.Name }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.labels }} +{{ toYaml .Values.kedaAutoscaling.labels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.annotations }} + annotations: +{{ toYaml .Values.kedaAutoscaling.annotations | indent 4 }} + {{- end }} spec: scaleTargetRef: apiVersion: argoproj.io/v1alpha1 @@ -42,6 +63,13 @@ apiVersion: keda.sh/v1alpha1 kind: TriggerAuthentication metadata: name: {{ $.Values.kedaAutoscaling.triggerAuthentication.name }} + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + spec: {{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml index c9cbb4162d4..2736332531c 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/poddisruptionbudget.yaml @@ -6,11 +6,17 @@ apiVersion: policy/v1beta1 {{- end }} kind: PodDisruptionBudget metadata: + {{- if .Values.podDisruptionBudget.name }} + name: {{ .Values.podDisruptionBudget.name }} + {{- else }} name: {{ include ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} spec: {{- if .Values.podDisruptionBudget.minAvailable }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} @@ -20,6 +26,10 @@ spec: {{- end }} selector: matchLabels: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 6 }} + {{- else }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} + {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml index cd733d48576..54c9f636eed 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/pre-sync-job.yaml @@ -4,6 +4,12 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ template ".Chart.Name .fullname" $ }}-migrator + labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} annotations: argocd.argoproj.io/hook: PreSync # argocd.argoproj.io/hook-delete-policy: HookSucceeded diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml index 90f398bff4c..c285de13883 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/prometheusrules.yaml @@ -2,13 +2,20 @@ apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: - name: {{ template ".Chart.Name .fullname" . }} + {{- if .Values.prometheusRule.name }} + name: {{ .Values.prometheusRule.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" . }} + {{- end }} {{- if .Values.prometheusRule.namespace }} namespace: {{ .Values.prometheusRule.namespace }} {{- end }} labels: kind: Prometheus - chart: {{ template ".Chart.Name .chart" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} release: {{ .Values.prometheus.release }} {{- if .Values.prometheusRule.additionalLabels }} {{ toYaml .Values.prometheusRule.additionalLabels | indent 4 }} @@ -16,7 +23,11 @@ metadata: spec: {{- with .Values.prometheusRule.rules }} groups: + {{- if $.Values.prometheusRule.name }} + - name: {{ $.Values.prometheusRule.name }} + {{- else }} - name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} rules: {{- toYaml . | nindent 6 }} {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml index 26a17b968ca..5ac3ae14101 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/secret.yaml @@ -4,8 +4,13 @@ apiVersion: v1 kind: Secret metadata: name: app-secret -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} type: Opaque @@ -22,8 +27,13 @@ apiVersion: v1 kind: Secret metadata: name: {{ .name}}-{{ $.Values.app }} -{{- if $.Values.appLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + release: {{ $.Release.Name }} + chart: {{ template ".Chart.Name .chart" $ }} +{{- if $.Values.appLabels }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} type: Opaque @@ -39,6 +49,11 @@ metadata: name: {{ .name}} {{- if $.Values.appLabels }} labels: + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} {{ toYaml $.Values.appLabels | indent 4 }} {{- end }} spec: diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml index f943af00ae1..ac9f9bb2c7d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/service.yaml @@ -47,7 +47,11 @@ spec: name: envoy-admin {{- end }} selector: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 4 }} + {{- else }} app: {{ template ".Chart.Name .name" . }} + {{- end }} {{- if .Values.service.sessionAffinity.enabled }} sessionAffinity: ClientIP {{- end }} @@ -88,6 +92,10 @@ spec: name: envoy-admin {{- end }} selector: + {{- if .Values.customPodLabels }} +{{ toYaml .Values.customPodLabels | indent 4 }} + {{- else }} app: {{ template ".Chart.Name .name" . }} + {{- end }} {{- end }} {{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml index ac258610fa8..f337548e942 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/serviceaccount.yaml @@ -4,8 +4,13 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "serviceAccountName" . }} - {{- if .Values.podLabels }} labels: + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + app: {{ template ".Chart.Name .name" $ }} + chart: {{ template ".Chart.Name .chart" $ }} + release: {{ $.Release.Name }} +{{- if .Values.podLabels }} {{ toYaml .Values.podLabels | indent 4 }} {{- end }} {{- if .Values.serviceAccount.annotations }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml index 1f90c722cb1..1e9e092ca55 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/servicemonitor.yaml @@ -4,7 +4,11 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: + {{- if .Values.servicemonitor.name }} + name: {{ .Values.servicemonitor.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-sm + {{- end }} labels: kind: Prometheus app: {{ template ".Chart.Name .name" . }} @@ -20,8 +24,50 @@ spec: {{- range .Values.ContainerPort }} {{- if .servicemonitor }} {{- if .servicemonitor.enabled}} - {{- if .servicePort }} + {{- if .servicemonitor.targetPort }} + - targetPort: {{ .servicemonitor.targetPort }} + {{- else if .servicePort }} - port: {{ .name }} + {{- end }} + {{- if .servicemonitor.path }} + path: {{ .servicemonitor.path}} + {{- end }} + {{- if .servicemonitor.scheme }} + scheme: {{ .servicemonitor.scheme}} + {{- end }} + {{- if .servicemonitor.interval }} + interval: {{ .servicemonitor.interval}} + {{- end }} + {{- if .servicemonitor.scrapeTimeout }} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout | quote }} + {{- end }} + {{- if .servicemonitor.basicAuth }} + basicAuth: + {{- toYaml .servicemonitor.basicAuth | nindent 8 }} + {{- end }} + {{- if .servicemonitor.insecureTLS }} + tlsConfig: + insecureSkipVerify: true + {{- else if .servicemonitor.tlsConfig }} + tlsConfig: + {{- toYaml .servicemonitor.tlsConfig | nindent 8 }} + {{- end }} + {{- if .servicemonitor.metricRelabelings}} + metricRelabelings: +{{toYaml .servicemonitor.metricRelabelings | indent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- range .Values.containers }} + {{- range .ports }} + {{- if .servicemonitor }} + {{- if .servicemonitor.enabled}} + {{- if .servicemonitor.targetPort }} + - targetPort: {{ .servicemonitor.targetPort }} + {{- else if .servicePort }} + - port: {{ .name }} + {{- end }} {{- if .servicemonitor.path }} path: {{ .servicemonitor.path}} {{- end }} @@ -34,6 +80,17 @@ spec: {{- if .servicemonitor.scrapeTimeout }} scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} {{- end }} + {{- if .servicemonitor.basicAuth }} + basicAuth: + {{- toYaml .servicemonitor.basicAuth | nindent 8 }} + {{- end }} + {{- if .servicemonitor.insecureTLS }} + tlsConfig: + insecureSkipVerify: true + {{- else if .servicemonitor.tlsConfig }} + tlsConfig: + {{- toYaml .servicemonitor.tlsConfig | nindent 8 }} + {{- end }} {{- if .servicemonitor.metricRelabelings}} metricRelabelings: {{toYaml .servicemonitor.metricRelabelings | indent 8 }} @@ -42,7 +99,16 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.servicemonitor.namespaceSelector }} + namespaceSelector: + matchNames: + {{- toYaml .Values.servicemonitor.namespaceSelector | nindent 6 }} + {{- end }} selector: matchLabels: + {{- if .Values.servicemonitor.matchLabels }} + {{- toYaml .Values.servicemonitor.matchLabels | nindent 6 }} + {{- else }} app: {{ template ".Chart.Name .name" $ }} + {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml index 2d3e7bae0fe..5ac2fd8443e 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/winter-soldier.yaml @@ -2,7 +2,11 @@ apiVersion: {{ $.Values.winterSoldier.apiVersion }} kind: Hibernator metadata: + {{- if .Values.winterSoldier.name }} + name: {{ .Values.winterSoldier.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-hibernator + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/app-values.yaml index 1b1912aa689..ffbe895ffde 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/app-values.yaml @@ -234,6 +234,9 @@ Spec: Key: # Key: kops.k8s.io/instancegroup Values: +affinity: + enabled: false + values: {} ambassadorMapping: enabled: false @@ -259,6 +262,10 @@ autoscaling: annotations: {} labels: {} behavior: {} + containerResource: + enabled: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 # scaleDown: # stabilizationWindowSeconds: 300 # policies: @@ -311,7 +318,7 @@ servicemonitor: additionalLabels: {} envoyproxy: - image: quay.io/devtron/envoy:v1.14.1 + image: quay.io/devtron/envoy:v1.16.0 configMapName: "" lifecycle: {} resources: @@ -386,3 +393,6 @@ hostAliases: [] # hostnames: # - "foo.remote" # - "bar.remote" + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/_helpers.tpl b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/_helpers.tpl index efbdad6de47..75ceac27e9f 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/_helpers.tpl +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/_helpers.tpl @@ -60,6 +60,14 @@ If release name contains chart name it will be used as a full name. {{- end -}} {{- end -}} +{{- define "VerticalPodAutoScalingEnabled" -}} + {{- $SMenabled := false -}} + {{- if and .Values.verticalPodScaling.enabled }} + {{- $SMenabled = true -}} + {{- end }} + {{- $SMenabled -}} +{{- end -}} + {{/* Create chart name and version as used by the chart label. */}} diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/externalsecrets.yaml index 129278add1d..efd291af5d2 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/externalsecrets.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/externalsecrets.yaml @@ -51,7 +51,15 @@ spec: {{- end }} target: name: {{ .name}} + {{- if .esoSecretData.template }} + template: + {{- toYaml .esoSecretData.template | nindent 6 }} + {{- end }} creationPolicy: Owner + {{- if .esoSecretData.esoDataFrom }} + dataFrom: + {{- toYaml .esoSecretData.esoDataFrom | nindent 4 }} + {{- else }} data: {{- range .esoSecretData.esoData }} - secretKey: {{ .secretKey }} @@ -64,4 +72,5 @@ spec: {{- end}} {{- end}} {{- end}} +{{- end}} {{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/hpa.yaml index a1fecd0cc37..bfe8efe8aef 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/hpa.yaml @@ -38,6 +38,28 @@ spec: minReplicas: {{ $.Values.autoscaling.MinReplicas }} maxReplicas: {{ $.Values.autoscaling.MaxReplicas }} metrics: + {{- if $.Values.autoscaling.containerResource.enabled }} + {{- with $.Values.autoscaling.containerResource }} + {{- if .TargetCPUUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: cpu + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetCPUUtilizationPercentage }} + {{- end}} + {{- if .TargetMemoryUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: memory + container: {{ $.Chart.Name }} + target: + type: Utilization + averageUtilization: {{ .TargetMemoryUtilizationPercentage }} + {{- end}} + {{- end }} + {{- end }} {{- if $.Values.autoscaling.TargetMemoryUtilizationPercentage }} - type: Resource resource: diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/keda-autoscaling.yaml index b0e804f591a..db5b1cf81b4 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/keda-autoscaling.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/keda-autoscaling.yaml @@ -13,6 +13,17 @@ metadata: release: {{ $.Release.Name }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} + release: {{ .Release.Name }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.labels }} +{{ toYaml .Values.kedaAutoscaling.labels | indent 4 }} + {{- end }} + {{- if .Values.kedaAutoscaling.annotations }} + annotations: +{{ toYaml .Values.kedaAutoscaling.annotations | indent 4 }} + {{- end }} spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/service.yaml index 8890359e31c..5900bf88904 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/service.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/service.yaml @@ -43,7 +43,7 @@ spec: {{- if (and (eq $.Values.service.type "NodePort") .nodePort )}} nodePort: {{ .nodePort }} {{- end }} - protocol: TCP + protocol: {{ .protocol }} name: {{ .name }} {{- end }} {{- if $.Values.appMetrics }} @@ -56,6 +56,13 @@ spec: {{- else }} app: {{ template ".Chart.Name .name" . }} {{- end }} +{{- if .Values.service.sessionAffinity.enabled }} + sessionAffinity: ClientIP +{{- end }} +{{- if .Values.service.sessionAffinityConfig }} + sessionAffinityConfig: +{{ toYaml .Values.service.sessionAffinityConfig | indent 4 }} +{{- end }} {{- end }} --- {{- if or .Values.service.enabled .Values.serviceheadless.enabled }} @@ -114,6 +121,13 @@ spec: {{- else }} app: {{ template ".Chart.Name .name" . }} {{- end }} +{{- if .Values.serviceheadless.sessionAffinity.enabled }} + sessionAffinity: ClientIP +{{- end }} +{{- if .Values.serviceheadless.sessionAffinityConfig }} + sessionAffinityConfig: +{{ toYaml .Values.serviceheadless.sessionAffinityConfig | indent 4 }} +{{- end }} type: ClusterIP {{- if (and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges )}} loadBalancerSourceRanges: @@ -121,4 +135,4 @@ spec: - {{ . }} {{- end }} {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/servicemonitor.yaml index 276a50211e7..57d745dbe8b 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/servicemonitor.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/servicemonitor.yaml @@ -39,7 +39,7 @@ spec: interval: {{ .servicemonitor.interval}} {{- end }} {{- if .servicemonitor.scrapeTimeout }} - scrapeTimeout: {{ .servicemonitor.scrapeTimeout}} + scrapeTimeout: {{ .servicemonitor.scrapeTimeout | quote}} {{- end }} {{- if .servicemonitor.basicAuth }} basicAuth: diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/statefulset.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/statefulset.yaml index f693b05ff49..55cb8ed17ac 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/statefulset.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/statefulset.yaml @@ -119,12 +119,18 @@ spec: operator: In values: - {{ $.Values.Spec.Affinity.Values | default "nodes" }} +{{- else if $.Values.affinity.enabled }} + affinity: +{{ toYaml .Values.affinity.values | indent 8 }} {{- end }} {{- if $.Values.serviceAccountName }} serviceAccountName: {{ $.Values.serviceAccountName }} {{- else }} serviceAccountName: {{ template "serviceAccountName" . }} {{- end }} +{{- if $.Values.schedulerName }} + schedulerName: {{ .Values.schedulerName }} +{{- end }} {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml $.Values.nodeSelector | indent 10 }} @@ -148,6 +154,17 @@ spec: - maxSkew: {{ .maxSkew }} topologyKey: {{ .topologyKey }} whenUnsatisfiable: {{ .whenUnsatisfiable }} + {{- if semverCompare "<=1.30-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .minDomains }} + minDomains: {{ .minDomains }} + {{- end }} + {{- end }} + {{- if .nodeAffinityPolicy }} + nodeAffinityPolicy: {{ .nodeAffinityPolicy }} + {{- end }} + {{- if .nodeTaintsPolicy }} + nodeTaintsPolicy: {{ .nodeTaintsPolicy }} + {{- end }} labelSelector: matchLabels: {{- if and .autoLabelSelector .customLabelSelector }} @@ -181,6 +198,10 @@ spec: command: {{ toYaml .command | indent 12 -}} {{- end}} +{{- if .args}} + args: +{{ toYaml .args | indent 12 -}} +{{- end}} {{- if .resources}} resources: {{ toYaml .resources | indent 12 -}} @@ -198,7 +219,7 @@ spec: containers: {{- if $.Values.appMetrics }} - name: envoy - image: {{ $.Values.envoyproxy.image | default "envoyproxy/envoy:v1.14.1"}} + image: {{ $.Values.envoyproxy.image | default "quay.io/devtron/envoy:v1.16.0"}} {{- if $.Values.envoyproxy.lifecycle }} lifecycle: {{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} @@ -286,7 +307,7 @@ spec: {{- range $.Values.ContainerPort }} - name: {{ .name}} containerPort: {{ .port }} - protocol: TCP + protocol: {{ .protocol }} {{- end}} {{- if and $.Values.command.enabled $.Values.command.workingDir }} workingDir: {{ $.Values.command.workingDir }} @@ -301,9 +322,9 @@ spec: {{- end }} env: - name: CONFIG_HASH - value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }} + value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }} - name: SECRET_HASH - value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }} + value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }} - name: DEVTRON_APP_NAME value: {{ template ".Chart.Name .name" $ }} - name: POD_NAME @@ -376,6 +397,7 @@ spec: httpGet: path: {{ $.Values.LivenessProbe.Path }} port: {{ $.Values.LivenessProbe.port }} + scheme: {{ $.Values.LivenessProbe.scheme }} {{- if $.Values.LivenessProbe.httpHeaders }} httpHeaders: {{- range $.Values.LivenessProbe.httpHeaders}} @@ -502,7 +524,22 @@ spec: mountPath: {{ $cmMountPath }} {{- else }} - {{- range $k, $v := .data }} + {{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}} + {{- if and (.esoSubPath) (ne (len .esoSubPath) 0) }} + {{- range .esoSubPath }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ . }} + subPath: {{ . }} + {{- end }} + {{- else }} + {{- range .esoSecretData.esoData }} + - name: {{ $cmName | replace "." "-"}}-vol + mountPath: {{ $cmMountPath}}/{{ .secretKey }} + subPath: {{ .secretKey }} + {{- end }} + {{- end }} + {{- else }} + {{- range $k, $v := .data }} # for others secrets the mount path will be .data[i].secretKey - name: {{ $cmName | replace "." "-"}}-vol mountPath: {{ $cmMountPath}}/{{ $k}} subPath: {{ $k}} @@ -511,8 +548,89 @@ spec: {{- end }} {{- end }} {{- end }} - {{- if and (eq (len .Values.volumes) 0) (eq (len .Values.statefulSetConfig.volumeClaimTemplates) 0) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} - {{- if and (eq (len .Values.volumeMounts) 0) (eq (len .Values.statefulSetConfig.volumeClaimTemplates) 0) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} + {{- end }} + {{- if and (eq (len .Values.volumes) 0) (or (eq (.Values.ConfigSecrets.enabled) true) (eq (.Values.ConfigMaps.enabled) true)) (eq ($hasCMVolumeExists) false) (eq ($hasSecretVolumeExists) false) }} []{{- end }} + {{- if and (eq (len .Values.volumeMounts) 0) (eq (.Values.ConfigSecrets.enabled) false) (eq (.Values.ConfigMaps.enabled) false) }} [] {{- end }} +{{- if $.Values.appMetrics }} + - name: envoy + image: {{ $.Values.envoyproxy.image | default "quay.io/devtron/envoy:v1.16.0"}} + {{- if $.Values.envoyproxy.lifecycle }} + lifecycle: +{{ toYaml .Values.envoyproxy.lifecycle | indent 12 -}} + {{- else if $.Values.containerSpec.lifecycle.enabled }} + lifecycle: + {{- if $.Values.containerSpec.lifecycle.preStop }} + preStop: +{{ toYaml $.Values.containerSpec.lifecycle.preStop | indent 12 -}} + {{- end }} + {{- end }} + resources: +{{ toYaml $.Values.envoyproxy.resources | trim | indent 12 }} + ports: + - containerPort: 9901 + protocol: TCP + name: envoy-admin + {{- range $index, $element := .Values.ContainerPort }} + - name: {{ $element.name}} + containerPort: {{ $element.envoyPort | default (add 8790 $index) }} + protocol: TCP + {{- end }} + command: ["/usr/local/bin/envoy"] + args: ["-c", "/etc/envoy-config/envoy-config.json", "-l", "info", "--log-format", "[METADATA][%Y-%m-%d %T.%e][%t][%l][%n] %v"] + volumeMounts: + - name: {{ $.Values.envoyproxy.configMapName | default "envoy-config-volume" }} + mountPath: /etc/envoy-config/ +{{- if $.Values.envoyproxy.readinessProbe}} + readinessProbe: +{{ toYaml $.Values.envoyproxy.readinessProbe | indent 12}} +{{- end }} +{{- if $.Values.envoyproxy.livenessProbe}} + livenessProbe: +{{ toYaml $.Values.envoyproxy.livenessProbe | indent 12}} +{{- end }} +{{- end}} +{{- if $.Values.containers }} +{{- range $i, $c := .Values.containers }} +{{- if .reuseContainerImage}} + - name: {{ $.Chart.Name }}-sidecontainer-{{ add1 $i }} + image: "{{ $.Values.server.deployment.image }}:{{ $.Values.server.deployment.image_tag }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} +{{- if .env }} + env: +{{ toYaml .env | indent 12 }} +{{- end }} + {{- if .envFrom }} + envFrom: +{{ toYaml .env | indent 12 }} +{{- end }} +{{- if .securityContext }} + securityContext: +{{ toYaml .securityContext | indent 12 }} +{{- end }} +{{- if .command}} + command: +{{ toYaml .command | indent 12 -}} +{{- end}} +{{- if .resizePolicy }} + resizePolicy: +{{ toYaml .resziePolicy | indent 12}} +{{- end }} +{{- if .resources}} + resources: +{{ toYaml .resources | indent 12 -}} +{{- end}} +{{- if .volumeMounts}} + volumeMounts: +{{ toYaml .volumeMounts | indent 12 -}} +{{- end}} +{{- else}} + - +{{ toYaml . | indent 10 }} +{{- end}} +{{- end}} +{{- end}} + + volumes: {{- if $.Values.appMetrics }} - name: envoy-config-volume diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/vertical-pod-autoscaler.yaml new file mode 100644 index 00000000000..27de013e0e2 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/vertical-pod-autoscaler.yaml @@ -0,0 +1,27 @@ +{{ $VerticalPodAutoScalingEnabled := include "VerticalPodAutoScalingEnabled" . }} +{{- if eq "true" $VerticalPodAutoScalingEnabled -}} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: {{ template ".Chart.Name .fullname" . }}-vpa + labels: + kind: Prometheus + app: {{ template ".Chart.Name .name" . }} + appId: {{ $.Values.app | quote }} + envId: {{ $.Values.env | quote }} + chart: {{ template ".Chart.Name .chart" . }} + release: {{ .Values.prometheus.release }} +spec: +{{- if .Values.verticalPodScaling.resourcePolicy }} + resourcePolicy: +{{ toYaml .Values.verticalPodScaling.resourcePolicy}} +{{- end }} +{{- if .Values.verticalPodScaling.updatePolicy }} + updatePolicy: +{{ toYaml .Values.verticalPodScaling.updatePolicy}} +{{- end }} + targetRef: + apiVersion: apps/v1 + kind: StatefulSet + name: {{ include ".Chart.Name .fullname" $ }} +{{- end }} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/values.yaml index 5c534b4541f..bc8aff2ffcd 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/values.yaml @@ -114,18 +114,23 @@ kedaAutoscaling: secret: enabled: false serviceheadless: - enabled: true + enabled: false + sessionAffinity: + enabled: false service: type: ClusterIP enabled: false #name: "test-service" annotations: {} + sessionAffinity: + enabled: false # test1: test2 # test3: test4 statefulSetConfig: mountPath: "/tmp" serviceheadless: enabled: false + volumeClaimTemplates: [] # - spec: @@ -600,3 +605,9 @@ tolerations: [] imagePullSecrets: [] # - test1 # - test2 + +affinity: + enabled: false + +verticalPodScaling: + enabled: false \ No newline at end of file From 77785302712c0233ac6d13714d657e76a78debe2 Mon Sep 17 00:00:00 2001 From: kartik-579 <84493919+kartik-579@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:57:24 +0530 Subject: [PATCH 61/65] helm app list cluster filter fix (#6019) --- .../installedApp/repository/InstalledAppRepository.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/appStore/installedApp/repository/InstalledAppRepository.go b/pkg/appStore/installedApp/repository/InstalledAppRepository.go index aead7617b40..970eff6f96f 100644 --- a/pkg/appStore/installedApp/repository/InstalledAppRepository.go +++ b/pkg/appStore/installedApp/repository/InstalledAppRepository.go @@ -439,15 +439,15 @@ func (impl *InstalledAppRepositoryImpl) GetAllInstalledApps(filter *appStoreBean } if len(filter.ChartRepoId) > 0 { query = query + " AND ch.id IN (?) " - queryParams = append(queryParams, sqlIntSeq(filter.ChartRepoId)) + queryParams = append(queryParams, pg.In(filter.ChartRepoId)) } if len(filter.EnvIds) > 0 { query = query + " AND env.id IN (?) " - queryParams = append(queryParams, sqlIntSeq(filter.EnvIds)) + queryParams = append(queryParams, pg.In(filter.EnvIds)) } if len(filter.ClusterIds) > 0 { query = query + " AND cluster.id IN (?) " - queryParams = append(queryParams, sqlIntSeq(filter.ClusterIds)) + queryParams = append(queryParams, pg.In(filter.ClusterIds)) } if len(filter.AppStatuses) > 0 { appStatuses := pg.In(filter.AppStatuses) From 5f3e8425ffa3699cf3189da4eeb262184e455f34 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:00:14 +0530 Subject: [PATCH 62/65] migration seq rename (#6023) --- ...er_v1_1.down.sql => 28901901_devtron_ci_trigger_v1_1.down.sql} | 0 ...rigger_v1_1.up.sql => 28901901_devtron_ci_trigger_v1_1.up.sql} | 0 ...902_019_docker_lint.down.sql => 28901902_docker_lint.down.sql} | 0 ...{028902_019_docker_lint.up.sql => 28901902_docker_lint.up.sql} | 0 ...0_019_release_rbac.down.sql => 29001900_release_rbac.down.sql} | 0 ...29000_019_release_rbac.up.sql => 29001900_release_rbac.up.sql} | 0 ...tion_settings.up.sql => 29101900_notification_settings.up.sql} | 0 ...tettings.down.sql => 29101900_notification_stettings.down.sql} | 0 ...age.down.sql => 29201900_helm_app_deployment_message.down.sql} | 0 ...message.up.sql => 29201900_helm_app_deployment_message.up.sql} | 0 ...ded_flag.down.sql => 29302000_artifact_uploaded_flag.down.sql} | 0 ...ploaded_flag.up.sql => 29302000_artifact_uploaded_flag.up.sql} | 0 ...ployment_event.down.sql => 29402000_deployment_event.down.sql} | 0 ...0_deployment_event.up.sql => 29402000_deployment_event.up.sql} | 0 ...-19-0.down.sql => 29502100_refrence-chart-ref_4-19-0.down.sql} | 0 ...ef_4-19-0.up.sql => 29502100_refrence-chart-ref_4-19-0.up.sql} | 0 ...-20-0.down.sql => 29602100_refrence-chart-ref_4-20-0.down.sql} | 0 ...ef_4-20-0.up.sql => 29602100_refrence-chart-ref_4-20-0.up.sql} | 0 ...0-0.down.sql => 29702100_deployment-chart-ref_4-20-0.down.sql} | 0 ..._4-20-0.up.sql => 29702100_deployment-chart-ref_4-20-0.up.sql} | 0 ..._images.down.sql => 29802100_cluster_terminal_images.down.sql} | 0 ...inal_images.up.sql => 29802100_cluster_terminal_images.up.sql} | 0 22 files changed, 0 insertions(+), 0 deletions(-) rename scripts/sql/{028901_019_devtron_ci_trigger_v1_1.down.sql => 28901901_devtron_ci_trigger_v1_1.down.sql} (100%) rename scripts/sql/{028901_019_devtron_ci_trigger_v1_1.up.sql => 28901901_devtron_ci_trigger_v1_1.up.sql} (100%) rename scripts/sql/{028902_019_docker_lint.down.sql => 28901902_docker_lint.down.sql} (100%) rename scripts/sql/{028902_019_docker_lint.up.sql => 28901902_docker_lint.up.sql} (100%) rename scripts/sql/{029000_019_release_rbac.down.sql => 29001900_release_rbac.down.sql} (100%) rename scripts/sql/{029000_019_release_rbac.up.sql => 29001900_release_rbac.up.sql} (100%) rename scripts/sql/{029100_019_notification_settings.up.sql => 29101900_notification_settings.up.sql} (100%) rename scripts/sql/{029100_019_notification_stettings.down.sql => 29101900_notification_stettings.down.sql} (100%) rename scripts/sql/{029200_019_helm_app_deployment_message.down.sql => 29201900_helm_app_deployment_message.down.sql} (100%) rename scripts/sql/{029200_019_helm_app_deployment_message.up.sql => 29201900_helm_app_deployment_message.up.sql} (100%) rename scripts/sql/{029300_020_artifact_uploaded_flag.down.sql => 29302000_artifact_uploaded_flag.down.sql} (100%) rename scripts/sql/{029300_020_artifact_uploaded_flag.up.sql => 29302000_artifact_uploaded_flag.up.sql} (100%) rename scripts/sql/{029400_020_deployment_event.down.sql => 29402000_deployment_event.down.sql} (100%) rename scripts/sql/{029400_020_deployment_event.up.sql => 29402000_deployment_event.up.sql} (100%) rename scripts/sql/{029500_021_refrence-chart-ref_4-19-0.down.sql => 29502100_refrence-chart-ref_4-19-0.down.sql} (100%) rename scripts/sql/{029500_021_refrence-chart-ref_4-19-0.up.sql => 29502100_refrence-chart-ref_4-19-0.up.sql} (100%) rename scripts/sql/{029600_021_refrence-chart-ref_4-20-0.down.sql => 29602100_refrence-chart-ref_4-20-0.down.sql} (100%) rename scripts/sql/{029600_021_refrence-chart-ref_4-20-0.up.sql => 29602100_refrence-chart-ref_4-20-0.up.sql} (100%) rename scripts/sql/{029700_021_deployment-chart-ref_4-20-0.down.sql => 29702100_deployment-chart-ref_4-20-0.down.sql} (100%) rename scripts/sql/{029700_021_deployment-chart-ref_4-20-0.up.sql => 29702100_deployment-chart-ref_4-20-0.up.sql} (100%) rename scripts/sql/{029800_021_cluster_terminal_images.down.sql => 29802100_cluster_terminal_images.down.sql} (100%) rename scripts/sql/{029800_021_cluster_terminal_images.up.sql => 29802100_cluster_terminal_images.up.sql} (100%) diff --git a/scripts/sql/028901_019_devtron_ci_trigger_v1_1.down.sql b/scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql similarity index 100% rename from scripts/sql/028901_019_devtron_ci_trigger_v1_1.down.sql rename to scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql diff --git a/scripts/sql/028901_019_devtron_ci_trigger_v1_1.up.sql b/scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql similarity index 100% rename from scripts/sql/028901_019_devtron_ci_trigger_v1_1.up.sql rename to scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql diff --git a/scripts/sql/028902_019_docker_lint.down.sql b/scripts/sql/28901902_docker_lint.down.sql similarity index 100% rename from scripts/sql/028902_019_docker_lint.down.sql rename to scripts/sql/28901902_docker_lint.down.sql diff --git a/scripts/sql/028902_019_docker_lint.up.sql b/scripts/sql/28901902_docker_lint.up.sql similarity index 100% rename from scripts/sql/028902_019_docker_lint.up.sql rename to scripts/sql/28901902_docker_lint.up.sql diff --git a/scripts/sql/029000_019_release_rbac.down.sql b/scripts/sql/29001900_release_rbac.down.sql similarity index 100% rename from scripts/sql/029000_019_release_rbac.down.sql rename to scripts/sql/29001900_release_rbac.down.sql diff --git a/scripts/sql/029000_019_release_rbac.up.sql b/scripts/sql/29001900_release_rbac.up.sql similarity index 100% rename from scripts/sql/029000_019_release_rbac.up.sql rename to scripts/sql/29001900_release_rbac.up.sql diff --git a/scripts/sql/029100_019_notification_settings.up.sql b/scripts/sql/29101900_notification_settings.up.sql similarity index 100% rename from scripts/sql/029100_019_notification_settings.up.sql rename to scripts/sql/29101900_notification_settings.up.sql diff --git a/scripts/sql/029100_019_notification_stettings.down.sql b/scripts/sql/29101900_notification_stettings.down.sql similarity index 100% rename from scripts/sql/029100_019_notification_stettings.down.sql rename to scripts/sql/29101900_notification_stettings.down.sql diff --git a/scripts/sql/029200_019_helm_app_deployment_message.down.sql b/scripts/sql/29201900_helm_app_deployment_message.down.sql similarity index 100% rename from scripts/sql/029200_019_helm_app_deployment_message.down.sql rename to scripts/sql/29201900_helm_app_deployment_message.down.sql diff --git a/scripts/sql/029200_019_helm_app_deployment_message.up.sql b/scripts/sql/29201900_helm_app_deployment_message.up.sql similarity index 100% rename from scripts/sql/029200_019_helm_app_deployment_message.up.sql rename to scripts/sql/29201900_helm_app_deployment_message.up.sql diff --git a/scripts/sql/029300_020_artifact_uploaded_flag.down.sql b/scripts/sql/29302000_artifact_uploaded_flag.down.sql similarity index 100% rename from scripts/sql/029300_020_artifact_uploaded_flag.down.sql rename to scripts/sql/29302000_artifact_uploaded_flag.down.sql diff --git a/scripts/sql/029300_020_artifact_uploaded_flag.up.sql b/scripts/sql/29302000_artifact_uploaded_flag.up.sql similarity index 100% rename from scripts/sql/029300_020_artifact_uploaded_flag.up.sql rename to scripts/sql/29302000_artifact_uploaded_flag.up.sql diff --git a/scripts/sql/029400_020_deployment_event.down.sql b/scripts/sql/29402000_deployment_event.down.sql similarity index 100% rename from scripts/sql/029400_020_deployment_event.down.sql rename to scripts/sql/29402000_deployment_event.down.sql diff --git a/scripts/sql/029400_020_deployment_event.up.sql b/scripts/sql/29402000_deployment_event.up.sql similarity index 100% rename from scripts/sql/029400_020_deployment_event.up.sql rename to scripts/sql/29402000_deployment_event.up.sql diff --git a/scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql b/scripts/sql/29502100_refrence-chart-ref_4-19-0.down.sql similarity index 100% rename from scripts/sql/029500_021_refrence-chart-ref_4-19-0.down.sql rename to scripts/sql/29502100_refrence-chart-ref_4-19-0.down.sql diff --git a/scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql b/scripts/sql/29502100_refrence-chart-ref_4-19-0.up.sql similarity index 100% rename from scripts/sql/029500_021_refrence-chart-ref_4-19-0.up.sql rename to scripts/sql/29502100_refrence-chart-ref_4-19-0.up.sql diff --git a/scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql b/scripts/sql/29602100_refrence-chart-ref_4-20-0.down.sql similarity index 100% rename from scripts/sql/029600_021_refrence-chart-ref_4-20-0.down.sql rename to scripts/sql/29602100_refrence-chart-ref_4-20-0.down.sql diff --git a/scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql b/scripts/sql/29602100_refrence-chart-ref_4-20-0.up.sql similarity index 100% rename from scripts/sql/029600_021_refrence-chart-ref_4-20-0.up.sql rename to scripts/sql/29602100_refrence-chart-ref_4-20-0.up.sql diff --git a/scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql b/scripts/sql/29702100_deployment-chart-ref_4-20-0.down.sql similarity index 100% rename from scripts/sql/029700_021_deployment-chart-ref_4-20-0.down.sql rename to scripts/sql/29702100_deployment-chart-ref_4-20-0.down.sql diff --git a/scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql b/scripts/sql/29702100_deployment-chart-ref_4-20-0.up.sql similarity index 100% rename from scripts/sql/029700_021_deployment-chart-ref_4-20-0.up.sql rename to scripts/sql/29702100_deployment-chart-ref_4-20-0.up.sql diff --git a/scripts/sql/029800_021_cluster_terminal_images.down.sql b/scripts/sql/29802100_cluster_terminal_images.down.sql similarity index 100% rename from scripts/sql/029800_021_cluster_terminal_images.down.sql rename to scripts/sql/29802100_cluster_terminal_images.down.sql diff --git a/scripts/sql/029800_021_cluster_terminal_images.up.sql b/scripts/sql/29802100_cluster_terminal_images.up.sql similarity index 100% rename from scripts/sql/029800_021_cluster_terminal_images.up.sql rename to scripts/sql/29802100_cluster_terminal_images.up.sql From 46e941aaaa059321ca6285b342b3d9f59c88dc87 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:13:16 +0530 Subject: [PATCH 63/65] fix: Rename migration seq (#6024) * migration seq rename * migration seq fix and renamed --- scripts/sql/28901900_release_rbac.down.sql | 4 + scripts/sql/28901900_release_rbac.up.sql | 41 +++++++++++ .../29001900_notification_settings.down.sql | 1 + .../sql/29001900_notification_settings.up.sql | 2 + ...01900_helm_app_deployment_message.down.sql | 3 + ...9101900_helm_app_deployment_message.up.sql | 3 + .../29201901_devtron_ci_trigger_v1_1.down.sql | 6 ++ .../29201901_devtron_ci_trigger_v1_1.up.sql | 36 +++++++++ scripts/sql/29201902_docker_lint.down.sql | 23 ++++++ scripts/sql/29201902_docker_lint.up.sql | 73 +++++++++++++++++++ 10 files changed, 192 insertions(+) create mode 100644 scripts/sql/28901900_release_rbac.down.sql create mode 100644 scripts/sql/28901900_release_rbac.up.sql create mode 100644 scripts/sql/29001900_notification_settings.down.sql create mode 100644 scripts/sql/29001900_notification_settings.up.sql create mode 100644 scripts/sql/29101900_helm_app_deployment_message.down.sql create mode 100644 scripts/sql/29101900_helm_app_deployment_message.up.sql create mode 100644 scripts/sql/29201901_devtron_ci_trigger_v1_1.down.sql create mode 100644 scripts/sql/29201901_devtron_ci_trigger_v1_1.up.sql create mode 100644 scripts/sql/29201902_docker_lint.down.sql create mode 100644 scripts/sql/29201902_docker_lint.up.sql diff --git a/scripts/sql/28901900_release_rbac.down.sql b/scripts/sql/28901900_release_rbac.down.sql new file mode 100644 index 00000000000..82053ba8896 --- /dev/null +++ b/scripts/sql/28901900_release_rbac.down.sql @@ -0,0 +1,4 @@ +ALTER TABLE roles DROP COLUMN "release"; +ALTER TABLE roles DROP COLUMN "release_track"; +DELETE from rbac_role_resource_detail where resource in ('release','release-track'); +DELETE from rbac_policy_resource_detail where resource in ('release','release-track'); \ No newline at end of file diff --git a/scripts/sql/28901900_release_rbac.up.sql b/scripts/sql/28901900_release_rbac.up.sql new file mode 100644 index 00000000000..6f4e61114dd --- /dev/null +++ b/scripts/sql/28901900_release_rbac.up.sql @@ -0,0 +1,41 @@ + +INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", + "resource_object", "eligible_entity_access_types", "deleted", "created_on", + "created_by", "updated_on", "updated_by") +VALUES ('release', '{"value": "release", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); + +INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", + "resource_object", "eligible_entity_access_types", "deleted", "created_on", + "created_by", "updated_on", "updated_by") +VALUES ('release-requirement', '{"value": "release-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); + +INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", + "resource_object", "eligible_entity_access_types", "deleted", "created_on", + "created_by", "updated_on", "updated_by") +VALUES ('release-track', '{"value": "release-track", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); + +INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", + "resource_object", "eligible_entity_access_types", "deleted", "created_on", + "created_by", "updated_on", "updated_by") +VALUES ('release-track-requirement', '{"value": "release-track-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); + + + + + +INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key", + "eligible_entity_access_types", "deleted", "created_on", "created_by", + "updated_on", "updated_by") +VALUES ('release', 'Release', 'Release', ARRAY ['release'], false, now(), 1, now(), 1); + + +INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key", + "eligible_entity_access_types", "deleted", "created_on", "created_by", + "updated_on", "updated_by") +VALUES ('release-track', 'ReleaseTrack', 'ReleaseTrack', ARRAY ['release'], false, now(), 1, now(), 1); + + + + +ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release" text; +ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release_track" text; \ No newline at end of file diff --git a/scripts/sql/29001900_notification_settings.down.sql b/scripts/sql/29001900_notification_settings.down.sql new file mode 100644 index 00000000000..045fc2f80d9 --- /dev/null +++ b/scripts/sql/29001900_notification_settings.down.sql @@ -0,0 +1 @@ +ALTER TABLE notification_settings DROP COLUMN IF EXISTS cluster_id INT; \ No newline at end of file diff --git a/scripts/sql/29001900_notification_settings.up.sql b/scripts/sql/29001900_notification_settings.up.sql new file mode 100644 index 00000000000..cbe10af1a07 --- /dev/null +++ b/scripts/sql/29001900_notification_settings.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE notification_settings drop constraint IF EXISTS notification_settings_env_id_fkey; +ALTER TABLE notification_settings ADD COLUMN IF NOT EXISTS cluster_id INT; diff --git a/scripts/sql/29101900_helm_app_deployment_message.down.sql b/scripts/sql/29101900_helm_app_deployment_message.down.sql new file mode 100644 index 00000000000..25eb9b043aa --- /dev/null +++ b/scripts/sql/29101900_helm_app_deployment_message.down.sql @@ -0,0 +1,3 @@ +-- Drop the message column from the "public"."installed_app_version_history" table +ALTER TABLE "public"."installed_app_version_history" + DROP COLUMN IF EXISTS message; \ No newline at end of file diff --git a/scripts/sql/29101900_helm_app_deployment_message.up.sql b/scripts/sql/29101900_helm_app_deployment_message.up.sql new file mode 100644 index 00000000000..8d08f591750 --- /dev/null +++ b/scripts/sql/29101900_helm_app_deployment_message.up.sql @@ -0,0 +1,3 @@ +-- Add message column to "public"."installed_app_version_history" table +ALTER TABLE "public"."installed_app_version_history" + ADD COLUMN IF NOT EXISTS message TEXT; \ No newline at end of file diff --git a/scripts/sql/29201901_devtron_ci_trigger_v1_1.down.sql b/scripts/sql/29201901_devtron_ci_trigger_v1_1.down.sql new file mode 100644 index 00000000000..d3ed16f788e --- /dev/null +++ b/scripts/sql/29201901_devtron_ci_trigger_v1_1.down.sql @@ -0,0 +1,6 @@ +DELETE FROM plugin_step_variable WHERE plugin_step_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); +DELETE FROM plugin_step where plugin_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); +DELETE FROM plugin_pipeline_script where id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); +DELETE FROM plugin_stage_mapping where plugin_id=(SELECT id from plugin_metadata where name='Devtron CI Trigger'); +DELETE FROM plugin_metadata where name='Devtron CI Trigger'; +UPDATE plugin_metadata SET is_latest = true WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= false); diff --git a/scripts/sql/29201901_devtron_ci_trigger_v1_1.up.sql b/scripts/sql/29201901_devtron_ci_trigger_v1_1.up.sql new file mode 100644 index 00000000000..9b120ceb431 --- /dev/null +++ b/scripts/sql/29201901_devtron_ci_trigger_v1_1.up.sql @@ -0,0 +1,36 @@ +UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= true); + +INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest") +VALUES (nextval('id_seq_plugin_metadata'), 'Devtron CI Trigger','Triggers the CI pipeline of Devtron Application','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='devtron-ci-trigger-v1-0-0'),'1.1.0', false, true); + +INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by") +VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.1.0' and name='Devtron CI Trigger' and deleted= false),0,'now()', 1, 'now()', 1); + +INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by")VALUES ( + nextval('id_seq_plugin_pipeline_script'), + E'#!/bin/sh + docker run -e DevtronApiToken=$DevtronApiToken -e DevtronEndpoint=$DevtronEndpoint -e DevtronApp=$DevtronApp -e CiPipeline=$CiPipeline -e DevtronEnv=$DevtronEnv -e GitCommitHash=$GitCommitHash -e Timeout=$Timeout -e IgnoreCache=$IgnoreCache --name devtron-ci-trigger quay.io/devtron/devtron-utils:ci-trigger-plugin-v1.1.0 + exit_code=$? + if [ $ExitOnFail == true ];then + if [ $exit_code == 2 ];then + echo "The triggered build has been failed terminating the current process." + exit $exit_code + fi + fi + if [ $exit_code -ne 0 ] && [ $exit_code -ne 2 ] ; then + echo "The Docker container exited with code $exit_code. Terminating current process." + exit $exit_code + fi','SHELL','f','now()',1,'now()',1); + + +INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_step'), (SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'),'Step 1','Runnig the plugin','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1); + +INSERT INTO plugin_step_variable (id,plugin_step_id,name,format, description,is_exposed,allow_empty_value,default_value,value,variable_type,value_type,previous_step_index,variable_step_index,variable_step_index_in_plugin,reference_variable_name,deleted,created_on,created_by,updated_on,updated_by)VALUES +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApiToken','STRING','Enter Devtron API Token with required permissions.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEndpoint','STRING','Enter the URL of Devtron Dashboard for.eg (https://devtron.example.com).','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApp','STRING','Enter the name or ID of the Application whose build is to be triggered.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEnv','STRING','Enter the name or ID of the Environment to which the CI is attached. Required if CiPipeline is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'CiPipeline','STRING','Enter the name or ID of the CI pipeline to be triggered. Required if DevtronEnv is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null, 'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'GitCommitHash','STRING','Enter the commit hash from which the build is to be triggered. If not given then will pick the latest.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'Timeout','NUMBER','Enter the maximum time to wait for the build status.', 't','t',-1,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), +(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'IgnoreCache','STRING','Set true if you want to ignore cache for the build.', 't','t','false',null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1); diff --git a/scripts/sql/29201902_docker_lint.down.sql b/scripts/sql/29201902_docker_lint.down.sql new file mode 100644 index 00000000000..da8a0ad9c88 --- /dev/null +++ b/scripts/sql/29201902_docker_lint.down.sql @@ -0,0 +1,23 @@ +DELETE FROM plugin_step_variable WHERE plugin_step_id in (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false); + + +DELETE FROM plugin_step WHERE plugin_id = (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); + + +DELETE FROM plugin_stage_mapping WHERE plugin_id =(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); + + +DELETE FROM plugin_tag_relation WHERE plugin_id in (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); + +DELETE FROM pipeline_stage_step_variable where pipeline_stage_step_id in (select id from pipeline_stage_step where name = 'Docker Lint') ; + +DELETE FROM pipeline_stage_step where ref_plugin_id in (SELECT id from plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false); + + +DELETE from plugin_pipeline_script where id = (SELECT script_id from plugin_step WHERE plugin_id=(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false)); + + +DELETE FROM plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false; + + +DELETE FROM plugin_parent_metadata WHERE identifier ='docker-lint'; \ No newline at end of file diff --git a/scripts/sql/29201902_docker_lint.up.sql b/scripts/sql/29201902_docker_lint.up.sql new file mode 100644 index 00000000000..af3901e6718 --- /dev/null +++ b/scripts/sql/29201902_docker_lint.up.sql @@ -0,0 +1,73 @@ +INSERT INTO "plugin_parent_metadata" ("id", "name","identifier", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_parent_metadata'), 'Docker Lint','docker-lint','This is used to analyze the Dockerfile and offer suggestions for improvements','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/hadolint.png','f', 'now()', 1, 'now()', 1); + + +UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Docker Lint' and is_latest= true); + + +INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest") +VALUES (nextval('id_seq_plugin_metadata'), 'Docker Lint','This is used to analyze the Dockerfile and offer suggestions for improvements','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='docker-lint'),'1.0.0', false, true); + + +INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='Security') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1); + + +INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='DevSecOps') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1); + + +INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by") +VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),3,'now()', 1, 'now()', 1); + +INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by") +VALUES ( + nextval('id_seq_plugin_pipeline_script'), + E' + set -ex + arch=$(uname -m) + os=$(uname -s) + echo $arch + echo $os + command=$(wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-$os-$arch) + echo $command + docker_path="Dockerfile" + echo $docker_path + if [ ! -z "$DockerFilePath" ] + then + docker_path=$DockerFilePath + fi + echo $docker_path + cp hadolint-Linux-x86_64 hadolint + chmod +x hadolint + if [[ $FailOnError == "true" ]] + then + ./hadolint "/devtroncd/$docker_path" + else + ./hadolint "/devtroncd/$docker_path" --no-fail + fi + +', + 'SHELL', + 'f', + 'now()', + 1, + 'now()', + 1 +); + + + + + +INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_step'),(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'Step 1','Step 1 - Triggering Docker Lint','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1); + + +INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value", "variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'DockerFilePath','STRING','Specify the file path to the Dockerfile for linting. Default path is Dockerfile if not specified',true,true,'INPUT','NEW','',1 ,'f','now()', 1, 'now()', 1); + + +INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value","variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") +VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'FailOnError','STRING','Pass true/false to fail/pass the pipeline on error in docker lint',true,false,'INPUT','NEW','false',1 ,'f','now()', 1, 'now()', 1); + From 85279c8127453c6b83e5db8cafa3b451ed5bb5df Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:49:39 +0530 Subject: [PATCH 64/65] delete unwanted files (#6025) --- .../28901901_devtron_ci_trigger_v1_1.down.sql | 6 -- .../28901901_devtron_ci_trigger_v1_1.up.sql | 36 --------- scripts/sql/28901902_docker_lint.down.sql | 23 ------ scripts/sql/28901902_docker_lint.up.sql | 73 ------------------- scripts/sql/29001900_release_rbac.down.sql | 4 - scripts/sql/29001900_release_rbac.up.sql | 41 ----------- .../sql/29101900_notification_settings.up.sql | 2 - .../29101900_notification_stettings.down.sql | 1 - ...01900_helm_app_deployment_message.down.sql | 3 - ...9201900_helm_app_deployment_message.up.sql | 3 - 10 files changed, 192 deletions(-) delete mode 100644 scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql delete mode 100644 scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql delete mode 100644 scripts/sql/28901902_docker_lint.down.sql delete mode 100644 scripts/sql/28901902_docker_lint.up.sql delete mode 100644 scripts/sql/29001900_release_rbac.down.sql delete mode 100644 scripts/sql/29001900_release_rbac.up.sql delete mode 100644 scripts/sql/29101900_notification_settings.up.sql delete mode 100644 scripts/sql/29101900_notification_stettings.down.sql delete mode 100644 scripts/sql/29201900_helm_app_deployment_message.down.sql delete mode 100644 scripts/sql/29201900_helm_app_deployment_message.up.sql diff --git a/scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql b/scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql deleted file mode 100644 index d3ed16f788e..00000000000 --- a/scripts/sql/28901901_devtron_ci_trigger_v1_1.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELETE FROM plugin_step_variable WHERE plugin_step_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); -DELETE FROM plugin_step where plugin_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); -DELETE FROM plugin_pipeline_script where id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'); -DELETE FROM plugin_stage_mapping where plugin_id=(SELECT id from plugin_metadata where name='Devtron CI Trigger'); -DELETE FROM plugin_metadata where name='Devtron CI Trigger'; -UPDATE plugin_metadata SET is_latest = true WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= false); diff --git a/scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql b/scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql deleted file mode 100644 index 9b120ceb431..00000000000 --- a/scripts/sql/28901901_devtron_ci_trigger_v1_1.up.sql +++ /dev/null @@ -1,36 +0,0 @@ -UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= true); - -INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest") -VALUES (nextval('id_seq_plugin_metadata'), 'Devtron CI Trigger','Triggers the CI pipeline of Devtron Application','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='devtron-ci-trigger-v1-0-0'),'1.1.0', false, true); - -INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by") -VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.1.0' and name='Devtron CI Trigger' and deleted= false),0,'now()', 1, 'now()', 1); - -INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by")VALUES ( - nextval('id_seq_plugin_pipeline_script'), - E'#!/bin/sh - docker run -e DevtronApiToken=$DevtronApiToken -e DevtronEndpoint=$DevtronEndpoint -e DevtronApp=$DevtronApp -e CiPipeline=$CiPipeline -e DevtronEnv=$DevtronEnv -e GitCommitHash=$GitCommitHash -e Timeout=$Timeout -e IgnoreCache=$IgnoreCache --name devtron-ci-trigger quay.io/devtron/devtron-utils:ci-trigger-plugin-v1.1.0 - exit_code=$? - if [ $ExitOnFail == true ];then - if [ $exit_code == 2 ];then - echo "The triggered build has been failed terminating the current process." - exit $exit_code - fi - fi - if [ $exit_code -ne 0 ] && [ $exit_code -ne 2 ] ; then - echo "The Docker container exited with code $exit_code. Terminating current process." - exit $exit_code - fi','SHELL','f','now()',1,'now()',1); - - -INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_step'), (SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'),'Step 1','Runnig the plugin','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1); - -INSERT INTO plugin_step_variable (id,plugin_step_id,name,format, description,is_exposed,allow_empty_value,default_value,value,variable_type,value_type,previous_step_index,variable_step_index,variable_step_index_in_plugin,reference_variable_name,deleted,created_on,created_by,updated_on,updated_by)VALUES -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApiToken','STRING','Enter Devtron API Token with required permissions.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEndpoint','STRING','Enter the URL of Devtron Dashboard for.eg (https://devtron.example.com).','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApp','STRING','Enter the name or ID of the Application whose build is to be triggered.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEnv','STRING','Enter the name or ID of the Environment to which the CI is attached. Required if CiPipeline is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'CiPipeline','STRING','Enter the name or ID of the CI pipeline to be triggered. Required if DevtronEnv is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null, 'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'GitCommitHash','STRING','Enter the commit hash from which the build is to be triggered. If not given then will pick the latest.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'Timeout','NUMBER','Enter the maximum time to wait for the build status.', 't','t',-1,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1), -(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'IgnoreCache','STRING','Set true if you want to ignore cache for the build.', 't','t','false',null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1); diff --git a/scripts/sql/28901902_docker_lint.down.sql b/scripts/sql/28901902_docker_lint.down.sql deleted file mode 100644 index da8a0ad9c88..00000000000 --- a/scripts/sql/28901902_docker_lint.down.sql +++ /dev/null @@ -1,23 +0,0 @@ -DELETE FROM plugin_step_variable WHERE plugin_step_id in (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false); - - -DELETE FROM plugin_step WHERE plugin_id = (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); - - -DELETE FROM plugin_stage_mapping WHERE plugin_id =(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); - - -DELETE FROM plugin_tag_relation WHERE plugin_id in (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false); - -DELETE FROM pipeline_stage_step_variable where pipeline_stage_step_id in (select id from pipeline_stage_step where name = 'Docker Lint') ; - -DELETE FROM pipeline_stage_step where ref_plugin_id in (SELECT id from plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false); - - -DELETE from plugin_pipeline_script where id = (SELECT script_id from plugin_step WHERE plugin_id=(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false)); - - -DELETE FROM plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false; - - -DELETE FROM plugin_parent_metadata WHERE identifier ='docker-lint'; \ No newline at end of file diff --git a/scripts/sql/28901902_docker_lint.up.sql b/scripts/sql/28901902_docker_lint.up.sql deleted file mode 100644 index af3901e6718..00000000000 --- a/scripts/sql/28901902_docker_lint.up.sql +++ /dev/null @@ -1,73 +0,0 @@ -INSERT INTO "plugin_parent_metadata" ("id", "name","identifier", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_parent_metadata'), 'Docker Lint','docker-lint','This is used to analyze the Dockerfile and offer suggestions for improvements','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/hadolint.png','f', 'now()', 1, 'now()', 1); - - -UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Docker Lint' and is_latest= true); - - -INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest") -VALUES (nextval('id_seq_plugin_metadata'), 'Docker Lint','This is used to analyze the Dockerfile and offer suggestions for improvements','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='docker-lint'),'1.0.0', false, true); - - -INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='Security') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1); - - -INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='DevSecOps') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1); - - -INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by") -VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),3,'now()', 1, 'now()', 1); - -INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by") -VALUES ( - nextval('id_seq_plugin_pipeline_script'), - E' - set -ex - arch=$(uname -m) - os=$(uname -s) - echo $arch - echo $os - command=$(wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-$os-$arch) - echo $command - docker_path="Dockerfile" - echo $docker_path - if [ ! -z "$DockerFilePath" ] - then - docker_path=$DockerFilePath - fi - echo $docker_path - cp hadolint-Linux-x86_64 hadolint - chmod +x hadolint - if [[ $FailOnError == "true" ]] - then - ./hadolint "/devtroncd/$docker_path" - else - ./hadolint "/devtroncd/$docker_path" --no-fail - fi - -', - 'SHELL', - 'f', - 'now()', - 1, - 'now()', - 1 -); - - - - - -INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_step'),(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'Step 1','Step 1 - Triggering Docker Lint','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1); - - -INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value", "variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'DockerFilePath','STRING','Specify the file path to the Dockerfile for linting. Default path is Dockerfile if not specified',true,true,'INPUT','NEW','',1 ,'f','now()', 1, 'now()', 1); - - -INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value","variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") -VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'FailOnError','STRING','Pass true/false to fail/pass the pipeline on error in docker lint',true,false,'INPUT','NEW','false',1 ,'f','now()', 1, 'now()', 1); - diff --git a/scripts/sql/29001900_release_rbac.down.sql b/scripts/sql/29001900_release_rbac.down.sql deleted file mode 100644 index 82053ba8896..00000000000 --- a/scripts/sql/29001900_release_rbac.down.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE roles DROP COLUMN "release"; -ALTER TABLE roles DROP COLUMN "release_track"; -DELETE from rbac_role_resource_detail where resource in ('release','release-track'); -DELETE from rbac_policy_resource_detail where resource in ('release','release-track'); \ No newline at end of file diff --git a/scripts/sql/29001900_release_rbac.up.sql b/scripts/sql/29001900_release_rbac.up.sql deleted file mode 100644 index 6f4e61114dd..00000000000 --- a/scripts/sql/29001900_release_rbac.up.sql +++ /dev/null @@ -1,41 +0,0 @@ - -INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", - "resource_object", "eligible_entity_access_types", "deleted", "created_on", - "created_by", "updated_on", "updated_by") -VALUES ('release', '{"value": "release", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); - -INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", - "resource_object", "eligible_entity_access_types", "deleted", "created_on", - "created_by", "updated_on", "updated_by") -VALUES ('release-requirement', '{"value": "release-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); - -INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", - "resource_object", "eligible_entity_access_types", "deleted", "created_on", - "created_by", "updated_on", "updated_by") -VALUES ('release-track', '{"value": "release-track", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); - -INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions", - "resource_object", "eligible_entity_access_types", "deleted", "created_on", - "created_by", "updated_on", "updated_by") -VALUES ('release-track-requirement', '{"value": "release-track-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1); - - - - - -INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key", - "eligible_entity_access_types", "deleted", "created_on", "created_by", - "updated_on", "updated_by") -VALUES ('release', 'Release', 'Release', ARRAY ['release'], false, now(), 1, now(), 1); - - -INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key", - "eligible_entity_access_types", "deleted", "created_on", "created_by", - "updated_on", "updated_by") -VALUES ('release-track', 'ReleaseTrack', 'ReleaseTrack', ARRAY ['release'], false, now(), 1, now(), 1); - - - - -ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release" text; -ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release_track" text; \ No newline at end of file diff --git a/scripts/sql/29101900_notification_settings.up.sql b/scripts/sql/29101900_notification_settings.up.sql deleted file mode 100644 index cbe10af1a07..00000000000 --- a/scripts/sql/29101900_notification_settings.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE notification_settings drop constraint IF EXISTS notification_settings_env_id_fkey; -ALTER TABLE notification_settings ADD COLUMN IF NOT EXISTS cluster_id INT; diff --git a/scripts/sql/29101900_notification_stettings.down.sql b/scripts/sql/29101900_notification_stettings.down.sql deleted file mode 100644 index 045fc2f80d9..00000000000 --- a/scripts/sql/29101900_notification_stettings.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE notification_settings DROP COLUMN IF EXISTS cluster_id INT; \ No newline at end of file diff --git a/scripts/sql/29201900_helm_app_deployment_message.down.sql b/scripts/sql/29201900_helm_app_deployment_message.down.sql deleted file mode 100644 index 25eb9b043aa..00000000000 --- a/scripts/sql/29201900_helm_app_deployment_message.down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Drop the message column from the "public"."installed_app_version_history" table -ALTER TABLE "public"."installed_app_version_history" - DROP COLUMN IF EXISTS message; \ No newline at end of file diff --git a/scripts/sql/29201900_helm_app_deployment_message.up.sql b/scripts/sql/29201900_helm_app_deployment_message.up.sql deleted file mode 100644 index 8d08f591750..00000000000 --- a/scripts/sql/29201900_helm_app_deployment_message.up.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add message column to "public"."installed_app_version_history" table -ALTER TABLE "public"."installed_app_version_history" - ADD COLUMN IF NOT EXISTS message TEXT; \ No newline at end of file From 6d7f925e8072eb96d3b998bd65761f98cafeb926 Mon Sep 17 00:00:00 2001 From: Vikram <73224103+vikramdevtron@users.noreply.github.com> Date: Thu, 24 Oct 2024 23:36:17 +0530 Subject: [PATCH 65/65] chore: Common lib update (#6026) * misc: Replaced != with <> for PostgreSQL compatibility (#5987) * error handling while creating github repo * Replaced != with <> for PostgreSQL compatibility * removed deployment group validation when deleting CD pipelines (#5989) * fix for multiple param of filter in helm app list (#6013) * fix: plugin getByName method error handling (#6016) * plugin fix * reverted errnorows change * dep import --------- Co-authored-by: prakhar katiyar <39842461+prkhrkat@users.noreply.github.com> Co-authored-by: kartik-579 <84493919+kartik-579@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- pkg/plugin/GlobalPluginService.go | 2 +- vendor/modules.txt | 4 ++-- wire_gen.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 1efd69ec72a..ab7367a2f70 100644 --- a/go.mod +++ b/go.mod @@ -288,7 +288,7 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect replace ( github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.10 - github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c + github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241024135802-b4888f54a136 github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127 github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5 k8s.io/api => k8s.io/api v0.29.7 diff --git a/go.sum b/go.sum index 8b6d8016e78..4577dd412f5 100644 --- a/go.sum +++ b/go.sum @@ -794,8 +794,8 @@ github.com/devtron-labs/argo-workflows/v3 v3.5.10 h1:6rxQOesOzDz6SgQCMDQNHaehsKF github.com/devtron-labs/argo-workflows/v3 v3.5.10/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 h1:2+Q7Jdhpo/uMiaQiZZzAh+ZX7wEJIFuMFG6DEiMuo64= github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8/go.mod h1:702R6WIf5y9UzKGoCGxQ+x3l5Ws+l0fXg2xlCpSGFZI= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c h1:8WIzXcESSOAfkF7SmNLvxNxMnNS9DJtji6qlJr/5XzI= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241024135802-b4888f54a136 h1:rNGxjU5L6NvObxGMt0+vNFmjkqstm7zDASiS+pakrgQ= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241024135802-b4888f54a136/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ= github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU= github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y= github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys= diff --git a/pkg/plugin/GlobalPluginService.go b/pkg/plugin/GlobalPluginService.go index a39cef039b3..3335251b402 100644 --- a/pkg/plugin/GlobalPluginService.go +++ b/pkg/plugin/GlobalPluginService.go @@ -389,7 +389,7 @@ func (impl *GlobalPluginServiceImpl) GetRefPluginIdByRefPluginName(pluginName st impl.logger.Errorw("error in fetching plugin metadata by name", "err", err) return nil, err } - if pluginMetadata == nil { + if len(pluginMetadata) == 0 { return nil, nil } pluginVersionDetail = make([]bean2.PluginsVersionDetail, 0) diff --git a/vendor/modules.txt b/vendor/modules.txt index b53070b21c5..ba2dc057ac1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -344,7 +344,7 @@ github.com/devtron-labs/authenticator/jwt github.com/devtron-labs/authenticator/middleware github.com/devtron-labs/authenticator/oidc github.com/devtron-labs/authenticator/password -# github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c +# github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241024135802-b4888f54a136 ## explicit; go 1.21 github.com/devtron-labs/common-lib/async github.com/devtron-labs/common-lib/blob-storage @@ -2212,7 +2212,7 @@ xorm.io/xorm/log xorm.io/xorm/names xorm.io/xorm/schemas xorm.io/xorm/tags -# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241014135751-87207db6607c +# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241024135802-b4888f54a136 # github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127 # github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5 # k8s.io/api => k8s.io/api v0.29.7 diff --git a/wire_gen.go b/wire_gen.go index 110c18853a3..52afbd14764 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:generate go run github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject