From a5da7c95ce073bc23b13bfe056f287bec10fb2d8 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Mon, 9 May 2022 17:05:11 +0100 Subject: [PATCH] Update docs for deploying Fleet on Kubernetes (#4755) * feat[WIP]: updating docs for deploying Fleet on Kubernetes * feat: update spec to include environment variables * chore: add fleet image version to yml file * doc: add Kubernetes manifest file Add Kubernetes manifest file to files to be edited for Fleet version change when releasing. * docs: link to the docs on deploying Fleet via K8s * feat: add kubernetes deployment.yml * feat: update Fleet version --- docs/Contributing/Releasing-Fleet.md | 1 + docs/Deploying/Server-Installation.md | 70 ++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/docs/Contributing/Releasing-Fleet.md b/docs/Contributing/Releasing-Fleet.md index 6237570969..5b97f604c5 100644 --- a/docs/Contributing/Releasing-Fleet.md +++ b/docs/Contributing/Releasing-Fleet.md @@ -17,6 +17,7 @@ Note: Please prefix versions with `fleet-v` (eg. `fleet-v4.0.0`) in git tags, He - [fleetctl package.json](https://github.com/fleetdm/fleet/blob/main/tools/fleetctl-npm/package.json) (do not yet `npm publish`) - [Helm chart.yaml](https://github.com/fleetdm/fleet/blob/main/charts/fleet/Chart.yaml) and [values file](https://github.com/fleetdm/fleet/blob/main/charts/fleet/values.yaml) - Terraform variables ([AWS](https://github.com/fleetdm/fleet/blob/main/infrastructure/dogfood/terraform/aws/variables.tf)/[GCP](https://github.com/fleetdm/fleet/blob/main/infrastructure/dogfood/terraform/gcp/variables.tf)) + - [Kubernetes `deployment.yml` example file](https://github.com/fleetdm/fleet/blob/main/docs/Deploying/Server-Installation.md#deploying-fleet-on-kubernetes) Commit these changes via Pull Request and pull the changes on the `main` branch locally. Check that `HEAD` of the `main` branch points to the commit with these changes. diff --git a/docs/Deploying/Server-Installation.md b/docs/Deploying/Server-Installation.md index 17262e69e5..c759b4324a 100644 --- a/docs/Deploying/Server-Installation.md +++ b/docs/Deploying/Server-Installation.md @@ -420,7 +420,75 @@ If you go back to [https://localhost:8080/hosts/manage](https://localhost:8080/h ## Deploying Fleet on Kubernetes -In this guide, we're going to install Fleet and all of its application dependencies on a Kubernetes cluster. Kubernetes is a container orchestration tool that was open sourced by Google in 2014. +In this guide, we're going to focus on deploying Fleet only on a Kubernetes cluster. Kubernetes is a container orchestration tool that was open sourced by Google in 2014. + +We will assume you have `kubectl` and MySQL and Redis are all set up and running. Optionally you have minikube to test your deployment locally on your machine. + +To deploy the Fleet server and connect to its dependencies(MySQL and Redis) we will set up a `deployment.yml` file with the following specifications: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fleet-deployment + labels: + app: fleet +spec: + replicas: 3 + selector: + matchLabels: + app: fleet + template: + metadata: + labels: + app: fleet + spec: + containers: + - name: fleet + image: fleetdm/fleet:4.13.2 + env: + - name: FLEET_MYSQL_ADDRESS + valueFrom: + secretKeyRef: + name: fleet_secrets + key: mysql_address + - name: FLEET_MYSQL_DATABASE + valueFrom: + secretKeyRef: + name: fleet_secrets + key: mysql_database + - name: FLEET_MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: fleet_secrets + key: mysql_password + - name: FLEET_MYSQL_USERNAME + valueFrom: + secretKeyRef: + name: fleet_secrets + key: mysql_username + - name: FLEET_REDIS_ADDRESS + valueFrom: + secretKeyRef: + name: fleet_secrets + key: redis_address + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 3000 + +``` +Notice we are using secrets to pass in values for Fleet's dependencies' environment variables. + +Let's tell Kubernetes to create the cluster by running the below command + +`kubectl apply -f ./deployment.yml` + ### Installing infrastructure dependencies