From d5252cceda236735896e411692b80b8dbb71bad9 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 14:59:14 +0100 Subject: [PATCH 01/20] start working on tests --- .github/workflows/tests.yaml | 11 +++++++++++ manifests/example.yaml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..cc6aff7 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,11 @@ +name: Tests +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 diff --git a/manifests/example.yaml b/manifests/example.yaml index 4a818e8..d3bc285 100644 --- a/manifests/example.yaml +++ b/manifests/example.yaml @@ -4,5 +4,5 @@ metadata: name: my-neon-database spec: compute_image_ref: "melenion/compute-node-v15" - neon_image_ref: "neondatabase/neon" + neon_image_ref: "neondatabase/neon:release-6210" postgres_version: "15" -- 2.44.1 From 8908ebd6d130feaa457397a7684fe129e43fe591 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 15:03:02 +0100 Subject: [PATCH 02/20] add workflow dispatch --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index cc6aff7..a69899b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,6 +3,7 @@ on: pull_request: branches: - main + workflow_dispatch: jobs: test: -- 2.44.1 From 2030a7d4f43b715007d7f9e0d7a7e57df94befb7 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 16:41:48 +0100 Subject: [PATCH 03/20] WIP --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a69899b..01cc777 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,5 +1,6 @@ name: Tests on: + push: pull_request: branches: - main -- 2.44.1 From 4b673506df67c537d149475209dd3f1d9a704a7a Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:20:18 +0100 Subject: [PATCH 04/20] WIP --- .github/workflows/tests.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 01cc777..fe69f18 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,3 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Setup Kubernetes Tools + uses: yokawasa/action-setup-kube-tools@v0.11.1 + with: + tilt: "v0.33.20" + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 -- 2.44.1 From d41890df3f4c59a90f2fa5e4cfc951ff80090a00 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:26:31 +0100 Subject: [PATCH 05/20] WIP --- .github/workflows/tests.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fe69f18..3252ee2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,3 +17,7 @@ jobs: tilt: "v0.33.20" - name: Create k8s Kind Cluster uses: helm/kind-action@v1 + - name: Run the tests + run: | + kubectl apply -f manifests/example.yaml + tilt ci -- 2.44.1 From a1f0eb2b9fb875e82f19ee88a7c2fb1cff80a9ae Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:31:50 +0100 Subject: [PATCH 06/20] WIP --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3252ee2..0edb119 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,5 +19,5 @@ jobs: uses: helm/kind-action@v1 - name: Run the tests run: | - kubectl apply -f manifests/example.yaml + kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From d56ddfe8a6e02fd4948f1fe08984121278e641b2 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:48:05 +0100 Subject: [PATCH 07/20] WIP, fixing networking? --- .github/workflows/tests.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0edb119..4a05eb9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,5 +19,13 @@ jobs: uses: helm/kind-action@v1 - name: Run the tests run: | - kubectl apply -f manifests/example.yaml --validate=false - tilt ci + export KUBECONFIG=$HOME/.kube/config # if not already set + export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} + + kind create cluster \ + --kubeconfig $KUBECONFIG \ + --config=./kind-config.yaml + + kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 + kubectl apply -f manifests/example.yaml --validate=false + tilt ci -- 2.44.1 From 28442ade62c2ad95aebde5e8c8612e4579be4f6f Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:52:29 +0100 Subject: [PATCH 08/20] WIP, fixing networking? --- .github/workflows/tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4a05eb9..8bb38f6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,7 +19,6 @@ jobs: uses: helm/kind-action@v1 - name: Run the tests run: | - export KUBECONFIG=$HOME/.kube/config # if not already set export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} kind create cluster \ -- 2.44.1 From 6615d9b5bd9fa50c81ca5cb0421ed387ede978bf Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 17:57:27 +0100 Subject: [PATCH 09/20] fix path --- .github/workflows/tests.yaml | 2 +- kind/kind-config-ci.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 kind/kind-config-ci.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8bb38f6..ea4be37 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,7 +23,7 @@ jobs: kind create cluster \ --kubeconfig $KUBECONFIG \ - --config=./kind-config.yaml + --config=./kind/kind-config-ci.yaml kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 kubectl apply -f manifests/example.yaml --validate=false diff --git a/kind/kind-config-ci.yaml b/kind/kind-config-ci.yaml new file mode 100644 index 0000000..69302a5 --- /dev/null +++ b/kind/kind-config-ci.yaml @@ -0,0 +1,5 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +networking: + apiServerAddress: "127.0.0.1" + apiServerPort: 6443 -- 2.44.1 From a365b32063d4946b9ce015c6de470c9935177137 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 18:09:47 +0100 Subject: [PATCH 10/20] hmm --- .github/workflows/tests.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ea4be37..c824a6e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,14 +17,18 @@ jobs: tilt: "v0.33.20" - name: Create k8s Kind Cluster uses: helm/kind-action@v1 + with: + name: kind + wait: 90s + - name: Run the tests run: | - export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} + # export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} - kind create cluster \ - --kubeconfig $KUBECONFIG \ - --config=./kind/kind-config-ci.yaml + # kind create cluster \ + # --kubeconfig $KUBECONFIG \ + # --config=./kind/kind-config-ci.yaml - kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 - kubectl apply -f manifests/example.yaml --validate=false - tilt ci + # kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 + kubectl apply -f manifests/example.yaml --validate=false + tilt ci -- 2.44.1 From 228fe10ae83276fae792ef4f03ea4fbaa0b5420c Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 18:31:36 +0100 Subject: [PATCH 11/20] maybe fix the network --- .github/workflows/tests.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c824a6e..170cfd4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,17 +18,17 @@ jobs: - name: Create k8s Kind Cluster uses: helm/kind-action@v1 with: - name: kind - wait: 90s + install_only: true - name: Run the tests run: | - # export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} + echo ${{ job.container.network }} + export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} - # kind create cluster \ - # --kubeconfig $KUBECONFIG \ - # --config=./kind/kind-config-ci.yaml + kind create cluster \ + --kubeconfig $KUBECONFIG \ + --config=./kind/kind-config-ci.yaml - # kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 + kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From 6c4f9e0ccc436e5679949cf4f43b336a45db076d Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 18:33:01 +0100 Subject: [PATCH 12/20] old kind doesnt get cleaned up? --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 170cfd4..5d17ead 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,6 +29,6 @@ jobs: --kubeconfig $KUBECONFIG \ --config=./kind/kind-config-ci.yaml - kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 + kubectl config set-cluster kind-something --server=https://kind-control-plane:6443 kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From 88400f1be220c2f26ac8366f0b08ae8306d8bb90 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 18:34:47 +0100 Subject: [PATCH 13/20] old kind doesnt get cleaned up? --- .github/workflows/tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5d17ead..ff0de45 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,9 +26,10 @@ jobs: export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} kind create cluster \ + --name ${{ github.run_id }} \ --kubeconfig $KUBECONFIG \ --config=./kind/kind-config-ci.yaml - kubectl config set-cluster kind-something --server=https://kind-control-plane:6443 + kubectl config set-cluster kind- --server=https://kind-control-plane:6443 kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From 1da5d8955eb03b975544c0ab4b551c849bacb300 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 18:42:50 +0100 Subject: [PATCH 14/20] doubt itll work --- .github/workflows/tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ff0de45..0cd8a6e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,6 +30,7 @@ jobs: --kubeconfig $KUBECONFIG \ --config=./kind/kind-config-ci.yaml - kubectl config set-cluster kind- --server=https://kind-control-plane:6443 + kubectl cluster-info --context kind-19 --kubeconfig --config=./kind/kind-config-ci.yaml + kubectl config set-cluster kind-${{ github.run_id }} --server=https://kind-control-plane:6443 kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From b79fc625997f97f6760434f2303760762fdcb288 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 21:01:53 +0100 Subject: [PATCH 15/20] trying something different --- .github/workflows/tests.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0cd8a6e..e78ae6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,6 +1,8 @@ name: Tests on: push: + branches: + - main pull_request: branches: - main @@ -17,9 +19,6 @@ jobs: tilt: "v0.33.20" - name: Create k8s Kind Cluster uses: helm/kind-action@v1 - with: - install_only: true - - name: Run the tests run: | echo ${{ job.container.network }} -- 2.44.1 From eb443e0f1b554adad2dcdee8c1d82f107fa4d8d5 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 21:12:55 +0100 Subject: [PATCH 16/20] trying something different --- .github/workflows/tests.yaml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e78ae6a..6944ab8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,15 +21,6 @@ jobs: uses: helm/kind-action@v1 - name: Run the tests run: | - echo ${{ job.container.network }} - export KIND_EXPERIMENTAL_DOCKER_NETWORK=${{ job.container.network }} - - kind create cluster \ - --name ${{ github.run_id }} \ - --kubeconfig $KUBECONFIG \ - --config=./kind/kind-config-ci.yaml - - kubectl cluster-info --context kind-19 --kubeconfig --config=./kind/kind-config-ci.yaml - kubectl config set-cluster kind-${{ github.run_id }} --server=https://kind-control-plane:6443 + kubectl apply -f manifests/deployment.yaml kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From 10a755d41b11e4539b4fbc40890e4af18ed037c7 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 21:20:45 +0100 Subject: [PATCH 17/20] even older --- manifests/example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/example.yaml b/manifests/example.yaml index d3bc285..24c1a03 100644 --- a/manifests/example.yaml +++ b/manifests/example.yaml @@ -4,5 +4,5 @@ metadata: name: my-neon-database spec: compute_image_ref: "melenion/compute-node-v15" - neon_image_ref: "neondatabase/neon:release-6210" + neon_image_ref: "neondatabase/neon:release-5940" postgres_version: "15" -- 2.44.1 From 2eedcb29633d50f5ad0086247a3ca73d889a3dc9 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 21:23:59 +0100 Subject: [PATCH 18/20] add crd manually --- .github/workflows/tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6944ab8..185aebd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,6 +21,4 @@ jobs: uses: helm/kind-action@v1 - name: Run the tests run: | - kubectl apply -f manifests/deployment.yaml - kubectl apply -f manifests/example.yaml --validate=false tilt ci -- 2.44.1 From fd4424f5ff04f0c459bdc91dbf0eefe37beac533 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 21:24:54 +0100 Subject: [PATCH 19/20] Missing updates? --- src/neon.rs | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/neon.rs b/src/neon.rs index d253244..2438c01 100644 --- a/src/neon.rs +++ b/src/neon.rs @@ -3,6 +3,7 @@ use k8s_openapi::api::core::v1::{ Container, ContainerPort, EnvVar, PodSpec, PodTemplateSpec, Service, ServicePort, ServiceSpec, }; use k8s_openapi::apimachinery::pkg::apis::meta::v1::{LabelSelector, OwnerReference}; +use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString; use kube::api::{ObjectMeta, Patch, PatchParams}; use kube::{Api, Client, Error}; use std::collections::BTreeMap; @@ -414,16 +415,38 @@ pub async fn reconcile_compute( containers: vec![Container { name: "compute".to_string(), image: Some(compute_image.to_string()), - ports: Some(vec![ContainerPort { - container_port: 9898, - ..Default::default() - }]), + + ports: Some(vec![ + ContainerPort { + container_port: 3080, + ..Default::default() + }, + // TODO: The port the compute node listens on comes from the spec, + // so it should be part of the CRD so it can be dynamically set + ContainerPort { + container_port: 55433, + ..Default::default() + }, + ]), env: Some(vec![EnvVar { name: "PG_VERSION".to_string(), value: Some("15".to_string()), ..Default::default() }]), command: Some(vec!["/shell/compute.sh".to_string()]), + readiness_probe: Some(k8s_openapi::api::core::v1::Probe { + http_get: Some(k8s_openapi::api::core::v1::HTTPGetAction { + // HACK: This is a hack to get around the fact that most of the compute node's HTTP endppoints + // returns 200 OK event when the response contains an error message. Would be nice + // to fix that upstream, or write a small script to parse the reponse + // but I worry that'd be more fragile than using this endpoint + path: Some("/dbs_and_roles".to_string()), + port: IntOrString::Int(3080), + ..Default::default() + }), + period_seconds: Some(1), + ..Default::default() + }), ..Default::default() }], ..Default::default() @@ -445,7 +468,7 @@ pub async fn reconcile_compute( spec: Some(ServiceSpec { selector: Some(BTreeMap::from([("app".to_string(), "compute".to_string())])), ports: Some(vec![ServicePort { - port: 9898, + port: 55433, ..Default::default() }]), ..Default::default() -- 2.44.1 From 5714b48667684888df5ae18508b0717919e985d0 Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Wed, 11 Sep 2024 22:59:48 +0100 Subject: [PATCH 20/20] even older --- manifests/example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/example.yaml b/manifests/example.yaml index 24c1a03..177f347 100644 --- a/manifests/example.yaml +++ b/manifests/example.yaml @@ -4,5 +4,5 @@ metadata: name: my-neon-database spec: compute_image_ref: "melenion/compute-node-v15" - neon_image_ref: "neondatabase/neon:release-5940" + neon_image_ref: "neondatabase/neon:release-5545" postgres_version: "15" -- 2.44.1