I am new to kubernetes and trying to deploy a simple hello-world app. I am using Ubuntu 20.04 and running it on VMware workstation. I have installed minikube and trying to deploy. However, the pods are deployed but the service is not accessible through browser.
Below is my deployment.yaml
file:
---
kind: Service
apiVersion: v1
metadata:
name: exampleservice
spec:
selector:
name: myapp
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 8081
# Port to forward to inside the pod
targetPort: 8080
# Port accessible outside cluster
nodePort: 30000
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myappdeployment
spec:
replicas: 5
selector:
matchLabels:
name: myapp
template:
metadata:
labels:
name: myapp
spec:
containers:
- name: myapp
image: pritishkapli/example:v1.0.0
ports:
- containerPort: 8080
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
Below is the kubernetes service:
pritish@ubuntu:~$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
exampleservice LoadBalancer 10.101.149.155 <pending> 8081:30000/TCP 12m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 9h
Below is the pods running:
pritish@ubuntu:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
myappdeployment-b85b56d64-knhhc 1/1 Running 0 17m
myappdeployment-b85b56d64-m4vbg 1/1 Running 0 17m
myappdeployment-b85b56d64-qss4l 1/1 Running 0 17m
myappdeployment-b85b56d64-r2jq4 1/1 Running 0 17m
myappdeployment-b85b56d64-tflnz 1/1 Running 0 17m
Please help!
PS: I have updated the deployment.yaml
file and it's working as expected.