Norrin Radd:
Hi, I was wondering if I could get some help, on the mock exam 2, we’re asked to create a deployment and upgrade the version. On the solution video they use this command “kubectl run deploy --image=nginx:1.16 --replicas=1 --record” however when i run the same command it creates a pod, not a deployment. I have tried using “k create deployment nginx-deploy --image=nginx:1.16 --replicas=1 --record” but throws an error not recognising the --record flag. I have also tried " run --generator=run-deployment/apps.v1 nginx-deploy --image=nginx:1.16 --replicas=1 --record", could do with some pointers?
Sunny Goel:
I think, the purpose of --record flag is to save the kubectl command that is making change to an existing resource…
Sunny Goel:
I don’t think, this flag will work when you are creating the object 1st time…
Marco Tony:
Thank to answered to this first
Marco Tony:
Yes I know. I just didn’t like the --record
Edmund Kueh:
k run is used to create pods only…It will not work with deployment…Initally use k create deployment <name> -o yaml --dry-run=client > <http://deployment.to|deployment.yaml to> create your deployment YAML file…Then edit your YAML file …Once you are done editing, create your resources using k create -f deployment.yaml --record. Hopefully my sequence is correct…as it has been a while since I tackled the mock exam…
Norrin Radd:
Thanks all, creating the yaml file first and then using —record seems to do the trick. @Edmund Kueh your memory serves you well :spock-hand:
Lakshminarayanan Krishnan:
So, I remember encountering this issue, hence remember doing this differently, in the following manner:
kc create deployment nginx-deploy --image=nginx:1.16 --replicas=1 --dry-run -o yaml > deploy.yaml
kc apply -f deploy.yaml --record
kc rollout history deployment.apps nginx-deploy
Laks NK:
Upon doing this, this is the output, and some other commands playing around with the deployment:
[ controlplane : ~ ]
# kc rollout history deployment.apps nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl apply --filename=deploy.yaml --record=true
[ controlplane : ~ ]
# kc set image deployment nginx-deploy nginx=nginx:alpine --record
deployment.apps/nginx-deploy image updated
[ controlplane : ~ ]
# kc rollout history deployment.apps nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl apply --filename=deploy.yaml --record=true
2 kubectl set image deployment nginx-deploy nginx=nginx:alpine --record=true
[ controlplane : ~ ]
# kc scale deployment nginx-deploy --replicas=3 --record
deployment.apps/nginx-deploy scaled
[ controlplane : ~ ]
# kc rollout history deployment.apps nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl apply --filename=deploy.yaml --record=true
2 kubectl scale deployment nginx-deploy --replicas=3 --record=true