# Copyright 2020 Google LLC
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     https://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pluscode
spec:
  replicas: 3
  selector:
    matchLabels:
      app: pluscode
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: pluscode
    spec:
      topologySpreadConstraints: #A
        - maxSkew: 1  #B
          topologyKey: kubernetes.io/hostname #C
          whenUnsatisfiable: ScheduleAnyway #D
          labelSelector: #E
            matchLabels: #E
              app: pluscode #E
      containers:
      - name: pluscode-container
        image: wdenniss/pluscode-demo:latest
        resources:
          requests:
            cpu: 200m
            memory: 250Mi
          limits:
            cpu: 300m
            memory: 400Mi

#A the topology constraint added
#B the maximum number of replica imbalance
#C the node label to use for the topology
#D The behavior to use when it’s not possible to satisfy the topology requirement
#E another label selector set to this template’s metadata label
