1

I know there are many questions concerning this aspect... but until now I could not find any answers. I tried two images (Apache Solr and Neo4J). Tried different namespaces, clusterIP, edit /etc/hosts, ingress, tunnel, minikube ip and all my requests got no response.

I tried these images standalone in Docker and they answer properly... with localhost, 127.0.0.1 and my ethernet IP - in case 192.168.0.15. I guessed that could be an internal configuration (from Sol, Neo4J) to allow requests only from localhost... but as they replied the calling from IP address and through a custom domain I set in /etc/hosts, I turned to kubernetes configuration.

Below are the following steps and environment:

1) MacOS 10.15 Catalina
2) minikube version: v1.24.0 - commit: 76b94fb3c4e8ac5062daf70d60cf03ddcc0a741b
3) Kubectl:
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:33:37Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:35:25Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}
4) Docker:
Client:
 Cloud integration: v1.0.22
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.10
 Git commit:        dea9396
 Built:             Thu Nov 18 00:36:09 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:35:39 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
minikube start --mount --mount-string="/my/local/path:/analytics" --driver='docker'
kubectl apply -f neo4j-configmap.yaml
kubectl apply -f neo4j-secret.yaml
kubectl apply -f neo4j-volume.yaml
kubectl apply -f neo4j-volume-claim.yaml
kubectl apply -f neo4j.yaml
kubectl apply -f neo4j-service.yaml
apiVersion: v1
kind: ConfigMap
metadata:
    name: neo4j-configmap
data:
     neo4j-url: neo4j-service
---
apiVersion: v1
kind: Secret
metadata:
  name: neo4j-secret
type: Opaque
data:
    neo4j-user: bmVvNGoK
    neo4j-password: bmVvNGoK
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: neo4j-volume
spec:
  storageClassName: hostpath
  capacity:
    storage: 101Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
      path: "/analytics/neo4j"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: neo4j-volume-claim
  labels:
    app: neo4j
spec:
  storageClassName: hostpath
  volumeMode: Filesystem
  volumeName: neo4j-volume
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 101Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: neo4j-application
  labels:
    app: neo4j
spec:
  replicas: 1
  selector:
    matchLabels:
      app: neo4j
  template:
    metadata:
      labels:
        app: neo4j
    spec:
      volumes:
        - name: neo4j-storage
          persistentVolumeClaim:
            claimName: neo4j-volume-claim
      containers:
        - name: neo4j
          image: neo4j:4.1.4
          ports:
          - containerPort: 7474
            name: neo4j-7474
          - containerPort: 7687
            name: neo4j-7687
          volumeMounts:
          - name: neo4j-storage
            mountPath: "/data"
---
apiVersion: v1
kind: Service
metadata:
  name: neo4j-service
spec:
  type: NodePort
  selector:
    app: neo4j
  ports:
    - protocol: TCP
      port: 7474
      targetPort: neo4j-7474
      nodePort: 30001
      name: neo4j-port-7474
    - protocol: TCP
      port: 7687
      targetPort: neo4j-7687
      nodePort: 30002
      name: neo4j-port-7687

The bash steps where executed in that order. I have each yaml configuration in a separated file. I joined they here as just one yaml just to expose then.

What part or parts of the setup process or configuration process am I missing?

Below follows the kubectl describe all with only neo4j. I tried http, https request from all possibles IP... Connected to each pod and perform a curl inside the pod... and got successfully responses.

Name:         neo4j-application-7757948b98-2pxr2
Namespace:    default
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Sun, 09 Jan 2022 14:19:32 -0300
Labels:       app=neo4j
              pod-template-hash=7757948b98
Annotations:  <none>
Status:       Running
IP:           172.17.0.4
IPs:
  IP:           172.17.0.4
