Hi, I have question on the kodekloud lab as per below: ``` Create a new pod ca . . .

ameya agashe:
Hi,
I have question on the kodekloud lab as per below:

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

I did as below:

k run custom-nginx --image=nginx
pod/custom-nginx created

controlplane ~ ✖ k expose pod custom-nginx --port=8080
service/custom-nginx exposed

controlplane ~ ➜  k get po
NAME                      READY   STATUS    RESTARTS   AGE
nginx-pod                 1/1     Running   0          8m41s
redis                     1/1     Running   0          6m42s
webapp-7b59bf687d-9vxfb   1/1     Running   0          2m33s
webapp-7b59bf687d-fsqqr   1/1     Running   0          2m33s
webapp-7b59bf687d-kgsz4   1/1     Running   0          2m33s
custom-nginx              1/1     Running   0          79s

controlplane ~ ➜  k get svc
NAME            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
kubernetes      ClusterIP   10.43.0.1      <none>        443/TCP    39m
redis-service   ClusterIP   10.43.168.75   <none>        6379/TCP   5m44s
custom-nginx    ClusterIP   10.43.47.186   <none>        8080/TCP   2m33s

controlplane ~ ➜  k describe svc custom-nginx
Name:              custom-nginx
Namespace:         default
Labels:            run=custom-nginx
Annotations:       <none>
Selector:          run=custom-nginx
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.43.47.186
IPs:               10.43.47.186
Port:              <unset>  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.42.0.14:8080
Session Affinity:  None
Events:            <none>

But when I click on “Check” I get Error. I am wondering why?

Alistair Mackay:
Hi,
Which lab is this?
I think the question is asking you to set the containerPort on the pod itself rather than expose as a service,
That means

k run custom-nginx --image=nginx --dry-run=client -o yaml > pod.yaml
vi pod.yaml

…then set containerPort property on pod

https://kubernetes.io/docs/concepts/workloads/pods/#using-pods

ameya agashe:
Spot on

ameya agashe:
Thanks mate!

Radoslaw Czajkowski:
but containerport itself is not required for a service to work - it is used only as information what ports are open

Radoslaw Czajkowski:

Radoslaw Czajkowski:
adding this property is not doing anything except that it is used as information what ports are open on the container

Radoslaw Czajkowski:
so Ameya did it correctly (exposed the port via the service)

ameya agashe:
Thanks mate @Radoslaw Czajkowski