Skip to content

Latest commit

 

History

History

task_004__local__expose_svc_via_nodeport

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

-- Create whoami deployment

$ kubectl create deployment whoami-dep --image=containous/whoami:latest --replicas=1
deployment.apps/whoami-dep created
  • Get the pods
$ kubectl get pods                                                                  
NAME                          READY   STATUS    RESTARTS   AGE
whoami-dep-69bccbf994-h8j69   1/1     Running   0          13s
  • Now expose port 80 of the deployment docker whoami via a NodePort
$ kubectl expose deployment whoami-dep --name=whoami-dep-svc --type=NodePort --port=80 --target-port=80  
service/whoami-dep-svc exposed
  • Get the service
$ kubectl get svc                                                                                      
NAME             TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes       ClusterIP   10.96.0.1      <none>        443/TCP        34d
whoami-dep-svc   NodePort    10.101.89.89   <none>        80:31773/TCP   14s
  • Access the deployment using the NodePort
$ curl http://localhost:31773
Hostname: whoami-dep-69bccbf994-h8j69
IP: 127.0.0.1
IP: 10.1.5.169
RemoteAddr: 192.168.65.6:59354
GET / HTTP/1.1
Host: localhost:31773
User-Agent: curl/7.64.1
Accept: */*