Install Install Sensu docker image in K8S

I’m trying to setup a showcase for Sensu in K8s cluster.
I followed de dose here Install Sensu - Sensu Docs

  • Create namespace : sensu-system

  • Created Deployment file

[]$ cat sensu-backend.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sensu-backend
spec:
  selector:
    matchLabels:
      app: sensu-backend
  replicas: 1
  template:
    metadata:
      name: sensu-backend
      labels:
        app: sensu-backend
    spec:
      containers:
        - name: sensu-backend
          image: sensu/sensu:latest
          command: ["/opt/sensu/bin/sensu-backend", "start", "--state-dir", "/var/lib/sensu/sensu-backend", "--log-level", "debug"]
          ports:
            - protocol: TCP
              containerPort: 8080
            - protocol: TCP
              containerPort: 8081
            - protocol: TCP
              containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: sensu-backend
spec:
  selector:
    app: sensu-backend
  type: NodePort
  ports:
    - name: api
      protocol: TCP
      port: 8080
      targetPort: 8080
    - name: ws
      protocol: TCP
      port: 8081
      targetPort: 8081
    - name: webui
      protocol: TCP
      port: 3000
      targetPort: 3000
      nodePort: 30030
  • According to the docs I should skip initialization with a docker image.

The login screen appears when I go to port 30030, but the default user name password is not logging me in.

[]$ kubectl -n sensu-system get pods
NAME                             READY   STATUS    RESTARTS   AGE
sensu-backend-54b7d67b69-hwc57   1/1     Running   0          88m
[]$ kubectl exec -n sensu-system --stdin --tty sensu-backend-54b7d67b69-hwc57 -- sh
/ # sensuctl configure -n --url http://127.0.0.1:8080 \
> --username admin \
> --password "P@ssw0rd!" \
> --namespace default

Error: unable to authenticate with error: Unauthorized

Same for namespace sensu-system …

Is this changed or do I forget something ??

Hey,
So here’s what you did.
By using the full path to /opt/sensu/bin/sensu-backend you’ve bypassed the script wrapper located in the executable path that attempts to do the init for you. The wrapper script eventually does call the executable installed in /opt/ but has some additional while loop logic to attempt to init.

You’ll noticed that the documented docker and docker compose examples don’t use the explicit full path and rely on the system’s executable path env to find the executable named sensu-backend (which is the wrapper script).

If you want the wrapper script logic to fire use this:

command: ["sensu-backend", "start", "--state-dir", "/var/lib/sensu/sensu-backend", "--log-level", "debug"]

The wrapper script doesn’t work in all production environments (especially once you need to scale into using an external etcd). Its really tuned for getting a service up quickly so you can test. So its not wrong to bypass the wrapper, in fact, you’ll probably want to bypass the wrapper in any production k8s environment you spin up. But you will have to do the init step if you bypass.

Once you are ready to look at a production k8s deployment you may want to take a look at:

https://github.com/sensu/sensu-k8s-quick-start/tree/master/kubernetes

That saved my day, thanks for the info :grinning: