Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable service type #48

Closed
wants to merge 2 commits into from

Conversation

pb82
Copy link
Collaborator

@pb82 pb82 commented Sep 15, 2019

Allow setting the type of the grafana service (ClusterIP, NodePort or LoadBalancer) via an operator flag. This PR adds a new optional operator flag --service-type which can be used to set the type of the grafana service. Defaults to ClusterIP (if not set).

The latest tag has been updated and contains this change.

Use case: en GCE only NodePort or LoadBalancer type services can be used with Ingresses.

Fixes #46

Verification steps:

  1. Create a copy of operator.yaml and change the service type flag to NodePort or LoadBalancer.
  2. Make sure the image is pointing to the latest tag and deploy the operator.
  3. Deploy Grafana
  4. Check the created service and make sure its of the desired type

ping @jsanda

@jsanda
Copy link

jsanda commented Sep 17, 2019

Hi @pb82,

I have verified that the NodePort service gets created; however, I am not able to access Grafana. Here is my manifest:

apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
  name: example-grafana
spec:
  config:
    log:
      mode: "console"
      level: "warn"
    security:
      admin_user: "root"
      admin_password: "secret"
    auth:
      disable_login_form: False
      disable_signout_menu: True
    auth.basic:
      enabled: False
    auth.anonymous:
      enabled: True
  dashboardLabelSelector:
    - matchExpressions:
        - {key: app, operator: In, values: [grafana]}

I am able to access Grafana when I use a ClusterIP service with kubectl port-forward.

@pb82
Copy link
Collaborator Author

pb82 commented Sep 17, 2019

@jsanda Is the Ingress assigned an IP when you use NodePort?

@jsanda
Copy link

jsanda commented Sep 17, 2019

@pb82 The Ingress is assigned an IP:

apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      ingress.kubernetes.io/backends: '{"k8s-be-30250--d5cbb4a3db91b92d":"Unknown","k8s-be-32028--d5cbb4a3db91b92d":"Unknown"}'
      ingress.kubernetes.io/forwarding-rule: k8s-fw-default-grafana-ingress--d5cbb4a3db91b92d
      ingress.kubernetes.io/target-proxy: k8s-tp-default-grafana-ingress--d5cbb4a3db91b92d
      ingress.kubernetes.io/url-map: k8s-um-default-grafana-ingress--d5cbb4a3db91b92d
    creationTimestamp: "2019-09-17T18:37:46Z"
    generation: 1
    labels:
      app: grafana
    name: grafana-ingress
    namespace: default
    ownerReferences:
    - apiVersion: integreatly.org/v1alpha1
      blockOwnerDeletion: true
      controller: true
      kind: Grafana
      name: example-grafana
      uid: 3dfb5ea6-d97a-11e9-91a9-42010a8e0166
    resourceVersion: "2165"
    selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/grafana-ingress
    uid: 3e3b22b7-d97a-11e9-91a9-42010a8e0166
  spec:
    rules:
    - http:
        paths:
        - backend:
            serviceName: grafana-service
            servicePort: 3000
          path: /
  status:
    loadBalancer:
      ingress:
      - ip: 1.2.3.4
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

I am not sure how access the Grafana UI though.

@jsanda
Copy link

jsanda commented Sep 17, 2019

After a bit longer I did get a response from the load balancer IP, but something is not working correctly. I got an error response page:

If you're seeing this Grafana has failed to load its application files

1. This could be caused by your reverse proxy settings.

2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath

3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build

4. Sometimes restarting grafana-server can help

@pb82
Copy link
Collaborator Author

pb82 commented Sep 17, 2019

@jsanda I think you need the external IP:

kubectl get ingress grafana-ingress

You should be able to reach Grafana under the IP listed with this command.

@pb82
Copy link
Collaborator Author

pb82 commented Sep 18, 2019

@jsanda That looks like the Grafana frontend was not able to make requests to the backend. I'd say inspecting the connections it makes in the browser debug tools would be a first step to start debugging this.

@pb82
Copy link
Collaborator Author

pb82 commented Oct 7, 2019

@pb82 pb82 closed this Oct 7, 2019
@pb82 pb82 deleted the configurable-service-type branch October 7, 2019 11:06
NissesSenap pushed a commit to NissesSenap/grafana-operator that referenced this pull request Mar 10, 2023
* Set default securityContext for grafana instances
* Change how we check if we are in a OCP cluster or not.
NissesSenap pushed a commit to NissesSenap/grafana-operator that referenced this pull request Mar 14, 2023
* Set default securityContext for grafana instances
* Change how we check if we are in a OCP cluster or not.
NissesSenap pushed a commit that referenced this pull request Mar 14, 2023
* Set default securityContext for grafana instances
* Change how we check if we are in a OCP cluster or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ingress is not set up properly in k8s clusters
2 participants