Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfaast
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
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Santhosh Kumar
dfaast
Commits
db69f3ea
Commit
db69f3ea
authored
May 04, 2024
by
Santhosh Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup code
parent
bc8339a3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
6 deletions
+57
-6
cmd.txt
cmd.txt
+14
-0
src/.faas.py.swp
src/.faas.py.swp
+0
-0
src/faas.py
src/faas.py
+43
-6
No files found.
cmd.txt
View file @
db69f3ea
...
...
@@ -10,3 +10,17 @@ sudo kubeadm token create --print-join-command
# Run this command to join.
kubectl exec -it test-f7bbc6dcb-kzdsw -- /bin/bash
kubectl describe HorizontalPodAutoscaler test-hpa
kubectl get pods -n kube-system
kubectl logs metrics-server-8857d6b7c-59xbb -n kube-system
kubectl delete pod metrics-server-8857d6b7c-59xbb -n kube-system
http://localhost:5000/memory?size=1G
kubectl scale deployment test --replicas=1
src/.faas.py.swp
0 → 100644
View file @
db69f3ea
File added
src/faas.py
View file @
db69f3ea
...
...
@@ -111,6 +111,36 @@ def rollback_deployment(function_name):
print
(
"Rolling back deployment..."
)
apps_api
.
rollback_namespaced_deployment
(
name
=
function_name
,
namespace
=
"default"
)
def
manual_scale
():
deployment_name
=
input
(
"Enter the deployment name: "
)
replicas
=
int
(
input
(
"Enter the number of replicas to scale to: "
))
try
:
# Get current replicas
deployment
=
apps_api
.
read_namespaced_deployment
(
name
=
deployment_name
,
namespace
=
"default"
)
current_replicas
=
deployment
.
spec
.
replicas
# Determine scaling action
if
replicas
>
current_replicas
:
action
=
"up"
elif
replicas
<
current_replicas
:
action
=
"down"
else
:
action
=
"unchanged"
# Scale deployment
apps_api
.
patch_namespaced_deployment_scale
(
name
=
deployment_name
,
namespace
=
"default"
,
body
=
{
"spec"
:
{
"replicas"
:
replicas
}}
)
print
(
f
"Deployment '{deployment_name}' scaled {action} to {replicas} replicas successfully."
)
except
ApiException
as
e
:
if
e
.
status
==
404
:
print
(
f
"Deployment '{deployment_name}' does not exist."
)
else
:
print
(
f
"Error scaling deployment '{deployment_name}': {e}"
)
def
scale_deployment
():
function_name
=
input
(
"Enter the function name: "
)
min_replicas
=
int
(
input
(
"Enter min replicas: "
))
...
...
@@ -262,6 +292,8 @@ def get_deployment_info():
for
deployment
in
deployments
:
deployment_name
=
deployment
.
metadata
.
name
replicas
=
deployment
.
status
.
replicas
if
replicas
==
None
:
replicas
=
0
# Get resource limits
limits
=
deployment
.
spec
.
template
.
spec
.
containers
[
0
]
.
resources
.
limits
...
...
@@ -517,17 +549,18 @@ def select_operation():
print
(
"6. Expose Service"
)
print
(
"7. Get Function Logs"
)
print
(
"8. Get resource usage"
)
print
(
"9. Misc functions"
)
print
(
"10. Exit"
)
print
(
"9. Manual Scaling "
)
print
(
"10. Misc functions"
)
print
(
"11. Exit"
)
while
True
:
try
:
choice
=
int
(
input
(
"Enter your choice (1-1
0
): "
))
if
1
<=
choice
<=
1
0
:
choice
=
int
(
input
(
"Enter your choice (1-1
1
): "
))
if
1
<=
choice
<=
1
1
:
return
choice
else
:
print
(
choice
)
print
(
"Invalid choice. Please enter a number between 1 and 1
0
."
)
print
(
"Invalid choice. Please enter a number between 1 and 1
1
."
)
except
ValueError
:
print
(
"Invalid input. Please enter a number."
)
...
...
@@ -570,7 +603,11 @@ if __name__ == "__main__":
elif
choice
==
9
:
print
(
"Resource Information ..."
)
# Call function to expose service
m
isc_info
()
m
anual_scale
()
elif
choice
==
10
:
print
(
"Resource Information ..."
)
# Call function to expose service
misc_info
()
elif
choice
==
11
:
print
(
"Exiting..."
)
break
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