Cloud Native Development (CND) is about running your development flow entirely in kubernetes, avoiding the time-consuming docker build/push/pull/redeploy
cycle.
CND helps you achieve this with a mix of kubernetes automation, file synching between your local file system and kubernetes and hot reloading of containers.
This is how a standard dev environment looks like:
And this how it looks after converting it into a cloud native environment:
The cnd container duplicates the manifest of the api pod, so it is fully integrated with every Kubernetes feature.
Local changes are synched to the cnd container via ksync
. As you save locally, it will be automatically synched in your cnd container in seconds.
Once you're ready to integrate, you can revert back to your original configuration for general end-to-end testing before sending a PR or pushing to production.
The synching functionality of cnd is provided by ksync.
To install ksync
, execute:
curl https://vapor-ware.github.io/gimme-that/gimme.sh | bash
and:
ksync init --image=vaporio/ksync:0.3.2-hotfix
check the ksync
installation by executing:
ksync doctor
If ksync
is successfully installed, install cnd from by executing:
go get github.com/okteto/cnd
Note: these instructions assume that you already have a kubernetes-based application running.
Define your Cloud Native Development file (cnd.yml
). A cnd.yml
looks like this:
name: dev
swap:
deployment:
file: nginx-deployment.yml
container: nginx
image: ubuntu
service:
file: nginx-service.yml
mount:
source: .
target: /src
For more information about the Cloud Native Development file, see its reference.
To convert your dev environment to a cloud native environment, execute:
cnd up
by default, it uses a cnd.yml
in your current folder. For using a different file, execute:
cnd up -f path-to-cnd-file
To create a long-running session to your cloud native environment, execute:
cnd exec sh
You can also execute standalone commands like:
cnd exec go test
In order to revert back to your original configuration, execute:
cnd down
Switch back and forth your development mode as you wish by executing cnd up
and cnd down
.
Finally, in order to permanently remove your cloud native development, execute:
cnd rm
For a full demo of Cloud Native Development, check the Voting App demo.
cnd uses ksync and syncthing to sync files between your environments. If your cloud native environment is not being updated correctly, review the following:
- Verify that ksync is functioning correctly by running
ksync doctor
- Review ksync's logs (~/.ksync/daemon.log) for errors
- Browse to http://localhost:8384 to see if there are any syncthing-specific issues.
Please follow syncthing's docs to troubleshoot this.