what is -c in argument of container in kubernetes

12/17/2020

I have attached the Kubernetes script wherein the argument has "-c" why it is required t be provided?

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    run: ngn
  name: ngn
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      run: ngn
  template:
    metadata:
      labels:
        run: ngn
    spec:
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: ngn
        command: ["/bin/sh"]
        args: ["-c", "while true; do echo hello; sleep 10;done"]
-- kumar
kubernetes
linux
sh

1 Answer

12/17/2020

The -c you are asking here is an argument to /bin/sh, Here in your snippet you are supplying while true; do echo hello; sleep 10;done to /bin/sh as an argument.

       -c               Read commands from the command_string operand instead of from the standard input.  Special parameter 0 will be set from the
                        command_name operand and the positional parameters ($1, $2, etc.)  set from the remaining argument operands.
-- P....
Source: StackOverflow