How can we deploy sensu-go server cluster on Kubernetes?

Hi Geeks,

I want to deploy susugo Monitoring Stack on Kubernetes. I have created sensugo docker images. How can I deploy sensugo cluster on Kubernetes. Is there any tutorial to get help. Please share.

Hi @aaronsachs. Your reply will be of great help.

Here’s a statefulset, ingress and services. I haven’t quite tuned a liveness or readiness check. You’ll need to provide your persistent storage. This is running on kubernetes 1.16.2. If you also run an agent on the backend server instances, you’ll need to supply an agent.yml via a configmap.


apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sensu-backend
namespace: sensu-go
spec:
selector:
matchLabels:
app: sensu
serviceName: sensu-backend-etcd
replicas: 3
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: sensu
spec:
volumes:
- name: sensu-backend-etcd
persistentVolumeClaim:
claimName: sensu-backend-etcd
- name: sensu-backend-agent-config
configMap:
name: sensu-backend-agent-config
containers:
- name: sensu-backend
image: sensu/sensu:5.14.2
command: [
“/opt/sensu/bin/sensu-backend”, “start”,
“–state-dir”,"/var/lib/sensu/(POD_NAME)", "--etcd-name", "(POD_NAME)",
“–etcd-initial-advertise-peer-urls”, “http://(POD_NAME).sensu-backend-etcd.sensu-go.svc.cluster.local:2380", "--etcd-advertise-client-urls", "http://(POD_NAME).sensu-backend-etcd.sensu-go.svc.cluster.local:2379”,
“–etcd-listen-peer-urls”, “http://0.0.0.0:2380”,
“–etcd-listen-client-urls”, “http://0.0.0.0:2379”,
“–etcd-initial-cluster-token”, “”,
“–etcd-initial-cluster-state”, “new”,
“–etcd-initial-cluster”, “sensu-backend-0=http://sensu-backend-0.sensu-backend-etcd.sensu-go.svc.cluster.local:2380,sensu-backend-1=http://sensu-backend-1.sensu-backend-etcd
.sensu-go.svc.cluster.local:2380,sensu-backend-2=http://sensu-backend-2.sensu-backend-etcd.sensu-go.svc.cluster.local:2380”
]
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- protocol: TCP
containerPort: 8080
- protocol: TCP
containerPort: 8081
- protocol: TCP
containerPort: 3000
volumeMounts:
- name: sensu-backend-etcd
mountPath: /var/lib/sensu
- name: sensu-agent
image: sensu/sensu:5.14.2
command: ["/opt/sensu/bin/sensu-agent", “start”]
volumeMounts:
- name: sensu-backend-agent-config
mountPath: /etc/sensu

Services

apiVersion: v1
kind: Service
metadata:
name: sensu-backend-agent
namespace: sensu-go
spec:
selector:
app: sensu
ports:

  • name: sensu-transport
    protocol: TCP
    port: 8081
    targetPort: 8081
    type: LoadBalancer

apiVersion: v1
kind: Service
metadata:
name: sensu-backend-api
namespace: sensu-go
spec:
ports:
- name: api
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: sensu
type: LoadBalancer

apiVersion: v1
kind: Service
metadata:
name: sensu-backend-etcd
namespace: sensu-go
spec:
selector:
app: sensu
clusterIP: None
ports:

  • name: sensu-etcd-client
    port: 2379
  • name: sensu-etcd-server
    port: 2380

apiVersion: v1
kind: Service
metadata:
name: sensu-backend-web
namespace: sensu-go
labels:
name: sensu
spec:
ports:
- name: web
port: 80
protocol: TCP
targetPort: 3000
selector:
app: sensu

Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: sensu
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:

  • host: sensu.example.net
    http:
    paths:
    • backend:
      serviceName: sensu-backend-web
      servicePort: 80
      path: /
  • host: sensu
    http:
    paths:
    • backend:
      serviceName: sensu-backend-web
      servicePort: 80
      path: /