Kubernetes YAML 3-page Bit Paper

The Kubernetes YAML has been evolving like forever and still continues to change. However, after some time it starts making sense.  The sheer number of specifications can  however be overwhelming for anyone and so I came up with this bitpaper that can save countless visits to the kubernetes.io website. This is not exhaustive nor complete but has most of the commonly used specs and their nuances and can be printed on 3 sides.

This has been made for Kubernetes 1.10.

Hope you find this useful

M - Mandatory , Must Specify

O - Optional
kind

Deployment

ReplicaSet

StatefulSet

apiVersion

apps/v1

apps/v1

apps/v1

metadata.name

M

M

M

metadata.namespace

O

O

O

spec.selector

spec.matchLabels
spec.matchExpressions

spec.matchLabels

spec.matchLabels

spec.template

M(Pod template)

M(Pod template)

M(Pod template)

spec.template.spec.restartPolicy

Always only

spec.template.metadata.labels

M

M

M

spec.replicas

O(1)

O(1)

O(1)

spec.strategy.type

O(RollingUpdate)
Recreate

spec.maxSurge

M(strategy==RollingUpdate)

spec.maxUnavailable

M(strategy==RollingUpdate)

spec.minReadySeconds

O(0)

spec.progressDeadlineSeconds

O(> minReadySeconds)

spec.revisionHistoryLimit

O(10s)

spec.paused

O(False)

spec.serviceName

O

spec.volumeClaimTemplates

M

Notes kubectl rollout status deployments
kubectl rollout history –record | –revision=n
kubectl rollout undo | –to-revision=n

kubectl scale deployment | –replicas=n

kubectl autoscale deployment –min= –max= –cpu-percent=

kubectl rollout pause

kubectl set resources deployment -c= –limits=cpu=,memory=

kubectl rollout resume

Allergic to kubectl rolling-update command
You can delete a ReplicaSet without affecting any of its pods, using kubectl delete with the –cascade=false
kind

DaemonSet

HorizontalPodAutoscaler

 ReplicationController

apiVersion

apps/v1

batch/v2alpha1

v1

metadata.name

M

M

M

metadata.namespace

O

O

spec.selector

spec.matchLabels
spec.matchExpressions

spec.template

M(Pod template)

M(Pod template)

spec.template.spec.restartPolicy

Always Only

Always Only

spec.template.metadata.labels

M

M

spec.template.spec.nodeSelector

O

spec.template.spec.affinity

O

Respect Taints and Tolerations

Yes

spec.replicas

O(1)

spec.scaleTargetRef

M(ReplicaSet)

spec.minReplicas

?

spec.maxReplicas

?

spec.targetCPUUtilizationPercentage

?

Notes Allergic to kubectl rolling-update command
You can delete a rc without affecting any of its pods, using kubectl delete with the –cascade=false
kind

Job

CronJob

apiVersion

apps/v1

autoscaling/v1

metadata.name

M

M

metadata.namespace

O

O

spec.selector

O

spec.template

M(Pod template)

spec.template.spec.restartPolicy

Never or OnFailure only

spec.parallelism

O

spec.completions

O
1 -single (default)
>1 -Parallel Jobs

.spec.backoffLimit

O

.spec.activeDeadlineSeconds

O

spec.jobTemplate

M(Job)

spec.startingDeadlineSeconds

O (Large Number)

spec.concurrencyPolicy

O
Allow(default)
Forbid
Replace

spec.suspend

O (False)

spec.successfulJobsHistoryLimit

O (3)

spec.failedJobsHistoryLimit

O (1)

Notes For Non-Parralel Jobs: spec.parallelism & spec.completions =1 (unset)
Fixed completion : spec.completions>1
Queue: spec.paralleism>1

As you must have noted by now, I’m only handling Controllers right now… Will do something similar for Services, Pods and other Infra components in later post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s