I am using Google Container Engine (GKE), how do I configure the amount of logs Stackdriver logging will retain (preferably: the number of days)?
Stack driver logging agent sends the logs to the cloud logging. By default it keeps 30 days of log. You can extend it by exporting the logs to Google storage.
update
it is possible to export your logs to a Cloud Storage bucket, to a BigQuery dataset, or to a Google Cloud Pub/Sub. In those cases, logs entries are stored immediately and exported according to your configuration as follows:
details on how to do it it can be read on https://cloud.google.com/logging/docs/export/using_exported_logs
Nearline cloud storage should cost you peanuts :)