Skip to content

Commit

Permalink
Update current feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fjammes committed May 26, 2024
1 parent e867c4d commit 135243c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Qserv operator CI workflow
---
name: "CI"
on:
push:
pull_request:
branches:
- master
jobs:
main:
name: Run nginx-controller demo
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Stop apparmor
run: |
sudo /etc/init.d/apparmor stop
- uses: actions/setup-go@v3
with:
go-version: '^1.19.2'
- name: Create k8s/kind cluster
run: |
go install github.com/k8s-school/ktbx@v1.1.1-rc17
ktbx create -c
- name: Install postgresl with helm
run: |
./ci.sh
7 changes: 7 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euxo pipefail

DIR=$(cd "$(dirname "$0")"; pwd -P)

$DIR/pgsql.sh
45 changes: 45 additions & 0 deletions pgsql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# See https://itnext.io/benchmark-results-of-kubernetes-network-plugins-cni-over-10gbit-s-network-36475925a560

set -euxo pipefail

DIR=$(cd "$(dirname "$0")"; pwd -P)


ID=0
NS="helm-$ID"

NODE1_IP=$(kubectl get nodes --selector="! node-role.kubernetes.io/master" \
-o=jsonpath='{.items[0].status.addresses[0].address}')

# Run on kubeadm cluster
# see "kubernetes in action" p391
kubectl delete ns -l "helm=$NS"
kubectl create namespace "$NS"
kubectl label ns "$NS" "helm=$NS"

# Exercice: Install one postgresql pod with helm and add label "tier:database" to master pod
# Disable data persistence
helm delete pgsql --namespace "$NS" || echo "WARN pgsql release not found"

helm repo add bitnami https://charts.bitnami.com/bitnami || echo "Failed to add bitnami repo"
helm repo update

helm install --version 11.9.1 --namespace "$NS" pgsql bitnami/postgresql --set primary.podLabels.tier="database",persistence.enabled="false"

kubectl run -n "$NS" nginx --image=nginx -l "tier=webserver"
kubectl wait --timeout=60s -n "$NS" --for=condition=Ready pods nginx
kubectl exec -n "$NS" -it nginx -- \
sh -c "apt-get update && apt-get install -y dnsutils inetutils-ping netcat net-tools procps tcpdump"

kubectl wait --timeout=120s -n "$NS" --for=condition=Ready pods -l app.kubernetes.io/instance=pgsql,tier=database

kubectl exec -n "$NS" nginx -- netcat -q 2 -zv pgsql-postgresql 5432

# Interactive mode
export POSTGRES_PASSWORD=$(kubectl get secret --namespace helm-0 pgsql-postgresql -o jsonpath="{.data.postgres-password}" | \
base64 -d)
kubectl run pgsql-postgresql-client --rm --tty -i --restart='Never' --namespace helm-0 \
--image docker.io/bitnami/postgresql:14.5.0-debian-11-r14 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
--command -- psql --host pgsql-postgresql -U postgres -d postgres -p 5432 -c '\copyright'

0 comments on commit 135243c

Please sign in to comment.