1
votes

I deployed grafana using helm and now it is running in pod. I can access it if I proxy port 3000 to my laptop. Im trying to point a domain grafana.something.com to that pod so I can access it externally. I have a domain in route53 that I can attach to a loadbalancer (Application Load Balancer, Network Load Balancer, Classic Load Balancer). That load balancer can forward traffic from port 80 to port 80 to a group of nodes (Let's leave port 443 for later). I'm really struggling with setting this up. Im sure there is something missing but I don't know what.

Basic diagram would look like this I imagine.

Internet
↓↓
Domain in route53 (grafana.something.com)
↓↓
Loadbalancer 80 to 80 (Application Load Balancer, Network Load Balancer, Classic Load Balancer) I guess that LB would forward traffic to port 80 to the below Ingress Controllers (Created when Grafana was deployed using Helm)
↓↓
Group of EKS worker nodes
↓↓
Ingress resource ?????
↓↓
Ingress Controllers - Created when Grafana was deployed using Helm in namespace test.

kubectl get svc grafana -n test

grafana Type:ClusterIP ClusterIP:10.x.x.x Port:80/TCP

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 
  labels:
    app: grafana
    chart: grafana-
    heritage: Tiller
    release: grafana-release
  name: grafana
  namespace: test
  resourceVersion: "xxxx"
  selfLink: 
  uid: 
spec:
  clusterIP: 10.x.x.x
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 3000
  selector:
    app: grafana
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

↓↓
Pod Grafana is listening on port 3000. I can access it successfully after proxying to my laptop port 3000.

2
Do you have an Ingress Controller installed? What you're showing is a Service (kubernetes.io/docs/concepts/services-networking/service) which is different from an Ingress (kubernetes.io/docs/concepts/services-networking/ingress)Esteban Garcia
Looks like I don't have one. The basic ingress would look like that I understand. It would forward traffic from grafana.something.com to the service I already have. apiVersion: extensions/v1beta1 kind: Ingress metadata: name: grafana-test-ingress-controller spec: rules: - host: grafana.something.com http: paths: - backend: serviceName: grafana # This is the app: grafana from the service servicePort: 80 #This is the port of the app: grafana service Would the ingress be between the Service and the route53domain/Loadbalancer?tr53

2 Answers

3
votes

Given that it seems you don't have an Ingress Controller installed, if you have the aws cloud-provider configured in your K8S cluster you can follow this guide to install the Nginx Ingress controller using Helm.

By the end of the guide you should have a load balancer created for your ingress controller, point your Route53 record to it and create an Ingress that uses your grafana service. Example:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/app-root: /
    nginx.ingress.kubernetes.io/enable-access-log: "true"
  name: grafana-ingress
  namespace: test
spec:
  rules:
  - host: grafana.something.com
    http:
      paths:
      - backend:
          serviceName: grafana
          servicePort: 80
        path: /

The final traffic path would be:

Route53 -> ELB -> Ingress -> Service -> Pods
0
votes

Adding 2 important suggestions here.

1 ) Following improvements to the ingress api in kubernetes 1.18 - a new ingressClassName field has been added to the Ingress spec that is used to reference the IngressClass that should be used to implement this Ingress.
Please consider to switch to ingressClassName field instead of the kubernetes.io/ingress.class annotation:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: grafana-ingress
  namespace: test
spec:
  ingressClassName: nginx # <-- Here
  rules:
    - host: grafana.something.com
      http:
        paths:
          - path: /
            backend:
              serviceName: grafana
              servicePort: 80

2 ) Consider using External-DNS for the integration between external DNS servers (Check this example on AWS Route53) and the Kubernetes Ingresses / Services.