Giter Site home page Giter Site logo

dev4devs-com / postgresql-operator Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 16.0 455 KB

Operator in Go developed using the Operator Framework to package, install, configure and manage a PostgreSQL database.

License: Apache License 2.0

Makefile 3.68% Dockerfile 0.20% Shell 0.27% Go 95.85%

postgresql-operator's People

Contributors

camilamacedo86 avatar pratikjagrut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

postgresql-operator's Issues

The PVC is no longer creating the PV.

Bug Report

What did you do?

The PVC is no longer creating the PV. So, we need to fix it. See that the postgresql is pending because is not possible to do the bound.

$ kubectl get events -n postgresql-operator
LAST SEEN   TYPE      REASON                 OBJECT                                      MESSAGE
<unknown>   Warning   FailedScheduling       pod/database-6896fdcbc-2dl4d                persistentvolumeclaim "database" not found
<unknown>   Warning   FailedScheduling       pod/database-6896fdcbc-2dl4d                persistentvolumeclaim "database" not found
<unknown>   Warning   FailedScheduling       pod/database-6896fdcbc-2dl4d                running "VolumeBinding" filter plugin for pod "database-6896fdcbc-2dl4d": pod has unbound immediate PersistentVolumeClaims
<unknown>   Warning   FailedScheduling       pod/database-6896fdcbc-g9dgj                persistentvolumeclaim "database" not found
<unknown>   Warning   FailedScheduling       pod/database-6896fdcbc-nlhc2                running "VolumeBinding" filter plugin for pod "database-6896fdcbc-nlhc2": pod has unbound immediate PersistentVolumeClaims
81s         Normal    SuccessfulCreate       replicaset/database-6896fdcbc               Created pod: database-6896fdcbc-2dl4d
81s         Normal    ScalingReplicaSet      deployment/database                         Scaled up replica set database-6896fdcbc to 1
5s          Normal    ExternalProvisioning   persistentvolumeclaim/database              waiting for a volume to be created, either by external provisioner "k8s.io/minikube-hostpath" or manually created by system administrator
<unknown>   Normal    Scheduled              pod/postgresql-operator-7cb8ccccd4-jrb5n    Successfully assigned postgresql-operator/postgresql-operator-7cb8ccccd4-jrb5n to minikube
97s         Normal    Pulling                pod/postgresql-operator-7cb8ccccd4-jrb5n    Pulling image "quay.io/camilamacedo86/postgresql-operator:test"
90s         Normal    Pulled                 pod/postgresql-operator-7cb8ccccd4-jrb5n    Successfully pulled image "quay.io/camilamacedo86/postgresql-operator:test"
90s         Normal    Created                pod/postgresql-operator-7cb8ccccd4-jrb5n    Created container postgresql-operator
89s         Normal    Started                pod/postgresql-operator-7cb8ccccd4-jrb5n    Started container postgresql-operator
98s         Normal    SuccessfulCreate       replicaset/postgresql-operator-7cb8ccccd4   Created pod: postgresql-operator-7cb8ccccd4-jrb5n
98s         Normal    ScalingReplicaSet      deployment/postgresql-operator              Scaled up replica set postgresql-operator-7cb8ccccd4 to 1
 $ kubectl get all -n postgresql-operator
NAME                                       READY   STATUS    RESTARTS   AGE
pod/database-6896fdcbc-2dl4d               0/1     Pending   0          78s
pod/postgresql-operator-7cb8ccccd4-jrb5n   1/1     Running   0          95s


NAME                                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE
service/database                      ClusterIP   10.100.130.78   <none>        5432/TCP            78s
service/postgresql-operator-metrics   ClusterIP   10.102.97.170   <none>        8383/TCP,8686/TCP   80s


NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/database              0/1     1            0           78s
deployment.apps/postgresql-operator   1/1     1            1           95s

NAME                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/database-6896fdcbc               1         1         0       78s
replicaset.apps/postgresql-operator-7cb8ccccd4   1         1         1       95s

.

.

GKE/EKS: mkdir: cannot create directory ‘/data/pgdata’: Permission denied

Question

I got this error in my GKE & EKS deployments by running make install, but it works well on my local minikube.
Through searching, I think this may be related to the securityContext setting.

Like this

 securityContext:
    runAsUser: 1000
    fsGroup: 2000

So this is what you mean about To install you need be logged in as a user with cluster privileges like the system:admin user. in README?

How can i add securityContext setting to Pod?

Any plan to upgrade the Operator from `v1beta1` to `v1`?

Question

What did you do?

Tried to install the Operator on OCP 4.9 using steps mentioned in redhat-developer/odo#4961.

What did you expect to see?

Operator to get installed and available for use

What did you see instead? Under which circumstances?

