码迷,mamicode.com
首页 > 其他好文 > 详细

pod-test

时间:2019-11-16 12:47:14      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:mys   html   rtp   lse   vol   sources   nbsp   names   cpu   

apiVersion: v1
kind: Pod
metadata:
  name: init-demo
  # 命名空间
  namespace: default
  labels:
    app: nginx
spec:
  # 调度约束:
  # nodeName: 将Pod调度到指定的Node名称上
  # nodeSelector: 将Pod调度到匹配Label的Node上
  # nodeName: k8s-node1
  # nodeSelector:
  #   env_role: dev
  containers:
  - name: nginx
    image: nginx
    # 镜像拉去策略:IfNotPresent, Never, Always
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 80
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "password"
    # pod资源请求和限制
    resources:
      requests:
      memory: "64Mi"
      cpu: "250m"
      limits:
      memory: "128Mi"
      cpu: "500m"
    # 健康检查策略:
    # livenessProbe: 检查失败,将杀死容器,根据Pod的restartPolicy来操作
    # readinessProde: 检查失败,Kubernetes会把Pod从service endpoints中剔除
    # 健康检查方法:httpGet, exec, tcpSocket
    livenessProbe:
      # exec:
      #   command:
      #   - cat 
      #   - /tmp/health
      # tcpSocket:
      #   port: 80
      httpGet:
        # scheme: HTTP
        path: /
        port: 80
      initialDelaySeconds: 10
      periodSeconds: 20

    # 挂载目录
    volumeMounts:
    - name: workdir
      mountPath: /usr/share/nginx/html
  imagePullSecrets:
    name: myregistrykey
  # 重启策略:Always, Never, Onfailure
  restartPolicy: Always
  # These containers are run during pod initialization初始化容器,先于业务容器开始执行
  initContainers:
  - name: install
    image: busybox
    command:
    - wget
    - "-O"
    - "/work-dir/index.html"
    - http://kubernetes.io
    volumeMounts:
    - name: workdir
      mountPath: "/work-dir"
  dnsPolicy: Default
# 存储 hostpath, emptydir, nfs, configmap
  volumes:
  - name: workdir
    emptyDir: {}
  - name: data
    hostPath:
    path: /tmp
    type: Directory
  - name: wwwroot
    nfs:
    server: 192.168.0.200
    path: /data/nfs
  - name: filebeat-config
    configMap:
    name: filebeat-config


pod-test

标签:mys   html   rtp   lse   vol   sources   nbsp   names   cpu   

原文地址:https://www.cnblogs.com/kevinlx/p/11871004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!