Luca Cerretani
Luca Cerretani

Reputation: 11

How to expose wordpress over hostname in kubernetes

I deploy a kubernetes cluster on Ubuntu following the steps described at this link

Then I deploy a Wordpress following steps found at here

Everything works fine but I miss what I should do to serve the wp instance at a specific hostname like http://wp.example.com instead of http://[kubeip]:port

I'd like to have several different WP instances which respond to specific url. I tried to have a look at Ingress but I did not find nothing clear and I don't know if it's the right choice.

Can someone suggest me something? Thanks

Upvotes: 0

Views: 639

Answers (3)

Mh Eftekhari
Mh Eftekhari

Reputation: 31

I suggest to you use Helm to install your wordpress with this command

helm upgrade --install picvec-wp bitnami/wordpress --set global.storageClass=nfs-client --set ingress.enabled=true --set ingress.hostname=wp.novinparva.com --set ingress.path=/ --set ingress.tls=true --set ingress.extraHosts[0].name=wp.novinparva.com --set ingress.extraHosts[0].path=/ --set ingress.certManager=true --set wordpressPassword=asdvqwkjn --set mariadb.auth.rootPassword=$MARIADB_ROOT_PASSWORD --set mariadb.auth.password=$MARIADB_PASSWORD  --set allowOverrideNone=false --set htaccessPersistenceEnabled=true

Upvotes: 0

Luca Cerretani
Luca Cerretani

Reputation: 11

TY. I follow the guide to add the nginx-ingress-controller in a bare-metal at https://kubernetes.github.io/ingress-nginx/deploy/#provider-specific-steps

Then I tried to use a ingress.yaml like this

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
    name: wordpress-ingress
    annotations:
        nginx.ingress.kubernetes.io/rewrite-target: /
spec:
    defaultBackend:
        service:
            name: wordpress
            port:
                number: 80
    rules:
      - host: wp.example.com
        http:
            paths:
              - path: /
                pathType: Prefix
                backend:
                    service:
                        name: wordpress
                        port:
                            number: 80

But it doesn't work as expected

Upvotes: 1

SYN
SYN

Reputation: 5042

You're looking for an ingress controller.

You could go with the nginx-ingress-controller, traefik, haproxy, ... several implementations exist.

Then, in addition to creating a Service exposing your wordpress container, you would create an Ingress object.

Upvotes: 1

Related Questions