study-lfs258-11-09-2026
Today I’m continueing to go through the journey of writing again. This time I will write my experience off learning for my CKA exam.
What I learned this morning:
Getting formiliar with the –dry-run flag
- Essentially this just give you the output without all the unique information printed it out to stdout.
- Somethink like this would look like:
kubectl create deployment two --image=nginx --dry-run=client -o yaml- It is in fact a simulation of the command without doing anything
Similar to just printing out a yaml file with the cat command you can also get its information with the -o yaml option:
kubectl get deployments nginx -o yamlThe biggest difference is with the way of looking it like this is that you can see the ’live’ data.
- It includes status and metadata.
- You can see it more like its latest ‘snapshot’
The same you can do for JSON as well:
kubectl get deployment nginx -o json- To be able to see the effect of the nginx container a service is needed to be able to see the ‘default web page ( nginx )’. With the following command you can create a service out of the deployment that is already there.
kubectl expose deployment/nginx- Also with the
kubectl expose -hyou can look up some more information about the command and see some different examples of using this. - Now this command will give you an error due to there is no declared port.
mjerta@pi-control-1:~ $ kubectl expose deployment nginx
error: couldn't find port via --port flag or introspectionWhat you could do is what the
expose -hwas already suggesting and just put the port in the same command but the course is trying to teach me another way.You can in fact change an object with the apply, edit or patch sub-commands. Not these are for non-disruptive updates.
If you need be given a disruptive update this could be done with
replace --forcesubcommand.By following the course I just did the edit manually by first adding the ports lines inside the correct container - vim into first.yaml
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
ports:
- containerPort: 80
protocol: TCP
resources: {}- And then perform the update with:
kubectl replace -f first.yaml --force- The result will look like this:
mjerta@pi-control-1:~ $ kubectl replace -f first.yaml force
deployment.apps/nginx replaced- Running the following you will that the creating of the deployment and the recreation of the pod is different now:
mjerta@pi-control-1:~ $ kubectl get deploy,pod
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 2d23h
NAME READY STATUS RESTARTS AGE
pod/nginx-75fdcbbc74-5bbl5 1/1 Running 0 5m35sI notice I’m also repeating my own notes a bit much now. So I will try to give you in the an more general overview at the end. If I’m not done with this journal yet.