字段小结练习

一级字段: apiVersion、kind、metadata、spec、status
修改镜像中的应用: command、args
标签: labels
标签选择器: selector
    等值关系: =,==,!=
    集合关系: 
        KEY in (VALUE1,VALUE2...)
        KEY notin (VALUE1,VALUE2...)
资源内嵌标签选择器:
    matchLabels
    matchExpressions
      操作符:
          In, Notin: values字段的值必须为非空列表
          Exists, NotExists: values字段的值必须为空列表
节点标签选择器: nodeSelector
指定节点: nodeName
注解: annotations
    与label不同在于,他不能挑选资源对象,仅用于为对象提供“元数据”
容器探测:
    liveness
    readiness
    lifecycle:
      postStart: #容器启动之后
      preStop: #容器关闭之前
探针类型:
    ExecAction,TCPSocketAction,HTTPGetAction
镜像策略:
    imagePullPolicy: IfNotPresent  #如果不存在则拉取
重启策略:
    RestarPolicy


apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: default
  labels:
    app: nginx
spec:
  selector:
    app: nginx
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30002
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: default
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14-alpine
        imagePullPolicy: IfNotPresent
        ports:
        - name: http
          containerPort: 80
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "hostname >> /usr/share/nginx/html/index.html"]
        livenessProbe:
          httpGet:
            port: http
            path: /index.html
          initialDelaySeconds: 60

猜你喜欢

转载自www.cnblogs.com/orange-lsc/p/11923272.html