diff --git a/k8s/.header.md b/k8s/.header.md index 482f6b7..033f2ba 100644 --- a/k8s/.header.md +++ b/k8s/.header.md @@ -37,15 +37,15 @@ data: .dockerconfigjson: ``` -In order for the deployment to go through successfully, you'll need to create some secrets so Fleet knows how to authenticate against things like MySQL and Redis. While we'll only cover creating simple secrets, the deployment via terraform also supports instructing Fleet to pull the `valuesFrom:` an external secret store such as AWS Secrets Manager. +In order for the deployment to go through successfully, you'll need to create some secrets so Fleet knows how to authenticate against things like MySQL and Redis. ```yaml --- apiVersion: v1 kind: Secret metadata: - name: redis-password - namespace: + name: redis + namespace: type: kubernetes.io/basic-auth stringData: password: @@ -53,8 +53,8 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: mysql-password - namespace: + name: mysql + namespace: type: kubernetes.io/basic-auth stringData: password: @@ -84,10 +84,11 @@ If you have a Fleet premium license you would create a secret like the one below apiVersion: v1 kind: Secret metadata: - name: fleet-license - namespace: -data: - license: + name: license + namespace: +type: Opaque +stringData: + license-key: ``` Once all of your secrets are configured, use `kubectl apply -f --namespace ` to configure them in the cluster. @@ -130,7 +131,7 @@ The below will be in preparation for deployment through the `terraform apply` in In `main.tf` make sure the following variable `fleet.tls.enabled = false`, otherwise the Fleet terraform deployment will fail. In `main.tf` make sure the following map is configured with the correct values. - `ingress.enabled` must be `true`, if you'd like Fleet to deploy the nginx ingress for you. - - `ingress.class_name` needs to be set to `nginx` + - `ingress.class_name` needs to be set to `nginx`, but can be changed to values like `traefik`, if you have another compatible ingress. - `ingress.hosts.name` must have a matching entry in `ingress.tls.hosts` - example: `ingress.hosts.name = fleet.example.com` and `ingress.tls.hosts = fleet.example.com` - Last, `ingress.tls.secret_name` must be a valid secret name in your current namespace.* @@ -144,16 +145,16 @@ In `main.tf` make sure the following map is configured with the correct values. annotations = {} labels = {} hosts = [{ - name = "fleet.example.com" + name = "fleet.localhost.local" paths = [{ path = "/" path_type = "ImplementationSpecific" }] }] tls = { - secret_name = "fleet-tls" + secret_name = "chart-example-tls" hosts = [ - "fleet.example.com" + "fleet.localhost.local" ] } } diff --git a/k8s/README.md b/k8s/README.md index fc03f9b..621937c 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -37,15 +37,15 @@ data: .dockerconfigjson: ``` -In order for the deployment to go through successfully, you'll need to create some secrets so Fleet knows how to authenticate against things like MySQL and Redis. While we'll only cover creating simple secrets, the deployment via terraform also supports instructing Fleet to pull the `valuesFrom:` an external secret store such as AWS Secrets Manager. +In order for the deployment to go through successfully, you'll need to create some secrets so Fleet knows how to authenticate against things like MySQL and Redis. ```yaml --- apiVersion: v1 kind: Secret metadata: - name: redis-password - namespace: + name: redis + namespace: type: kubernetes.io/basic-auth stringData: password: @@ -53,8 +53,8 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: mysql-password - namespace: + name: mysql + namespace: type: kubernetes.io/basic-auth stringData: password: @@ -84,10 +84,11 @@ If you have a Fleet premium license you would create a secret like the one below apiVersion: v1 kind: Secret metadata: - name: fleet-license - namespace: -data: - license: + name: license + namespace: +type: Opaque +stringData: + license-key: ``` Once all of your secrets are configured, use `kubectl apply -f --namespace ` to configure them in the cluster. @@ -130,7 +131,7 @@ The below will be in preparation for deployment through the `terraform apply` in In `main.tf` make sure the following variable `fleet.tls.enabled = false`, otherwise the Fleet terraform deployment will fail. In `main.tf` make sure the following map is configured with the correct values. - `ingress.enabled` must be `true`, if you'd like Fleet to deploy the nginx ingress for you. - - `ingress.class_name` needs to be set to `nginx` + - `ingress.class_name` needs to be set to `nginx`, but can be changed to values like `traefik`, if you have another compatible ingress. - `ingress.hosts.name` must have a matching entry in `ingress.tls.hosts` - example: `ingress.hosts.name = fleet.example.com` and `ingress.tls.hosts = fleet.example.com` - Last, `ingress.tls.secret_name` must be a valid secret name in your current namespace.* @@ -143,16 +144,16 @@ In `main.tf` make sure the following map is configured with the correct values. annotations = {} labels = {} hosts = [{ - name = "fleet.example.com" + name = "fleet.localhost.local" paths = [{ path = "/" path_type = "ImplementationSpecific" }] }] tls = { - secret_name = "fleet-tls" + secret_name = "chart-example-tls" hosts = [ - "fleet.example.com" + "fleet.localhost.local" ] } } @@ -317,12 +318,12 @@ No modules. |------|-------------|------|---------|:--------:| | [affinity\_rules](#input\_affinity\_rules) | Used to configure affinity rules for the fleet deployment, migration job, and vuln-processing cron job. |
object({ 
required_during_scheduling_ignored_during_execution = optional(list(any), [])
preferred_during_scheduling_ignored_during_execution = optional(list(any), [])
})
| n/a | yes | | [anti\_affinity\_rules](#input\_anti\_affinity\_rules) | Used to configure anti-affinity rules for the fleet deployment, migration job, and vuln-processing cron job. |
object({ 
required_during_scheduling_ignored_during_execution = optional(list(any), [])
preferred_during_scheduling_ignored_during_execution = optional(list(any),
[
{
weight = 100
label_selector = {
match_expressions = [
{
key = "app"
operator = "In"
values = ["fleet"]
}
]
}
topology_key = "kubernetes.io/hostname"
}
])
})
| n/a | yes | -| [cache](#input\_cache) | Used to configure redis specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
enabled = optional(bool, false)
address = optional(string, "redis:6379")
database = optional(number, 0)
use_password = optional(bool, false)
secret_name = optional(string, "redis-password")
password_key = optional(string, "redis")
})
| n/a | yes | -| [database](#input\_database) | Used to configure database specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
enabled = optional(bool, false)
secret_name = optional(string, "password")
address = optional(string, "mysql:3306")
database = optional(string, "fleet")
username = optional(string, "fleet")
password_key = optional(string, "mysql-password")
max_open_conns = optional(number, 50)
max_idle_conns = optional(number, 50)
conn_max_lifetime = optional(number, 0)

tls = object({
enabled = optional(bool, false)
config = optional(string, "")
server_name = optional(string, "")
ca_cert_key = optional(string, "")
cert_key = optional(string, "")
key_key = optional(string, "")
})
})
| n/a | yes | +| [cache](#input\_cache) | Used to configure redis specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
enabled = optional(bool, false)
address = optional(string, "redis:6379")
database = optional(number, 0)
use_password = optional(bool, false)
secret_name = optional(string, "redis")
password_key = optional(string, "password")
})
| n/a | yes | +| [database](#input\_database) | Used to configure database specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
enabled = optional(bool, false)
secret_name = optional(string, "mysql")
address = optional(string, "mysql:3306")
database = optional(string, "fleet")
username = optional(string, "fleet")
password_key = optional(string, "password")
max_open_conns = optional(number, 50)
max_idle_conns = optional(number, 50)
conn_max_lifetime = optional(number, 0)

tls = object({
enabled = optional(bool, false)
config = optional(string, "")
server_name = optional(string, "")
ca_cert_key = optional(string, "")
cert_key = optional(string, "")
key_key = optional(string, "")
})
})
| n/a | yes | | [environment\_from\_config\_maps](#input\_environment\_from\_config\_maps) | Used to configure additional environment variables from a config map for the fleet deployment and vuln-processing cron job. | `list(map(string))` | `[]` | no | | [environment\_from\_secrets](#input\_environment\_from\_secrets) | Used to configure additional environment variables from a secret for the fleet deployment and vuln-processing cron job. | `list(map(string))` | `[]` | no | | [environment\_variables](#input\_environment\_variables) | Used to configure additional environment variables for the fleet deployment and vuln-processing cron job. | `list(map(string))` | `[]` | no | -| [fleet](#input\_fleet) | Used to configure Fleet specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
listen_port = optional(number, 8080)
secret_name = optional(string, "fleet")
migrations = object({
auto_apply_sql_migrations = optional(bool, true)
migration_job_annotations = optional(map(string), {})
parallelism = optional(number, 1)
completions = optional(number, 1)
active_deadline_seconds = optional(number, 900)
backoff_limit = optional(number, 6)
ttl_seconds_after_finished = optional(number, 100)
manual_selector = optional(bool, false)
restart_policy = optional(string, "Never")
})
tls = object({
enabled = optional(bool, false)
unique_tls_secret = optional(bool, false)
secret_name = optional(string, "fleet-tls")
compatibility = optional(string, "modern")
cert_secret_key = optional(string, "server.cert")
key_secret_key = optional(string, "server.key")
})
auth = object({
b_crypto_cost = optional(number, 12)
salt_key_size = optional(number, 24)
})
app = object({
token_key_size = optional(number, 24)
invite_token_validity_period = optional(string, "120h")
})
session = object({
key_size = optional(number, 64)
duration = optional(string, "2160h")
})
logging = object({
debug = optional(bool, false)
json = optional(bool, false)
disable_banner = optional(bool, false)
})
carving = object({
s3 = object({
bucket_name = optional(string, "")
prefix = optional(string, "")
access_key_id = optional(string, "")
secret_key = optional(string, "s3-bucket")
sts_assume_role_arn = optional(string, "")
})
})
license = object({
secret_name = optional(string, "")
license_key = optional(string, "license-key")
})
extra_volumes = optional(list(any), [])
extra_volume_mounts = optional(list(any), [])
security_context = object({
run_as_user = optional(number, 3333)
run_as_group = optional(number, 3333)
})
})
| n/a | yes | +| [fleet](#input\_fleet) | Used to configure Fleet specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
listen_port = optional(number, 8080)
secret_name = optional(string, "fleet")
migrations = object({
auto_apply_sql_migrations = optional(bool, true)
migration_job_annotations = optional(map(string), {})
parallelism = optional(number, 1)
completions = optional(number, 1)
active_deadline_seconds = optional(number, 900)
backoff_limit = optional(number, 6)
manual_selector = optional(bool, false)
restart_policy = optional(string, "Never")
})
tls = object({
enabled = optional(bool, false)
unique_tls_secret = optional(bool, false)
secret_name = optional(string, "fleet-tls")
compatibility = optional(string, "modern")
cert_secret_key = optional(string, "server.cert")
key_secret_key = optional(string, "server.key")
})
auth = object({
b_crypto_cost = optional(number, 12)
salt_key_size = optional(number, 24)
})
app = object({
token_key_size = optional(number, 24)
invite_token_validity_period = optional(string, "120h")
})
session = object({
key_size = optional(number, 64)
duration = optional(string, "2160h")
})
logging = object({
debug = optional(bool, false)
json = optional(bool, false)
disable_banner = optional(bool, false)
})
carving = object({
s3 = object({
bucket_name = optional(string, "")
prefix = optional(string, "")
access_key_id = optional(string, "")
secret_key = optional(string, "s3-bucket")
sts_assume_role_arn = optional(string, "")
})
})
license = object({
secret_name = optional(string, "")
license_key = optional(string, "license-key")
})
extra_volumes = optional(list(any), [])
extra_volume_mounts = optional(list(any), [])
security_context = object({
run_as_user = optional(number, 3333)
run_as_group = optional(number, 3333)
})
})
| n/a | yes | | [gke](#input\_gke) | Used to configure gke specific values for use in the Fleet deployment, migration job, and vuln-processing cron job. |
object({
workload_identity_email = optional(string, "")
cloud_sql = object({
enable_proxy = optional(bool, false)
image_repository = optional(string, "gcr.io/cloudsql-docker/gce-proxy")
image_tag = optional(string, "1.17-alpine")
verbose = optional(bool, true)
instance_name = optional(string, "")
})
ingress = object({
use_managed_certificate = optional(bool, false)
use_gke_ingress = optional(bool, false)
node_port = optional(number, 0)
hostnames = optional(list(string), [""])
})
})
| n/a | yes | | [hostname](#input\_hostname) | Used as the hostname that you will access fleet on. | `string` | `"fleet.localhost"` | no | | [image\_pull\_secrets](#input\_image\_pull\_secrets) | Used to inject image pull secrets for access to a private container registry. |
list(object({
name = string
}))
| `[]` | no | diff --git a/k8s/cronjob.tf b/k8s/cronjob.tf index e5682c0..8993d7b 100644 --- a/k8s/cronjob.tf +++ b/k8s/cronjob.tf @@ -97,8 +97,8 @@ resource "kubernetes_cron_job_v1" "fleet_vuln_processing_cron_job" { name = "FLEET_MYSQL_PASSWORD" value_from { secret_key_ref { - key = local.database.secret_name - name = local.database.password_key + name = local.database.secret_name + key = local.database.password_key } } } diff --git a/k8s/deploy.tf b/k8s/deploy.tf index 55b50d6..d455015 100644 --- a/k8s/deploy.tf +++ b/k8s/deploy.tf @@ -173,8 +173,8 @@ resource "kubernetes_deployment" "fleet" { name = "FLEET_MYSQL_PASSWORD" value_from { secret_key_ref { - key = local.database.secret_name - name = local.database.password_key + name = local.database.secret_name + key = local.database.password_key } } } diff --git a/k8s/example/main.tf b/k8s/example/main.tf index 79534cc..dc882cf 100644 --- a/k8s/example/main.tf +++ b/k8s/example/main.tf @@ -1,5 +1,5 @@ module "fleet" { - source = "git::https://github.com/fleetdm/fleet-terraform//k8s?depth=1&ref=tf-mod-k8s-v1.0.0" + source = "git::https://github.com/fleetdm/fleet-terraform//k8s?depth=1&ref=tf-mod-k8s-v1.1.0" namespace = "fleet" hostname = "fleet.localhost.local" @@ -13,7 +13,7 @@ module "fleet" { { name = "docker_pull_secret_two"} ] */ - image_pull_secrets = [{}] + image_pull_secrets = [] pod_annotations = {} service_annotations = {} service_account_annotations = {} @@ -125,20 +125,20 @@ module "fleet" { ingress = { enabled = false - class_name = "nginx" + class_name = "" annotations = {} labels = {} hosts = [{ - name = "fleet.example.com" + name = "fleet.localhost.local" paths = [{ path = "/" path_type = "ImplementationSpecific" }] }] tls = { - secret_name = "fleet-tls" + secret_name = "chart-example-tls" hosts = [ - "fleet.example.com" + "fleet.localhost.local" ] } } @@ -153,7 +153,6 @@ module "fleet" { completions = 1 active_deadline_seconds = 900 backoff_limit = 6 - ttl_seconds_after_finished = 100 manual_selector = false restart_policy = "Never" } @@ -258,11 +257,11 @@ module "fleet" { database = { enabled = false - secret_name = "password" - address = "mysql:3306" + secret_name = "mysql" + address = "fleet-database-mysql:3306" database = "fleet" - username = "root" - password_key = "mysql-password" + username = "fleet" + password_key = "password" max_open_conns = 50 max_idle_conns = 50 conn_max_lifetime = 0 @@ -279,11 +278,11 @@ module "fleet" { cache = { enabled = false - address = "redis:6379" + address = "fleet-cache-redis-headless:6379" database = "0" - use_password = false - secret_name = "redis-password" - password_key = "redis" + use_password = true + secret_name = "redis" + password_key = "password" } gke = { diff --git a/k8s/job.tf b/k8s/job.tf index 04a492d..c843bbb 100644 --- a/k8s/job.tf +++ b/k8s/job.tf @@ -12,7 +12,6 @@ resource "kubernetes_job" "migration" { completions = local.fleet.migrations.completions active_deadline_seconds = local.fleet.migrations.active_deadline_seconds backoff_limit = local.fleet.migrations.backoff_limit - ttl_seconds_after_finished = local.fleet.migrations.ttl_seconds_after_finished manual_selector = local.fleet.migrations.manual_selector @@ -95,8 +94,8 @@ resource "kubernetes_job" "migration" { name = "FLEET_MYSQL_PASSWORD" value_from { secret_key_ref { - key = local.database.secret_name - name = local.database.password_key + name = local.database.secret_name + key = local.database.password_key } } } diff --git a/k8s/variables.tf b/k8s/variables.tf index 5f7b51e..eeb963e 100644 --- a/k8s/variables.tf +++ b/k8s/variables.tf @@ -198,7 +198,6 @@ variable "fleet" { completions = optional(number, 1) active_deadline_seconds = optional(number, 900) backoff_limit = optional(number, 6) - ttl_seconds_after_finished = optional(number, 100) manual_selector = optional(bool, false) restart_policy = optional(string, "Never") }) @@ -303,11 +302,11 @@ variable "osquery" { variable "database" { type = object({ enabled = optional(bool, false) - secret_name = optional(string, "password") + secret_name = optional(string, "mysql") address = optional(string, "mysql:3306") database = optional(string, "fleet") username = optional(string, "fleet") - password_key = optional(string, "mysql-password") + password_key = optional(string, "password") max_open_conns = optional(number, 50) max_idle_conns = optional(number, 50) conn_max_lifetime = optional(number, 0) @@ -330,8 +329,8 @@ variable "cache" { address = optional(string, "redis:6379") database = optional(number, 0) use_password = optional(bool, false) - secret_name = optional(string, "redis-password") - password_key = optional(string, "redis") + secret_name = optional(string, "redis") + password_key = optional(string, "password") }) description = "Used to configure redis specific values for use in the Fleet deployment, migration job, and vuln-processing cron job." }