diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000000..3d150d2967 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,82 @@ +# Deployment Guide (Draft) + +## Rre-requests + +* Make sure a Kubernetes cluster is created and you can use `kubectl` to access it. +* Create HTTP source(s) in your Sumo Logic account and get HTTP Source URL(s). +* Run `echo -n '' | base64` to encode URL. + +## Setting up Fluentd + +* Download kubernetes .yaml manifest files from GitHub: + +```sh +curl -LJO https://raw.githubusercontent.com/SumoLogic/sumologic-kubernetes-collection/master/deploy/kubernetes/fluentd-sumologic.yaml +``` + +* Open the .yaml file, find line with `endpoint-metrics:`, replace `XXXX` with the encoded URL; save it. +* Apply the .yaml file with `kubectl`: + +```sh +kubectl apply -f ./fluentd-sumologic.yaml +``` + +* Verify the pod(s) are running: + +```sh +kubectl -n sumologic get pod +``` + +## Setting up Prometheus + +* Install `helm`: + +```sh +brew install kubernetes-helm +``` + +* Download tiller RBAC .yaml manifest files from GitHub: + +```sh +curl -LJO https://raw.githubusercontent.com/SumoLogic/sumologic-kubernetes-collection/master/deploy/helm/tiller-rbac.yaml +``` + +* Apply the .yaml file with `kubectl` and init tiller: + +```sh +kubectl apply -f tiller-rbac.yaml \ + && helm init --service-account tiller +``` + +* Download Prometheus operator override .yaml files from GitHub: + +```sh +curl -LJO https://raw.githubusercontent.com/SumoLogic/sumologic-kubernetes-collection/master/deploy/helm/overrides.yaml +``` + +* Install the `prometheus-operator` using `helm`: + +```sh +helm repo update \ + && helm install stable/prometheus-operator --name prometheus-operator --namespace sumologic -f overrides.yaml +``` + +* Verify the `prometheus-operator` is running: + +```sh +kubectl -n sumologic logs prometheus-prometheus-operator-prometheus-0 prometheus -f +``` + +## Tearing down + +* Delete `prometheus-operator` from the Kubernetes cluster: + +```sh +helm del --purge prometheus-operator +``` + +* Delete `fluentd-sumologic` app: + +```sh +kubectl delete -f ./fluentd-sumologic.yaml +``` diff --git a/deploy/helm/overrides.yaml b/deploy/helm/overrides.yaml new file mode 100644 index 0000000000..81a14bf206 --- /dev/null +++ b/deploy/helm/overrides.yaml @@ -0,0 +1,4 @@ +prometheus: + prometheusSpec: + remoteWrite: + - url: http://fluentd:9888/prometheus.metrics diff --git a/deploy/helm/tiller-rbac.yaml b/deploy/helm/tiller-rbac.yaml new file mode 100644 index 0000000000..1fcf47dca7 --- /dev/null +++ b/deploy/helm/tiller-rbac.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: tiller + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: tiller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: tiller + namespace: kube-system diff --git a/deploy/kubernetes/deployment-fluentd.yaml b/deploy/kubernetes/fluentd-sumologic.yaml similarity index 90% rename from deploy/kubernetes/deployment-fluentd.yaml rename to deploy/kubernetes/fluentd-sumologic.yaml index 57492b97cc..c4fa73849d 100644 --- a/deploy/kubernetes/deployment-fluentd.yaml +++ b/deploy/kubernetes/fluentd-sumologic.yaml @@ -1,4 +1,60 @@ -# Deploy singleton fluentd instance in the whole cluster for aggregating and forwarding to sumologic +--- +apiVersion: v1 +kind: Namespace +metadata: + name: sumologic +--- +apiVersion: v1 +kind: Secret +metadata: + name: sumologic + namespace: sumologic + labels: + k8s-app: fluentd-sumologic +type: Opaque +data: + # value is base-64 encoded, using following command to get it + # echo -n 'plaintext' | base64 + endpoint-metrics: XXXX +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: fluentd +subjects: +- kind: ServiceAccount + name: fluentd + namespace: sumologic +roleRef: + kind: ClusterRole + name: fluentd + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: fluentd + labels: + k8s-app: fluentd-sumologic +rules: +- apiGroups: [""] + resources: + - nodes + - namespaces + - events + - pods + - replicasets + - statefulsets + - deployments + verbs: ["get", "list", "watch"] +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: fluentd + namespace: sumologic + labels: + k8s-app: fluentd-sumologic --- apiVersion: v1 kind: ConfigMap @@ -50,7 +106,7 @@ data: @type null --- -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: fluentd @@ -127,7 +183,6 @@ metadata: labels: k8s-app: fluentd-sumologic spec: - type: LoadBalancer selector: k8s-app: fluentd-sumologic ports: @@ -136,42 +191,3 @@ spec: targetPort: 9888 protocol: TCP --- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: fluentd -subjects: -- kind: ServiceAccount - name: fluentd - namespace: sumologic -roleRef: - kind: ClusterRole - name: fluentd - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: fluentd - labels: - k8s-app: fluentd-sumologic -rules: -- apiGroups: [""] - resources: - - nodes - - namespaces - - events - - pods - - replicasets - - statefulsets - - deployments - verbs: ["get", "list", "watch"] ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: fluentd - namespace: sumologic - labels: - k8s-app: fluentd-sumologic ---- \ No newline at end of file diff --git a/deploy/kubernetes/namespace-sumologic.yaml b/deploy/kubernetes/namespace-sumologic.yaml deleted file mode 100644 index 7ce6fdf9c0..0000000000 --- a/deploy/kubernetes/namespace-sumologic.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# Create sumologic namespace -apiVersion: v1 -kind: Namespace -metadata: - name: sumologic diff --git a/deploy/kubernetes/secret-sumologic.yaml b/deploy/kubernetes/secret-sumologic.yaml deleted file mode 100644 index 3749ea8691..0000000000 --- a/deploy/kubernetes/secret-sumologic.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: sumologic - namespace: sumologic - labels: - k8s-app: fluentd-sumologic -type: Opaque -data: - # value is base-64 encoded, using following command to get it - # echo -n 'plaintext' | base64 - endpoint-metrics: XXXX