Quickstart
We can tell and document so much about our project but it seems you just want to get started. Let us show you the fastest way to use CPO.
- git
- helm (optional)
- kubectl or oc
To get started, you can fork our tutorial repository on Github and then download it. CYBERTEC-operator-tutorials
git clone https://github.com/cybertec-postgresql/CYBERTEC-operator-tutorials.git
cd CYBERTEC-operator-tutorials
Two options are available for the installation:
- Installation via Helm-Chart
- Installation via apply
kubectl apply -n cpo -k setup/namespace/.
helm install cpo -n cpo setup/helm/operator/
kubectl apply -n cpo -k setup/namespace/.
kubectl apply -n cpo -k setup/helm/operator/.
You can check if the operator pod is in operation.
kubectl get pods -n cpo --selector=cpo.cybertec.at/pod/type=postgres-operator
The result should look like this:
NAME READY STATUS RESTARTS AGE
postgres-operator-599688d948-fw8pw 1/1 Running 0 41s
Hint: If you want, you can get rid of the need to define -n cpo every time. To do this, you can set your current default namespace in kubectl or oc to cpo
The operator is ready and the setup is complete. The next step is the creation of a Postgres cluster
# kubectl
kubectl config set-context --current --namespace=cpo
# oc
oc project cpo
To create a simple cluster, the following command is sufficient
kubectl apply -n cpo -f cluster-tutorials/single-cluster
watch kubectl get pods -n cpo --selector cluster-name=cluster-1
The result should look like this:
Alle 2.0s: kubectl get pods -n cpo --selector cluster-name=cluster-1
NAME READY STATUS RESTARTS AGE
cluster-1-0 2/2 Running 0 28s
cluster-1-1 0/2 PodInitializing 0 9s
Get your login information from the secret.
kubectl get secret -n cpo postgres.cluster-1.credentials.postgresql.cpo.opensource.cybertec.at -o jsonpath='{.data}' | jq '.|map_values(@base64d)'
The result should look like this:
{
"password": "2rZG1Kx9asdHscswQGzff4Ru0xW6uasacy3GQ0sjdCH3wWr0kguUXUZek6dkemsf",
"username": "postgres"
}
kubectl port-forward -n cpo cluster-1-0 5432:5432
# using psql
PGPASSWORD=2rZG1Kx9asdHscswQGzffjdCH3wWr0kguUXUZek6dkemsf psql -h 127.0.0.1 -p 5432 -U postgres
# using usql
PGPASSWORD=2rZG1Kx9asdHscswQGzffjdCH3wWr0kguUXUZek6dkemsf usql postgresql://postgres@127.0.0.1/postgres
Congratulations, your first cluster is ready and you were able to connect to it. On the following pages we have put together an introduction with lots of information and details to show you the different possibilities and components of CPO.