0

i have express app running at docker at http://127.0.0.1:3000/

i am trying to access it from microk8s services from http://127.0.0.1:30002/ but getting not found . here is my deployment file for kubernetes

kubernetes.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: simple-node
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      simple: node
  template:
    metadata:
      labels:
        simple: node
    spec:
      containers:
        - name: simple-node
          image: simple-node:1.0
---
apiVersion: v1
kind: Service
metadata:
  name: simple-node
  namespace: default
spec:
  type: NodePort
  selector:
    simple: node
  ports:
    - port: 3000
      targetPort: 3000
      nodePort: 30002

here is my services and deployment at microk8s .

services

1 Answers1

0

You have to tag and push image to docker registry. The containerd daemon used by MicroK8s is configured to trust this insecure registry. To upload images we have to tag simple-node before pushing it.

You can install the registry with:

microk8s enable registry

Execute commands below:

$ docker build . 
$ docker tag aaabbccc simple-node:1.0
$ docker push simple-node:1.0

Pushing to this insecure registry may fail in some versions of Docker unless the daemon is explicitly configured to trust this registry. To address this you need to edit /etc/docker/daemon.json and add:

{
  "insecure-registries" : ["localhost:32000"]
}

Then restart Docker to load new configuration.

$ sudo systemctl restart docker

Take a look: registry-built-in.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27