Difference between revisions of "Liveness-exec with sidecar container"

From wikieduonline
Jump to navigation Jump to search
(Created page with " cat kk.yml apiVersion: v1 kind: Pod metadata: labels: test: liveness name: liveness-exec spec: containers: - name: liveness image: registry.k8s.io/busybox...")
 
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
cat kk.yml
 
apiVersion: v1
 
kind: Pod
 
metadata:
 
  labels:
 
    test: liveness
 
  name: liveness-exec
 
spec:
 
  containers:
 
  - name: liveness
 
    image: registry.k8s.io/busybox
 
    args:
 
    - /bin/sh
 
    - -c
 
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
 
    livenessProbe:
 
      exec:
 
        command:
 
        - cat
 
        - /tmp/healthy
 
      initialDelaySeconds: 5
 
      periodSeconds: 5
 
  - name: sidecar-container
 
    image: busybox
 
    command: ["sh", "-c", "while true; do sleep 3600; done"]
 
  
 +
Non working example:
 +
[[apiVersion: v1]]
 +
[[kind: Pod]]
 +
metadata:
 +
  labels:
 +
    test: liveness
 +
  name: [[liveness-exec]]
 +
spec:
 +
  containers:
 +
  - name: liveness
 +
    image: registry.k8s.io/busybox
 +
    args:
 +
    - /bin/sh
 +
    - -c
 +
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
 +
    livenessProbe:
 +
      exec:
 +
        command:
 +
        - cat
 +
        - /tmp/healthy
 +
      initialDelaySeconds: 5
 +
      periodSeconds: 5
 +
  [[initContainers:]]
 +
  - name: init-container
 +
    image: busybox
 +
    command: ["sh", "-c", "while true; do sleep 3600; done"]
 +
  [[restartPolicy:]] Never
  
 +
== Errors ==
 +
The [[Pod]] "[[liveness-exec]]" is invalid: spec.[[containers]][1].restartPolicy: Forbidden: may not be set for [[non-init containers]]
  
 
== See also ==
 
== See also ==
* {{pods}}
+
* {{sidecar}}
  
 
[[Category:K8s]]
 
[[Category:K8s]]

Latest revision as of 11:16, 22 October 2024


Non working example:

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: liveness
    image: registry.k8s.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
  initContainers:
  - name: init-container
    image: busybox
    command: ["sh", "-c", "while true; do sleep 3600; done"]
  restartPolicy: Never

Errors[edit]

The Pod "liveness-exec" is invalid: spec.containers[1].restartPolicy: Forbidden: may not be set for non-init containers

See also[edit]

Advertising: