-
Notifications
You must be signed in to change notification settings - Fork 3
🤖 feat: add CloudNativePG-backed CoderControlPlane example #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: coder | ||
| labels: | ||
| app.kubernetes.io/part-of: coder-k8s-example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # CloudNativePG-backed CoderControlPlane example | ||
|
|
||
| This example deploys a `CoderControlPlane` backed by a PostgreSQL cluster managed by [CloudNativePG](https://cloudnative-pg.io/). | ||
|
|
||
| It creates: | ||
|
|
||
| - a `coder` namespace | ||
| - a CloudNativePG `Cluster` named `coder-db` | ||
| - a `CoderControlPlane` named `coder` wired to the CloudNativePG app Secret (`coder-db-app`) | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - A Kubernetes cluster | ||
| - `kubectl` configured for that cluster | ||
| - `helm` | ||
|
|
||
| ## 1. Install the CloudNativePG operator | ||
|
|
||
| ```bash | ||
| helm repo add cnpg https://cloudnative-pg.github.io/charts | ||
| helm repo update | ||
| helm upgrade --install cnpg cnpg/cloudnative-pg \ | ||
| --namespace cnpg-system \ | ||
| --create-namespace | ||
| ``` | ||
|
|
||
| ## 2. Install the coder-k8s controller | ||
|
|
||
| Follow [Deploy the controller (in-cluster)](../../docs/how-to/deploy-controller.md), or run: | ||
|
|
||
| ```bash | ||
| kubectl create namespace coder-system | ||
| kubectl apply -f config/crd/bases/ | ||
| kubectl apply -f deploy/rbac.yaml | ||
| kubectl apply -f deploy/controller-deployment.yaml | ||
| kubectl rollout status deployment/coder-k8s-controller -n coder-system | ||
| ``` | ||
|
|
||
| ## 3. Deploy this example | ||
|
|
||
| ```bash | ||
| kubectl apply -f examples/cloudnativepg/ | ||
| ``` | ||
|
|
||
| The namespace manifest is prefixed (`00-namespace.yaml`) so `kubectl apply -f` creates `coder` before namespaced resources. | ||
|
|
||
| Wait for PostgreSQL and verify the generated Secret: | ||
|
|
||
| ```bash | ||
| kubectl -n coder wait --for=condition=Ready cluster/coder-db --timeout=10m | ||
| kubectl -n coder get secret coder-db-app | ||
| ``` | ||
|
|
||
| Wait for the `CoderControlPlane` deployment: | ||
|
|
||
| ```bash | ||
| kubectl -n coder rollout status deployment/coder --timeout=10m | ||
| kubectl -n coder get codercontrolplane coder | ||
| ``` | ||
|
|
||
| ## 4. Access Coder | ||
|
|
||
| In one terminal: | ||
|
|
||
| ```bash | ||
| kubectl -n coder port-forward svc/coder 8080:80 | ||
| ``` | ||
|
|
||
| Then open: | ||
|
|
||
| - <http://localhost:8080/setup> | ||
|
|
||
| Use the setup flow to create the first admin user. | ||
|
|
||
| ## Important limitation of this quickstart | ||
|
|
||
| This example sets: | ||
|
|
||
| - `CODER_ACCESS_URL=http://localhost:8080` | ||
|
|
||
| That value is convenient for UI smoke tests through `kubectl port-forward`, but it is not suitable for end-to-end workspace connectivity because in-cluster components cannot reach your local `localhost`. | ||
|
|
||
| For a full setup, expose Coder with an ingress/load balancer and set `CODER_ACCESS_URL` to a real external URL (for example, `https://coder.example.com`). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: coder-db | ||
| namespace: coder | ||
| spec: | ||
| instances: 1 | ||
| storage: | ||
| size: 5Gi | ||
| bootstrap: | ||
| initdb: | ||
| database: coder | ||
| owner: coder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: coder.com/v1alpha1 | ||
| kind: CoderControlPlane | ||
| metadata: | ||
| name: coder | ||
| namespace: coder | ||
| spec: | ||
| replicas: 1 | ||
| service: | ||
| type: ClusterIP | ||
| port: 80 | ||
| extraEnv: | ||
| - name: CODER_PG_CONNECTION_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: coder-db-app | ||
| key: uri | ||
| - name: CODER_ACCESS_URL | ||
| value: http://localhost:8080 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.