k8s acquaintance POD (II)

kubernetes call pod to which node is irrelevant, but the actual situation, each node inconsistent hardware environment, so in some cases require different pod tuned to run on a given node. It can also be achieved by label.
kubectl label node node-id gpu=true
The pod call into this node only needs to describe in the yaml
apiVersion: v1
kind: pod
metadata:
    kubia-gpu
spec:
    nodeSelector:
        gpu: "true"
    containers:
        - image: luksa/kubia
           name: kubia

 

 
 
Probe: For the pod containers are to be monitored, the probe can be used.
Embodiment three probes:
http get returns 2xx, 3xx is not wrong 4xx, 5xx
tcp socket connector to establish normal, abnormal and vice versa
exec execute a command, that is, 0 success, otherwise fail
 
http get a description of the method:
apiVersion: v1
kind: Pod
metadata:
  name: kubia-liveneess
spec:
  containers:
  - image: luksa/kubia-unhealthy
    name: kubia
    livenessProbe:
      httpGet:
        path: /
        port: 8080

 

luksa / kubia-unhealthy this image as node.js, provide web services, where the application has been added to make this web service returns only the first five times normal, an error is returned after five times.
 
After the general error three times, it will restart vessel, then you want to see the error log depends on the last container logs so use --previous parameters
kuectl logs mypod --previous
 
Use kubectl describe po pod-id to see the specific error code, and shows why the bottom of the container termination, - kubernetes container found unhealthy, so the termination and re-create
 
In the description of the default probe, a POD will be detected immediately at the start when activated, thus detecting the best practice is to add an initial delay.
apiVersion: v1
kind: Pod
metadata:
  name: kubia-liveneess
spec:
  containers:
  - image: luksa/kubia-unhealthy
    name: kubia
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 15
Initial delay of 15 seconds

Guess you like

Origin www.cnblogs.com/zhming26/p/11719387.html