diff --git a/dataplane-webserver/Cargo.toml b/dataplane-webserver/Cargo.toml index 99e2455b0..295c82a99 100644 --- a/dataplane-webserver/Cargo.toml +++ b/dataplane-webserver/Cargo.toml @@ -27,4 +27,4 @@ kube = { version = "0.90.0", features = ["runtime", "derive"] } k8s-openapi = { version = "0.21.0", features = ["v1_25"] } indexmap = "2.0.0" regex = "1.9.6" -jsonwebtoken = "8.3.0" \ No newline at end of file +jsonwebtoken = "8.3.0" diff --git a/dataplane-webserver/src/config.rs b/dataplane-webserver/src/config.rs index 07ea4cfdf..47dd41c2a 100644 --- a/dataplane-webserver/src/config.rs +++ b/dataplane-webserver/src/config.rs @@ -15,6 +15,7 @@ impl Default for Config { "PROMETHEUS_URL", "http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090", ), + prometheus_timeout_ms: match from_env_default("PROMETHEUS_TIMEOUT_MS", "500") .parse::() { diff --git a/tembo-operator/CONTRIBUTING.md b/tembo-operator/CONTRIBUTING.md index 978385179..9b9fe9ac0 100644 --- a/tembo-operator/CONTRIBUTING.md +++ b/tembo-operator/CONTRIBUTING.md @@ -1,20 +1,23 @@ # Contributing to the Tembo Kubernetes Operator + Welcome! And thank you for your interest in contributing to the Tembo Kubernetes Operator. Here are some quick pointers for orientation: + - Check out the project's [README](https://github.com/tembo-io/tembo/blob/main/tembo-operator/README.md) to learn about the less technical aspects. - Questions or comments? We'd love to hear from you on our [Tembo Slack Channel](https://join.slack.com/t/tembocommunity/shared_invite/zt-277pu7chi-NHtvHWvLhHwyK0Y5Y6vTPw)! ## Table of Contents + 1. [Prerequisites](#prerequisites) 2. [Running locally with Kind](#running-locally) - 1. [Initial setup](#1.-initial-setup) - 2. [Applying YAML files](#2.-applying-YAML-files) - 3. [Loading Docker images](#3.-loading-docker-images) - 4. [Connect via psql](#4.-connect-via-psql) - 5. [Exec into the pod](#5.-exec-into-the-pod) + 1. [Initial setup](#1.-initial-setup) + 2. [Applying YAML files](#2.-applying-YAML-files) + 3. [Loading Docker images](#3.-loading-docker-images) + 4. [Connect via psql](#4.-connect-via-psql) + 5. [Exec into the pod](#5.-exec-into-the-pod) 3. [Updating the CRD (CustomResourceDefinition)](#updating-the-crd) - 1. [Making and applying changes](#1.-making-and-applying-changes) + 1. [Making and applying changes](#1.-making-and-applying-changes) 4. [Testing](#testing) ## Prerequisites @@ -25,6 +28,7 @@ Here are some quick pointers for orientation: - [kind](https://github.com/kubernetes-sigs/kind) — Simplifies creation of local Kubernetes clusters using Docker (_**K**ubernetes **IN** **D**ocker_) - [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) — Kubernetes primary CLI - [just](https://github.com/casey/just) — Simplifies running complex, project-specific commands. If you find a new, useful command, consider adding it to the `justfile` +- [helm](https://helm.sh/) - The package manager for Kubernetes ## Running locally @@ -35,22 +39,27 @@ If you haven't already, go ahead and clone the tembo repository to your local ma ```bash git clone https://github.com/tembo-io/tembo.git ``` + ```bash cd tembo/tembo-operator ``` From there, initiate a local Kubernetes cluster: + ```bash just start-kind ``` + :bulb: Details on this command, as well as others that invoke `just` can be found within the directory's `justfile`. :wrench: If you encounter an error, confirm that your Docker engine is running. Once complete, start the Tembo Operator: + ```bash just run ``` + :bulb: This operation will be running continuously, so we advise opening a new terminal workspace. ### 2. Applying YAML files @@ -62,10 +71,13 @@ You can try out any of the sample YAML files, for example by running the followi ```bash kubectl apply -f yaml/sample-standard.yaml ``` + After some moments, confirm the newly-made kubernetes pod: + ```bash kubectl get pods ``` + ```text NAME READY STATUS RESTARTS AGE sample-standard-1 1/1 Running 0 14s @@ -104,6 +116,7 @@ Bear this in mind as you define your own names and tags. You can confirm that your local Docker registry is running by invoking `docker ps`. Then you can push the newly-created image and check for it by running the following: + ```bash docker push localhost:5000/my-custom-image:15-0.0.1 ``` @@ -112,7 +125,7 @@ docker push localhost:5000/my-custom-image:15-0.0.1 docker images ``` -#### 3.3. Apply custom image and connecting +#### 3.3. Apply custom image and connecting Say, for example you'd like to update the image of the `sample-standard.yaml` file. You would begin by replacing the image parameter with the following: @@ -136,7 +149,7 @@ kubectl apply -f yaml/sample-standard.yaml ### 4. Connect via psql Connecting via psql will require a password, which is linked to your current Kubernetes session. -Sections `4.1` and `4.2` will illustrate how to respectively reveal the password, if you're work is more sessions-based, and how to save the password for later use. +Sections `4.1` and `4.2` will illustrate how to respectively reveal the password, if you're work is more sessions-based, and how to save the password for later use. #### 4.1. Revealing password @@ -161,6 +174,7 @@ export PGPASSWORD=$(kubectl get secrets/sample-standard-connection --template={{ ``` Add the following line to /etc/hosts + ``` 127.0.0.1 sample-standard.localhost ``` diff --git a/tembo-operator/yaml/sample-sql-runner.yaml b/tembo-operator/yaml/sample-sql-runner.yaml new file mode 100644 index 000000000..57ae553ff --- /dev/null +++ b/tembo-operator/yaml/sample-sql-runner.yaml @@ -0,0 +1,31 @@ +apiVersion: coredb.io/v1alpha1 +kind: CoreDB +metadata: + name: sample-sql +spec: + appServices: + - image: quay.io/tembo/sql-runner:6778cb5 + name: sqlrunner + resources: + requests: + cpu: 10m + memory: 100Mi + limits: + cpu: 200m + memory: 100Mi + routing: + - port: 3000 + ingressPath: "/v1/sql" + middlewares: + - strip-auth-header + - strip-path-prefix + - replacePathRegex + middlewares: + - replacePathRegex: + name: map-sql + config: + regex: ^\/sql\/? + replacement: /v1/sql + env: + - name: CONNECTION_STRING + valueFromPlatform: ReadWriteConnection diff --git a/tembo-stacks/Cargo.lock b/tembo-stacks/Cargo.lock index 2df1d2807..c3c353f1b 100644 --- a/tembo-stacks/Cargo.lock +++ b/tembo-stacks/Cargo.lock @@ -2471,7 +2471,7 @@ dependencies = [ [[package]] name = "tembo-stacks" -version = "0.17.2" +version = "0.18.0" dependencies = [ "anyhow", "clap", diff --git a/tembo-stacks/Cargo.toml b/tembo-stacks/Cargo.toml index 9dd30d119..a42544d25 100644 --- a/tembo-stacks/Cargo.toml +++ b/tembo-stacks/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tembo-stacks" description = "Tembo Stacks for Postgres" -version = "0.17.2" +version = "0.18.0" authors = ["tembo.io"] edition = "2021" license = "Apache-2.0" diff --git a/tembo-stacks/src/apps/app.rs b/tembo-stacks/src/apps/app.rs index 7dbc16051..6663753d6 100644 --- a/tembo-stacks/src/apps/app.rs +++ b/tembo-stacks/src/apps/app.rs @@ -23,6 +23,8 @@ lazy_static! { serde_yaml::from_str(include_str!("embeddings.yaml")).expect("embeddings.yaml not found"); pub static ref PGANALYZE: App = serde_yaml::from_str(include_str!("pganalyze.yaml")).expect("pganalyze.yaml not found"); + pub static ref SQLRUNNER: App = + serde_yaml::from_str(include_str!("sql-runner.yaml")).expect("sql-runner.yaml not found"); } // handling merging requirements coming from an App into the final @@ -135,6 +137,13 @@ pub fn merge_app_reqs( final_pg_configs.extend(pg_cfg); } } + AppType::SqlRunner(_) => { + // there is only 1 app_service in the restAPI + let sqlrunner = SQLRUNNER.clone().app_services.unwrap().clone()[0].clone(); + user_app_services.push(sqlrunner); + // sqlrunner only has app_service containers + // no extensions or trunk installs + } AppType::Custom(custom_app) => { user_app_services.push(custom_app); } diff --git a/tembo-stacks/src/apps/sql-runner.yaml b/tembo-stacks/src/apps/sql-runner.yaml new file mode 100644 index 000000000..6a112deaf --- /dev/null +++ b/tembo-stacks/src/apps/sql-runner.yaml @@ -0,0 +1,35 @@ +name: !sqlrunner +appServices: + - image: quay.io/tembo/sql-runner:6778cb5 + name: sqlrunner + resources: + requests: + cpu: 10m + memory: 100Mi + limits: + cpu: 200m + memory: 100Mi + routing: + - port: 3000 + ingressPath: "/v1/sql" + middlewares: + - strip-auth-header + - strip-path-prefix + - replacePathRegex + middlewares: + - !customRequestHeaders + name: strip-auth-header + config: + Authorization: "" + - !stripPrefix + name: strip-path-prefix + config: + - /v1/sql + - !replacePathRegex + name: map-sql + config: + regex: ^\/sql\/? + replacement: /v1/sql + env: + - name: CONNECTION_STRING + valueFromPlatform: ReadWriteConnection diff --git a/tembo-stacks/src/apps/types.rs b/tembo-stacks/src/apps/types.rs index 3157201e1..a0aa92dd2 100644 --- a/tembo-stacks/src/apps/types.rs +++ b/tembo-stacks/src/apps/types.rs @@ -39,6 +39,8 @@ pub enum AppType { Embeddings(Option), #[serde(rename = "pganalyze")] PgAnalyze(Option), + #[serde(rename = "sqlrunner")] + SqlRunner(Option), #[serde(rename = "custom")] Custom(AppService), } @@ -73,6 +75,7 @@ impl TryFrom for AppType { "mq-api" => Ok(AppType::MQ(app_config)), "embeddings" => Ok(AppType::Embeddings(app_config)), "pganalyze" => Ok(AppType::PgAnalyze(app_config)), + "sqlrunner" => Ok(AppType::SqlRunner(app_config)), _ => { // everything else is a custom app Ok(AppType::Custom(app_service))