Copied from bugzilla

$ k logs catalog-operator-55f45c8665-zg6nn | grep apiextensions.k8s.io/v1beta1
E0825 15:50:44.863539       1 queueinformer_operator.go:290] sync {"update" "test/install-8qsnt"} failed: api-server resource not found installing CustomResourceDefinition backups.postgresql.dev4devs.com: GroupVersionKind apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition not found on the cluster. This API may have been deprecated and removed, see https://kubernetes.io/docs/reference/using-api/deprecation-guide/ for more information.
E0825 15:50:45.312012       1 queueinformer_operator.go:290] sync {"update" "test/install-8qsnt"} failed: api-server resource not found installing CustomResourceDefinition backups.postgresql.dev4devs.com: GroupVersionKind apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition not found on the cluster. This API may have been deprecated and removed, see https://kubernetes.io/docs/reference/using-api/deprecation-guide/ for more information.
E0825 15:50:46.116916       1 queueinformer_operator.go:290] sync {"update" "test/install-8qsnt"} failed: api-server resource not found installing CustomResourceDefinition backups.postgresql.dev4devs.com: GroupVersionKind apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition not found on the cluster. This API may have been deprecated and removed, see https://kubernetes.io/docs/reference/using-api/deprecation-guide/ for more information.
...

Environment

