0

Im learning kubernetes (im using KIND) and im facing to a problem. Im following this tutorial This exemple work well, but i want to change the pod image by one of mines (it's a nodeJS api that just return a sentence with the route : http://localhost:3001 )

File bealdungConfig.yaml

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: baeldung-kind
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"    
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
  - containerPort: 3001
    hostPort: 3001
    protocol: TCP

File baeldung-service.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: baeldung-app
  labels:
    app: baeldung-app
spec:
  selector:
    matchLabels:
      app: baeldung-app
  replicas: 5
  template:
    metadata:
      labels:
        app: baeldung-app
    spec:
      containers:
        - name: baeldung-app
          image: klemensgalus/backend:latest
          ports:
            - containerPort: 3001
---
kind: Service
apiVersion: v1
metadata:
  name: baeldung-service
spec:
  selector:
    app: baeldung-app
  ports:
  # Default port used by the image
  - port: 3001
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: baeldung-ingress
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: "/baeldung"
        backend:
          service:
            name: baeldung-service
            port:
              number: 3001
---

I create my cluster like this kind create cluster --config baeldungConfig.yaml

I add the ingress NGINX controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

And i apply the service kubectl apply -f baeldung-service.yaml

If I go http://localhost/baeldung i get a 504 Error

Do you have any tips to fix this ?

I tried to change container ports and to remove the replicas

ps : the docker container work without kubernetes on my computer with a docker run

Bronems
  • 1
  • 1

0 Answers0