RAW Output Example Manifest #
Create Blueprint Deployment #
# Create an example deployment with "Nginx" container to use as blueprint
kubectl create deployment nginx --image=nginx
List Event Details #
# List events
kubectl get events
# Shell output:
LAST SEEN TYPE REASON OBJECT MESSAGE
2m12s Normal Scheduled pod/nginx-7854ff8877-482k8 Successfully assigned default/nginx-7854ff8877-482k8 to ubuntu2
2m12s Normal Pulling pod/nginx-7854ff8877-482k8 Pulling image "nginx"
2m4s Normal Pulled pod/nginx-7854ff8877-482k8 Successfully pulled image "nginx" in 7.397s (7.397s including waiting)
2m4s Normal Created pod/nginx-7854ff8877-482k8 Created container nginx
2m4s Normal Started pod/nginx-7854ff8877-482k8 Started container nginx
2m12s Normal SuccessfulCreate replicaset/nginx-7854ff8877 Created pod: nginx-7854ff8877-482k8
2m12s Normal ScalingReplicaSet deployment/nginx Scaled up replica set nginx-7854ff8877 to 1
List & Save RAW Output Deployment Details #
# List deploments
kubectl get deployments
# Shell output:
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 10
# List deployment details
kubectl describe deployment nginx
# List deployment: Output in yaml format
kubectl get deployment nginx -o yaml
# List deployment: Output in yaml format, save into file
kubectl get deployment nginx -o yaml > nginx_version-1.yaml
Delete the Deployment #
# Delete the deployment
kubectl delete deployment nginx
Adopt RAW Output Deployment Details #
Remove the creationTimestamp
, resourceVersion
& uid
lines and also the whole status
block:
vi nginx_version-1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2024-11-04T17:17:45Z" # Remove line
generation: 1
labels:
app: nginx
name: nginx
namespace: default
resourceVersion: "4156" # Remove line
uid: 7347425b-1a93-4079-8918-d3eed8742c9e # Remove line
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: # Remove whole satus block
availableReplicas: 1
conditions:
- lastTransitionTime: "2024-11-04T17:17:54Z"
lastUpdateTime: "2024-11-04T17:17:54Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2024-11-04T17:17:45Z"
lastUpdateTime: "2024-11-04T17:17:54Z"
message: ReplicaSet "nginx-7854ff8877" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 1
readyReplicas: 1
replicas: 1
updatedReplicas: 1
The adopted manifest should look like this:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels:
app: nginx
name: nginx
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
Recreate the Deployment #
# Create the deployment again from the file
kubectl create -f nginx_version-1.yaml
# List deployment: Output in yaml format, save into file
kubectl get deployment nginx -o yaml > nginx_version-2.yaml
diff nginx_version-1.yaml nginx_version-2.yaml
# Shell output:
5a6
> creationTimestamp: "2024-11-04T17:33:34Z"
10a12,13
> resourceVersion: "6197"
> uid: 1b3168cb-ecdb-4ff0-b090-03223a89c2f7
40a44,62
> status:
> availableReplicas: 1
> conditions:
> - lastTransitionTime: "2024-11-04T17:33:35Z"
> lastUpdateTime: "2024-11-04T17:33:35Z"
> message: Deployment has minimum availability.
> reason: MinimumReplicasAvailable
> status: "True"
> type: Available
> - lastTransitionTime: "2024-11-04T17:33:34Z"
> lastUpdateTime: "2024-11-04T17:33:35Z"
> message: ReplicaSet "nginx-7854ff8877" has successfully progressed.
> reason: NewReplicaSetAvailable
> status: "True"
> type: Progressing
> observedGeneration: 1
> readyReplicas: 1
> replicas: 1
> updatedReplicas: 1
-
5a6
Means on line 5 of nginx_version-1.yaml, a line has been added at line 6 in nginx_version-2.yaml -
10a12,13
Means that starting from line 10 in nginx_version-1.yaml, two lines (12 and 13) were added in nginx_version-2.yaml
The previously removed creationTimestamp
, resourceVersion
& uid
lines and thestatus
block are in the new file. These are generated for each created resource and must be deleted fo avoid conflicts.
Delete the Deployment #
# Delete the deployment
kubectl delete deployment nginx
Dry-Run Example Manifest #
# Create an example manifest via dry-run
kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > nginx_version-3.yaml
--dry-run=client
Simulates the command on the client side without sending any changes to the Kubernetes API server
This manifest lacks the unique information that was manually removed from the RAW Output manifest.
# Open the manifest
vi nginx_version-3.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}