当前位置:   article > 正文

k8s常用资源模板

k8s常用资源模板

注: 仅自己备用

1、pod

apiVersion: v1
kind: Pod
metadata:
  name: plato
  labels:
    app: plato
spec:
  containers:
  - name: plato
    image: ccr.ccs.tencentyun.com/chens/plato:jenkins-plato-test-15-427d21f0
    imagePullPolicy: IfNotPresent
    volumeMounts:
      - name: soc-pla-path
        mountPath: /biz-code/plato/
  restartPolicy: Never
  volumes:
    - name: soc-pla-path
      hostPath:
        path: /plato
        type: Directory
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

2、deploy

apiVersion: apps/v1
kind: Deployment
metadata:
  name: socrates
  labels:
    app: socrates
    env: release
spec:
  selector:
    matchLabels:
      app: socrates
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  # minReadySeconds: 30
  template:
    metadata:
      labels:
        app: socrates
    spec:
      containers:
        - name: filebeat                        
          image: registry.cn-beijing.aliyuncs.com/dotbalo/filebeat:7.10.2 
          resources:
            requests:
              memory: "100Mi"
              cpu: "10m"
            limits:
              cpu: "200m"
              memory: "300Mi"
          imagePullPolicy: IfNotPresent
          env:
            - name: podIp
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.podIP
            - name: podName
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: podNamespace
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: podDeployName
              value: socrates
            - name: TZ
              value: "Asia/Shanghai"
          securityContext:
            runAsUser: 0
          volumeMounts:
            - name: logpath
              mountPath: /data/log/
            - name: filebeatconf
              mountPath: /usr/share/filebeat/filebeat.yml 
              subPath: usr/share/filebeat/filebeat.yml
        - name: socrates
          image: ccr.ccs.tencentyun.com/chens/socrates:jenkins-socrates-test-45-4450adbbaa
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: logpath
              mountPath: /biz-code/socrates/runtime/
            - name: plato-vue
              mountPath: /biz-code/socrates/public/vue
            - name: plato-src
              mountPath: /biz-code/socrates/public/src
            - name: plato-index
              mountPath: /biz-code/socrates/public/index.html
          env:
            - name: TZ
              value: "Asia/Shanghai"
            - name: LANG
              value: C.UTF-8
            - name: LC_ALL
              value: C.UTF-8
          livenessProbe:
            failureThreshold: 2
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 80
            timeoutSeconds: 2
          ports:
          - containerPort: 80
            name: web
            protocol: TCP
          readinessProbe:
            failureThreshold: 2
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 80
            timeoutSeconds: 2
          resources:
            limits:
              cpu: 994m
              memory: 1170Mi
            requests:
              cpu: 300m
              memory: 300Mi
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: qcloudregistrykey
      restartPolicy: Always
      securityContext: {}
      serviceAccountName: default
      volumes:
        - name: logpath
          emptyDir: {}
        - name: filebeatconf
          configMap:
            name: filebeatconf
            items:
              - key: filebeat.yml
                path: usr/share/filebeat/filebeat.yml
        - name: plato-vue
          hostPath:
            path: /plato/vue
            type: Directory
        - name: plato-src
          hostPath:
            path: /plato/src
            type: Directory
        - name: plato-index
          hostPath:
            path: /plato/index.html
            type: File
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135

3、service

apiVersion: v1
kind: Service
metadata:
  labels:
    app: hume
  name: hume-service
  namespace: dev
spec:
  ports:
  - name: hume
    port: 7777
    protocol: TCP
    targetPort: 7777
  selector:
    app: hume
  sessionAffinity: None
  type: NodePort
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

4、cronjob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: sync-stock-record
  namespace: dev
  labels:
    app: sync-stock-record
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    metadata:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: counter
            image: ccr.ccs.tencentyun.com/chens/marx:jenkins-marx-sync_stock_record-test-1-2982d99
            volumeMounts:
            - name: config
              mountPath: /biz-code/config.yaml
              subPath: config.yaml
              # command: ["/bin/sh","-c","whoami;chmod +x sync_stock_record;pwd;ls;./sync-stock-record -time='-5' -c config.yaml"]
            command: ["/bin/sh","-c","./sync_stock_record -time='-5' -c config.yaml"]
          imagePullSecrets:
          - name: qcloudregistrykey
          volumes:
          - name: config
            configMap:
              name: config
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/563759
推荐阅读
相关标签
  

闽ICP备14008679号