Spotinst labels allow you to adjust the default behavior of scaling in Ocean, by adding Spotinst labels to your pods you can control the node termination process or its life cycle.

If you wish to use custom labels you can use this guide.

Available labels:
Label Key Accepted Values Description
spotinst.io/restrict-scale-down true When a node is running a pod with such a label, The node will not violently scale down
spotinst.io/node-lifecycle od Pods which contain this node selector/affinity are forced to run on an on-demand instance
spotinst.io/gpu-type nvidia-tesla-v100
nvidia-tesla-p100
nvidia-tesla-k80
nvidia-tesla-p4
nvidia-tesla-t4
Sets the GPU accelerator

Note: This setting applies only to GKE clusters

 

Examples

using OD nodeSelector:

apiVersion: v1
kind: Pod
metadata:
  name: with-node-selector
spec:
  containers:
  - name: with-node-selector
    image: k8s.gcr.io/pause:2.0
    imagePullPolicy: IfNotPresent
  nodeSelector:
    spotinst.io/node-lifecycle: od

using OD nodeAffinity:

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: spotinst.io/node-lifecycle
            operator: In
            values:
            - od
  containers:
  - name: with-node-affinity
    image: k8s.gcr.io/pause:2.0

using restrict scale down label:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
        spotinst.io/restrict-scale-down: 'true'
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        resources:
          requests:
            memory: "2Gi"
            cpu: "2"
          limits:
            memory: "4Gi"
            cpu: "4"