Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
Helm-Automation-Script
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
Helm-Automation-Script
Commits
f95bd626
Commit
f95bd626
authored
Oct 13, 2022
by
sangeetha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
content push changes
parent
62834a9d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
.env
.env
+4
-3
helm_automate_script.py
helm_automate_script.py
+6
-4
scripts/core/helm_handler.py
scripts/core/helm_handler.py
+4
-2
No files found.
.env
View file @
f95bd626
DB_URI=sqlite:///./ilens_versions.db
#DB_URI=mysql://svc-devops:Ut#devops$sql546@192.168.0.220:3306/
CONFIG_MAP_VARIABLES=MONGO_URI
#
HELM_REPO = https://gitlab-pm.knowledgelens.com/KnowledgeLens/Products/iLens-2.0/core/devops/helm-charts
HELM_REPO = https://gitlab-pm.knowledgelens.com/Harshavardhan.C/helm-charts
#
HELM_REPO = https://gitlab-pm.knowledgelens.com/KnowledgeLens/Products/iLens-2.0/core/devops/helm-charts.git
HELM_REPO = https://gitlab-pm.knowledgelens.com/Harshavardhan.C/helm-charts
.git
GIT_USERNAME = harshavardhan.c
GIT_TOKEN = FEMA6PnP63fJCs6DrtZJ
GLOBAL_VARIABLES_FILE=ilens-global-configmap.yml
\ No newline at end of file
helm_automate_script.py
View file @
f95bd626
...
...
@@ -45,13 +45,15 @@ def push_helm_deployments(repo_link: str, private_token: str, branch: str, final
pl
=
pl
[
0
]
commit_actions
=
[]
files_list
=
os
.
listdir
(
final_helm_path
)
branches
=
pl
.
branches
.
list
()
branches
=
pl
.
branches
.
list
(
get_all
=
True
)
branches_names
=
[
x
.
name
for
x
in
branches
]
if
branch
not
in
branches_names
:
pl
.
branches
.
create
({
'branch'
:
branch
,
'ref'
:
'master'
if
branch
.
split
(
"_"
)[
0
]
not
in
branches_names
else
branch
.
split
(
"_"
)[
0
]})
if
not
files_list
:
logging
.
debug
(
'Files not found for pushing to git.'
)
for
file
in
files_list
:
_action
=
{
'action'
:
'
cre
ate'
,
'action'
:
'
upd
ate'
,
'file_path'
:
os
.
path
.
join
(
HELM_PATH
,
file
),
'content'
:
open
(
f
'{final_helm_path}/{file}'
)
.
read
()
}
...
...
@@ -188,7 +190,7 @@ if __name__ == '__main__':
helm_out_file_path
=
helm_out_file_path
,
global_config_data
=
global_config_data
,
module_name
=
f
'{_module}-celery'
)
#
push_helm_deployments(helm_repo, git_access_token, _branch, final_helm_path=OUTPUT_PATH, base_path=helm_path)
push_helm_deployments
(
helm_repo
,
git_access_token
,
_branch
,
final_helm_path
=
OUTPUT_PATH
,
base_path
=
helm_path
)
except
Exception
as
e
:
logging
.
exception
(
f
"Exception Occurred while processing the Helm-Script Preparation {e.args}"
)
...
...
scripts/core/helm_handler.py
View file @
f95bd626
...
...
@@ -28,12 +28,14 @@ class HelmHandler:
"value"
):
global_config_vars
[
"SERVICE_PORT"
]
=
module_env_variables
[
_each
][
"value"
]
continue
if
module_env_variables
.
get
(
_each
):
existing_data
[
'deployment'
][
'environmentVar'
]
.
append
(
module_env_variables
[
_each
])
existing_data
[
'deployment'
][
'imageName'
]
=
image_tag
or
existing_data
[
'deployment'
][
'imageName'
]
self
.
common_utils
.
convert_json_to_yaml
(
json_data
=
existing_data
,
output_file_path
=
template_file
)
self
.
render_helm_chart
(
data_dict
=
global_config_vars
,
helm_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
template_path
)
return
True
except
Exception
as
e
:
logging
.
exception
(
f
'Exception occurred while preparing the helm deployment file {e.args}'
)
return
False
...
...
@@ -44,7 +46,7 @@ class HelmHandler:
environment
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
template_path
),
trim_blocks
=
True
,
variable_start_string
=
'<{'
,
variable_end_string
=
'}>'
)
variable_start_string
=
'<{'
,
variable_end_string
=
'}>'
,
autoescape
=
True
)
_render
=
environment
.
get_template
(
helm_template_file
)
.
render
(
**
data_dict
)
with
open
(
outfile_path
,
"w"
)
as
fp
:
fp
.
write
(
_render
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment