Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

kubernetes hello world simple app does not work

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"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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:

  1. Using a node port
  2. Using an ingress controller
  3. Port forwarding with kubectl

Easiest would be:

kubectl port-forward svc/admin-service 4444:4444
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading