diff --git a/.github/workflows/multiarch_new.yaml b/.github/workflows/multiarch_new.yaml index 7fb1a849c2..9834deb50c 100644 --- a/.github/workflows/multiarch_new.yaml +++ b/.github/workflows/multiarch_new.yaml @@ -41,8 +41,8 @@ jobs: local image="$1" local image_ref=$(echo $image | sed 's/:.*//') - # skipping the check for 'inception', 'postgres' , 'postgres_exporter' and 'workflow-controller' images - if [[ "$image_ref" == "inception" || "$image_ref" == "postgres" || "$image_ref" == "postgres_exporter" || "$image_ref" == "workflow-controller" ]]; then + # skipping the check for 'inception', 'postgres' , 'postgres_exporter', 'workflow-controller', 'casbin' and 'scoop' images + if [[ "$image_ref" == "inception" || "$image_ref" == "postgres" || "$image_ref" == "postgres_exporter" || "$image_ref" == "workflow-controller" || "$image_ref" == "casbin" || "$image_ref" == "scoop" ]]; then return fi diff --git a/api/restHandler/app/appList/AppListingRestHandler_ent.go b/api/restHandler/app/appList/AppListingRestHandler_ent.go index f84749afcb..48ff9ff1f7 100644 --- a/api/restHandler/app/appList/AppListingRestHandler_ent.go +++ b/api/restHandler/app/appList/AppListingRestHandler_ent.go @@ -15,5 +15,5 @@ func (handler AppListingRestHandlerImpl) GetAllAppEnvsFromResourceNames(w http.R } func (handler AppListingRestHandlerImpl) updateApprovalConfigDataInAppDetailResp(appDetail AppView.AppDetailContainer, appId, envId int) (AppView.AppDetailContainer, error) { - return AppView.AppDetailContainer{}, nil + return appDetail, nil } diff --git a/fetchAllEnv/fetchAllEnv.go b/fetchAllEnv/fetchAllEnv.go index 372a77323e..ed6163dc6d 100644 --- a/fetchAllEnv/fetchAllEnv.go +++ b/fetchAllEnv/fetchAllEnv.go @@ -17,210 +17,9 @@ package main import ( - "encoding/json" - "errors" - "go/ast" - "go/parser" - "go/token" - "log" - "os" - "path/filepath" - "reflect" - "sort" - "strings" - "text/template" + "github.com/devtron-labs/common-lib/fetchAllEnv" ) -type EnvField struct { - Env string - EnvType string - EnvValue string - EnvDescription string - Example string - Deprecated string -} - -type CategoryField struct { - Category string - Fields []EnvField -} - -const ( - categoryCommentStructPrefix = "CATEGORY=" - defaultCategory = "DEVTRON" - deprecatedDefaultValue = "false" - - envFieldTypeTag = "env" - envDefaultFieldTypeTag = "envDefault" - envDescriptionFieldTypeTag = "description" - envPossibleValuesFieldTypeTag = "example" - envDeprecatedFieldTypeTag = "deprecated" - MARKDOWN_FILENAME = "env_gen.md" - MARKDOWN_JSON_FILENAME = "env_gen.json" -) - -const MarkdownTemplate = ` -{{range . }} -## {{ .Category }} Related Environment Variables -| Key | Type | Default Value | Description | Example | Deprecated | -|-------|----------|-------------------|-------------------|-----------------------|------------------| -{{range .Fields }} | {{ .Env }} | {{ .EnvType }} |{{ .EnvValue }} | {{ .EnvDescription }} | {{ .Example }} | {{ .Deprecated }} | -{{end}} -{{end}}` - func main() { - WalkThroughProject() - return -} - -func WalkThroughProject() { - categoryFieldsMap := make(map[string][]EnvField) - uniqueKeys := make(map[string]bool) - err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if !info.IsDir() && strings.HasSuffix(path, ".go") { - err = processGoFile(path, categoryFieldsMap, uniqueKeys) - if err != nil { - log.Println("error in processing go file", err) - return err - } - } - return nil - }) - if err != nil { - return - } - writeToFile(categoryFieldsMap) -} - -func processGoFile(filePath string, categoryFieldsMap map[string][]EnvField, uniqueKeys map[string]bool) error { - fset := token.NewFileSet() - node, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments) - if err != nil { - log.Println("error parsing file:", err) - return err - } - ast.Inspect(node, func(n ast.Node) bool { - if genDecl, ok := n.(*ast.GenDecl); ok { - // checking if type declaration, one of [func, map, struct, array, channel, interface] - if genDecl.Tok == token.TYPE { - for _, spec := range genDecl.Specs { - if typeSpec, ok := spec.(*ast.TypeSpec); ok { - // only checking struct type declarations - if structType, ok2 := typeSpec.Type.(*ast.StructType); ok2 { - allFields := make([]EnvField, 0, len(structType.Fields.List)) - for _, field := range structType.Fields.List { - if field.Tag != nil { - envField := getEnvKeyAndValue(field) - envKey := envField.Env - if len(envKey) == 0 || uniqueKeys[envKey] { - continue - } - allFields = append(allFields, envField) - uniqueKeys[envKey] = true - } - } - if len(allFields) > 0 { - category := getCategoryForAStruct(genDecl) - categoryFieldsMap[category] = append(categoryFieldsMap[category], allFields...) - } - } - } - } - } - } - return true - }) - return nil -} - -func getEnvKeyAndValue(field *ast.Field) EnvField { - tag := reflect.StructTag(strings.Trim(field.Tag.Value, "`")) // remove surrounding backticks - - envKey := addReadmeTableDelimiterEscapeChar(tag.Get(envFieldTypeTag)) - envValue := addReadmeTableDelimiterEscapeChar(tag.Get(envDefaultFieldTypeTag)) - envDescription := addReadmeTableDelimiterEscapeChar(tag.Get(envDescriptionFieldTypeTag)) - envPossibleValues := addReadmeTableDelimiterEscapeChar(tag.Get(envPossibleValuesFieldTypeTag)) - envDeprecated := addReadmeTableDelimiterEscapeChar(tag.Get(envDeprecatedFieldTypeTag)) - // check if there exist any value provided in env for this field - if value, ok := os.LookupEnv(envKey); ok { - envValue = value - } - env := EnvField{ - Env: envKey, - EnvValue: envValue, - EnvDescription: envDescription, - Example: envPossibleValues, - Deprecated: envDeprecated, - } - if indent, ok := field.Type.(*ast.Ident); ok && indent != nil { - env.EnvType = indent.Name - } - if len(envDeprecated) == 0 { - env.Deprecated = deprecatedDefaultValue - } - return env -} - -func getCategoryForAStruct(genDecl *ast.GenDecl) string { - category := defaultCategory - if genDecl.Doc != nil { - commentTexts := strings.Split(genDecl.Doc.Text(), "\n") - for _, comment := range commentTexts { - commentText := strings.TrimPrefix(strings.ReplaceAll(comment, " ", ""), "//") // this can happen if comment group is in /* */ - if strings.HasPrefix(commentText, categoryCommentStructPrefix) { - categories := strings.Split(strings.TrimPrefix(commentText, categoryCommentStructPrefix), ",") - if len(categories) > 0 && len(categories[0]) > 0 { //only supporting one category as of now - category = categories[0] //overriding category - break - } - } - } - } - return category -} - -func addReadmeTableDelimiterEscapeChar(s string) string { - return strings.ReplaceAll(s, "|", `\|`) -} - -func writeToFile(categoryFieldsMap map[string][]EnvField) { - cfs := make([]CategoryField, 0, len(categoryFieldsMap)) - for category, allFields := range categoryFieldsMap { - sort.Slice(allFields, func(i, j int) bool { - return allFields[i].Env < allFields[j].Env - }) - - cfs = append(cfs, CategoryField{ - Category: category, - Fields: allFields, - }) - } - sort.Slice(cfs, func(i, j int) bool { - return cfs[i].Category < cfs[j].Category - }) - file, err := os.Create(MARKDOWN_FILENAME) - if err != nil && !errors.Is(err, os.ErrExist) { - panic(err) - } - defer file.Close() - tmpl, err := template.New("markdown").Parse(MarkdownTemplate) - if err != nil { - panic(err) - } - err = tmpl.Execute(file, cfs) - if err != nil { - panic(err) - } - cfsMarshaled, err := json.Marshal(cfs) - if err != nil { - log.Println("error marshalling category fields:", err) - panic(err) - } - err = os.WriteFile(MARKDOWN_JSON_FILENAME, cfsMarshaled, 0644) - if err != nil { - panic(err) - } + fetchAllEnv.FetchEnvAndWriteToFile() } diff --git a/go.mod b/go.mod index 3f3cf7e8b9..a5b1939cba 100644 --- a/go.mod +++ b/go.mod @@ -288,8 +288,8 @@ 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.13 - github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127090829-f050f9c05226 - github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127090829-f050f9c05226 + github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127104410-85d6bfe0b45f + github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127104410-85d6bfe0b45f 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 edd0f20472..150815b113 100644 --- a/go.sum +++ b/go.sum @@ -792,10 +792,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU= github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA= -github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127090829-f050f9c05226 h1:67Im8ME0J2Ukd8xbKuR+0rzT3oO0Obcd58keDb80C3I= -github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127090829-f050f9c05226/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127090829-f050f9c05226 h1:yYHCt3F0xLW0VlBGXqAsXLJElLcnEJCUkpQJxmgkTb4= -github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127090829-f050f9c05226/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA= +github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127104410-85d6bfe0b45f h1:8nYP02cYX/9e3H8YfBV4b8hP4WwbGY/dUMNu+N9cH1Q= +github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127104410-85d6bfe0b45f/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127104410-85d6bfe0b45f h1:4wUbt+83DmpZFqYS69CJxNtBpSuCb58UwqOrWsZG82s= +github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127104410-85d6bfe0b45f/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA= 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/deploymentConfig/repository.go b/internal/sql/repository/deploymentConfig/repository.go index 0dac42b98b..45dad95627 100644 --- a/internal/sql/repository/deploymentConfig/repository.go +++ b/internal/sql/repository/deploymentConfig/repository.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2020-2024. Devtron Inc. + * + * 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. + */ + package deploymentConfig import ( @@ -29,7 +45,7 @@ type DeploymentConfig struct { ConfigType string `sql:"config_type"` RepoUrl string `sql:"repo_url"` RepoName string `sql:"repo_name"` - ReleaseMode string `json:"release_mode"` + ReleaseMode string `sql:"release_mode"` Active bool `sql:"active,notnull"` sql.AuditLog } @@ -46,6 +62,7 @@ type Repository interface { GetAppAndEnvLevelConfigsInBulk(appIdToEnvIdsMap map[int][]int) ([]*DeploymentConfig, error) GetByAppIdAndEnvIdEvenIfInactive(appId, envId int) (*DeploymentConfig, error) UpdateRepoUrlByAppIdAndEnvId(repoUrl string, appId, envId int) error + GetConfigByAppIds(appIds []int) ([]*DeploymentConfig, error) } type RepositoryImpl struct { @@ -86,14 +103,19 @@ func (impl *RepositoryImpl) Update(tx *pg.Tx, config *DeploymentConfig) (*Deploy return config, err } -func (impl *RepositoryImpl) UpdateAll(tx *pg.Tx, config []*DeploymentConfig) ([]*DeploymentConfig, error) { +func (impl *RepositoryImpl) UpdateAll(tx *pg.Tx, configs []*DeploymentConfig) ([]*DeploymentConfig, error) { var err error - if tx != nil { - err = tx.Update(config) - } else { - err = impl.dbConnection.Update(config) + for _, config := range configs { + if tx != nil { + _, err = tx.Model(config).WherePK().UpdateNotNull() + } else { + _, err = impl.dbConnection.Model(&config).UpdateNotNull() + } + if err != nil { + return nil, err + } } - return config, err + return configs, err } func (impl *RepositoryImpl) GetById(id int) (*DeploymentConfig, error) { @@ -172,3 +194,12 @@ func (impl *RepositoryImpl) UpdateRepoUrlByAppIdAndEnvId(repoUrl string, appId, Update() return err } + +func (impl *RepositoryImpl) GetConfigByAppIds(appIds []int) ([]*DeploymentConfig, error) { + var results []*DeploymentConfig + err := impl.dbConnection.Model(&results). + Where("app_id in (?) ", pg.In(appIds)). + Where("active = ?", true). + Select() + return results, err +} diff --git a/pkg/deployment/common/deploymentConfigService.go b/pkg/deployment/common/deploymentConfigService.go index 86b8ddcc10..2d4d5bd4fb 100644 --- a/pkg/deployment/common/deploymentConfigService.go +++ b/pkg/deployment/common/deploymentConfigService.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2020-2024. Devtron Inc. + * + * 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. + */ + package common import ( @@ -18,6 +34,7 @@ import ( type DeploymentConfigService interface { CreateOrUpdateConfig(tx *pg.Tx, config *bean.DeploymentConfig, userId int32) (*bean.DeploymentConfig, error) + CreateOrUpdateConfigInBulk(tx *pg.Tx, configToBeCreated, configToBeUpdated []*bean.DeploymentConfig, userId int32) error IsDeploymentConfigUsed() bool GetConfigForDevtronApps(appId, envId int) (*bean.DeploymentConfig, error) GetAndMigrateConfigIfAbsentForDevtronApps(appId, envId int) (*bean.DeploymentConfig, error) @@ -27,6 +44,7 @@ type DeploymentConfigService interface { GetAppLevelConfigForDevtronApp(appId int) (*bean.DeploymentConfig, error) UpdateRepoUrlForAppAndEnvId(repoURL string, appId, envId int) error GetDeploymentAppTypeForCDInBulk(pipelines []*pipelineConfig.Pipeline) (map[int]string, error) + GetConfigsByAppIds(appIds []int) ([]*bean.DeploymentConfig, error) } type DeploymentConfigServiceImpl struct { @@ -90,6 +108,41 @@ func (impl *DeploymentConfigServiceImpl) CreateOrUpdateConfig(tx *pg.Tx, config return ConvertDeploymentConfigDbObjToDTO(newDBObj), nil } +func (impl *DeploymentConfigServiceImpl) CreateOrUpdateConfigInBulk(tx *pg.Tx, configToBeCreated, configToBeUpdated []*bean.DeploymentConfig, userId int32) error { + + dbObjCreate := make([]*deploymentConfig.DeploymentConfig, 0, len(configToBeCreated)) + for i := range configToBeCreated { + dbObj := ConvertDeploymentConfigDTOToDbObj(configToBeCreated[i]) + dbObj.AuditLog.CreateAuditLog(userId) + dbObjCreate = append(dbObjCreate, dbObj) + } + + dbObjUpdate := make([]*deploymentConfig.DeploymentConfig, 0, len(configToBeUpdated)) + for i := range configToBeUpdated { + dbObj := ConvertDeploymentConfigDTOToDbObj(configToBeUpdated[i]) + dbObj.AuditLog.UpdateAuditLog(userId) + dbObjUpdate = append(dbObjUpdate, dbObj) + } + + if len(dbObjCreate) > 0 { + _, err := impl.deploymentConfigRepository.SaveAll(tx, dbObjCreate) + if err != nil { + impl.logger.Errorw("error in saving deploymentConfig", "dbObjCreate", dbObjCreate, "err", err) + return err + } + } + + if len(dbObjUpdate) > 0 { + _, err := impl.deploymentConfigRepository.UpdateAll(tx, dbObjUpdate) + if err != nil { + impl.logger.Errorw("error in updating deploymentConfig", "dbObjUpdate", dbObjUpdate, "err", err) + return err + } + } + + return nil +} + func (impl *DeploymentConfigServiceImpl) IsDeploymentConfigUsed() bool { return impl.deploymentServiceTypeConfig.UseDeploymentConfigData } @@ -478,3 +531,19 @@ func (impl *DeploymentConfigServiceImpl) GetDeploymentAppTypeForCDInBulk(pipelin } return resp, nil } + +func (impl *DeploymentConfigServiceImpl) GetConfigsByAppIds(appIds []int) ([]*bean.DeploymentConfig, error) { + if len(appIds) == 0 { + return nil, nil + } + configs, err := impl.deploymentConfigRepository.GetConfigByAppIds(appIds) + if err != nil { + impl.logger.Errorw("error in getting deployment config db object by appIds", "appIds", appIds, "err", err) + return nil, err + } + resp := make([]*bean.DeploymentConfig, 0, len(configs)) + for _, config := range configs { + resp = append(resp, ConvertDeploymentConfigDbObjToDTO(config)) + } + return resp, nil +} diff --git a/pkg/imageDigestPolicy/imageDigestPolicyService.go b/pkg/imageDigestPolicy/imageDigestPolicyService.go index ad744946ba..4f330e9d1b 100644 --- a/pkg/imageDigestPolicy/imageDigestPolicyService.go +++ b/pkg/imageDigestPolicy/imageDigestPolicyService.go @@ -138,7 +138,7 @@ func (impl ImageDigestPolicyServiceImpl) DeletePolicyForPipeline(tx *pg.Tx, pipe UpdatedBy: userId, } devtronResourceSearchableKeyMap := impl.devtronResourceSearchableKey.GetAllSearchableKeyNameIdMap() - err := impl.qualifierMappingService.DeleteByIdentifierKeyValue(resourceQualifiers.ImageDigest, devtronResourceSearchableKeyMap[bean.DEVTRON_RESOURCE_SEARCHABLE_KEY_PIPELINE_ID], pipelineId, auditLog, tx) + err := impl.qualifierMappingService.DeleteByIdentifierKeyAndValue(resourceQualifiers.ImageDigest, devtronResourceSearchableKeyMap[bean.DEVTRON_RESOURCE_SEARCHABLE_KEY_PIPELINE_ID], pipelineId, 0, auditLog, tx) if err != nil { impl.logger.Errorw("error in deleting image digest policy for pipeline", "err", err, "pipelineId", pipelineId) return pipelineId, err diff --git a/pkg/resourceQualifiers/QualifierMappingService.go b/pkg/resourceQualifiers/QualifierMappingService.go index ec3b2a67fc..98af688320 100644 --- a/pkg/resourceQualifiers/QualifierMappingService.go +++ b/pkg/resourceQualifiers/QualifierMappingService.go @@ -34,13 +34,14 @@ type QualifierMappingService interface { CreateQualifierMappings(qualifierMappings []*QualifierMapping, tx *pg.Tx) ([]*QualifierMapping, error) GetQualifierMappings(resourceType ResourceType, scope *Scope, resourceIds []int) ([]*QualifierMapping, error) DeleteAllQualifierMappings(resourceType ResourceType, auditLog sql.AuditLog, tx *pg.Tx) error - DeleteByIdentifierKeyValue(resourceType ResourceType, identifierKey int, identifierValue int, auditLog sql.AuditLog, tx *pg.Tx) error + DeleteByIdentifierKeyAndValue(resourceType ResourceType, identifierKey int, identifierValue int, qualifierId int, auditLog sql.AuditLog, tx *pg.Tx) error DeleteAllByIds(qualifierMappingIds []int, userId int32, tx *pg.Tx) error DeleteResourceMappingsForScopes(tx *pg.Tx, userId int32, resourceType ResourceType, qualifierSelector QualifierSelector, scopes []*SelectionIdentifier) error CreateMappingsForSelections(tx *pg.Tx, userId int32, resourceMappingSelections []*ResourceMappingSelection) ([]*ResourceMappingSelection, error) CreateMappings(tx *pg.Tx, userId int32, resourceType ResourceType, resourceIds []int, qualifierSelector QualifierSelector, selectionIdentifiers []*SelectionIdentifier) error GetResourceMappingsForSelections(resourceType ResourceType, qualifierSelector QualifierSelector, selectionIdentifiers []*SelectionIdentifier) ([]ResourceQualifierMappings, error) GetResourceMappingsForResources(resourceType ResourceType, resourceIds []int, qualifierSelector QualifierSelector) ([]ResourceQualifierMappings, error) + QualifierMappingServiceEnt } type QualifierMappingServiceImpl struct { @@ -70,7 +71,7 @@ func (impl *QualifierMappingServiceImpl) DeleteAllQualifierMappings(resourceType return impl.qualifierMappingRepository.DeleteAllQualifierMappings(resourceType, auditLog, tx) } -func (impl *QualifierMappingServiceImpl) DeleteByIdentifierKeyValue(resourceType ResourceType, identifierKey int, identifierValue int, auditLog sql.AuditLog, tx *pg.Tx) error { +func (impl *QualifierMappingServiceImpl) DeleteByIdentifierKeyAndValue(resourceType ResourceType, identifierKey int, identifierValue int, qualifierId int, auditLog sql.AuditLog, tx *pg.Tx) error { return impl.qualifierMappingRepository.DeleteByResourceTypeIdentifierKeyAndValue(resourceType, identifierKey, identifierValue, auditLog, tx) } @@ -86,28 +87,8 @@ func (impl *QualifierMappingServiceImpl) DeleteAllByIds(qualifierMappingIds []in func (impl *QualifierMappingServiceImpl) CreateMappingsForSelections(tx *pg.Tx, userId int32, resourceMappingSelections []*ResourceMappingSelection) ([]*ResourceMappingSelection, error) { - resourceKeyMap := impl.devtronResourceSearchableKeyService.GetAllSearchableKeyNameIdMap() - - parentMappings := make([]*QualifierMapping, 0) - childrenMappings := make([]*QualifierMapping, 0) - parentMappingsMap := make(map[string]*QualifierMapping) - - mappingsToSelection := make(map[*QualifierMapping]*ResourceMappingSelection) - for _, selection := range resourceMappingSelections { - - var parent *QualifierMapping - children := make([]*QualifierMapping, 0) - if selection.QualifierSelector.isCompound() { - parent, children = GetQualifierMappingsForCompoundQualifier(selection, resourceKeyMap, userId) - parentMappingsMap[parent.CompositeKey] = parent - } else { - intValue, stringValue := GetValuesFromSelectionIdentifier(selection.QualifierSelector, selection.SelectionIdentifier) - parent = selection.toResourceMapping(selection.QualifierSelector, resourceKeyMap, intValue, stringValue, "", userId) - } - mappingsToSelection[parent] = selection - parentMappings = append(parentMappings, parent) - childrenMappings = append(childrenMappings, children...) - } + parentMappings, childrenMappings, mappingsToSelection, parentMappingsMap := getParentAndChildrenMappingForCreation(resourceMappingSelections, + impl.devtronResourceSearchableKeyService.GetAllSearchableKeyNameIdMap(), userId) if len(parentMappings) > 0 { _, err := impl.qualifierMappingRepository.CreateQualifierMappings(parentMappings, tx) @@ -140,6 +121,32 @@ func (impl *QualifierMappingServiceImpl) CreateMappingsForSelections(tx *pg.Tx, return maps.Values(mappingsToSelection), nil } +func getParentAndChildrenMappingForCreation(resourceMappingSelections []*ResourceMappingSelection, resourceKeyMap map[bean.DevtronResourceSearchableKeyName]int, + userId int32) ([]*QualifierMapping, []*QualifierMapping, map[*QualifierMapping]*ResourceMappingSelection, map[string]*QualifierMapping) { + + parentMappings := make([]*QualifierMapping, 0) + childrenMappings := make([]*QualifierMapping, 0) + parentMappingsMap := make(map[string]*QualifierMapping) + + mappingsToSelection := make(map[*QualifierMapping]*ResourceMappingSelection) + for _, selection := range resourceMappingSelections { + + var parent *QualifierMapping + children := make([]*QualifierMapping, 0) + if selection.QualifierSelector.isCompound() { + parent, children = GetQualifierMappingsForCompoundQualifier(selection, resourceKeyMap, userId) + parentMappingsMap[parent.CompositeKey] = parent + } else { + intValue, stringValue := GetValuesFromSelectionIdentifier(selection.QualifierSelector, selection.SelectionIdentifier) + parent = selection.toResourceMapping(selection.QualifierSelector, resourceKeyMap, intValue, stringValue, "", userId) + } + mappingsToSelection[parent] = selection + parentMappings = append(parentMappings, parent) + childrenMappings = append(childrenMappings, children...) + } + return parentMappings, childrenMappings, mappingsToSelection, parentMappingsMap +} + func (impl *QualifierMappingServiceImpl) CreateMappings(tx *pg.Tx, userId int32, resourceType ResourceType, resourceIds []int, qualifierSelector QualifierSelector, selectionIdentifiers []*SelectionIdentifier) error { mappings := make([]*ResourceMappingSelection, 0) for _, id := range resourceIds { @@ -157,7 +164,7 @@ func (impl *QualifierMappingServiceImpl) CreateMappings(tx *pg.Tx, userId int32, return err } -func (impl *QualifierMappingServiceImpl) filterAndGroupMappings(mappings []*QualifierMapping, selector QualifierSelector, composites mapset.Set) [][]*QualifierMapping { +func filterAndGroupMappings(mappings []*QualifierMapping, selector QualifierSelector, composites mapset.Set) [][]*QualifierMapping { numQualifiers := GetNumOfChildQualifiers(selector.toQualifier()) parentIdToChildMappings := make(map[int][]*QualifierMapping) @@ -289,7 +296,7 @@ func (impl *QualifierMappingServiceImpl) GetResourceMappingsForResources(resourc } func (impl *QualifierMappingServiceImpl) processMappings(resourceType ResourceType, mappings []*QualifierMapping, qualifierSelector QualifierSelector, composites mapset.Set) ([]ResourceQualifierMappings, error) { - groups := impl.filterAndGroupMappings(mappings, qualifierSelector, composites) + groups := filterAndGroupMappings(mappings, qualifierSelector, composites) if qualifierSelector != ApplicationEnvironmentSelector { return nil, fmt.Errorf("selector currently not implemented") } diff --git a/pkg/resourceQualifiers/QualifierMappingService_ent.go b/pkg/resourceQualifiers/QualifierMappingService_ent.go new file mode 100644 index 0000000000..8bb5bdab29 --- /dev/null +++ b/pkg/resourceQualifiers/QualifierMappingService_ent.go @@ -0,0 +1,4 @@ +package resourceQualifiers + +type QualifierMappingServiceEnt interface { +} 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 6fc1879ed6..5f8d35bd27 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 @@ -56,10 +56,10 @@ spec: matchLabels: {{- if .Values.customMatchLabels }} {{ toYaml .Values.customMatchLabels | indent 6 }} - {{- else }} +{{- else }} app: {{ template ".Chart.Name .name" $ }} release: {{ $.Release.Name }} -{{- end }} +{{- end }} replicas: {{ $.Values.replicaCount }} minReadySeconds: {{ $.Values.MinReadySeconds }} template: @@ -71,20 +71,19 @@ spec: {{- end }} {{- end }} labels: + app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} - {{- if .Values.appLabels }} -{{ toYaml .Values.appLabels | indent 8 }} -{{- end }} + release: {{ $.Release.Name }} {{- if .Values.customPodLabels }} -{{ toYaml .Values.customPodLabels | indent 8 }} - {{- else }} - app: {{ template ".Chart.Name .name" $ }} - release: {{ $.Release.Name }} +{{ toYaml .Values.customPodLabels | indent 8 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} {{- if .Values.podLabels }} {{ toYaml .Values.podLabels | indent 8 }} {{- end }} -{{- end }} spec: {{- if $.Values.podExtraSpecs }} {{ toYaml .Values.podExtraSpecs | indent 6 }} @@ -492,7 +491,7 @@ spec: {{- 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 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"}} @@ -666,9 +665,10 @@ spec: matchLabels: {{- if .Values.customMatchLabels }} {{ toYaml .Values.customMatchLabels | indent 6 }} -{{- end }} +{{- else }} app: {{ template ".Chart.Name .name" $ }} release: {{ $.Release.Name }} +{{- end }} replicas: {{ $.Values.secondaryWorkload.replicaCount | default 1 }} minReadySeconds: {{ $.Values.MinReadySeconds }} template: @@ -1102,7 +1102,7 @@ spec: {{- 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 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"}} @@ -1233,7 +1233,7 @@ spec: {{- 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 }} + {{- 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 }} @@ -1248,4 +1248,5 @@ spec: {{- if eq .Values.deploymentType "RECREATE" }} type: "Recreate" {{- end }} -{{- end }} \ No newline at end of file +{{- 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 index 91553a09f5..fd7c7e3f60 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 @@ -8,7 +8,11 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if $.Values.autoscaling.name }} + name: {{ $.Values.autoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- end }} {{- if .Values.autoscaling.annotations }} annotations: {{ toYaml .Values.autoscaling.annotations | indent 4 }} @@ -22,6 +26,9 @@ metadata: {{- if .Values.autoscaling.labels }} {{ toYaml .Values.autoscaling.labels | indent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: apps/v1 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 index ac7b456ec5..8340555ff3 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: + {{- if .authorizationPolicy.name }} + name: {{ .authorizationPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index 47bef9a828..4d06deb0b8 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: DestinationRule metadata: + {{- if .destinationRule.name }} + name: {{ .destinationRule.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index d657959010..15c3638939 100644 --- 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 @@ -2,7 +2,11 @@ apiVersion: networking.istio.io/v1beta1 kind: Gateway metadata: + {{- if .Values.istio.gateway.name }} + name: {{ .Values.istio.gateway.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -28,7 +32,13 @@ spec: name: http protocol: HTTP hosts: +{{- if .Values.istio.gateway.host }} - {{ .Values.istio.gateway.host | quote -}} +{{- else if .Values.istio.gateway.hosts }} +{{- range .Values.istio.gateway.hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} {{ with .Values.istio.gateway }} {{- if .tls.enabled }} tls: @@ -38,7 +48,13 @@ spec: name: https protocol: HTTPS hosts: +{{- if .host }} - {{ .host | quote }} +{{- else if .hosts }} +{{- range .hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} tls: mode: SIMPLE credentialName: {{ .tls.secretName }} 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 index 481f8a9647..dedd971c6d 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: + {{- if .peerAuthentication.name }} + name: {{ .peerAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index 3429cee146..49bb89552d 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: RequestAuthentication metadata: + {{- if .requestAuthentication.name }} + name: {{.requestAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index af61039b8d..02a9007ed2 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: - name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- if .virtualService.name }} + name: {{ .virtualService.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -33,7 +37,13 @@ spec: {{- if or .gateway.enabled .virtualService.hosts }} hosts: {{- if .gateway.enabled }} + {{- if .gateway.host }} - {{ .gateway.host | quote }} + {{- else if .gateway.hosts }} +{{- range .gateway.hosts }} + - {{ . | quote }} +{{- end }} + {{- end }} {{- end }} {{- range .virtualService.hosts }} - {{ . | quote }} 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 371363ab1a..780afa73b1 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 @@ -69,7 +69,9 @@ metadata: release: {{ $.Release.Name }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} - + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} spec: {{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} {{- 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 index 350232a23b..ee8bdaf8be 100644 --- 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 @@ -1,9 +1,12 @@ {{- if .Values.networkPolicy.enabled -}} -{{- with .Values.networkPolicy }} apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: + {{- if .Values.networkPolicy.name }} + name: {{ .Values.networkPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -46,5 +49,4 @@ spec: 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/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-20-0/templates/vertical-pod-autoscaler.yaml index 921a04294f..ffbf24d823 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: + {{- if .Values.verticalPodScaling.name }} + name: {{ .Values.verticalPodScaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-vpa + {{- end }} labels: kind: Prometheus app: {{ template ".Chart.Name .name" . }} 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 dd0395f97f..968c865d21 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 @@ -162,17 +162,20 @@ service: # test3: test4 istio: - enable: false + enable: true gateway: - enabled: false + enabled: true labels: {} annotations: {} - host: example.com + # host: example.com + hosts: + - kamal + - "example4.com" tls: - enabled: false + enabled: true secretName: example-tls-secret virtualService: - enabled: false + enabled: true labels: {} annotations: {} gateways: [] @@ -766,7 +769,7 @@ affinity: topologyKey: topology.kubernetes.io/zone secondaryWorkload: - enabled: true + enabled: false postfix: "od" replicaCount: 1 affinity: {} 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 c015815fea..55219ab5cb 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 @@ -558,8 +558,6 @@ ConfigMaps: ConfigSecrets: enabled: false secrets: [] - enabled: false - secrets: [] # data: # key1: key1value-1 # key2: key2value-1 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 index 1d10f9e0c4..f293e21421 100644 --- 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 @@ -55,10 +55,10 @@ spec: matchLabels: {{- if .Values.customMatchLabels }} {{ toYaml .Values.customMatchLabels | indent 6 }} - {{- else }} +{{- else }} app: {{ template ".Chart.Name .name" $ }} release: {{ $.Release.Name }} -{{- end }} +{{- end }} replicas: {{ $.Values.replicaCount }} minReadySeconds: {{ $.Values.MinReadySeconds }} template: @@ -70,20 +70,19 @@ spec: {{- end }} {{- end }} labels: + app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} - {{- if .Values.appLabels }} -{{ toYaml .Values.appLabels | indent 8 }} -{{- end }} + release: {{ $.Release.Name }} {{- if .Values.customPodLabels }} -{{ toYaml .Values.customPodLabels | indent 8 }} - {{- else }} - app: {{ template ".Chart.Name .name" $ }} - release: {{ $.Release.Name }} +{{ toYaml .Values.customPodLabels | indent 8 }} +{{- end }} +{{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 8 }} +{{- end }} {{- if .Values.podLabels }} {{ toYaml .Values.podLabels | indent 8 }} {{- end }} -{{- end }} spec: {{- if $.Values.podExtraSpecs }} {{ toYaml .Values.podExtraSpecs | indent 6 }} @@ -622,4 +621,4 @@ spec: maxUnavailable: {{ $.Values.deployment.strategy.canary.maxUnavailable }} steps: {{ toYaml .Values.deployment.strategy.canary.steps | indent 8 }} - {{- end }} \ No newline at end of file + {{- 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 index c7ba46e15b..76ba9455c2 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 @@ -8,7 +8,11 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if $.Values.autoscaling.name }} + name: {{ $.Values.autoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- end }} {{- if .Values.autoscaling.annotations }} annotations: {{ toYaml .Values.autoscaling.annotations | indent 4 }} @@ -22,6 +26,9 @@ metadata: {{- if .Values.autoscaling.labels }} {{ toYaml .Values.autoscaling.labels | indent 4 }} {{- end }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: argoproj.io/v1alpha1 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 index ac7b456ec5..8340555ff3 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: + {{- if .authorizationPolicy.name }} + name: {{ .authorizationPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index 47bef9a828..4d06deb0b8 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: DestinationRule metadata: + {{- if .destinationRule.name }} + name: {{ .destinationRule.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index d657959010..ba654bc392 100644 --- 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 @@ -2,7 +2,11 @@ apiVersion: networking.istio.io/v1beta1 kind: Gateway metadata: + {{- if .Values.istio.gateway.name }} + name: {{ .Values.istio.gateway.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -28,7 +32,13 @@ spec: name: http protocol: HTTP hosts: +{{- if .Values.istio.gateway.host }} - {{ .Values.istio.gateway.host | quote -}} +{{- else if .Values.istio.gateway.hosts }} +{{- range .Values.istio.gateway.hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} {{ with .Values.istio.gateway }} {{- if .tls.enabled }} tls: @@ -38,7 +48,13 @@ spec: name: https protocol: HTTPS hosts: +{{- if .host }} - {{ .host | quote }} +{{- else if .hosts }} +{{- range .hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} tls: mode: SIMPLE credentialName: {{ .tls.secretName }} 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 index 481f8a9647..dedd971c6d 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: + {{- if .peerAuthentication.name }} + name: {{ .peerAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index 3429cee146..49bb89552d 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: RequestAuthentication metadata: + {{- if .requestAuthentication.name }} + name: {{.requestAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} 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 index af61039b8d..76c2c14a8a 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: - name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- if .virtualService.name }} + name: {{ .virtualService.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -33,7 +37,13 @@ spec: {{- if or .gateway.enabled .virtualService.hosts }} hosts: {{- if .gateway.enabled }} + {{- if .gateway.host }} - {{ .gateway.host | quote }} + {{- else if .gateway.hosts }} +{{- range .gateway.hosts }} + - {{ . | quote }} +{{- end }} + {{- end }} {{- end }} {{- range .virtualService.hosts }} - {{ . | quote }} 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 ae06dd63ee..b1ad9fa145 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 @@ -69,7 +69,9 @@ metadata: release: {{ $.Release.Name }} appId: {{ $.Values.app | quote }} envId: {{ $.Values.env | quote }} - + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} spec: {{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} {{- 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 index 350232a23b..d6f427e569 100644 --- 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 @@ -1,9 +1,12 @@ {{- if .Values.networkPolicy.enabled -}} -{{- with .Values.networkPolicy }} apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: + {{- if .Values.networkPolicy.name }} + name: {{ .Values.networkPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -47,4 +50,3 @@ spec: {{ 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/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-20-0/templates/vertical-pod-autoscaler.yaml index 6e783e2300..d981bfbea0 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: + {{- if .Values.verticalPodScaling.name }} + name: {{ .Values.verticalPodScaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-vpa + {{- end }} labels: kind: Prometheus app: {{ template ".Chart.Name .name" . }} 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 index 7077cd4327..b3bee9cf48 100644 --- 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 @@ -581,7 +581,7 @@ tolerations: [] # value: "value" # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" -appMetrics: false +appMetrics: true serviceAccount: ## @param serviceAccount.create Enable creation of ServiceAccount for pods ## @@ -646,3 +646,68 @@ affinity: values: - S1 topologyKey: topology.kubernetes.io/zone + +istio: + enable: true + gateway: + enabled: true + labels: {} + annotations: {} + host: "example.com" + hosts: + - "example1.com" + - "example2.com" + tls: + enabled: true + secretName: secret-name + virtualService: + enabled: true + labels: {} + annotations: {} + gateways: [] + hosts: + - "example3.com" + - "example4.com" + 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: [] diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml index 0555153aee..454d1b5fa9 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml @@ -40,6 +40,8 @@ ContainerPort: useHTTP2: false supportStreaming: false idleTimeout: 1800s + protocol: TCP + resizePolicy: [] # servicemonitor: # enabled: true # path: /abc @@ -223,6 +225,10 @@ Spec: # Key: kops.k8s.io/instancegroup Values: +affinity: + enabled: false + values: {} + ambassadorMapping: enabled: false labels: {} @@ -247,6 +253,10 @@ autoscaling: annotations: {} labels: {} behavior: {} + containerResource: + enabled: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 # scaleDown: # stabilizationWindowSeconds: 300 # policies: @@ -299,7 +309,7 @@ servicemonitor: additionalLabels: {} envoyproxy: - image: docker.io/envoyproxy/envoy:v1.16.0 + image: quay.io/devtron/envoy:v1.16.0 configMapName: "" lifecycle: {} resources: @@ -425,3 +435,8 @@ hostAliases: [] # 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_5-0-0/templates/_helpers.tpl b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/_helpers.tpl index ada78dad51..170e5fb273 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/_helpers.tpl +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/_helpers.tpl @@ -140,3 +140,11 @@ Create chart name and version as used by the chart label. {{ 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_5-0-0/templates/configmap.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/configmap.yaml index 72d5ca8479..4e7879665e 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/configmap.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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_5-0-0/templates/deployment.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/deployment.yaml index f10cf8325b..85e90fa56b 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/deployment.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/deployment.yaml @@ -11,6 +11,11 @@ {{- end }} {{- end }} + {{- $hasPVCExists := false -}} + {{- if .Values.persistentVolumeClaim.name }} + {{- $hasPVCExists = true }} + {{- end }} + {{- $hasSecretEnvExists := false -}} {{- $hasSecretVolumeExists := false -}} {{- if .Values.ConfigSecrets.enabled }} @@ -54,8 +59,12 @@ spec: {{- end }} selector: matchLabels: +{{- if .Values.customMatchLabels }} +{{ toYaml .Values.customMatchLabels | indent 6 }} +{{- else }} app: {{ template ".Chart.Name .name" $ }} release: {{ $.Release.Name }} +{{- end }} replicas: {{ $.Values.replicaCount }} minReadySeconds: {{ $.Values.MinReadySeconds }} template: @@ -71,6 +80,9 @@ spec: 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 }} @@ -97,12 +109,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.tolerations }} tolerations: {{ toYaml .Values.tolerations | indent 8 }} @@ -155,64 +173,9 @@ spec: 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 -}} +{{- if .args}} + args: +{{ toYaml .args | indent 12 -}} {{- end}} {{- if .resources}} resources: @@ -228,6 +191,7 @@ spec: {{- end}} {{- end}} {{- end}} + containers: - name: {{ $.Chart.Name }} image: "{{ .Values.server.deployment.image }}:{{ .Values.server.deployment.image_tag }}" imagePullPolicy: {{ $.Values.image.pullPolicy }} @@ -260,7 +224,7 @@ spec: {{- range $.Values.ContainerPort }} - name: {{ .name}} containerPort: {{ .port }} - protocol: TCP + protocol: {{ .protocol | default "TCP" }} {{- end}} {{- if and $.Values.command.enabled $.Values.command.workingDir }} workingDir: {{ $.Values.command.workingDir }} @@ -275,9 +239,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 @@ -354,6 +318,7 @@ spec: httpGet: path: {{ $.Values.LivenessProbe.Path }} port: {{ $.Values.LivenessProbe.port }} + scheme: {{ $.Values.LivenessProbe.scheme }} {{- if $.Values.LivenessProbe.httpHeaders }} httpHeaders: {{- range $.Values.LivenessProbe.httpHeaders}} @@ -383,6 +348,7 @@ spec: httpGet: path: {{ $.Values.ReadinessProbe.Path }} port: {{ $.Values.ReadinessProbe.port }} + scheme: {{ $.Values.ReadinessProbe.scheme }} {{- if $.Values.ReadinessProbe.httpHeaders }} httpHeaders: {{- range $.Values.ReadinessProbe.httpHeaders}} @@ -441,6 +407,10 @@ spec: {{- 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"}} @@ -471,7 +441,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}} @@ -480,15 +465,98 @@ spec: {{- 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 }} - + {{- 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 }} +{{- if .Values.persistentVolumeClaim.name }} + - name: {{.Values.persistentVolumeClaim.name}}-vol + persistentVolumeClaim: + claimName: {{.Values.persistentVolumeClaim.name }} +{{- end}} {{- with .Values.volumes }} {{ toYaml . | trim | indent 8 }} {{- end }} @@ -527,9 +595,8 @@ spec: {{- 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 }} - + {{- 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 }} @@ -549,6 +616,30 @@ spec: maxUnavailable: {{ $.Values.deployment.strategy.rolling.maxUnavailable }} {{- else if eq .Values.deploymentType "CANARY" }} canary: + {{- if .Values.deployment.strategy.canary.antiAffinity }} + antiAffinity: +{{ toYaml .Values.deployment.strategy.canary.antiAffinity | indent 8 }} + {{- end }} + {{- if .Values.deployment.strategy.canary.canaryMetadata }} + canaryMetadata: +{{ toYaml .Values.deployment.strategy.canary.canaryMetadata | indent 8 }} + {{- end }} +# {{- if .Values.deployment.strategy.canary.maxSurge }} +# maxSurge: +# {{ toYaml .Values.deployment.strategy.canary.maxSurge | indent 8 }} +# {{- end }} + {{- if .Values.deployment.strategy.canary.pingPong }} + pingPong: +{{ toYaml .Values.deployment.strategy.canary.pingPong | indent 8 }} + {{- end }} +# {{- if .Values.deployment.strategy.canary.maxUnavailable }} +# maxUnavailable: +# {{ toYaml .Values.deployment.strategy.canary.maxUnavailable | indent 8 }} +# {{- end }} + {{- if .Values.deployment.strategy.canary.stableMetadata }} + stableMetadata: +{{ toYaml .Values.deployment.strategy.canary.stableMetadata | indent 8 }} + {{- end }} {{- if .Values.deployment.strategy.canary.analysis }} analysis: {{ toYaml .Values.deployment.strategy.canary.analysis | indent 8 }} @@ -577,6 +668,40 @@ spec: {{- else }} trafficSplitName: {{ template ".Chart.Name .fullname" $ }}-traffic-split {{- end }} - {{- end }} + {{- else if .Values.deployment.strategy.canary.trafficRouting.alb }} + alb: + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.ingress }} + ingress: {{ .Values.deployment.strategy.canary.trafficRouting.alb.ingress }} + {{- else if $.Values.ingress.name }} + ingress: .Values.ingress.name + {{- else }} + ingress: {{ template ".Chart.Name .fullname" . }}-ingress + {{- end }} + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.rootService }} + rootService: {{ .Values.deployment.strategy.canary.trafficRouting.alb.rootService }} + {{- else }} + rootService: {{ template ".servicename" . }} + {{- end }} + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.annotationPrefix }} + annotationPrefix: {{ .Values.deployment.strategy.canary.trafficRouting.alb.annotationPrefix }} + {{- end }} + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.servicePort }} + servicePort: {{ .Values.deployment.strategy.canary.trafficRouting.alb.servicePort }} + {{- else }} + {{- with index .Values.ContainerPort 0 }} + servicePort: {{ .servicePort }} + {{- end }} + {{- end }} + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.stickinessConfig }} + stickinessConfig: +{{ toYaml .Values.deployment.strategy.canary.trafficRouting.alb.stickinessConfig | nindent 12 }} + {{- end }} + {{- if .Values.deployment.strategy.canary.trafficRouting.alb.ingresses }} + ingresses: + {{- range .Values.deployment.strategy.canary.trafficRouting.alb.ingresses }} + - {{ . }} + {{- end }} + {{- end }} + {{- end }} {{- end }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/externalsecrets.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/externalsecrets.yaml index bdb4223cc0..efd291af5d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/externalsecrets.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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: @@ -41,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 }} @@ -54,4 +72,5 @@ spec: {{- end}} {{- end}} {{- end}} +{{- end}} {{- end}} \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/hpa.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/hpa.yaml index a0e1515576..76ba9455c2 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/hpa.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/hpa.yaml @@ -8,15 +8,27 @@ apiVersion: autoscaling/v2beta1 {{- end }} kind: HorizontalPodAutoscaler metadata: + {{- if $.Values.autoscaling.name }} + name: {{ $.Values.autoscaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-hpa + {{- end }} {{- if .Values.autoscaling.annotations }} 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 }} +{{- if $.Values.appLabels }} +{{ toYaml $.Values.appLabels | indent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: argoproj.io/v1alpha1 @@ -25,6 +37,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/reference-chart_5-0-0/templates/ingress.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/ingress.yaml index 416b1af567..1d47899d0b 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/ingress.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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_5-0-0/templates/istio-authorizationpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-authorizationpolicy.yaml index ac7b456ec5..8340555ff3 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-authorizationpolicy.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-authorizationpolicy.yaml @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: + {{- if .authorizationPolicy.name }} + name: {{ .authorizationPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-destinationrule.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-destinationrule.yaml index 47bef9a828..4d06deb0b8 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-destinationrule.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-destinationrule.yaml @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: DestinationRule metadata: + {{- if .destinationRule.name }} + name: {{ .destinationRule.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-destinationrule + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-gateway.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-gateway.yaml index d657959010..ba654bc392 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-gateway.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-gateway.yaml @@ -2,7 +2,11 @@ apiVersion: networking.istio.io/v1beta1 kind: Gateway metadata: + {{- if .Values.istio.gateway.name }} + name: {{ .Values.istio.gateway.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-istio-gateway + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -28,7 +32,13 @@ spec: name: http protocol: HTTP hosts: +{{- if .Values.istio.gateway.host }} - {{ .Values.istio.gateway.host | quote -}} +{{- else if .Values.istio.gateway.hosts }} +{{- range .Values.istio.gateway.hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} {{ with .Values.istio.gateway }} {{- if .tls.enabled }} tls: @@ -38,7 +48,13 @@ spec: name: https protocol: HTTPS hosts: +{{- if .host }} - {{ .host | quote }} +{{- else if .hosts }} +{{- range .hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} tls: mode: SIMPLE credentialName: {{ .tls.secretName }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-peerauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-peerauthentication.yaml index 481f8a9647..dedd971c6d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-peerauthentication.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-peerauthentication.yaml @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: + {{- if .peerAuthentication.name }} + name: {{ .peerAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-requestauthentication.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-requestauthentication.yaml index 3429cee146..b314653d31 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-requestauthentication.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-requestauthentication.yaml @@ -3,7 +3,11 @@ apiVersion: security.istio.io/v1beta1 kind: RequestAuthentication metadata: + {{- if .requestAuthentication.name }} + name: {{ .requestAuthentication.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }} + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-virtualservice.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-virtualservice.yaml index af61039b8d..76c2c14a8a 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-virtualservice.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/istio-virtualservice.yaml @@ -3,7 +3,11 @@ apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: - name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- if .virtualService.name }} + name: {{ .virtualService.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" $ }}-virtualservice + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -33,7 +37,13 @@ spec: {{- if or .gateway.enabled .virtualService.hosts }} hosts: {{- if .gateway.enabled }} + {{- if .gateway.host }} - {{ .gateway.host | quote }} + {{- else if .gateway.hosts }} +{{- range .gateway.hosts }} + - {{ . | quote }} +{{- end }} + {{- end }} {{- end }} {{- range .virtualService.hosts }} - {{ . | quote }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/keda-autoscaling.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/keda-autoscaling.yaml index 8c703a5647..850312e16d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/keda-autoscaling.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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,15 @@ 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 }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} spec: {{ toYaml $.Values.kedaAutoscaling.triggerAuthentication.spec | indent 2 }} {{- end }} diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/networkpolicy.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/networkpolicy.yaml index 350232a23b..ee8bdaf8be 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/networkpolicy.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/networkpolicy.yaml @@ -1,9 +1,12 @@ {{- if .Values.networkPolicy.enabled -}} -{{- with .Values.networkPolicy }} apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: + {{- if .Values.networkPolicy.name }} + name: {{ .Values.networkPolicy.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" $ }}-networkpolicy + {{- end }} labels: app: {{ template ".Chart.Name .name" $ }} appId: {{ $.Values.app | quote }} @@ -46,5 +49,4 @@ spec: 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_5-0-0/templates/persistent-volume-claim.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/persistent-volume-claim.yaml new file mode 100644 index 0000000000..cee0fb2fde --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/persistent-volume-claim.yaml @@ -0,0 +1,27 @@ +{{- if .Values.persistentVolumeClaim.name }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{.Values.persistentVolumeClaim.name }} + 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 }} +{{- 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_5-0-0/templates/poddisruptionbudget.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/poddisruptionbudget.yaml index c9cbb4162d..869d380d40 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/poddisruptionbudget.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/poddisruptionbudget.yaml @@ -6,11 +6,20 @@ 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 }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} spec: {{- if .Values.podDisruptionBudget.minAvailable }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} @@ -20,6 +29,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_5-0-0/templates/service.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/service.yaml index 97eb5a16c9..2c31e1450d 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/service.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/service.yaml @@ -39,7 +39,7 @@ spec: {{- if (and (eq $.Values.service.type "NodePort") .nodePort )}} nodePort: {{ .nodePort }} {{- end }} - protocol: TCP + protocol: {{ .protocol | default "TCP"}} name: {{ .name }} {{- end }} {{- if $.Values.appMetrics }} @@ -47,7 +47,18 @@ 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 }} +{{- if .Values.service.sessionAffinityConfig }} + sessionAffinityConfig: +{{ toYaml .Values.service.sessionAffinityConfig | indent 4 }} +{{- end }} {{- if or (eq .Values.deploymentType "BLUE-GREEN") (eq .Values.deploymentType "CANARY") }} --- apiVersion: v1 @@ -70,7 +81,7 @@ spec: - port: {{ .port }} {{- end }} targetPort: {{ .name }} - protocol: TCP + protocol: {{ .protocol | default "TCP"}} name: {{ .name }} {{- end }} {{- if $.Values.appMetrics }} @@ -78,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/reference-chart_5-0-0/templates/servicemonitor.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/servicemonitor.yaml index 1f90c722cb..8600f9d65b 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/servicemonitor.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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" . }} @@ -15,13 +19,58 @@ metadata: {{- if .Values.servicemonitor.additionalLabels }} {{ toYaml .Values.servicemonitor.additionalLabels | indent 4 }} {{- end }} + {{- if .Values.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} spec: endpoints: {{- 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 +83,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 +102,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_5-0-0/templates/vertical-pod-autoscaler.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/vertical-pod-autoscaler.yaml new file mode 100644 index 0000000000..7d1d1db475 --- /dev/null +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/vertical-pod-autoscaler.yaml @@ -0,0 +1,41 @@ +{{ $VerticalPodAutoScalingEnabled := include "VerticalPodAutoScalingEnabled" . }} +{{- if eq "true" $VerticalPodAutoScalingEnabled -}} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + {{- if .Values.verticalPodScaling.name }} + name: {{ .Values.verticalPodScaling.name }} + {{- else }} + name: {{ template ".Chart.Name .fullname" . }}-vpa + {{- end }} + 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.appLabels }} +{{ toYaml .Values.appLabels | indent 4 }} + {{- end }} + {{- if $.Values.verticalPodScaling.labels }} +{{ toYaml $.Values.verticalPodScaling.labels | indent 4 }} + {{- end }} + {{- if $.Values.verticalPodScaling.annotations }} + annotations: +{{ toYaml $.Values.verticalPodScaling.annotations | indent 4 }} + {{- end }} +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_5-0-0/templates/winter-soldier.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/winter-soldier.yaml index 2d3e7bae0f..5ac2fd8443 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/templates/winter-soldier.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-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/reference-chart_5-0-0/test_values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/test_values.yaml index 6b58952e67..d2bb08e778 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/test_values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/test_values.yaml @@ -35,11 +35,12 @@ GracePeriod: 30 ContainerPort: - name: app port: 8080 - servicePort: 80 + servicePort: 8000 envoyTimeout: 15 targetPort: 8080 envoyPort: 8799 useHTTP2: false + protocol: UDP supportStreaming: false idleTimeout: 1800s servicemonitor: @@ -87,6 +88,10 @@ autoscaling: TargetCPUUtilizationPercentage: 90 TargetMemoryUtilizationPercentage: 80 behavior: {} + containerResource: + enable: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 # scaleDown: # stabilizationWindowSeconds: 300 # policies: @@ -123,6 +128,9 @@ service: annotations: {} # test1: test2 # test3: test4 + sessionAffinity: + enabled: false + sessionAffinityConfig: {} server: deployment: @@ -163,7 +171,11 @@ deployment: maxSurge: "25%" maxUnavailable: 1 # stableService: pro-rollout-manual-service - trafficRouting: {} + trafficRouting: + + alb: + rootService: kamal + ingresses: [] steps: - setWeight: 25 - pause: @@ -586,6 +598,10 @@ envoyproxy: requests: cpu: 50m memory: 50Mi + readinessProbe: + path: / + livenessProbe: + path: / podDisruptionBudget: {} # minAvailable: 1 @@ -601,7 +617,7 @@ tolerations: [] # value: "value" # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" -appMetrics: false +appMetrics: true serviceAccount: ## @param serviceAccount.create Enable creation of ServiceAccount for pods ## @@ -622,3 +638,7 @@ hostAliases: [] # hostnames: # - "foo.local" + + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/values.yaml index eba7f9eca3..4cd126fc19 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/values.yaml @@ -88,6 +88,10 @@ autoscaling: annotations: {} labels: {} behavior: {} + containerResource: + enable: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 # scaleDown: # stabilizationWindowSeconds: 300 # policies: @@ -152,6 +156,10 @@ service: annotations: {} # test1: test2 # test3: test4 + sessionAffinity: + enabled: false + sessionAffinityConfig: {} + server: deployment: @@ -177,25 +185,27 @@ EnvVariablesFromConfigMapKeys: [] # keyName: CONFIG_MAP_KEY LivenessProbe: - Path: / + Path: "" port: 8080 initialDelaySeconds: 20 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 5 failureThreshold: 3 + scheme: "" httpHeaders: [] # - name: Custom-Header # value: abc ReadinessProbe: - Path: / + Path: "" port: 8080 initialDelaySeconds: 20 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 5 failureThreshold: 3 + scheme: "" httpHeaders: [] # - name: Custom-Header # value: abc @@ -537,11 +547,8 @@ winterSoldier: # - AfterTime(AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '5m'), Now()) topologySpreadConstraints: [] - # - maxSkew: 1 - # topologyKey: zone - # whenUnsatisfiable: DoNotSchedule - # autoLabelSelector: true - # customLabelSelector: {} + +schedulerName: "" envoyproxy: image: docker.io/envoyproxy/envoy:v1.16.0 @@ -641,3 +648,13 @@ tolerations: [] imagePullSecrets: [] # - test1 # - test2 + +persistentVolumeClaim: {} + + +affinity: + enabled: false + values: {} + +verticalPodScaling: + enabled: false \ No newline at end of file diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-gateway.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-gateway.yaml index 7708a7ddcc..693a27f58e 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-gateway.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-gateway.yaml @@ -32,7 +32,13 @@ spec: name: http protocol: HTTP hosts: +{{- if .Values.istio.gateway.host }} - {{ .Values.istio.gateway.host | quote -}} +{{- else if .Values.istio.gateway.hosts }} +{{- range .Values.istio.gateway.hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} {{ with .Values.istio.gateway }} {{- if .tls.enabled }} tls: @@ -42,7 +48,13 @@ spec: name: https protocol: HTTPS hosts: +{{- if .host }} - {{ .host | quote }} +{{- else if .hosts }} +{{- range .hosts }} + - {{ . | quote }} +{{- end }} +{{- end }} tls: mode: SIMPLE credentialName: {{ .tls.secretName }} diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-virtualservice.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-virtualservice.yaml index 000acb5fc6..c71b44cc9d 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-virtualservice.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/templates/istio-virtualservice.yaml @@ -41,7 +41,13 @@ spec: {{- if or .gateway.enabled .virtualService.hosts }} hosts: {{- if .gateway.enabled }} + {{- if .gateway.host }} - {{ .gateway.host | quote }} + {{- else if .gateway.hosts }} +{{- range .gateway.hosts }} + - {{ . | quote }} +{{- end }} + {{- end }} {{- end }} {{- range .virtualService.hosts }} - {{ . | quote }} 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 index 27de013e0e..d92030cbd7 100644 --- 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 @@ -3,7 +3,11 @@ apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: + {{- if .Values.verticalPodScaling.name }} + name: {{ .Values.verticalPodScaling.name }} + {{- else }} name: {{ template ".Chart.Name .fullname" . }}-vpa + {{- end }} labels: kind: Prometheus app: {{ template ".Chart.Name .name" . }} diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/test_values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/test_values.yaml index 180ebbba25..4e16da2d69 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/test_values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-1-0/test_values.yaml @@ -9,6 +9,7 @@ istio: enabled: true gateway: enabled: true + host: example.com appLabels: test: thyjhgfv containerSpec: @@ -91,12 +92,18 @@ image: pullPolicy: IfNotPresent autoscaling: - enabled: true + enabled: false MinReplicas: 1 MaxReplicas: 2 - TargetCPUUtilizationPercentage: 90 + TargetCPUUtilizationPercentage: 70 TargetMemoryUtilizationPercentage: 80 + annotations: {} + labels: {} behavior: {} + containerResource: + enabled: false + TargetCPUUtilizationPercentage: 90 + TargetMemoryUtilizationPercentage: 80 # scaleDown: # stabilizationWindowSeconds: 300 # policies: diff --git a/vendor/github.com/devtron-labs/common-lib/fetchAllEnv/fetchAllEnv.go b/vendor/github.com/devtron-labs/common-lib/fetchAllEnv/fetchAllEnv.go new file mode 100644 index 0000000000..c8a19e282e --- /dev/null +++ b/vendor/github.com/devtron-labs/common-lib/fetchAllEnv/fetchAllEnv.go @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2024. Devtron Inc. + * + * 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. + */ + +package fetchAllEnv + +import ( + "encoding/json" + "errors" + "go/ast" + "go/parser" + "go/token" + "log" + "os" + "path/filepath" + "reflect" + "sort" + "strings" + "text/template" +) + +type EnvField struct { + Env string + EnvType string + EnvValue string + EnvDescription string + Example string + Deprecated string +} + +type CategoryField struct { + Category string + Fields []EnvField +} + +const ( + categoryCommentStructPrefix = "CATEGORY=" + defaultCategory = "DEVTRON" + deprecatedDefaultValue = "false" + + envFieldTypeTag = "env" + envDefaultFieldTypeTag = "envDefault" + envDescriptionFieldTypeTag = "description" + envPossibleValuesFieldTypeTag = "example" + envDeprecatedFieldTypeTag = "deprecated" + MARKDOWN_FILENAME = "env_gen.md" + MARKDOWN_JSON_FILENAME = "env_gen.json" +) + +const MarkdownTemplate = ` +{{range . }} +## {{ .Category }} Related Environment Variables +| Key | Type | Default Value | Description | Example | Deprecated | +|-------|----------|-------------------|-------------------|-----------------------|------------------| +{{range .Fields }} | {{ .Env }} | {{ .EnvType }} |{{ .EnvValue }} | {{ .EnvDescription }} | {{ .Example }} | {{ .Deprecated }} | +{{end}} +{{end}}` + +func FetchEnvAndWriteToFile() { + WalkThroughProject() + return +} + +func WalkThroughProject() { + categoryFieldsMap := make(map[string][]EnvField) + uniqueKeys := make(map[string]bool) + err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if !info.IsDir() && strings.HasSuffix(path, ".go") { + err = processGoFile(path, categoryFieldsMap, uniqueKeys) + if err != nil { + log.Println("error in processing go file", err) + return err + } + } + return nil + }) + if err != nil { + return + } + writeToFile(categoryFieldsMap) +} + +func processGoFile(filePath string, categoryFieldsMap map[string][]EnvField, uniqueKeys map[string]bool) error { + fset := token.NewFileSet() + node, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments) + if err != nil { + log.Println("error parsing file:", err) + return err + } + ast.Inspect(node, func(n ast.Node) bool { + if genDecl, ok := n.(*ast.GenDecl); ok { + // checking if type declaration, one of [func, map, struct, array, channel, interface] + if genDecl.Tok == token.TYPE { + for _, spec := range genDecl.Specs { + if typeSpec, ok := spec.(*ast.TypeSpec); ok { + // only checking struct type declarations + if structType, ok2 := typeSpec.Type.(*ast.StructType); ok2 { + allFields := make([]EnvField, 0, len(structType.Fields.List)) + for _, field := range structType.Fields.List { + if field.Tag != nil { + envField := getEnvKeyAndValue(field) + envKey := envField.Env + if len(envKey) == 0 || uniqueKeys[envKey] { + continue + } + allFields = append(allFields, envField) + uniqueKeys[envKey] = true + } + } + if len(allFields) > 0 { + category := getCategoryForAStruct(genDecl) + categoryFieldsMap[category] = append(categoryFieldsMap[category], allFields...) + } + } + } + } + } + } + return true + }) + return nil +} + +func getEnvKeyAndValue(field *ast.Field) EnvField { + tag := reflect.StructTag(strings.Trim(field.Tag.Value, "`")) // remove surrounding backticks + + envKey := addReadmeTableDelimiterEscapeChar(tag.Get(envFieldTypeTag)) + envValue := addReadmeTableDelimiterEscapeChar(tag.Get(envDefaultFieldTypeTag)) + envDescription := addReadmeTableDelimiterEscapeChar(tag.Get(envDescriptionFieldTypeTag)) + envPossibleValues := addReadmeTableDelimiterEscapeChar(tag.Get(envPossibleValuesFieldTypeTag)) + envDeprecated := addReadmeTableDelimiterEscapeChar(tag.Get(envDeprecatedFieldTypeTag)) + // check if there exist any value provided in env for this field + if value, ok := os.LookupEnv(envKey); ok { + envValue = value + } + env := EnvField{ + Env: envKey, + EnvValue: envValue, + EnvDescription: envDescription, + Example: envPossibleValues, + Deprecated: envDeprecated, + } + if indent, ok := field.Type.(*ast.Ident); ok && indent != nil { + env.EnvType = indent.Name + } + if len(envDeprecated) == 0 { + env.Deprecated = deprecatedDefaultValue + } + return env +} + +func getCategoryForAStruct(genDecl *ast.GenDecl) string { + category := defaultCategory + if genDecl.Doc != nil { + commentTexts := strings.Split(genDecl.Doc.Text(), "\n") + for _, comment := range commentTexts { + commentText := strings.TrimPrefix(strings.ReplaceAll(comment, " ", ""), "//") // this can happen if comment group is in /* */ + if strings.HasPrefix(commentText, categoryCommentStructPrefix) { + categories := strings.Split(strings.TrimPrefix(commentText, categoryCommentStructPrefix), ",") + if len(categories) > 0 && len(categories[0]) > 0 { //only supporting one category as of now + category = categories[0] //overriding category + break + } + } + } + } + return category +} + +func addReadmeTableDelimiterEscapeChar(s string) string { + return strings.ReplaceAll(s, "|", `\|`) +} + +func writeToFile(categoryFieldsMap map[string][]EnvField) { + cfs := make([]CategoryField, 0, len(categoryFieldsMap)) + for category, allFields := range categoryFieldsMap { + sort.Slice(allFields, func(i, j int) bool { + return allFields[i].Env < allFields[j].Env + }) + + cfs = append(cfs, CategoryField{ + Category: category, + Fields: allFields, + }) + } + sort.Slice(cfs, func(i, j int) bool { + return cfs[i].Category < cfs[j].Category + }) + file, err := os.Create(MARKDOWN_FILENAME) + if err != nil && !errors.Is(err, os.ErrExist) { + panic(err) + } + defer file.Close() + tmpl, err := template.New("markdown").Parse(MarkdownTemplate) + if err != nil { + panic(err) + } + err = tmpl.Execute(file, cfs) + if err != nil { + panic(err) + } + cfsMarshaled, err := json.Marshal(cfs) + if err != nil { + log.Println("error marshalling category fields:", err) + panic(err) + } + err = os.WriteFile(MARKDOWN_JSON_FILENAME, cfsMarshaled, 0644) + if err != nil { + panic(err) + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0fc716711a..f07ff09ba8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -336,7 +336,7 @@ github.com/davecgh/go-spew/spew # github.com/deckarep/golang-set v1.8.0 ## explicit; go 1.17 github.com/deckarep/golang-set -# github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127090829-f050f9c05226 +# github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127104410-85d6bfe0b45f ## explicit; go 1.21 github.com/devtron-labs/authenticator/apiToken github.com/devtron-labs/authenticator/client @@ -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-20250127090829-f050f9c05226 +# github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127104410-85d6bfe0b45f ## explicit; go 1.21 github.com/devtron-labs/common-lib/async github.com/devtron-labs/common-lib/blob-storage @@ -352,6 +352,7 @@ github.com/devtron-labs/common-lib/cloud-provider-identifier github.com/devtron-labs/common-lib/cloud-provider-identifier/bean github.com/devtron-labs/common-lib/cloud-provider-identifier/providers github.com/devtron-labs/common-lib/constants +github.com/devtron-labs/common-lib/fetchAllEnv github.com/devtron-labs/common-lib/git-manager github.com/devtron-labs/common-lib/git-manager/util github.com/devtron-labs/common-lib/imageScan/bean @@ -2214,8 +2215,8 @@ xorm.io/xorm/log xorm.io/xorm/names xorm.io/xorm/schemas xorm.io/xorm/tags -# github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127090829-f050f9c05226 -# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127090829-f050f9c05226 +# github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250127104410-85d6bfe0b45f +# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250127104410-85d6bfe0b45f # 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