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
GITHUB_USER='[YOUR_USERNAME]'
git clone https://github.com/$GITHUB_USER/CYBERTEC-operator-tutorials.git
cd CYBERTEC-operator-tutorials
Two options are available for the installation:
- Installation via Helm-Chart
- Installation via apply
kubectl apply -k setup/namespace/.
helm install cpo setup/helm/operator/ -n cpo
kubectl apply -k setup/namespace/.
kubectl apply -k setup/helm/operator/. -n cpo
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
The operator is ready and the setup is complete. The next step is the creation of a Postgres cluster
To create a simple cluster, the following command is sufficient
kubectl apply -k cluster-tutorials/single-cluster
watch kubectl get pods --selector cluster-name=cluster-1,application=spilo
The result should look like this:
Alle 2.0s: kubectl get pods --selector cluster-name=cluster-1,application=spilo
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 postgres.acid-cluster-1.credentials.postgresql.acid.zalan.do -o jsonpath='{.data}' | jq '.|map_values(@base64d)'
The result should look like this:
{
"password": "2rZG1Kx9asdHscswQGzff4Ru0xW6uasacy3GQ0sjdCH3wWr0kguUXUZek6dkemsf",
"username": "postgres"
}
port-forward acid-cluster-1-1 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.