Restart policy problem while creating RC via JSON

470 views
Skip to first unread message

Sujai S

unread,
Mar 30, 2016, 3:16:20 AM3/30/16
to kubernetes-dev
I tried creating a Replication Controller via an JSON file and I have mentioned restartPolicy as "Never"
{
   "kind":"ReplicationController",
   "apiVersion":"v1",
   "metadata":{
      "name":"ngnix-rc",
      "labels":{
         "app":"webserver"
      }
   },
   "spec":{
      "replicas":1,
      "selector":{
         "app":"webserver1"
      },
      "template":{
         "metadata":{
            "name":"ngnix-pod",
            "labels":{
               "app":"webserver1"
            }
         },
         "spec":{
            "containers":[
                {
                  "image":"ngnix",
                  "name":"nginx"
               }
            ],
            "restartPolicy":"Never"
         }
      }
   }
but I'm getting an error that,
Error:
The ReplicationController "ngnix-rc" is invalid.
"spec.template.spec.restartPolicy: Unsupported value: "Never": supported values: Always"

Is there any change in v1.2 that it supports only "Always" as an option for restartPolicy? I'm confused.

I tried another scenario where I faced a strange behavior.
I specified the restart policy as "never" and I got the error as,
Error:
The ReplicationController "ngnix-rc" is invalid.
* spec.template.spec.restartPolicy: Unsupported value: "never": supported values: Always, OnFailure, Never
* spec.template.spec.restartPolicy: Unsupported value: "never": supported values: Always

I don't know what is the exact problem.

Sujai S

unread,
Mar 30, 2016, 6:07:37 AM3/30/16
to kubernetes-dev
I found that the ReplicationController will allow only a restartPolicy that is equal to "Always". Is this a valid one? 
Else I need to use Job for OnFailure or Never option. 
But I need to deploy a web server which I cannot deploy as a Job and it should be as RC. 
In this scenario when deployed as RC, the container is restarting frequently which makes the web server useless.
What is the solution for this?

Brian Grant

unread,
Mar 30, 2016, 9:57:44 AM3/30/16
to kubernetes-dev
On Wednesday, March 30, 2016 at 3:07:37 AM UTC-7, Sujai S wrote:
I found that the ReplicationController will allow only a restartPolicy that is equal to "Always". Is this a valid one? 

 
Else I need to use Job for OnFailure or Never option. 

Or, if you really want the pods to never be restarted, just use pods.
 
But I need to deploy a web server which I cannot deploy as a Job and it should be as RC. 

You really want the webserver to never restart? You want to launch the containers and allow them to terminate and not restart? That's exactly what a Job does.

Why do you think you need a RC? Why do you think you cannot use a Job? It can create N copies of a pod.

 
In this scenario when deployed as RC, the container is restarting frequently which makes the web server useless.

The container should only restart if it exits or fails. If the restart policy were not Always, they'd go away permanently in this situation instead. Is that what you want?

What is the solution for this?

Could you explain more about what you're trying to do?
 

David Aronchick

unread,
Mar 30, 2016, 10:02:54 AM3/30/16
to Brian Grant, kubernetes-dev
As Brian said, I think the problem might be that your web server is having an issue. If the pod is running properly, it would stay up and running, theoretically forever. Kubernetes would not randomly restart a pod for no reason.

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/2bb149fa-49c2-4802-83aa-95314cf00acc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sujai S

unread,
Mar 30, 2016, 1:50:31 PM3/30/16
to kubernetes-dev
But, I have been using the same container image previously with v1.1, I didn't face this problem. Now I am using the same image with v1.2, and the container is restarting frequently. I will try to debug the problem with the webserver.
On the other side, I need to deploy the webserver as an RC for various reasons, one of the reason is to ensure that the minimum number of replicas are available and do not want them to terminate. When one pod is terminated, the RC will bring up a new pod. I don't think so that a Job can do this. Also I don't want to use Job which will execute for specified count and will be terminated.

Eric Tune

unread,
Mar 30, 2016, 1:52:48 PM3/30/16
to Sujai S, kubernetes-dev
If you want to restart your program when it exits with any exit code, or if a node fails, then use an RC.
If you want your program to be restarted when a node fails, or when it exits with a failure code, but to stop running when it exits with Success, then use Job. 

On Wed, Mar 30, 2016 at 10:50 AM, Sujai S <sujai....@gmail.com> wrote:
But, I have been using the same container image previously with v1.1, I didn't face this problem. Now I am using the same image with v1.2, and the container is restarting frequently. I will try to debug the problem with the webserver.
On the other side, I need to deploy the webserver as an RC for various reasons, one of the reason is to ensure that the minimum number of replicas are available and do not want them to terminate. When one pod is terminated, the RC will bring up a new pod. I don't think so that a Job can do this. Also I don't want to use Job which will execute for specified count and will be terminated.

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.

Prashanth B

unread,
Mar 30, 2016, 1:59:24 PM3/30/16
to Eric Tune, Sujai S, kubernetes-dev
On Wed, Mar 30, 2016 at 10:52 AM, 'Eric Tune' via kubernetes-dev <kuberne...@googlegroups.com> wrote:
If you want to restart your program when it exits with any exit code, or if a node fails, then use an RC.
If you want your program to be restarted when a node fails, or when it exits with a failure code, but to stop running when it exits with Success, then use Job. 

On Wed, Mar 30, 2016 at 10:50 AM, Sujai S <sujai....@gmail.com> wrote:
But, I have been using the same container image previously with v1.1, I didn't face this problem. Now I am using the same image with v1.2, and the container is restarting frequently. I will try to debug the problem with the webserver.

Fwiw your original json has a typo in "image":"ngnix", and a pod with the stock nginx image should not restart without some reason that shows up in `kubectl describe pod`.
 
On the other side, I need to deploy the webserver as an RC for various reasons, one of the reason is to ensure that the minimum number of replicas are available and do not want them to terminate. When one pod is terminated, the RC will bring up a new pod. I don't think so that a Job can do this. Also I don't want to use Job which will execute for specified count and will be terminated.

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/d0e9066d-9c0a-4968-9cff-125e442f1487%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.

Sujai S

unread,
Mar 31, 2016, 3:46:19 AM3/31/16
to kubernetes-dev, et...@google.com, sujai....@gmail.com



Fwiw your original json has a typo in "image":"ngnix", and a pod with the stock nginx image should not restart without some reason that shows up in `kubectl describe pod`.

Sorry for the typo. But I just gave this file for sample. In my original file I am using the stock nginx image.
I tried debugging the pod. I found that the docker daemon that is running in a node is itself restarting which results in restarting the containers.

Prashanth B

unread,
Mar 31, 2016, 12:24:21 PM3/31/16
to Sujai S, kubernetes-dev, Eric Tune
If it's restarting for mysterious, unexplainable reasons, the kubelet, docker and supervisord logs would help (should be in /var/log). 
 

--
You received this message because you are subscribed to the Google Groups "kubernetes-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.

Sujai S

unread,
Apr 13, 2016, 8:21:02 AM4/13/16
to kubernetes-dev, sujai....@gmail.com, et...@google.com
I found this error in docker log file.
time="2016-04-13T12:08:28.420608779Z" level=warning msg="Your kernel does not support CPU cfs period. Period discarded."
time="2016-04-13T12:08:28.420674445Z" level=warning msg="Your kernel does not support CPU cfs quota. Quota discarded."
time="2016-04-13T12:15:11.724535398Z" level=error msg="Force shutdown daemon"
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages