i’ve followed a tutorial called hello-world on youtube:
https://www.youtube.com/watch?v=xaZpu4C4joM
i’ve changed only the name: "hello-world" to "admin"
here the code:
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-deployment
spec:
selector:
matchLabels:
app: admin
template:
metadata:
labels:
app: admin
spec:
containers:
- name: admin
image: dockercloud/hello-world
resources:
requests:
memory: "32Mi"
cpu: "100m"
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 3000
env:
- name: LISTEN_PORT
value: "3000"
---
apiVersion: v1
kind: Service
metadata:
name: admin-service
spec:
type: ClusterIP
selector:
app: admin
ports:
- port: 4444
targetPort: 3000
but it’s not working when i call the server:
http://localhost:4444/
output doing:
kubectl describe service admin-service
Name: admin-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=admin
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.110.124
IPs: 10.105.110.124
Port: <unset> 4444/TCP
TargetPort: 3000/TCP
Endpoints: <none>
Session Affinity: None
Events: <none>
what it’s happening ?
thanks
UPDATE: i’ve add this ingress code to file:
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello
spec:
rules:
- host: localhost
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: admin-service
port:
number: 4444
but it’s not working too..
>Solution :
You need to expose your service to outside in some way:
- Using a node port
- Using an ingress controller
- Port forwarding with kubectl
Easiest would be:
kubectl port-forward svc/admin-service 4444:4444