Starting and restrting Apps from cli

mm0nst3r

Dabbler
Joined
Sep 5, 2021
Messages
33
What is the proper way to start the app on system start?
I can put something like 'docker start 7dda08892103' to init script for simple docker app, but what will I do for something like Prometheus truechart app that consists of 4 containers?
Same question for cron restarts.
 

FrostyCat

Explorer
Joined
Jan 4, 2022
Messages
79
SCALE runs Kubernetes so no need to invoke anything as Kubernetes will restore its state on bootup. You can use the command line, but I would advise against it unless you truly know what you're trying to achieve as the middleware will most likely interfere if you didn't press the stop button in the ui.

To stop/start/restart from the command line you can use commands such as the ones below. This is exactly what the UI does.

Code:
# stop or scale to zero
k3s kubectl -n <NAMESPACE> scale --replicas=0 deploy <DEPLOYMENT NAME>

# start or scale to 1
k3s kubectl -n <NAMESPACE> scale --replicas=1 deploy <DEPLOYMENT NAME>

# restart (no matter how many replicas)
k3s kubectl -n <NAMESPACE> rollout restart deploy <DEPLOYMENT NAME>


Use this command to list deployments in specific namespaces:
Code:
k3s kubectl -n <NAMESPACE> get deploy


Please note that there can be differences in these commands as you do have the options with some apps to run multiple replicas or auto scale depending on load - this will not work properly out of the box because it needs metrics and k3s by default comes with metrics-server disabled (easy fix but it will revert on SCALE upgrades).
 

mm0nst3r

Dabbler
Joined
Sep 5, 2021
Messages
33
Thank you for the explaination.
I would gladly not use CLI - but what option GUI gives me to automatically start apps on system boot and to reboot some apps nightly?

Just want to add that finding namespace wasn't also trivial, so I stumbled on some thread on this forum and this command let's you find the namespace:

Code:
k3s kubectl get pods,svc,daemonsets,deployments,statefulset,sc,pvc,ns,job --all-namespaces -o wide
 

FrostyCat

Explorer
Joined
Jan 4, 2022
Messages
79
If your app was started when you reboot or shutdown the system Kubernetes will happilly restore its state. For periodic restarts I think for now you are stuck with creating a cron job and running a rollout restart as I showed above.
 

mm0nst3r

Dabbler
Joined
Sep 5, 2021
Messages
33
If your app was started when you reboot or shutdown the system Kubernetes will happilly restore its state. For periodic restarts I think for now you are stuck with creating a cron job and running a rollout restart as I showed above.
Oh thanks - I didn't know it restores it's state and didn't read you first comment thorough enough.
Does it restore it's state after power loss and pretty much anything other than stopping it specifically - right?
 

FrostyCat

Explorer
Joined
Jan 4, 2022
Messages
79
It will restore either running or stopped state on reboot or shutdown.
 
Top