Skip to content

Commit 7ef05da

Browse files
Steve BoardwellShishir Narayan
Steve Boardwell
and
Shishir Narayan
authored
Use kustomize to create deployment resources (#65)
Use kustomize for deployment Co-authored-by: Shishir Narayan <[email protected]>
1 parent 8879217 commit 7ef05da

7 files changed

+38
-17
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ tags
7777
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
7878

7979
.idea
80-
deploy/secret.yaml
80+
deploy/secret.yaml
81+
# build artifact
82+
operator

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
# External PostgreSQL server operator for Kubernetes
22

33
## Features
4+
45
* Creates a database from a CR
56
* Creates a role with random username and password from a CR
67
* If the database exist, it will only create a role
78
* Multiple user roles can own one database
89
* Creates Kubernetes secret with postgres_uri in the same namespace as CR
910
* Support for AWS RDS and Azure Database for PostgresSQL
1011

11-
1212
## Cloud specific configuration
13+
1314
### AWS
15+
1416
In order for this operator to work correctly with AWS RDS, you need to set `POSTGRES_CLOUD_PROVIDER` to `AWS` either in
1517
the ext-postgres-operator kubernetes secret or directly in the deployment manifest (`operator.yaml`).
1618

1719
### Azure Database for PostgreSQL
20+
1821
In order for this operator to work correctly with Azure managed PostgreSQL database, two env variables needs to be provided for the operator:
22+
1923
* `POSTGRES_CLOUD_PROVIDER` set to `Azure`
2024
* `POSTGRES_DEFAULT_DATABASE` set to your default database, i.e. `postgres`
2125

2226
## Installation
27+
2328
This operator requires a Kubernetes Secret to be created in the same namespace as operator itself.
2429
Secret should contain these keys: POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASS, POSTGRES_URI_ARGS, POSTGRES_CLOUD_PROVIDER, POSTGRES_DEFAULT_DATABASE.
2530
Example:
@@ -43,18 +48,19 @@ data:
4348
To install the operator, follow the steps below.
4449
4550
1. Configure Postgres credentials for the operator in `deploy/secret.yaml`
46-
2. `kubectl apply -f deploy/crds/db.movetokube.com_postgres_crd.yaml`
47-
3. `kubectl apply -f deploy/crds/db.movetokube.com_postgresusers_crd.yaml`
48-
4. `kubectl apply -f deploy/namespace.yaml`
49-
5. `kubectl apply -f deploy/secret.yaml`
50-
6. `kubectl apply -f deploy/role.yaml`
51-
7. `kubectl apply -f deploy/role_binding.yaml`
52-
8. `kubectl apply -f deploy/service_account.yaml`
53-
9. `kubectl apply -f deploy/operator.yaml`
51+
2. Create namespace if needed with\
52+
`kubectl apply -f deploy/namespace.yaml`
53+
3. Apply the secret with\
54+
`kubectl apply -f deploy/secret.yaml`
55+
4. Create the operator with either\
56+
`kubectl kustomize deploy/ | apply -f -`\
57+
or by using [kustomize](https://github.com/kubernetes-sigs/kustomize) directly\
58+
`kustomize build deploy/ | apply -f -`
5459

5560
## CRs
5661

5762
### Postgres
63+
5864
```yaml
5965
apiVersion: db.movetokube.com/v1alpha1
6066
kind: Postgres
@@ -77,6 +83,7 @@ This creates a database called `test-db` and a role `test-db-group` that is set
7783
Reader and writer roles are also created. These roles have read and write permissions to all tables in the schemas created by the operator, if any.
7884

7985
### PostgresUser
86+
8087
```yaml
8188
apiVersion: db.movetokube.com/v1alpha1
8289
kind: PostgresUser
@@ -116,15 +123,20 @@ With the help of annotations it is possible to create annotation-based copies of
116123
For more information and an example, see [kubernetes-replicator#pull-based-replication](https://github.com/mittwald/kubernetes-replicator#pull-based-replication)
117124

118125
### Contribution
126+
119127
You can contribute to this project by opening a PR to merge to `master`, or one of the `vX.X.X` branches.
128+
120129
#### Branching
130+
121131
`master` branch contains the latest source code with all the features. `vX.X.X` contains code for the specific major versions.
122132
i.e. `v0.4.x` contains the latest code for 0.4 version of the operator. See compatibility matrix below.
123-
133+
124134
#### Tests
135+
125136
Please write tests and fix any broken tests before you open a PR. Tests should cover at least 80% of your code.
126137

127138
### Compatibility
139+
128140
Postgres operator uses Operator SDK, which uses kubernetes client. Kubernetes client compatibility with Kubernetes cluster
129141
can be found [here](https://github.com/kubernetes/client-go/blob/master/README.md#compatibility-matrix)
130142

@@ -134,5 +146,4 @@ Postgres operator compatibility with Operator SDK version is in the table below
134146
|-------------------------------|---------------------|--------------------|
135147
| `postgres-operator 0.4.x` | ✓ | - |
136148
| `postgres-operator 1.0.x` | - | ✓ |
137-
| `HEAD` | ✓ | - |
138-
149+
| `HEAD` | ✓ | - |

deploy/kustomization.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
namespace: operators
5+
6+
resources:
7+
- crds/db.movetokube.com_postgres_crd.yaml
8+
- crds/db.movetokube.com_postgresusers_crd.yaml
9+
- operator.yaml
10+
- role.yaml
11+
- role_binding.yaml
12+
- service_account.yaml

deploy/operator.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: ext-postgres-operator
5-
namespace: operators
65
spec:
76
replicas: 1
87
selector:

deploy/role_binding.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ metadata:
55
subjects:
66
- kind: ServiceAccount
77
name: ext-postgres-operator
8-
namespace: operators
98
roleRef:
109
kind: ClusterRole
1110
name: ext-postgres-operator

deploy/secret.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
name: ext-postgres-operator
5-
namespace: operators
65
type: Opaque
76
data:
87
POSTGRES_HOST: cG9zdGdyZXMuZGF0YWJhc2Vz

deploy/service_account.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ apiVersion: v1
22
kind: ServiceAccount
33
metadata:
44
name: ext-postgres-operator
5-
namespace: operators

0 commit comments

Comments
 (0)