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

k8s clustering doesn't work #49

Open
rjbaat opened this issue Apr 1, 2019 · 9 comments
Open

k8s clustering doesn't work #49

rjbaat opened this issue Apr 1, 2019 · 9 comments
Assignees
Labels
Milestone

Comments

@rjbaat
Copy link

rjbaat commented Apr 1, 2019

I have followed the documentation and used this setup:

apiVersion: v1
kind: Service
metadata:
  name: emqx
spec:
  ports:
  - port: 32333
    nodePort: 32333
    targetPort:  emqx-dashboard
    protocol: TCP
  selector:
    app: emqx
  type: NodePort
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: emqx
  labels:
        app: emqx
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: emqx
    spec:
      containers:
      - name: emqx
        image: emqx/emqx:latest
        ports:
        - name: emqx-dashboard
          containerPort: 18083
        env:
        - name: EMQX_CLUSTER__DISCOVERY
          value: k8s
        - name: EMQX_NAME
          value: emqx
        - name: EMQX_CLUSTER__K8S__APISERVER
          value: "https://kubernetes.default:443"
        - name: EMQX_CLUSTER__K8S__NAMESPACE
          value: default
        - name: EMQX_CLUSTER__K8S__SERVICE_NAME
          value: emqx
        - name: EMQX_CLUSTER__K8S__ADDRESS_TYPE
          value: ip
        - name: EMQX_CLUSTER__K8S__APP_NAME
          value: emqx
        tty: true

But when checking the logs i see that emqx gives the following message:

2019-04-01 07:56:53.613 [error] Ekka(AutoCluster): Discovery error: {403,
1-4-2019 09:56:53 "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"endpoints \\\"emqx\\\" is forbidden: User \\\"system:serviceaccount:default:default\\\" cannot get resource \\\"endpoints\\\" in API group \\\"\\\" in the namespace \\\"default\\\"\",\"reason\":\"Forbidden\",\"details\":{\"name\":\"emqx\",\"kind\":\"endpoints\"},\"code\":403}\n"}

Is there something i need to do to make the api accessible?
I am running k8s via rancher.

@rjbaat
Copy link
Author

rjbaat commented Apr 1, 2019

added this role to the service account that is used and now it works:

kubectl create clusterrolebinding default-admin --clusterrole cluster-admin --serviceaccount=default:default

@emqplus emqplus added the support label Jun 3, 2019
@emqplus emqplus added this to the 0.6.0 milestone Jun 3, 2019
@Rory-Z
Copy link
Member

Rory-Z commented Jun 3, 2019

@rjbaat Sorry to reply you so late
I suggest you try to deploy emqx on k8s using helm, you can get our chart from here.

@rjbaat
Copy link
Author

rjbaat commented Sep 17, 2019

@zhanghongtong i tried the helm chart, but it gives me an error:
Wait helm template failed. Error: stat /emqx: no such file or directory : exit status 1
What do i do wrong?

@Rory-Z
Copy link
Member

Rory-Z commented Sep 17, 2019

@rjbaat Please provide more details

@rjbaat
Copy link
Author

rjbaat commented Sep 17, 2019

Well i added the helm url as global to rancher catalog manager. Then launched the app via search on the catalog. Didn't change anything and launched. So with no answers. All default. Then it tries to start it but i get: Wait helm template failed. Error: stat /emqx: no such file or directory : exit status 1. I came accross this topic: rancher/rancher#18535 (comment) Can this be of some help to you?

@rjbaat
Copy link
Author

rjbaat commented Sep 17, 2019

Now i tried not to add the url: https://repos.emqx.io/charts but instead add the url: https://github.com/emqx/emqx-chart.git as chart repo and i can install the chart. It only doesnt want to get installed in a namespace other that default.

Edit: i see there is an answer in the chart that provides the namespace and this has to be the same as the namespace it is installed to.

@Rory-Z
Copy link
Member

Rory-Z commented Sep 17, 2019

@rjbaat Thank you for your feedback, If you want to install emqx in any other namespace, you need to create the namespace first

@rjbaat
Copy link
Author

rjbaat commented Sep 17, 2019

Thnx for your help. Any chance to point me in a direction of adding (LE) certificates to the cluster too?

@Rory-Z
Copy link
Member

Rory-Z commented Sep 17, 2019

@rjbaat I didn't try to add certificates to the previous cluster, I suggest you try to create the certificate file as a Secret resource and mount it on the pods
The command to create the Secret resource is as follows:

Kubectl create secret generic your-secret-name --from-file=/path/to/your/file

Looking forward to your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants