Description:
Deployment
Kubernetes Object
Manages a set of pods by describing the desired state thru Kubernetes ReplicaSet by sending configurations to it
when new deployment is applied, another replicaset is created and scaled up, the old rs is scaled down
when rollback, scale down new one, scale up old one
use change-cause
Use cases:
create a deployment to rollout a replicaset
declare the new state of the pods
rollback to earlier deployment
scale up the deployment to facilitate more load
pause a rollout
use the status of the deployment as an indicator that a rollout has stuck
clean up older replicasets
Create deployment
write .yaml file, then apply
or kubectl create deployment : kubectl create deployment --image nginx nginx-1
When a repository isn’t specified, the default behavior is to try and find the image either locally or in the Docker public registry. In this case, the image is pulled from the Docker public registry.
Updating a deployment
Rolling back a deployment
.
Checking rollout history of a deployment
kubectl rolleout history to display change-cause
CHANGE-CAUSE is copied from the Deployment Annotation kubernetes.io/change-cause to its revisions upon creation.
Specify theCHANGE-CAUSE message by:
Annotating the Deployment with kubectl annotate deployment/nginx-deployment kubernetes.io/change-cause="image updated to 1.16.1"
Manually editing the manifest of the resource.
Using tooling that sets the annotation automatically.
Scaling a deployment
API
apiVersion: apps/v1
kind: Deployment
metadata:
spec: DeploymentSpec
status
DeploymentSpec