Kubernetes Cluster API — Machine Health Check and AWS Spot instances

---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineHealthCheck
metadata:
name: cluster-1-node-unhealthy-5m
namespace: k8s
spec:
clusterName: cluster-1
maxUnhealthy: 40%
nodeStartupTimeout: 10m
selector:
matchLabels:
nodepool: nodepool-0
unhealthyConditions:
- type: Ready
status: Unknown
timeout: 300s
- type: Ready
status: "False"
timeout: 300s
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineHealthCheck
metadata:
name: cluster-1-master-unhealthy-5m
spec:
clusterName: cluster-1
maxUnhealthy: 30%
selector:
matchLabels:
cluster.x-k8s.io/control-plane: ""
unhealthyConditions:
- type: Ready
status: Unknown
timeout: 300s
- type: Ready
status: "False"
timeout: 300s
$ kubectl get machinehealthcheck
NAME MAXUNHEALTHY EXPECTEDMACHINES CURRENTHEALTHY
cluster-1-node-unhealthy-5m 40% 3 3
cluster-1-master-unhealthy-5m 30% 3 3
$ kubectl get machinehealthcheck
NAME MAXUNHEALTHY EXPECTEDMACHINES CURRENTHEALTHY
cluster-1-node-unhealthy-5m 40% 3 2
cluster-1-master-unhealthy-5m 30% 3 2
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: AWSMachineTemplate
metadata:
name: cluster-1-data-plane-0
namespace: k8s
spec:
template:
spec:
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
instanceType: t3.small
sshKeyName: default
spotMarketOptions:
maxPrice: ""

--

--

Highly versatile Senior technical Lead Engineer, I am a consummate and competent qualified IT Professional specialising in distributed systems

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store