apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        name: mysql
      annotations:
        # Restrict scheduling to zone where volume is located.
        scheduler.alpha.kubernetes.io/affinity: >
          {
            "nodeAffinity": {
              "requiredDuringSchedulingIgnoredDuringExecution": {
                "nodeSelectorTerms": [
                  {
                    "matchExpressions": [
                      {
                        "key": "failure-domain.beta.kubernetes.io/zone",
                        "operator": "In",
                        "values": ["asia-northeast1-b"]
                      }
                    ]
                  }
                ]
              }
            }
          }
    spec:
      containers: 
        - name: mysql
          image: mysql:5.6
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: root-password
          ports: 
            - containerPort: 3306
              name: mysql
          volumeMounts:
              # name must match the volume name below
            - name: mysql-persistent-storage
              # mount path within the container
              mountPath: /var/lib/mysql
          resources:
            requests:
              memory: 800Mi
              cpu: 250m
            limits:
              memory: 800Mi
              cpu: 500m
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-data

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        name: mysql
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: failure-domain.beta.kubernetes.io/zone
                operator: In
                values:
                - asia-northeast1-a
      containers: 
        - name: mysql
          image: mysql:5.6
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: root-password
          ports: 
            - containerPort: 3306
              name: mysql
          volumeMounts:
              # name must match the volume name below
            - name: mysql-persistent-storage
              # mount path within the container
              mountPath: /var/lib/mysql
          resources:
            requests:
              memory: 800Mi
              cpu: 250m
            limits:
              memory: 800Mi
              cpu: 500m
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-data

Update node affinity for mysql
Update node affinity for mysql
