PostgreSQL is an open-source database system (object-related), which uses extend of SQLlanguage which lsafely scales and stores the most perplexing data workloads. Kubernetes offers the possibility to scale your applications and test environment to ensure a smooth data migration path. For this, you need to use the msiexec.exe from the command line. To show this example we used the Cloud Platform Xelon HQ.
Before we begin, ensure you have installed one of these tools:
Kubernetes is an orchestration cluster platform that is used for the automatic deployment process of nodes.
We are using Kubectl for this guide.
2. Validate the Kubectl binary by downloading the checksum file here:
curl –LO https://dl.k8s.io/v1.21.0/bin/windows/amd64/kubectl.exe.sha256
3. Test the Kubectl installer by running the following command:
Kubectl version –client
kubectl --kubeconfig=config-e044b4259991.yaml --insecure-skip-tls-verify get nodes
To set up the PostgreSQL cluster on Xelon, you need to use PostgreSQL’s latest installer. However, there are different versions of PostgreSQL out there, you can opt to use the version that suits your needs but we recommend you use the latest version with the required documentation for successful configuration. To configure PostgreSQL Enterprise Edition,
Now that you have installed the PostgreSQL installer, you need to install the .yaml directories on the config servers and router for the PostgreSQL operator.
Check the condition of the PostgreSQL system namespace by typing the following command:
kubectl get all -o wide -n PostgreSQL-system
You need a Helm compiler to deploy and manage yaml files for the Kubernetes setup. Helm is a package manager which helps in managing all the Kubernetes clusters created using the yaml files. It is an open-source project which aims at providing more efficient ways to manage Kubernetes YAML directories when deploying apps.
Before deploying PostgreSQL, we have to have a Kubernetes cluster which has been configured and running. In our case we will use the following cluster:
apiVersion: v1
kind: Config
clusters:
- name: "k8s-technical-writer-cluster"
cluster:
server: "https://explicitip/k8s/clusters/c-6n7xc"
certificate-authority-data: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJpVENDQ\
VM2Z0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQTdNUnd3R2dZRFZRUUtFeE5rZVc1aGJXbGoKY\
kdsemRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYldsamJHbHpkR1Z1WlhJdFkyRXdIa\
GNOTWpFdwpOVEUwTURreE5qSTBXaGNOTXpFd05URXlNRGt4TmpJMFdqQTdNUnd3R2dZRFZRUUtFe\
E5rZVc1aGJXbGpiR2x6CmRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYldsamJHbHpkR\
1Z1WlhJdFkyRXdXVEFUQmdjcWhrak8KUFFJQkJnZ3Foa2pPUFFNQkJ3TkNBQVFYVlk0eGVNNEtkc\
nQyNzhwclNRMTdKK3hhRnlQaEdPeUVaOUsvYzZpUApJSFRCN2tINSt3eWNEVjhHaWxxd0VYS3FkN\
WFvOVkrRElCQzNleTBTUVg5Rm95TXdJVEFPQmdOVkhROEJBZjhFCkJBTUNBcVF3RHdZRFZSMFRBU\
UgvQkFVd0F3RUIvekFLQmdncWhrak9QUVFEQWdOSkFEQkdBaUVBMWtCTjlrNEgKYzlpSXNrMVMyV\
3plQlhTNkRFWE9xKzJORWpFZnpCaG1EbUVDSVFDRHRYbUZrbG1oL2tENXAxL1A2OGhPdW5EUwo1e\
Xl0T2NvU25oQXVYaUE3enc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t"
users:
- name: "k8s-technical-writer-cluster"
user:
token: "kubeconfig-user-hvpzh:r57s2f6sqlqfmkmxmxmfznhqq5w5kfbvzns6z5fpns5rfdhfhllwn2"
contexts:
- name: "k8s-technical-writer-cluster"
context:
user: "k8s-technical-writer-cluster"
cluster: "k8s-technical-writer-cluster"
current-context: "k8s-technical-writer-cluster"
In this case, we will use the Chocolatey manager since we are using a Windows environment but if you are using a MAC PC, then you need to use Homebrew and apt/get for Ubuntu and Debian.
To install Helm on windows, run the following command on the Chocolatey package manager
choco install kubernetes
After this is done, you’re ready to deploy PostgreSQL on the Windows environment. The next thing to do is to verify the version you are using. To do this, simply run the following command:
Kubectl-version
Depending on your cluster choice, configuration options may change. PostgreSQL charts of options to choose from when deploying your cluster. Here we are going to show you how to change username, port, password, and database name as you deploy in the Xelon HQ.
Minimal yaml files needed
Three types of files are required for the setup. The user can simply run a single command by combining all files into one or running every command against separate files.
This file contains the container/image details that are pulled while deployment. It also includes CPU resources, secrets that are configured, volume mounts location (where to mount the path in the system).
Service yaml fileThis file is needed to expose internal pods via some external port. Usually the port and target port are the same. The only port that needs to be configured is the “node port“ and it can be any ephemeral port
The storage class is configured in the local storage which is already set up inside the Xelon HQ Kubernetes cluster.
kind: StorageClass
apiVersion: k8s-technical-writer-cluster.io/v1
metadata:
name: k8s-technical-writer-cluster
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: k8s-technical-writer-cluster
Now we need to define the persistent Volume which will use the designated Storage Class. Note, you need to follow the persistent volume with a persistent volume claim so that the cluster created can claim the volume.
Here is the persistent volume command which will be used to activate the storage class of the PostgreSQL cluster.
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv
labels:
app: postgres
type: local
spec:
storageClassName: k8s-technical-writer-cluster
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/var/data"
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pv-claim
labels:
app: postgres
spec:
storageClassName: microk8s-hostpath
capacity:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
Now that we have both the storage and persistent volume, we need to define the service so that we can expose the database according to our desires.
apiVersion: v1
kind: Service
metadata:
name: postgres-service
labels:
app: postgres
spec:
ports:
- port: 5432
name: postgres
type: NodePort
selector:
app: postgres
apiVersion: v1
kind: Config
clusters:
- name: "k8s-technical-writer-cluster"
cluster:
server: "https://explicitip/k8s/clusters/c-6n7xc"
certificate-authority-data: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJpVENDQ\
VM2Z0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQTdNUnd3R2dZRFZRUUtFeE5rZVc1aGJXbGoKY\
kdsemRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYldsamJHbHpkR1Z1WlhJdFkyRXdIa\
GNOTWpFdwpOVEUwTURreE5qSTBXaGNOTXpFd05URXlNRGt4TmpJMFdqQTdNUnd3R2dZRFZRUUtFe\
E5rZVc1aGJXbGpiR2x6CmRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYldsamJHbHpkR\
1Z1WlhJdFkyRXdXVEFUQmdjcWhrak8KUFFJQkJnZ3Foa2pPUFFNQkJ3TkNBQVFYVlk0eGVNNEtkc\
nQyNzhwclNRMTdKK3hhRnlQaEdPeUVaOUsvYzZpUApJSFRCN2tINSt3eWNEVjhHaWxxd0VYS3FkN\
WFvOVkrRElCQzNleTBTUVg5Rm95TXdJVEFPQmdOVkhROEJBZjhFCkJBTUNBcVF3RHdZRFZSMFRBU\
UgvQkFVd0F3RUIvekFLQmdncWhrak9QUVFEQWdOSkFEQkdBaUVBMWtCTjlrNEgKYzlpSXNrMVMyV\
3plQlhTNkRFWE9xKzJORWpFZnpCaG1EbUVDSVFDRHRYbUZrbG1oL2tENXAxL1A2OGhPdW5EUwo1e\
Xl0T2NvU25oQXVYaUE3enc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t"
users:
- name: "k8s-technical-writer-cluster"
user:
token: "kubeconfig-user-hvpzh:r57s2f6sqlqfmkmxmxmfznhqq5w5kfbvzns6z5fpns5rfdhfhllwn2"
contexts:
- name: "k8s-technical-writer-cluster"
context:
user: "k8s-technical-writer-cluster"
cluster: "k8s-technical-writer-cluster"
current-context: "k8s-technical-writer-cluster"
To release the PostgreSQL Cluster on Xelon Kubernetes, proceed with the exit command which will release the PostgreSQL cluster from the server where it is saved. For this, run sc.exe delete PostgreSQL command. The command will successfully release the cluster in the path in the Xelon HQ.
If you have any question how to use PostgreSQL in the Xelon HQ please feel free to contact our support team!