* postgresql-operator version: 0.1.1 (Current) (used the one from https://operatorhub.io/operator/postgresql-operator-dev4devs-com)

(Confused above with minikube)

  • postgresql-operator version: Used the one available on OCP 4.9
  • Kubernetes version information:
  • Kubernetes cluster kind: OpenShift 4.9

Additional context

Looking at redhat-openshift-ecosystem/community-operators-prod#138, it seems like the PostgreSQL Operator will no longer be installed on OCP 4.9 as it uses v1beta1 API. Are there plans to upgrade the Operator to use v1 API?

.

.

Implementation of Restore

Feature Request

In order of this project be able to a full life cycle we would like to implement the Restore feature which would be able to get the backup of the database and restore it.

NOTE: A new CR/CRD and controller should be created to achieve this.

.

.

.

.

SSL connection config

Question

Is SSL connection a configurable parameter when creating a postgres instance with this operator?

What did you do?

Deployed with default parameters, and I'm unable to connect with a client that requires SSL connections.

.

.

Start to check the status of the secondary objects to update the OK status

Feature Request

Is your feature request related to a problem? Please describe.

The OK status means just that the objects were created by it is not check if they are running.

Describe the solution you'd like

In order to update the CR's with the OK status would be great to check the status of the required objects first.

Is the tag 0.1.1 branch still works?

Question

Is the tag 0.1.1 branch still works for building iamge? and is the code works fun for postgresql function?

What did you do?

Build image with code in tag 0.1.1

  1. git clone https://github.com/dev4devs-com/postgresql-operator.git
  2. cd postgresql-operator
  3. git checkout 0.1.1
  4. make image-build-master failed
[root@kvm4ocp5 postgresql-operator]# make image-build-master
make: *** No rule to make target 'image-build-master'.  Stop.
  1. try to use operator-sdk still failed:
[root@kvm4ocp5 postgresql-operator]# operator-sdk build postgresql-operator:0.1.1
[Deprecation Notice] Operator SDK has a new CLI and project layout that is aligned with Kubebuilder.
See `operator-sdk init -h` and the following doc on how to scaffold a new project:
https://v0-19-x.sdk.operatorframework.io/docs/golang/quickstart/
To migrate existing projects to the new layout see:
https://sdk.operatorframework.io/docs/building-operators/golang/project_migration_guide/

go: github.com/operator-framework/[email protected] requires
	github.com/operator-framework/[email protected] requires
	github.com/operator-framework/[email protected] requires
	github.com/operator-framework/[email protected] requires
	bitbucket.org/ww/[email protected]: reading https://api.bitbucket.org/2.0/repositories/ww/goautoneg?fields=scm: 404 Not Found
FATA[0002] Failed to build operator binary: failed to exec []string{"go", "build", "-o", "/root/wxk/postgresql-operator/build/_output/bin/postgresql-operator", "-gcflags", "all=-trimpath=/root/wxk", "-asmflags", "all=-trimpath=/root/wxk", "github.com/dev4devs-com/postgresql-operator/cmd/manager"}: exit status 1 

What did you expect to see?

can successfully build the image postgresql-operator for 0.1.1

Environment

  • postgresql-operator version: 0.1.1
  • Kubernetes version information: OpenShit4.8
  • Kubernetes cluster kind:

Additional context

Integrate with Travis

Feature Request

Currently, the project is using Circle CI.
We would like to move forward to use Travis.

Operator projects using the removed APIs in k8s 1.22 requires changes.

Problem Description

Kubernetes has been deprecating API(s), which will be removed and are no longer available in 1.22. Operators projects using these APIs versions will not work on Kubernetes 1.22 or any cluster vendor using this Kubernetes version(1.22), such as OpenShift 4.9+. Following the APIs that are most likely your projects to be affected by:

  • apiextensions.k8s.io/v1beta1: (Used for CRDs and available since v1.16)
  • rbac.authorization.k8s.io/v1beta1: (Used for RBAC/rules and available since v1.8)
  • admissionregistration.k8s.io/v1beta1 (Used for Webhooks and available since v1.16)

Therefore, looks like this project distributes solutions in the repository and does not contain any version compatible with k8s 1.22/OCP 4.9. (More info). Following some findings by checking the distributions published:

NOTE: The above findings are only about the manifests shipped inside of the distribution. It is not checking the codebase.

How to solve

It would be very nice to see new distributions of this project that are no longer using these APIs and so they can work on Kubernetes 1.22 and newer and published in the community-operators collection. OpenShift 4.9, for example, will not ship operators anymore that do still use v1beta1 extension APIs.

Due to the number of options available to build Operators, it is hard to provide direct guidance on updating your operator to support Kubernetes 1.22. Recent versions of the OperatorSDK greater than 1.0.0 and Kubebuilder greater than 3.0.0 scaffold your project with the latest versions of these APIs (all that is generated by tools only). See the guides to upgrade your projects with OperatorSDK Golang, Ansible, Helm or the Kubebuilder one. For APIs other than the ones mentioned above, you will have to check your code for usage of removed API versions and upgrade to newer APIs. The details of this depend on your codebase.

If this projects only need to migrate the API for CRDs and it was built with OperatorSDK versions lower than 1.0.0 then, you maybe able to solve it with an OperatorSDK version >= v0.18.x < 1.0.0:

$ operator-sdk generate crds --crd-version=v1
INFO[0000] Running CRD generator.
INFO[0000] CRD generation complete.

Alternatively, you can try to upgrade your manifests with controller-gen (version >= v0.4.1) :

If this project does not use Webhooks:

$ controller-gen crd:trivialVersions=true,preserveUnknownFields=false rbac:roleName=manager-role paths="./..."

If this project is using Webhooks:

  1. Add the markers sideEffects and admissionReviewVersions to your webhook (Example with sideEffects=None and admissionReviewVersions={v1,v1beta1}: memcached-operator/api/v1alpha1/memcached_webhook.go):

  2. Run the command:

$ controller-gen crd:trivialVersions=true,preserveUnknownFields=false rbac:roleName=manager-role webhook paths="./..."

For further information and tips see the comment.

Storage class not working

Bug Report

What did you do?

I've followed the instructions and deployed the operator inside a custom namespace (postgresql-operator). Logs show it's working and when deploying a Database object inside the same namespace, it creates the deployment, service, and PVC objects, but the PVC hangs in pending status because it has no storage class.

What did you expect to see?

Running database with attached dynamically provisioned volume.

Environment

Kubernetes v1.19.7 running on rke
Postgres Operator by Dev4devs v0.1.1

I have already working storage and PostgreSQL databases working with that storage classes, but it seems that the mapping to the PVC doesn't work. Here is some additional output:

> kubectl get pods -n postgresql-operator
NAME                                   READY   STATUS    RESTARTS   AGE
my-database-5886cc5d7c-92fqc           0/1     Pending   0          11m
postgresql-operator-767db75547-6dlpc   1/1     Running   0          67m

> kubectl describe pvc -n postgresql-operator
Name:          my-database
Namespace:     postgresql-operator
StorageClass:
Status:        Pending
Volume:
Labels:        cr=my-database
               owner=postgresqloperator
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Mounted By:    my-database-5886cc5d7c-92fqc
Events:
  Type    Reason         Age                 From                         Message
  ----    ------         ----                ----                         -------
  Normal  FailedBinding  93s (x42 over 11m)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set

> kubectl get sc
NAME         PROVISIONER                                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
ceph-fs      rook-ceph.cephfs.csi.ceph.com              Delete          Immediate           false                  8d
nfs-client   cluster.local/nfs-nfs-client-provisioner   Delete          Immediate           true                   243d

I've read the docs, but nothing helps it seems. Any idea why? Or where to lookup?

Thanks!

Specify PVC Storage Class Name

Feature Request

Is your feature request related to a problem? Please describe.

I do not have default storage classes defined, and need to specify which storageclassname the pvc should request.

Describe the solution you'd like

Have the ability to specify the storageclassname in the CRD.

.

.

.

...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.