Skip to content

Commit c1da2a1

Browse files
aviralsrivastava01Abhinav-26Aviral Srivastavapghildiyal
authored
feat: Multicharts (#927)
* added cronjob chart with migrations * added .image_descriptor_template.json * minor indentation fixes * indentation & logic corrected * configMap & secrets bug fixed * bug fixed & version updated * added job.yaml * restartPolicy error fixed * conditionals added * apiversion fixed in job.yaml * conditions added in cronjob.yaml for suspend * sql query * sql query * sql query * sql query change * add name * add name * chart-sync * update data type for bytea * fixed issue with sql query * added if not exists condition * chart-sync-error-handling * reverted changes for chart sync response * changed name of rollout to rollout deployment and deactived other chart types Co-authored-by: Abhinav-26 <[email protected]> Co-authored-by: Aviral Srivastava <[email protected]> Co-authored-by: Prashant Ghildiyal <[email protected]>
1 parent 3758a76 commit c1da2a1

36 files changed

+2597
-14
lines changed

api/restHandler/AppStoreRestHandler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ func (handler *AppStoreRestHandlerImpl) TriggerChartSyncManual(w http.ResponseWr
477477
common.WriteJsonResp(w, err, nil, http.StatusUnauthorized)
478478
return
479479
}
480+
481+
//Chart repo sync error handling
480482
TriggerResult := handler.appStoreService.TriggerChartSyncManual()
481483
common.WriteJsonResp(w, nil, TriggerResult, http.StatusOK)
482-
}
484+
}

internal/sql/repository/chartConfig/ChartRepository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ type ChartRef struct {
271271
Version string `sql:"version"`
272272
Active bool `sql:"active"`
273273
Default bool `sql:"is_default"`
274+
Name string `sql:"name"`
275+
ChartData []byte `sql:"chart_data"`
274276
models.AuditLog
275277
}
276278

