0

I am trying to setup a local wordpress application together with an NGINX Ingress Controller and a NodePort Service following this tutorial .

However, when I try to check if my host is reachable:

curl wordpress.info  
                    

I get the following error:

curl: (7) Failed to connect to wordpress.info port 80: Network is unreachable

I am also not able to reach the page through my browser using my current setup.

This is my current setup in kubernetes:

# Services
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1     <none>        443/TCP          177m
wordpress    NodePort    10.111.2.21   <none>        8080:30007/TCP   28m

# Ingress 
NAME                CLASS    HOSTS            ADDRESS          PORTS   AGE
wordpress-ingress   <none>   wordpress.info   192.168.99.100   80      48m

My configuration files look like this:

# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: wordpress
  name: wordpress
spec:
  selector:
    matchLabels:
      run: wordpress
  replicas: 2
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
      - name: wordpress
        image: wordpress:latest
        ports:
        - containerPort: 8080
        env:
        - name: WORDPRESS_DB_HOST
          value: 127.0.0.1:3306
        - name: WORDPRESS_DB_NAME
          value: wordpress_db_1
        - name: WORDPRESS_DB_PREFIX
          value: wp_


# NodePort Service
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: wordpress
  name: wordpress
spec:
  type: NodePort
  selector:
    app: wordpress
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 80
    nodePort: 30007

# Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wordpress-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: wordpress.info
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: wordpress
                port:
                  number: 8080

What do I need to do to be able to access the wordpress application locally? Why is the application unreachable? I am using Linux operating system.

3
  • Where is your kubernetes cluster running? – Samit Jun 5 at 20:19
  • Have you configure the hosts file (/etc/hosts) ? map $(minikube ip) to wordpress.info ? – Jerry Chen Jun 6 at 6:47
  • I am running it on my localhost using minikube, no I have not added the ip to my /etc/hosts file, is this always necessary to do this step when working locally like this? – Benny Jun 8 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.