apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx-sts
spec:
  selector:
    matchLabels:
      app: nginx-sts
  podManagementPolicy: Parallel
  serviceName: "nginx"
  replicas: 8
  template:
    metadata:
      labels:
        app: nginx-sts
    spec:
      affinity:
        podAffinity:
          # requiredDuringSchedulingIgnoredDuringExecution:
          # - labelSelector:
          #     matchExpressions:
          #     - key: app
          #       operator: In
          #       values:
          #       - nginx-sts
          #   topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - nginx-sts
              topologyKey: kubernetes.io/hostname
      # tolerations:
      # - key: node-role.kubernetes.io/master
      #   operator: Exists
      #   effect: NoSchedule
      containers:
      - name: nginx
        image: harbor.myk8s.aliyunpoc.com/library/busybox
        command:
        - sh
        - "-c"
        - |
          while true; do
            echo "huizhi testing";
            echo "yes ">>/data/yes.txt;
            sleep 120s
          done;
        resources:
          requests:
            cpu: 4
            memory: 8Gi
          limits:
            cpu: 8
            memory: 16Gi