pkg/appstore/AppStoreService.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func (impl *AppStoreServiceImpl) ValidateAndCreateChartRepo(request *ChartRepoDt
686686
if err != nil {
687687
impl.logger.Errorw("Error in triggering chart sync job manually", "err", err)
688688
}
689-
689+
690690
return chartRepo, err, validationResult
691691
}
692692
func (impl *AppStoreServiceImpl) ValidateAndUpdateChartRepo(request *ChartRepoDto) (*chartConfig.ChartRepo, error, *DetailedErrorHelmRepoValidation) {
@@ -761,13 +761,13 @@ func (impl *AppStoreServiceImpl) get(href string, chartRepository *repo.ChartRep
761761
func (impl *AppStoreServiceImpl) TriggerChartSyncManual() error {
762762
defaultClusterBean, err := impl.clusterService.FindOne(cluster.ClusterName)
763763
if err != nil {
764-
impl.logger.Errorw("defaultClusterBean err, TriggerChartSyncManual","err", err)
764+
impl.logger.Errorw("defaultClusterBean err, TriggerChartSyncManual", "err", err)
765765
return err
766766
}
767767

768768
defaultClusterConfig, err := impl.clusterService.GetClusterConfig(defaultClusterBean)
769769
if err != nil {
770-
impl.logger.Errorw("defaultClusterConfig err, TriggerChartSyncManual","err", err)
770+
impl.logger.Errorw("defaultClusterConfig err, TriggerChartSyncManual", "err", err)
771771
return err
772772
}
773773

@@ -779,6 +779,5 @@ func (impl *AppStoreServiceImpl) TriggerChartSyncManual() error {
779779
return err
780780
}
781781

782-
783782
return nil
784783
}

pkg/pipeline/ChartService.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ func (impl ChartServiceImpl) IsReadyToTrigger(appId int, envId int, pipelineId i
810810
type chartRef struct {
811811
Id int `json:"id"`
812812
Version string `json:"version"`
813+
Name string `json:"name"`
813814
}
814815

815816
type chartRefResponse struct {
@@ -845,17 +846,20 @@ func (impl ChartServiceImpl) ChartRefAutocompleteForAppOrEnv(appId int, envId in
845846

846847
var LatestAppChartRef int
847848
for _, result := range results {
848-
chartRefs = append(chartRefs, chartRef{Id: result.Id, Version: result.Version})
849+
if len(result.Name) == 0 {
850+
result.Name = "Rollout Deployment"
851+
}
852+
chartRefs = append(chartRefs, chartRef{Id: result.Id, Version: result.Version, Name: result.Name})
849853
if result.Default == true {
850854
LatestAppChartRef = result.Id
851855
}
852856
}
853-
854857
chart, err := impl.chartRepository.FindLatestChartForAppByAppId(appId)
855858
if err != nil && err != pg.ErrNoRows {
856859
impl.logger.Errorw("error in fetching latest chart", "err", err)
857860
return chartRefResponse, err
858861
}
862+
859863
if envId > 0 {
860864
envOverride, err := impl.envOverrideRepository.FindLatestChartForAppByAppIdAndEnvId(appId, envId)
861865
if err != nil && !errors.IsNotFound(err) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"server":{"deployment":{"image_tag":"{{.Tag}}","image":"{{.Name}}"}},"pipelineName": "{{.PipelineName}}","releaseVersion":"{{.ReleaseVersion}}","deploymentType": "{{.DeploymentType}}", "app": "{{.App}}", "env": "{{.Env}}", "appMetrics": {{.AppMetrics}}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for Kubernetes
4+
name: cronjob-chart_1-2-0
5+
version: 1.2.0
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# Mandatory configs
2+
kind: Job
3+
4+
jobConfigs:
5+
backoffLimit: 5
6+
activeDeadlineSeconds: 100
7+
parallelism: 1
8+
completions: 2
9+
suspend: false
10+
ttlSecondsAfterFinished: 100
11+
12+
cronjobConfigs:
13+
schedule: "* * * * *"
14+
startingDeadlineSeconds: 100
15+
concurrencyPolicy: Allow
16+
suspend: false
17+
successfulJobsHistoryLimit: 3
18+
failedJobsHistoryLimit: 1
19+
restartPolicy: OnFailure
20+
21+
replicaCount: 1
22+
MinReadySeconds: 60
23+
GracePeriod: 30
24+
image:
25+
pullPolicy: IfNotPresent
26+
service:
27+
type: ClusterIP
28+
#name: "service-1234567890"
29+
annotations: {}
30+
# test1: test2
31+
# test3: test4
32+
ContainerPort:
33+
- name: app
34+
port: 8080
35+
servicePort: 80
36+
envoyPort: 8799
37+
useHTTP2: true
38+
supportStreaming: true
39+
idleTimeout: 1800s
40+
# servicemonitor:
41+
# enabled: true
42+
# path: /abc
43+
# scheme: 'http'
44+
# interval: 30s
45+
# scrapeTimeout: 20s
46+
# metricRelabelings:
47+
# - sourceLabels: [namespace]
48+
# regex: '(.*)'
49+
# replacement: myapp
50+
# targetLabel: target_namespace
51+
resources:
52+
# We usually recommend not to specify default resources and to leave this as a conscious
53+
# choice for the user. This also increases chances charts run on environments with little
54+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
55+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
56+
limits:
57+
cpu: 1
58+
memory: 200Mi
59+
requests:
60+
cpu: 0.10
61+
memory: 100Mi
62+
63+
64+
# Optional configs
65+
LivenessProbe:
66+
Path: ""
67+
port: 8080
68+
scheme: ""
69+
httpHeader:
70+
name: ""
71+
value: ""
72+
tcp: false
73+
command: []
74+
initialDelaySeconds: 20
75+
periodSeconds: 10
76+
successThreshold: 1
77+
timeoutSeconds: 5
78+
failureThreshold: 3
79+
80+
ReadinessProbe:
81+
Path: ""
82+
port: 8080
83+
scheme: ""
84+
httpHeader:
85+
name: ""
86+
value: ""
87+
tcp: false
88+
command: []
89+
initialDelaySeconds: 20
90+
periodSeconds: 10
91+
successThreshold: 1
92+
timeoutSeconds: 5
93+
failureThreshold: 3
94+
95+
ingress:
96+
enabled: false
97+
annotations:
98+
nginx.ingress.kubernetes.io/force-ssl-redirect: 'false'
99+
nginx.ingress.kubernetes.io/ssl-redirect: 'false'
100+
kubernetes.io/ingress.class: nginx
101+
# nginx.ingress.kubernetes.io/rewrite-target: /$2
102+
# nginx.ingress.kubernetes.io/canary: "true"
103+
# nginx.ingress.kubernetes.io/canary-weight: "10"
104+
105+
hosts:
106+
- host: chart-example1.local
107+
paths:
108+
- /example1
109+
- host: chart-example2.local
110+
paths:
111+
- /example2
112+
- /example2/healthz
113+
tls: []
114+
# - secretName: chart-example-tls
115+
# hosts:
116+
# - chart-example.local
117+
118+
ingressInternal:
119+
enabled: false
120+
annotations: {}
121+
# kubernetes.io/ingress.class: nginx
122+
# kubernetes.io/tls-acme: "true"
123+
# nginx.ingress.kubernetes.io/canary: "true"
124+
# nginx.ingress.kubernetes.io/canary-weight: "10"
125+
126+
hosts:
127+
- host: chart-example1.internal
128+
paths:
129+
- /example1
130+
- host: chart-example2.internal
131+
paths:
132+
- /example2
133+
- /example2/healthz
134+
tls: []
135+
# - secretName: chart-example-tls
136+
# hosts:
137+
# - chart-example.local
138+
139+
command:
140+
enabled: false
141+
value: []
142+
143+
args:
144+
enabled: false
145+
value:
146+
- /bin/sh
147+
- -c
148+
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
149+
150+
#For adding custom labels to pods
151+
152+
podLabels: {}
153+
# customKey: customValue
154+
podAnnotations: {}
155+
# customKey: customValue
156+
157+
rawYaml: []
158+
159+
initContainers: []
160+
## Additional init containers to run before the Scheduler pods.
161+
## for example, be used to run a sidecar that chown Logs storage.
162+
#- name: volume-mount-hack
163+
# image: busybox
164+
# command: ["sh", "-c", "chown -R 1000:1000 logs"]
165+
# volumeMounts:
166+
# - mountPath: /usr/local/airflow/logs
167+
# name: logs-data
168+
169+
containers: []
170+
## Additional containers to run along with application pods.
171+
## for example, be used to run a sidecar that chown Logs storage .
172+
#- name: volume-mount-hack
173+
# image: busybox
174+
# command: ["sh", "-c", "chown -R 1000:1000 logs"]
175+
# volumeMounts:
176+
# - mountPath: /usr/local/airflow/logs
177+
# name: logs-data
178+
179+
volumeMounts: []
180+
# - name: log-volume
181+
# mountPath: /var/log
182+
183+
volumes: []
184+
# - name: log-volume
185+
# emptyDir: {}
186+
187+
dbMigrationConfig:
188+
enabled: false
189+
190+
tolerations: []
191+
192+
Spec:
193+
Affinity:
194+
Key:
195+
# Key: kops.k8s.io/instancegroup
196+
Values:
197+
198+
autoscaling:
199+
enabled: false
200+
MinReplicas: 1
201+
MaxReplicas: 2
202+
TargetCPUUtilizationPercentage: 70
203+
TargetMemoryUtilizationPercentage: 80
204+
extraMetrics: []
205+
# - external:
206+
# metricName: pubsub.googleapis.com|subscription|num_undelivered_messages
207+
# metricSelector:
208+
# matchLabels:
209+
# resource.labels.subscription_id: echo-read
210+
# targetAverageValue: "2"
211+
# type: External
212+
#
213+
214+
prometheus:
215+
release: monitoring
216+
217+
server:
218+
deployment:
219+
image_tag: 1-95af053
220+
image: ""
221+
222+
servicemonitor:
223+
additionalLabels: {}
224+
225+
envoyproxy:
226+
image: envoyproxy/envoy:v1.14.1
227+
configMapName: ""
228+
resources:
229+
limits:
230+
cpu: 50m
231+
memory: 50Mi
232+
requests:
233+
cpu: 50m
234+
memory: 50Mi
235+
236+
237+
imagePullSecrets: []
238+
# - test1
239+
# - test2
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
replicaCount: 1
2+
MaxSurge: 1
3+
MaxUnavailable: 0
4+
GracePeriod: 30
5+
pauseForSecondsBeforeSwitchActive: 30
6+
waitForSecondsBeforeScalingDown: 30
7+
8+
Spec:
9+
Affinity:
10+
key: ""
11+
Values: nodes
12+
13+
autoscaling:
14+
enabled: false
15+
MinReplicas: 1
16+
MaxReplicas: 2
17+
TargetCPUUtilizationPercentage: 90
18+
TargetMemoryUtilizationPercentage: 80
19+
20+
secret:
21+
enabled: false
22+
data: {}
23+
# my_own_secret: S3ViZXJuZXRlcyBXb3Jrcw==
24+
25+
EnvVariables: []
26+
# - name: FLASK_ENV
27+
# value: qa
28+
29+
resources:
30+
# We usually recommend not to specify default resources and to leave this as a conscious
31+
# choice for the user. This also increases chances charts run on environments with little
32+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
33+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
34+
limits:
35+
cpu: "0.05"
36+
memory: 50Mi
37+
requests:
38+
cpu: "0.01"
39+
memory: 10Mi
40+
41+

0 commit comments

Comments
 (0)