Could someone assist me on the below question. Apply the following manifest fil . . .

Tanumoy Ghosh:
Could someone assist me on the below question.

Apply the following manifest file in your Kubernetes enviornement:
https://github.com/zealvora/myrepo/blob/master/demo-files/troubleshoot-service.yaml
Verify if you are able to access website by referencing to the service IP address from a busybox pod. If it’s not working, fix the issue so that the website is downloadable when following command is ran: wget [SERVICE-IP]:8080

Thanks in advance, my approach is written in thread

Tanumoy Ghosh:
The above yaml from the link would create a deployment and service

NAME             READY   UP-TO-DATE   AVAILABLE   AGE
kplabs-service   3/3     3            3           29m
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kplabs-service   NodePort    10.103.253.123   <none>        8080:32001/TCP   26m

Even if I create a networkpolicy I could not reach the IP

netpol.yaml

apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: NetworkPolicy
metadata:
  namespace: default
spec:
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          project: default
    ports:
    - port: 8080
      protocol: TCP
  podSelector:
    matchLabels:
      app: kplabs-service
  policyTypes:
  - Ingress

Attempting to reach from temp busybox pod:

kubectl run busy --image busybox --rm -it --restart=Never -- wget -O- 10.103.253.123:8080
...

wget: can't connect to remote host (10.103.253.123): Connection timed out
pod "busy" deleted
pod default/busy terminated (Error)

Fernando Jimenez:
nginx by default does not run in port 8080 but rather 80.

spec:
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP

Should be in the service.
spec:
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP

Fernando Jimenez:
Please, give it a try

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: kplabs-service
  name: kplabs-fix
spec:
  replicas: 2
  selector:
    matchLabels:
      run: kplabs-fix
  template:
    metadata:
      labels:
        run: kplabs-fix
    spec:
      containers:
      - image: nginx
        name: kplabs-service
        ports:
        - containerPort: 80     
---
apiVersion: v1
kind: Service
metadata:
  name: fix-service
  labels:
    run: fix-service
spec:
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
  selector:
    run: kplabs-fix

Tanumoy Ghosh:
It’s working after setting the targetPort as 80 in service config

Thanks Fernando, much appreciated !