pihole-kubernetes icon indicating copy to clipboard operation
pihole-kubernetes copied to clipboard

configuring services using traefik annotations

Open ghost opened this issue 2 years ago • 5 comments

Hello,

I am running a k3s cluster on two raspberryPis.

❯ kubectl get services -A
NAMESPACE     NAME             TYPE           CLUSTER-IP      EXTERNAL-IP                 PORT(S)                      AGE
default       kubernetes       ClusterIP      10.43.0.1       <none>                      443/TCP                      17h
kube-system   kube-dns         ClusterIP      10.43.0.10      <none>                      53/UDP,53/TCP,9153/TCP       17h
kube-system   metrics-server   ClusterIP      10.43.54.24     <none>                      443/TCP                      17h
kube-system   traefik          LoadBalancer   10.43.25.3      192.168.0.20,192.168.0.21   80:30437/TCP,443:30849/TCP   7h10m

I am noticing, that having traefik running AND running it on port 80 could be a problem.

To get Pi-hole up dan running I was using this command

helm install pihole mojo2600/pihole -f values.yaml -n pihole

using the following values.yaml file:

replicaCount: 1

dnsmasq:
  customDnsEntries:
  # Add custom DNS records in
  # dnsmasq-installation of Pi-Hole
  - address=/pihole.local/192.168.0.20

persistentVolumeClaim:
  enabled: true

serviceWeb:
  annotations:
    metallb.universe.tf/address-pool: pihole
    metallb.universe.tf/allow-shared-ip: pihole-svc
  type: LoadBalancer

serviceDns:
  annotations:
    metallb.universe.tf/address-pool: pihole
    metallb.universe.tf/allow-shared-ip: pihole-svc
  type: LoadBalancer

adminPassword: admin

I noticed, that the annotation set to use metallb and not traefik That being said, I'd like to ask kindly for advice how to setup the annotations to work with traefik in order to get the serviceWeb up and running. I hope this is the issue why the pihole-web service is not starting

❯ kubectl get services -A
NAMESPACE     NAME             TYPE           CLUSTER-IP      EXTERNAL-IP                 PORT(S)                      AGE
default       kubernetes       ClusterIP      10.43.0.1       <none>                      443/TCP                      18h
kube-system   kube-dns         ClusterIP      10.43.0.10      <none>                      53/UDP,53/TCP,9153/TCP       18h
kube-system   metrics-server   ClusterIP      10.43.54.24     <none>                      443/TCP                      18h
kube-system   traefik          LoadBalancer   10.43.25.3      192.168.0.20,192.168.0.21   80:30437/TCP,443:30849/TCP   7h19m
pihole        pihole-dhcp      NodePort       10.43.156.198   <none>                      67:32395/UDP                 3m25s
pihole        pihole-web       LoadBalancer   10.43.111.140   <pending>                   80:30850/TCP,443:30177/TCP   3m25s
pihole        pihole-dns-udp   LoadBalancer   10.43.55.156    192.168.0.20,192.168.0.21   53:32654/UDP                 3m25s
pihole        pihole-dns-tcp   LoadBalancer   10.43.22.102    192.168.0.20,192.168.0.21   53:30533/TCP                 3m25s
NAMESPACE     NAME                                     READY   STATUS      RESTARTS          AGE
kube-system   metrics-server-9cf544f65-ptscs           1/1     Running     123 (7h26m ago)   18h
kube-system   local-path-provisioner-64ffb68fd-cnspg   1/1     Running     126 (7h21m ago)   18h
kube-system   coredns-85cb69466-bmrxz                  1/1     Running     167 (7h24m ago)   18h
kube-system   helm-install-traefik-crd--1-rkq6c        0/1     Completed   82                18h
kube-system   helm-install-traefik--1-qlm9b            0/1     Completed   83                18h
kube-system   svclb-traefik-dz4bn                      2/2     Running     0                 7h19m
kube-system   svclb-traefik-8sjm9                      2/2     Running     0                 7h19m
kube-system   traefik-74dd4975f9-8c6hj                 1/1     Running     0                 7h19m
pihole        svclb-pihole-web-wb2h2                   0/2     Pending     0                 3m52s
pihole        svclb-pihole-web-dm72k                   0/2     Pending     0                 3m51s
pihole        svclb-pihole-dns-udp-xtqnx               1/1     Running     0                 3m53s
pihole        svclb-pihole-dns-udp-w66kt               1/1     Running     0                 3m53s
pihole        svclb-pihole-dns-tcp-tpdpn               1/1     Running     0                 3m52s
pihole        svclb-pihole-dns-tcp-blnxv               1/1     Running     0                 3m52s
pihole        pihole-76b8d674fd-stxst                  1/1     Running     0                 3m52s

Thanks in advance!

ghost avatar Feb 14 '22 17:02 ghost

Hi, Just change the port for pihole-web. I use following values.yaml file:

replicaCount: 1
persistentVolumeClaim:
  enabled: true
ingress:
  enabled: false
serviceWeb:
  loadBalancerIP: 10.61.61.111
  annotations:
    metallb.universe.tf/allow-shared-ip: pihole-svc
  type: LoadBalancer
  http:
    port: 8080
  https:
    port: 8443
serviceDns:
  loadBalancerIP: 10.61.61.111
  annotations:
    metallb.universe.tf/allow-shared-ip: pihole-svc
  type: LoadBalancer
resources:
  limits:
    cpu: 200m
    memory: 256Mi
  requests:
    cpu: 100m
    memory: 128Mi

mkoese avatar Feb 27 '22 11:02 mkoese

From what I have been learning with k3s traefik, we should not need to change the the service to loadbalancer for pihole. It should remain on clusterip. There is something else that is missing and I havent figured it out yet. I get a 404 but that is as close as I get.

alteredtech avatar Mar 03 '22 06:03 alteredtech

@avendretter I have figured it out for k3s traefik ingress. This is the basic values.yml to get it working.

---
ingress:
  enabled: true
adminPassword: admin

Then edit your /etc/hosts file with loadbalancer ip chart-example.local

The chart-example.local is the default value in the complete values file. You can change that in the values file but adding a line to ingress so that it looks like this

ingress:
  enabled: true
  hosts:
  # virtualHost (default value is pi.hole) will be appended to the hosts
  - pihole.home

Then update your /etc/hosts with the lb ip and the host you put for ingress.

For some reason when you try to go to pi.hole it just gives a 404 on the cluster.

alteredtech avatar Mar 03 '22 18:03 alteredtech

I think the issue here is the comment in the values file:

# virtualHost (default value is pi.hole) will be appended to the hosts

After the deployment using the default values, I can only access the console as "chart-example.local" but not as "pi.hole":

$ kubectl get ingress --all-namespaces
NAMESPACE   NAME     CLASS    HOSTS                 ADDRESS                       PORTS   AGE
pihole      pihole   <none>   chart-example.local   192.168.2.157,192.168.2.164   80      102s

Either the comment is wrong or the deployment does not work as the comment stipulates.

anon-software avatar Mar 11 '22 17:03 anon-software

I think #221 is related to this issue. But I have no idea how to solve this. Any ideas?

MoJo2600 avatar Mar 15 '22 08:03 MoJo2600