zoukankan      html  css  js  c++  java
  • K8S-yaml里初始化容器

    初始化容器:

    • 验证业务应用依赖的组件是否均已启动
    • 修改目录的权限
    • 调整系统参数
          initContainers:
          - command:
            - /sbin/sysctl
            - -w
            - vm.max_map_count=262144
            image: alpine:3.6
            imagePullPolicy: IfNotPresent
            name: elasticsearch-logging-init
            resources: {}
            securityContext:
              privileged: true
          - name: fix-permissions
            image: alpine:3.6
            command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
            securityContext:
              privileged: true
            volumeMounts:
            - name: elasticsearch-logging
              mountPath: /usr/share/elasticsearch/data
    
    

    验证Pod生命周期:

    apiVersion: v1
    kind: Pod
    metadata:
      name: demo-start-stop
      namespace: luffy
      labels:
        component: demo-start-stop
    spec:
      initContainers:
      - name: init
        image: busybox
        command: ['sh', '-c', 'echo $(date +%s): INIT >> /loap/timing']
        volumeMounts:
        - mountPath: /loap
          name: timing
      containers:
      - name: main
        image: busybox
        command: ['sh', '-c', 'echo $(date +%s): START >> /loap/timing;
    sleep 10; echo $(date +%s): END >> /loap/timing;']
        volumeMounts:
        - mountPath: /loap 
          name: timing
        livenessProbe:
          exec:
            command: ['sh', '-c', 'echo $(date +%s): LIVENESS >> /loap/timing']
        readinessProbe:
          exec:
            command: ['sh', '-c', 'echo $(date +%s): READINESS >> /loap/timing']
        lifecycle:
          postStart:
            exec:
              command: ['sh', '-c', 'echo $(date +%s): POST-START >> /loap/timing']
          preStop:
            exec:
              command: ['sh', '-c', 'echo $(date +%s): PRE-STOP >> /loap/timing']
      volumes:
      - name: timing
        hostPath:
          path: /tmp/loap
    
    

    创建pod测试:

    $ kubectl create -f demo-pod-start.yaml
    
    ## 查看demo状态
    $ kubectl -n luffy get po -o wide -w
    
    ## 查看调度节点的/tmp/loap/timing
    $ cat /tmp/loap/timing
    1585424708: INIT
    1585424746: START
    1585424746: POST-START
    1585424754: READINESS
    1585424756: LIVENESS
    1585424756: END
    
    
  • 相关阅读:
    存图方式---邻接表&邻接矩阵&前向星
    Bellman-Ford算法的改进---SPFA算法
    POJ-2240 Arbitrage---判断正环+枚举
    POJ-1860 Currency Exchange---Bellman-Ford判断正环
    单源最短路径---Bellman-Ford算法
    ZOJ-2750 Idiomatic Phrases Game---Dijk最短路
    POJ-1135 Domino Effect---最短路Dijk
    单源最短路径---Dijkstra算法
    POJ-1679 The Unique MST---判断最小生成树是否唯一
    POJ-2031 Building a Space Station---MST + 空间距离
  • 原文地址:https://www.cnblogs.com/dinghc/p/14384822.html
Copyright © 2011-2022 走看看