WIP: start working on tests #1
|
@ -0,0 +1,24 @@
|
||||||
|
name: Tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
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
|
||||||
|
- name: Run the tests
|
||||||
|
run: |
|
||||||
|
tilt ci
|
|
@ -0,0 +1,5 @@
|
||||||
|
kind: Cluster
|
||||||
|
apiVersion: kind.x-k8s.io/v1alpha4
|
||||||
|
networking:
|
||||||
|
apiServerAddress: "127.0.0.1"
|
||||||
|
apiServerPort: 6443
|
|
@ -4,5 +4,5 @@ metadata:
|
||||||
name: my-neon-database
|
name: my-neon-database
|
||||||
spec:
|
spec:
|
||||||
compute_image_ref: "melenion/compute-node-v15"
|
compute_image_ref: "melenion/compute-node-v15"
|
||||||
neon_image_ref: "neondatabase/neon"
|
neon_image_ref: "neondatabase/neon:release-5545"
|
||||||
postgres_version: "15"
|
postgres_version: "15"
|
||||||
|
|
33
src/neon.rs
33
src/neon.rs
|
@ -3,6 +3,7 @@ use k8s_openapi::api::core::v1::{
|
||||||
Container, ContainerPort, EnvVar, PodSpec, PodTemplateSpec, Service, ServicePort, ServiceSpec,
|
Container, ContainerPort, EnvVar, PodSpec, PodTemplateSpec, Service, ServicePort, ServiceSpec,
|
||||||
};
|
};
|
||||||
use k8s_openapi::apimachinery::pkg::apis::meta::v1::{LabelSelector, OwnerReference};
|
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::{ObjectMeta, Patch, PatchParams};
|
||||||
use kube::{Api, Client, Error};
|
use kube::{Api, Client, Error};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
@ -414,16 +415,38 @@ pub async fn reconcile_compute(
|
||||||
containers: vec![Container {
|
containers: vec![Container {
|
||||||
name: "compute".to_string(),
|
name: "compute".to_string(),
|
||||||
image: Some(compute_image.to_string()),
|
image: Some(compute_image.to_string()),
|
||||||
ports: Some(vec![ContainerPort {
|
|
||||||
container_port: 9898,
|
ports: Some(vec![
|
||||||
..Default::default()
|
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 {
|
env: Some(vec![EnvVar {
|
||||||
name: "PG_VERSION".to_string(),
|
name: "PG_VERSION".to_string(),
|
||||||
value: Some("15".to_string()),
|
value: Some("15".to_string()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]),
|
}]),
|
||||||
command: Some(vec!["/shell/compute.sh".to_string()]),
|
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()
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -445,7 +468,7 @@ pub async fn reconcile_compute(
|
||||||
spec: Some(ServiceSpec {
|
spec: Some(ServiceSpec {
|
||||||
selector: Some(BTreeMap::from([("app".to_string(), "compute".to_string())])),
|
selector: Some(BTreeMap::from([("app".to_string(), "compute".to_string())])),
|
||||||
ports: Some(vec![ServicePort {
|
ports: Some(vec![ServicePort {
|
||||||
port: 9898,
|
port: 55433,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]),
|
}]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
Loading…
Reference in New Issue