Question Create a new pod called `custom-nginx` using the `nginx` image and expo . . .

subham Saha:
Question
Create a new pod called custom-nginx using the nginx image and expose it on container port 8080.

For the solution I have first created POD then exposed it to port. Then why its showing me wrong

FYI,

root@controlplane:~# kubectl run --image=nginx custom-nginx
pod/custom-nginx created
root@controlplane:~# kubectl expose pod custom-nginx --port=8080
service/custom-nginx exposed

And the solution is given is
kubectl run custom-nginx --image=nginx --port=8080

I want to know the difference between these 2 commands.

Thanks in Advance.

Rustam Rakhimbayev:
When use kubectl expose, you are creating service to access. With kubectl run custom-nginx --image=nginx --port=8080 - container port exposed
https://theithollow.com/2019/02/05/kubernetes-service-publishing/

subham Saha:
Thank you ! got it :smiley:

in the command line -

vim redis123.yml

this opens the text editor. put this in -

apiVersion: v1
kind: Pod
metadata:
name: redis
spec:
containers:

  • name: redis
    image: redis123

then hit esc until cursor goes to bottom left and type ‘:wq’ enter to save and exit.

then in command -

kubectl apply -f redis123.yml