apiVersion: apps/v1
kind: StatefulSet
metadata:
  #命名规范:应用名称-版本
  name: android-id01
  namespace: desktop
  labels:
    app: android-id01
    canary: android-id01
spec:
  #保留历史版本数量
  revisionHistoryLimit: 3
  replicas: 1
  serviceName: android-id01
  selector:
    matchLabels:
      app: android-id01
      canary: android-id01
      version: v2
#  minReadySeconds: 60     #滚动升级时60s后认为该pod就绪
  template:
    metadata:
      labels:
        app: android-id01
        canary: android-id01
        version: v2
      annotations:
        #enable istio sidecar injection
        sidecar.istio.io/inject: "false"
    spec:
      terminationGracePeriodSeconds: 60 ##k8s将会给应用发送SIGTERM信号，可以用来正确、优雅地关闭应用,默认为30秒
      #imagePullSecrets:
      #- name: registrykey-ali-ext
      containers:
      - name: android
        image: budtmo/docker-android-x86-8.1
        imagePullPolicy: Always
        #livenessProbe: #kubernetes认为该pod是存活的,不存活则需要重启
        #  httpGet:
        #    path: /
        #    port: 80
        #    scheme: HTTP
        #  initialDelaySeconds: 60 ## equals to the maximum startup time of the application + couple of seconds
        #  timeoutSeconds: 5
        #  successThreshold: 1
        #  failureThreshold: 5
        #readinessProbe: #kubernetes认为该pod是启动成功的
        #  httpGet:
        #    path: /
        #    port: 80
        #    scheme: HTTP
        #  initialDelaySeconds: 30 ## equals to minimum startup time of the application
        #  timeoutSeconds: 5
        #  successThreshold: 1
        #  failureThreshold: 5
        resources:
          # keep request = limit to keep this container in guaranteed class
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 4
            memory: 8Gi
        securityContext:
          privileged: true
          #fsGroup: 1000
          #capabilities:
          #  add: ["NET_ADMIN"]
        env:
          - name: DEVICE
            value: "Samsung Galaxy S6"
          - name: PGID
            value: "1000"
          - name: PASSWORD
            value: "mypassword"
          #- name: LC_ALL
          #  value: "zh_CN.UTF-8"
          #- name: LANG
          #  value: "zh_CN.UTF-8"
          - name: TZ
            value: "Asia/Shanghai"
        ports:
          - name: novnc
            containerPort: 6080
        volumeMounts:
           - mountPath: /dev/shm
             name: shm-volume
           - mountPath: /home
             name: home
      volumes:
      - emptyDir:
          medium: Memory
          sizeLimit: 640Mi
        name: shm-volume
  volumeClaimTemplates:
  - metadata:
      name: home
    spec:
      accessModes:
      - ReadWriteOnce
      #ceph rbd storageclass
      #storageClassName: rbd
      resources:
        requests:
          storage: 60Gi
