{"id":24203,"date":"2021-11-19T18:32:38","date_gmt":"2021-11-19T13:02:38","guid":{"rendered":"https:\/\/mobisoftinfotech.com\/resources\/?p=24203"},"modified":"2025-11-27T12:43:55","modified_gmt":"2025-11-27T07:13:55","slug":"install-postgresql-and-postgis-in-gke","status":"publish","type":"post","link":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke","title":{"rendered":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Though there are PostgreSQL Operators to fully manage PostgreSQL High Availability (HA) installations in Kubernetes (K8S), sometimes you don&#8217;t need HA. For many small applications, you just need a single instance of PostgreSQL with daily backup. For these cases, simple K8S deployment with persistent volume and once in 24 hours backup with K8S CronJob is fine. I will show you how to run a single instance of PostgreSQL with daily backups in this post.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">For this tutorial, I assume you have a K8S cluster on GCP and Kubectl configured on your local machine.&nbsp; If you don&#8217;t have one, please refer to this <\/span><a href=\"https:\/\/cloud.google.com\/kubernetes-engine\/docs\/quickstart\"><span style=\"font-weight: 400;\">Quickstart <\/span><\/a><span style=\"font-weight: 400;\">on Google Kubernetes Engine docs. Google also gives you $300 credit to explore Google Cloud Services, which should be more than sufficient to try out this tutorial.&nbsp;<\/span><\/p>\n\n\n\n<h2><b>Namespace<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">I am using a namespace called <span class=\"inline-code\">prod<\/span>.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\"><strong>Filename: namespace.yaml<\/strong><\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">apiVersion: v1\nkind: <span class=\"hljs-keyword\">Namespace<\/span>\n<span class=\"hljs-title\">metadata<\/span>:\n  <span class=\"hljs-title\">name<\/span>: <span class=\"hljs-title\">prod<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">To create the namespace, run the command:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">kubectl<\/span> <span class=\"hljs-selector-tag\">apply<\/span> <span class=\"hljs-selector-tag\">-f<\/span> <span class=\"hljs-selector-tag\">namespace<\/span><span class=\"hljs-selector-class\">.yaml<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">This should create the namespace for you.&nbsp;<\/span><\/p>\n\n\n\n<h2><b>K8S Secret<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Now we need to create a K8S secret so that we don&#8217;t have to specify the PostgreSQL user password in plain text.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Create a file named <span class=\"inline-code\">prod-postgresql-12-password.txt<\/span> and add a sufficiently complex password in it. Make sure that the file contains only 1 line, and you DO NOT put a line break (Enter) at the end of the line. Once the file is ready, you can run the following command to create the Kubernetes Secret:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl create secret --namespace=prod generic prod-pgsql<span class=\"hljs-number\">-12<\/span>-password \\\n  --<span class=\"hljs-keyword\">from<\/span>-file=password=.\/passwords\/prod-postgresql<span class=\"hljs-number\">-12<\/span>-password.txt<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\"><b>K8S Deployment and Service<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Next, we need to create the Persistent Volume, Deployment, and Service for PostgreSQL. We will put all of these in the same file so that we can refer to them together later.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\"><strong>Filename: postgresql-12.yaml<\/strong><\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">apiVersion: v1\n<span class=\"hljs-attr\">kind<\/span>: PersistentVolumeClaim\n<span class=\"hljs-attr\">metadata<\/span>:\n  name: pgsql12-volumeclaim\n  <span class=\"hljs-attr\">namespace<\/span>: prod\n<span class=\"hljs-attr\">spec<\/span>:\n  storageClassName: standard\n  <span class=\"hljs-attr\">accessModes<\/span>:\n    - ReadWriteOnce\n  <span class=\"hljs-attr\">resources<\/span>:\n    requests:\n      storage: <span class=\"hljs-number\">20<\/span>Gi\n---\napiVersion: apps\/v1\n<span class=\"hljs-attr\">kind<\/span>: Deployment\n<span class=\"hljs-attr\">metadata<\/span>:\n  name: pgsql12\n  <span class=\"hljs-attr\">namespace<\/span>: prod\n<span class=\"hljs-attr\">spec<\/span>:\n  replicas: <span class=\"hljs-number\">1<\/span>\n  <span class=\"hljs-attr\">selector<\/span>:\n    matchLabels:\n      app: pgsql12\n  <span class=\"hljs-attr\">strategy<\/span>:\n    type: Recreate\n  <span class=\"hljs-attr\">template<\/span>:\n    metadata:\n      labels:\n        app: pgsql12\n      <span class=\"hljs-attr\">namespace<\/span>: prod\n    <span class=\"hljs-attr\">spec<\/span>:\n      containers:\n        - name: postgres\n          <span class=\"hljs-attr\">image<\/span>: postgis\/postgis:<span class=\"hljs-number\">12<\/span><span class=\"hljs-number\">-3.1<\/span>\n          <span class=\"hljs-attr\">resources<\/span>:\n            requests:\n              memory: <span class=\"hljs-string\">\"1024Mi\"<\/span>\n              <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"250m\"<\/span>\n            <span class=\"hljs-attr\">limits<\/span>:\n              memory: <span class=\"hljs-string\">\"1024Mi\"<\/span>\n              <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"250m\"<\/span>\n          <span class=\"hljs-attr\">imagePullPolicy<\/span>: <span class=\"hljs-string\">\"IfNotPresent\"<\/span>\n          <span class=\"hljs-attr\">ports<\/span>:\n            - containerPort: <span class=\"hljs-number\">5432<\/span>\n          <span class=\"hljs-attr\">env<\/span>:\n            - name: POSTGRES_DB\n              <span class=\"hljs-attr\">value<\/span>: <span class=\"hljs-string\">\"postgresdb\"<\/span>\n            - name: POSTGRES_USER\n              <span class=\"hljs-attr\">value<\/span>: <span class=\"hljs-string\">\"pguser\"<\/span>\n            - name: POSTGRES_PASSWORD\n              <span class=\"hljs-attr\">valueFrom<\/span>:\n                secretKeyRef:\n                  name: prod-pgsql<span class=\"hljs-number\">-12<\/span>-password\n                  <span class=\"hljs-attr\">key<\/span>: password\n          <span class=\"hljs-attr\">volumeMounts<\/span>:\n            - mountPath: <span class=\"hljs-regexp\">\/var\/<\/span>lib\/postgresql\/data\n              <span class=\"hljs-attr\">name<\/span>: postgredb\n              <span class=\"hljs-attr\">subPath<\/span>: postgres\n      <span class=\"hljs-attr\">volumes<\/span>:\n        - name: postgredb\n          <span class=\"hljs-attr\">persistentVolumeClaim<\/span>:\n            claimName: pgsql12-volumeclaim\n---\napiVersion: v1\n<span class=\"hljs-attr\">kind<\/span>: Service\n<span class=\"hljs-attr\">metadata<\/span>:\n  name: pgsql12\n  <span class=\"hljs-attr\">namespace<\/span>: prod\n  <span class=\"hljs-attr\">labels<\/span>:\n    app: pgsql12\n<span class=\"hljs-attr\">spec<\/span>:\n  type: ClusterIP\n  <span class=\"hljs-attr\">ports<\/span>:\n    - protocol: TCP\n      <span class=\"hljs-attr\">port<\/span>: <span class=\"hljs-number\">5451<\/span>\n      <span class=\"hljs-attr\">targetPort<\/span>: <span class=\"hljs-number\">5432<\/span>\n  <span class=\"hljs-attr\">selector<\/span>:\n    app: pgsql12\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">Here we are creating 3 K8S objects:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><b>PersistentVolumeClaim <\/b><span style=\"font-weight: 400;\">of 20GB to hold our PostgreSQL data.<\/span><\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><b>Deployment, <\/b><span style=\"font-weight: 400;\">which runs <span class=\"inline-code\">postgis\/postgis:12-3.1<\/span> image so that we can use the wonderful PostGIS extension for GeoSpatial analysis along with PostgreSQL. Here we have assigned 1GB RAM and 1\/4th of the CPU core to this DB. To get better performance, you might need to increase this value depending on the kind of nodes you have in your K8S cluster.&nbsp;<\/span><\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><b>Service <\/b><span style=\"font-weight: 400;\">which exposes the PostgreSQL service at port 5451 using Cluster IP. Since this is specified as Cluster IP, one can&#8217;t connect to the database outside the cluster.&nbsp;<\/span><\/li>\n<\/ol>\n\n\n\n<p><span style=\"font-weight: 400;\">To create these objects, you can run the following command:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">kubectl<\/span> <span class=\"hljs-selector-tag\">apply<\/span> <span class=\"hljs-selector-tag\">-f<\/span> <span class=\"hljs-selector-tag\">postgresql-12<\/span><span class=\"hljs-selector-class\">.yaml<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">At this point, you should have PostgreSQL running inside your GKE cluster.&nbsp;<\/span><\/p>\n\n\n\n<h2><b>Port Forwarding<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">To connect to the database from your local machine, you need to set up temporary port forwarding. You can do the same using the following command:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">kubectl port-forward service\/pgsql12 <span class=\"hljs-number\">5451<\/span>:<span class=\"hljs-number\">5451<\/span> --<span class=\"hljs-keyword\">namespace<\/span>=<span class=\"hljs-title\">prod<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">At this point, the PostgreSQL server should be available on your <span class=\"inline-code\">localhost:5451<\/span> port. You can connect to it using the <span class=\"inline-code\">psql<\/span> command-line utility or using a GUI tool like DBeaver. You will need to use <span class=\"inline-code\">pguser<\/span> as the username and the password you used while creating the K8S secret.&nbsp;<\/span><\/p>\n\n\n\n<a href=\"https:\/\/mobisoftinfotech.com\/services\/hire-java-jee-programmers?utm_source=blog_cta&#038;utm_campaign=install-postgresql-and-postgis-in-gke-cta1\"><figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"120\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/Inline-cta-2.png\" alt=\"Extend your team with proven Java developers to create dynamic Java-based web and mobile apps.\" class=\"wp-image-24332\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"120\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20120%22%3E%3C%2Fsvg%3E\" alt=\"Extend your team with proven Java developers to create dynamic Java-based web and mobile apps.\" class=\"wp-image-24332 lazyload\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/Inline-cta-2.png\"><\/figure><\/a>\n\n\n\n<h2><b>Backup using K8S CronJob<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Now that we have the PostgreSQL Server running, we should set up a regular backup for our data. For that, we will use K8S CronJob. However, for this backup, we will need a custom script. So we will first need to create a Docker image for this backup script and then schedule it as a cron job.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">We will store the data in a GCP storage bucket. To write to this bucket, we will need a GCP service account and get its credentials as a JSON file. The process of setting a GCP service account is out of the scope of this tutorial. You can read more about service accounts <\/span><a href=\"https:\/\/cloud.google.com\/iam\/docs\/service-accounts\"><span style=\"font-weight: 400;\">here<\/span><\/a><span style=\"font-weight: 400;\">.&nbsp;<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>PgBackup Docker Image<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">To create a docker image, I have set up a folder structure like the following:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">pgbackup-k8s\n|\n| -- files\n|    | -- gcp-service-account.json\n|    | -- pgbackups.sh\n|\n| -- Dockerfile  \n<\/code><\/span><\/pre>\n\n\n<p><span style=\"font-weight: 400;\"><strong>Filename:&nbsp; pgbackups.sh<\/strong><\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">#!\/bin\/bash<\/span>\n<span class=\"hljs-comment\">#<\/span>\n<span class=\"hljs-comment\"># Backup a Postgresql database into a daily file.<\/span>\n<span class=\"hljs-comment\">#<\/span>\n\nTIMESTAMP=`date +<span class=\"hljs-string\">\"%Y-%m-%d-%H-%M\"<\/span>`\nBACKUP_DIR=\/tmp\/pgsql-backup\/<span class=\"hljs-string\">\"$TIMESTAMP\"<\/span>\nFILE_SUFFIX=-pg.sql\n\nHOST=$PGSQL_HOST\nPORT=$PGSQL_PORT\nUSER=$PGSQL_USER\nexport PGPASSWORD=<span class=\"hljs-string\">\"$PGSQL_PASS\"<\/span>\n\nGCLOUD_KEY_FILE=$GCLOUD_KEY_FILE\nBACKUP_BUCKET_LOC=$BACKUP_BUCKET_LOC\n\n<span class=\"hljs-comment\"># Remove backup dir if already exists<\/span>\nrm -rf $BACKUP_DIR\n\n<span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Listing db names\"<\/span>\n\nDBNAMES=<span class=\"hljs-string\">\"`\/usr\/bin\/psql -h \"<\/span>$HOST<span class=\"hljs-string\">\" -p \"<\/span>$PORT<span class=\"hljs-string\">\" -U \"<\/span>$USER<span class=\"hljs-string\">\" -l -A -F: | sed -ne \"<\/span>\/:\/ { \/Name:Owner\/d; \/template0\/d; s\/:.*$<span class=\"hljs-comment\">\/\/; p }\"`\"<\/span>\n\n<span class=\"hljs-keyword\">echo<\/span> $DBNAMES\n\n<span class=\"hljs-keyword\">for<\/span> MDB in $DBNAMES\n<span class=\"hljs-keyword\">do<\/span>\n        DATABASE=$MDB\n        FILE=`date +<span class=\"hljs-string\">\"%Y-%m-%d-%H-%M\"<\/span>`-$DATABASE${FILE_SUFFIX}\n\n        OUTPUT_DIR=${BACKUP_DIR}\n        mkdir -p ${OUTPUT_DIR}\n        OUTPUT_FILE=${OUTPUT_DIR}\/${FILE}\n\n        <span class=\"hljs-comment\"># do the database backup (dump)<\/span>\n        \/usr\/bin\/pg_dump -h $HOST -p $PORT -U $USER -F p -f ${OUTPUT_FILE} ${DATABASE}\n\n        <span class=\"hljs-comment\"># show the user the result<\/span>\n        <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"${OUTPUT_FILE} was created:\"<\/span>\n        ls -lh ${OUTPUT_FILE}\ndone\n\n<span class=\"hljs-comment\"># Zip backup<\/span>\ncd $BACKUP_DIR\nBACKUP_FILE=$PGSQL_HOST-$PGSQL_PORT-backup-${TIMESTAMP}.tar.gz\ntar -zcvf $BACKUP_FILE *.sql\n\ngcloud auth activate-service-account --key-file=$GCLOUD_KEY_FILE\ngsutil cp $BACKUP_FILE $BACKUP_BUCKET_LOC\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\"><strong>Filename: Dockerfile<\/strong><\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">FROM gcr.io\/google.com\/cloudsdktool\/cloud-sdk:alpine\n\nRUN apk --update add --no-cache postgresql-client\nRUN mkdir \/srv\/jobs\n\nENV PGSQL_HOST <span class=\"hljs-string\">\"127.0.0.1\"<\/span>\nENV PGSQL_PORT <span class=\"hljs-number\">5432<\/span>\nENV PGSQL_USER <span class=\"hljs-string\">\"postgres\"<\/span>\nENV PGSQL_PASS <span class=\"hljs-string\">\"\"<\/span>\nENV GCLOUD_KEY_FILE <span class=\"hljs-string\">\"\"<\/span>\nENV BACKUP_BUCKET_LOC <span class=\"hljs-string\">\"\"<\/span>\n\nCOPY files<span class=\"hljs-comment\">\/* \/srv\/jobs\/\n\nENTRYPOINT \"\/srv\/jobs\/pgbackups.sh\"\n<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">To build the docker image and to push it to your GCP private container registry, run the following commands:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">docker build -t pgbackup-k8s .\ndocker tag pgbackup-k8s gcr.io\/your-repo\/pgbackup-k8s\ndocker push gcr.io\/your-repo\/pgbackup-k8s<\/code><\/span><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">Note: If you want to know the process of setting a GCP Container Registry, please <\/span><a href=\"https:\/\/cloud.google.com\/container-registry\/docs\/quickstart\"><span style=\"font-weight: 400;\">click here<\/span><\/a><span style=\"font-weight: 400;\">.&nbsp;<\/span><\/p>\n\n\n\n<h2><b>PostgreSQL backup K8S CronJob<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Once the image is available in our private GCP container registry, we need to set up the K8S CronJob to run the backups periodically. For that, create the following file:<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\"><strong>filename: pgsql-12-backup-cronjob.yaml<\/strong><\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">apiVersion: batch\/v1\n<span class=\"hljs-attr\">kind<\/span>: CronJob\n<span class=\"hljs-attr\">metadata<\/span>:\n  name: pgsql12-k8s-backup\n  <span class=\"hljs-attr\">namespace<\/span>: prod\n<span class=\"hljs-attr\">spec<\/span>:\n  schedule: <span class=\"hljs-string\">\"0 0 * * *\"<\/span>\n  <span class=\"hljs-attr\">jobTemplate<\/span>:\n    spec:\n      template:\n        spec:\n          containers:\n          - name: pgsql12-k8s-backup-prod\n            <span class=\"hljs-attr\">image<\/span>: gcr.io\/mobisoftk8s\/pgbackup-k8s\n            <span class=\"hljs-attr\">resources<\/span>:\n              requests:\n                memory: <span class=\"hljs-string\">\"256Mi\"<\/span>\n                <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"10m\"<\/span>\n              <span class=\"hljs-attr\">limits<\/span>:\n                memory: <span class=\"hljs-string\">\"512Mi\"<\/span>\n                <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"30m\"<\/span>\n            <span class=\"hljs-attr\">env<\/span>:\n            - name: PGSQL_HOST\n              <span class=\"hljs-attr\">value<\/span>: pgsql12.prod\n            - name: PGSQL_PORT\n              <span class=\"hljs-attr\">value<\/span>: <span class=\"hljs-string\">\"5451\"<\/span>\n            - name: PGSQL_USER\n              <span class=\"hljs-attr\">value<\/span>: pguser\n            - name: GCLOUD_KEY_FILE\n              <span class=\"hljs-attr\">value<\/span>: <span class=\"hljs-string\">\"\/srv\/jobs\/gcp-service-account.json\"<\/span>\n            - name: BACKUP_BUCKET_LOC\n              <span class=\"hljs-attr\">value<\/span>: <span class=\"hljs-string\">\"gs:\/\/your-bucket\/pgsql12-backups\/\"<\/span>\n            - name: PGSQL_PASS\n              <span class=\"hljs-attr\">valueFrom<\/span>:\n                secretKeyRef:\n                  name: prod-pgsql<span class=\"hljs-number\">-12<\/span>-password\n                  <span class=\"hljs-attr\">key<\/span>: password\n            <span class=\"hljs-attr\">imagePullPolicy<\/span>: IfNotPresent\n          <span class=\"hljs-attr\">restartPolicy<\/span>: OnFailure\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">Here please pay attention to the environment variable values and make sure that those are correct as per your deployment.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">To create the CronJob run:<\/span><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">kubectl<\/span> <span class=\"hljs-selector-tag\">apply<\/span> <span class=\"hljs-selector-tag\">-f<\/span> <span class=\"hljs-selector-tag\">pgsql-12-backup-cronjob<\/span><span class=\"hljs-selector-class\">.yaml<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><span style=\"font-weight: 400;\">This will create the CronJob in your K8S cluster. It will run every midnight. If you want to run it right away to check how it works, you can log in to your GKE dashboard. Go to the CornJob deployment and run it by clicking on the <span class=\"inline-code\">Run Now<\/span> button in the top row.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">That&#8217;s it. This concludes our tutorial on how to run PostgreSQL on GKE along with PostGIS and a daily backup.&nbsp;<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>In Conclusion,<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Take advantage of our extensive experience and a decade of technical expertise to get started with this powerful and open-source container management system. At Mobisoft, we have seasoned technical professionals to help you utilize resources effectively using Kubernetes. You can get in touch with us for further deployment, development, and consulting for Kubernetes.<\/span><\/p>\n\n\n\n<a href=\"https:\/\/mobisoftinfotech.com\/contact-us?utm_source=blog&#038;utm_medium=install-postgresql-and-postgis-in-gke-cta2\"><figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"219\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/ctanew.png\" alt class=\"wp-image-24375\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"219\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20219%22%3E%3C%2Fsvg%3E\" alt class=\"wp-image-24375 lazyload\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/ctanew.png\"><\/figure><\/a>\n\n\n<div class=\"modern-author-card\">\n    <div class=\"author-card-content\">\n        <div class=\"author-info-section\">\n            <div class=\"author-avatar\">\n                <noscript><img decoding=\"async\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2022\/04\/Pritam1.jpg\" alt=\"Pritam Barhate\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"Pritam Barhate\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2022\/04\/Pritam1.jpg\" class=\" lazyload\">\n            <\/div>\n            <div class=\"author-details\">\n                <h3 class=\"author-name\">Pritam Barhate<\/h3>\n                <p class=\"author-title\">Head of Technology Innovation<\/p>\n                <a href=\"javascript:void(0);\" class=\"read-more-link read-more-btn\" onclick=\"toggleAuthorBio(this); return false;\">Read more <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"expand\" class=\"read-more-arrow down-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"expand\" class=\"read-more-arrow down-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <div class=\"author-bio-expanded\">\n                    <p>Pritam Barhate, with an experience of 14+ years in technology, heads Technology Innovation at <a href=\"https:\/\/mobisoftinfotech.com\" target=\"_blank\" rel=\"noopener\">Mobisoft Infotech<\/a>. He has a rich experience in design and development. He has been a consultant for a variety of industries and startups. At Mobisoft Infotech, he primarily focuses on technology resources and develops the most advanced solutions.<\/p>\n                    <div class=\"author-social-links\">\n                        <div class=\"social-icon\">\n                            <a href=\"https:\/\/www.linkedin.com\/in\/pritam-barhate-90b93414\/\" target=\"_blank\" rel=\"nofollow noopener\"><i class=\"icon-sprite linkedin\"><\/i><\/a>\n                            <a href=\"https:\/\/twitter.com\/pritambarhate\" target=\"_blank\" rel=\"nofollow noopener\"><i class=\"icon-sprite twitter\"><\/i><\/a>\n                        <\/div>\n                    <\/div>\n                    <a href=\"javascript:void(0);\" class=\"read-more-link read-less-btn\" onclick=\"toggleAuthorBio(this); return false;\" style=\"display: none;\">Read less <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"collapse\" class=\"read-more-arrow up-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"collapse\" class=\"read-more-arrow up-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <\/div>\n            <\/div>\n        <\/div>\n        <div class=\"share-section\">\n            <span class=\"share-label\">Share Article<\/span>\n            <div class=\"social-share-buttons\">\n                <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Finstall-postgresql-and-postgis-in-gke\" target=\"_blank\" class=\"share-btn facebook-share\"><i class=\"fa fa-facebook-f\"><\/i><\/a>\n                <a href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Finstall-postgresql-and-postgis-in-gke\" target=\"_blank\" class=\"share-btn linkedin-share\"><i class=\"fa fa-linkedin\"><\/i><\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Though there are PostgreSQL Operators to fully manage PostgreSQL High Availability (HA) installations in Kubernetes (K8S), sometimes you don&#8217;t need HA. For many small applications, you just need a single instance of PostgreSQL with daily backup. For these cases, simple K8S deployment with persistent volume and once in 24 hours backup with K8S CronJob is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":24328,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"","footnotes":""},"categories":[286],"tags":[2282,2283,768,391],"class_list":["post-24203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-k8s","tag-kubernetes","tag-postgis","tag-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)<\/title>\n<meta name=\"description\" content=\"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)\" \/>\n<meta property=\"og:description\" content=\"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\" \/>\n<meta property=\"og:site_name\" content=\"Mobisoft Infotech\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-19T13:02:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-27T07:13:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/og-how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"525\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Pritam Barhate\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/og-how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pritam Barhate\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\"},\"author\":{\"name\":\"Pritam Barhate\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\"},\"headline\":\"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)\",\"datePublished\":\"2021-11-19T13:02:38+00:00\",\"dateModified\":\"2025-11-27T07:13:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\"},\"wordCount\":884,\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\",\"keywords\":[\"K8S\",\"Kubernetes\",\"PostGIS\",\"PostgreSQL\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\",\"name\":\"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\",\"datePublished\":\"2021-11-19T13:02:38+00:00\",\"dateModified\":\"2025-11-27T07:13:55+00:00\",\"author\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\"},\"description\":\"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.\",\"breadcrumb\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\",\"contentUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png\",\"width\":855,\"height\":392,\"caption\":\"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobisoftinfotech.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/\",\"name\":\"Mobisoft Infotech\",\"description\":\"Discover Mobility\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\",\"name\":\"Pritam Barhate\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"caption\":\"Pritam Barhate\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)","description":"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke","og_locale":"en_US","og_type":"article","og_title":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)","og_description":"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.","og_url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke","og_site_name":"Mobisoft Infotech","article_published_time":"2021-11-19T13:02:38+00:00","article_modified_time":"2025-11-27T07:13:55+00:00","og_image":[{"width":1000,"height":525,"url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/og-how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","type":"image\/png"}],"author":"Pritam Barhate","twitter_card":"summary_large_image","twitter_image":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/og-how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","twitter_misc":{"Written by":"Pritam Barhate","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#article","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke"},"author":{"name":"Pritam Barhate","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee"},"headline":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)","datePublished":"2021-11-19T13:02:38+00:00","dateModified":"2025-11-27T07:13:55+00:00","mainEntityOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke"},"wordCount":884,"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","keywords":["K8S","Kubernetes","PostGIS","PostgreSQL"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke","url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke","name":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage"},"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","datePublished":"2021-11-19T13:02:38+00:00","dateModified":"2025-11-27T07:13:55+00:00","author":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee"},"description":"This tutorial describes how to run a single instance of PostgreSQL with daily backups and PostGIS in the Google Kubernetes Engine (GKE) cluster.","breadcrumb":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#primaryimage","url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","contentUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2021\/11\/how-to-install-postgreSQL-and-postGIS-in-google-kubernetes-engine.png","width":855,"height":392,"caption":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)"},{"@type":"BreadcrumbList","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/install-postgresql-and-postgis-in-gke#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobisoftinfotech.com\/resources\/"},{"@type":"ListItem","position":2,"name":"How to Install PostgreSQL and PostGIS in Google Kubernetes Engine (GKE)"}]},{"@type":"WebSite","@id":"https:\/\/mobisoftinfotech.com\/resources\/#website","url":"https:\/\/mobisoftinfotech.com\/resources\/","name":"Mobisoft Infotech","description":"Discover Mobility","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee","name":"Pritam Barhate","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","caption":"Pritam Barhate"}}]}},"_links":{"self":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/24203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/comments?post=24203"}],"version-history":[{"count":124,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/24203\/revisions"}],"predecessor-version":[{"id":45667,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/24203\/revisions\/45667"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media\/24328"}],"wp:attachment":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media?parent=24203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/categories?post=24203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/tags?post=24203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}