How to restart application rather than stop and recreate a new one?

newbacai

Dabbler
Joined
May 21, 2022
Messages
11
How to restart application rather than stop and recreate a new one?
I tried:
k3s kubectl get pod {podname} -n {namespace} -o yaml | kubectl replace --force -f -
But not working, it returns:
zsh: command not found: kubectl
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
You forgot to prepend k3s in the 2nd invocation of kubectl.
 

newbacai

Dabbler
Joined
May 21, 2022
Messages
11
You forgot to prepend k3s in the 2nd invocation of kubectl.
Thanks so much. But I found that the system still remove and build a new one:
1653413460564.png


Is any possbile to keep the same pod?
 

stavros-k

Patron
Joined
Dec 26, 2020
Messages
231
Is any possbile to keep the same pod?
Pod dies the moment the service inside it is stopped/crashed/killed.
It's not designed to be restarted. It's designed to be recreated into a new pod.

It might be better explain what you want to achieve, so people can help you do it right, rather than trying to "hack" a solution
 

newbacai

Dabbler
Joined
May 21, 2022
Messages
11
Pod dies the moment the service inside it is stopped/crashed/killed.
It's not designed to be restarted. It's designed to be recreated into a new pod.

It might be better explain what you want to achieve, so people can help you do it right, rather than trying to "hack" a solution
Thanks for your expianation. Here is what I want to achieve:
  1. To visit some service I have to run "export http_proxy=xxx" each time when a new container / pod created because I'm in China where many network service including truenas has been forbidden.
  2. I need some tools like "iputils-ping" but many images don't have them. I have to install it manually each time.
  3. Last but not least, I need to run crontab jobs, cause the images don't support it, I was using "docker exec" in the TrueNAS Scale host. If the name or id changed each time, I have to modify the crontab then.
 

stavros-k

Patron
Joined
Dec 26, 2020
Messages
231
To visit some service I have to run "export http_proxy=xxx" each time when a new container / pod created because I'm in China where many network service including truenas has been forbidden.
This is "easy", as for the most part of containers/images you use Environment Variables to set things.
In a normal k8s deployment what would be couple of lines in YAML.
In case of SCALE Apps, app developer, has to expose such fields in the UI.

I don't know if official apps has such fields, but TrueCharts apps have for sure.
I need some tools like "iputils-ping" but many images don't have them. I have to install it manually each time.

This is hard as not all apps allow you to install packages into an image/container. (As containers are not designed to do that)
It might be "ok" to do once in a while for troubleshooting, but if it's needed more often, you might want to ask the upstream container creator to add it to the container.
Last but not least, I need to run crontab jobs, cause the images don't support it, I was using "docker exec" in the TrueNAS Scale host. If the name or id changed each time, I have to modify the crontab then.

This is also able to be implemented in k8s (without the need of cronjobs in Host),
But I don't think there is such an option in official apps Scale GUI, For sure there aren't in TrueCharts apps.

But generally if an app needs a cronjob for core things, TrueCharts apps has CronJobs defined in the background.

eg. Nextcloud. , Firefly etc

If you want to give TrueCharts apps a shot, you can reach us for support in our Discord
 
Top