Controlled By:  ReplicaSet/neo4j-application-7757948b98
Containers:
  neo4j:
    Container ID:   docker://2deda46b3bb15712ff6dde5d2f3493c07b616c2eef3433dec6fe6f0cd6439c5f
    Image:          neo4j:4.1.4
    Image ID:       docker-pullable://neo4j@sha256:b1bc8a5c5136f4797dc553c114c0269537c85d3580e610a8e711faacb48eb774
    Ports:          7474/TCP, 7687/TCP
    Host Ports:     0/TCP, 0/TCP
    State:          Running
      Started:      Sun, 09 Jan 2022 14:19:43 -0300
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /data from neo4j-storage (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-z5hq9 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  neo4j-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  neo4j-volume-claim
    ReadOnly:   false
  kube-api-access-z5hq9:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  35m   default-scheduler  0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims.
  Normal   Scheduled         35m   default-scheduler  Successfully assigned default/neo4j-application-7757948b98-2pxr2 to minikube
  Normal   Pulling           35m   kubelet            Pulling image "neo4j:4.1.4"
  Normal   Pulled            35m   kubelet            Successfully pulled image "neo4j:4.1.4" in 3.087215911s
  Normal   Created           34m   kubelet            Created container neo4j
  Normal   Started           34m   kubelet            Started container neo4j


Name:              kubernetes
Namespace:         default
Labels:            component=apiserver
                   provider=kubernetes
Annotations:       <none>
Selector:          <none>
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.96.0.1
IPs:               10.96.0.1
Port:              https  443/TCP
TargetPort:        8443/TCP
Endpoints:         192.168.49.2:8443
Session Affinity:  None
Events:            <none>


Name:                     neo4j-service
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=neo4j
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.98.131.77
IPs:                      10.98.131.77
Port:                     neo4j-port-7474  7474/TCP
TargetPort:               neo4j-7474/TCP
NodePort:                 neo4j-port-7474  30001/TCP
Endpoints:                172.17.0.4:7474
Port:                     neo4j-port-7687  7687/TCP
TargetPort:               neo4j-7687/TCP
NodePort:                 neo4j-port-7687  30002/TCP
Endpoints:                172.17.0.4:7687
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>


Name:                   neo4j-application
Namespace:              default
CreationTimestamp:      Sun, 09 Jan 2022 14:19:27 -0300
Labels:                 app=neo4j
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=neo4j
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=neo4j
  Containers:
   neo4j:
    Image:        neo4j:4.1.4
    Ports:        7474/TCP, 7687/TCP
    Host Ports:   0/TCP, 0/TCP
    Environment:  <none>
    Mounts:
      /data from neo4j-storage (rw)
  Volumes:
   neo4j-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  neo4j-volume-claim
    ReadOnly:   false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   neo4j-application-7757948b98 (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  35m   deployment-controller  Scaled up replica set neo4j-application-7757948b98 to 1


Name:           neo4j-application-7757948b98
Namespace:      default
Selector:       app=neo4j,pod-template-hash=7757948b98
Labels:         app=neo4j
                pod-template-hash=7757948b98
Annotations:    deployment.kubernetes.io/desired-replicas: 1
                deployment.kubernetes.io/max-replicas: 2
                deployment.kubernetes.io/revision: 1
Controlled By:  Deployment/neo4j-application
Replicas:       1 current / 1 desired
Pods Status:    1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=neo4j
           pod-template-hash=7757948b98
  Containers:
   neo4j:
    Image:        neo4j:4.1.4
    Ports:        7474/TCP, 7687/TCP
    Host Ports:   0/TCP, 0/TCP
    Environment:  <none>
    Mounts:
      /data from neo4j-storage (rw)
  Volumes:
   neo4j-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  neo4j-volume-claim
    ReadOnly:   false
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulCreate  35m   replicaset-controller  Created pod: neo4j-application-7757948b98-2pxr2
lordshark
  • 83
  • 9
  • 2
    You should be able to use the IP address reported by `minikube ip`, plus the `NodePort` port number from `kubectl describe service neo4j-service`. There's also a helper `minikube service neo4j-service --url` that should print out a reachable URL. There's further discussion in [Expose port in minikube](https://stackoverflow.com/questions/40767164/expose-port-in-minikube). – David Maze Jan 09 '22 at 20:06
  • First of all, thank you so much @DavidMaze. I tried `minikube ip + NodePort` described in service and got no response. With the url fro minikube service I could reach the endpoint! ` Starting tunnel for service neo4j-service. http://127.0.0.1:49523 and http://127.0.0.1:49524`. But considering the domain of the application... What should I do with NodePort 30001? What is the correct way to configure a kubernetes node? – lordshark Jan 09 '22 at 20:57
  • Are you trying to access your service from VM running minikube or from your host machine? – mdobrucki Jan 10 '22 at 09:03
  • 1
    Hey @mdobrucki - I am trying to access from host machine. I did not accessed minikube. I just accessed the pod through ssh and tried http://localhost:8983 (considering Solr) - via curl - and got a success response. No more updates, @WytrzymałyWiktor! Sorry :-( - I stopped the "brute force" comprehension / understanding method of learning k8 and focused on courses, watching videos and so on. – lordshark Jan 19 '22 at 01:47

1 Answers1

1

As mentioned in comments and in this post, the way you would expose app running in minikube via NodePort is my running the command:

minikube service <SERVICE_NAME> --url

Which prints out url you can paste in your browser. You also mentioned:

With the url fro minikube service I could reach the endpoint! Starting tunnel for service neo4j-service. http://127.0.0.1:49523 and http://127.0.0.1:49524. But considering the domain of the application... What should I do with NodePort 30001? What is the correct way to configure a kubernetes node?

The output you pasted is correct, you are getting a successful response. As for the NodePort - minikube maps this port to url that you are getting when running command mentioned before. Read more on accessing apps running in minikube here

mdobrucki
  • 462
  • 1
  • 7
  • 1
    My comment is to big for allowed number of chars. For me, the scope of this question require understanding, reading, discussion. As I could not reduce ou compress my sentence to properly understand the problem I'll post an answer to try to be more accurate concerning the problem. Thanks again for your reply @mdobrucki – lordshark Jan 20 '22 at 03:30