-
Notifications
You must be signed in to change notification settings - Fork 20
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
Tutorial: How to Create a Development Environment with Realistic Data in Okteto #959
base: main
Are you sure you want to change the base?
Tutorial: How to Create a Development Environment with Realistic Data in Okteto #959
Conversation
❌ Deploy Preview for okteto-docs failed.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! My main suggestion is to use okteto deploy
instead of kubectl commands to deploy the environment. okteto/fastapi-snapshot-app#2 has those changes, I just tested it and it works
Using Okteto Volume Snapshots, you can quickly create development environments that include production or staging data—without manually copying databases or waiting for CI/CD pipelines. | ||
|
||
:::tip | ||
Volume Snapshots are also useful for loading test data when running tests in Okteto Test. If your tests require a database with preloaded data, you can configure your test environment to restore from a snapshot instead of initializing an empty database. This ensures consistency across test runs and reduces setup time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do a benchmark at some point but I wouldn't be surprise is there's a 5-10X difference
Volume Snapshots are also useful for loading test data when running tests in Okteto Test. If your tests require a database with preloaded data, you can configure your test environment to restore from a snapshot instead of initializing an empty database. This ensures consistency across test runs and reduces setup time. | |
Volume Snapshots are also useful for loading test data when running tests in Okteto Test. If your tests require a database with preloaded data, you can configure your test environment to restore from a snapshot instead of initializing an empty database. This ensures consistency across test runs and significantly reduces setup time. |
```console | ||
okteto kubeconfig | ||
kubectl apply -f manifests/ | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```console | |
okteto kubeconfig | |
kubectl apply -f manifests/ | |
``` | |
```console | |
okteto deploy |
|
||
Expected output: | ||
```console | ||
deployment.apps/fastapi-snapshot-demo created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we put the okteto output? (I can send a PR to the sample to use okteto.yaml and deploy)
deployment.apps/fastapi-snapshot-demo created | |
i Using clone-wars @ demo.okteto.dev as context | |
i Running stage 'kubectl apply -f manifests' | |
Executing command 'kubectl apply -f manifests'... | |
deployment.apps/fastapi-snapshot-demo unchanged | |
service/fastapi-snapshot-demo unchanged | |
persistentvolumeclaim/data unchanged | |
service/mongodb unchanged | |
statefulset.apps/mongodb unchanged | |
Command 'kubectl apply -f manifests' successfully executed | |
i Endpoints available: | |
- https://fastapi-snapshot-demo-cindy.example.okteto.com | |
✓ Development environment 'fastapi-snapshot-app' successfully deployed |
"ingredients": ["Flour", "Milk", "Sugar", "Vegetable Oil"] | ||
}' | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about a first step to put the endpoint on an env var, and then we use that for all the curls?
|
||
A Volume Snapshot will capture the database state at this moment. | ||
|
||
Create a new manifest file `snapshot.yml` in the `manifests` folder and add the following to it: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is currently available at the root of the repo, its the vol.yaml
file (I think). should we remove it? (or maybe we keep a separate branch with all the completed manifests?
spec: | ||
volumeSnapshotClassName: okteto-snapshot-class | ||
source: | ||
persistentVolumeClaimName: data-mongodb-0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
today, the sample creates a PVC called data
. do you want me to update it so it's called data-mongodb-0
instead?
- A **Kubernetes cluster with Okteto** installed | ||
- Familiarity with **Kubernetes manifests** | ||
- [kubectl](https://kubernetes.io/docs/tasks/tools/) installed on your machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to create the volumesnapshotclass that we use (https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes/). I believe we have docs for this, I don't think we create one by default when you install Okteto (which maybe we should?)
### 1. Create a New Namespace for Development | ||
|
||
```console | ||
okteto namespace create data-clone-$YOUR_OKTETO_USERNAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are no longer multitenant, the suffix is not needed by default. maybe we don't include it to keep it simpler?
cp manifests/{k8s.yml,mongo.yml} data-clone-manifest | ||
``` | ||
|
||
Update `mongo.yml` to reference the snapshot: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mongo.yml on the repo is diferent, it declares the volumeclaim first and then it uses it on the stateful set. do you want to change the sample to this model?
|
||
```console | ||
mkdir data-clone-manifest | ||
cp manifests/{k8s.yml,mongo.yml} data-clone-manifest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we include the manifests already on a separate folder ? or do you think there's value on the user manually modifying it as a learning experience?
Port of https://deploy-preview-1230--okteto-website.netlify.app/blog/how-to-create-and-use-data-clones-in-okteto-cloud/