|
| 1 | +# Quickstart kubectl example |
| 2 | + |
| 3 | +This example shows you how to develop a small node express application with devspace and devspace-cloud. |
| 4 | + |
| 5 | +# Step 0: Prerequisites |
| 6 | + |
| 7 | +In order to use this example, make sure you have docker installed and a docker registry where you can push to (hub.docker.com, gcr.io etc.). Make sure you are logged in to the registry via `docker login`. |
| 8 | + |
| 9 | +Exchange the image name in `.devspace/config.yaml` under `images.default.name` with the image name you want to use. Do the same thing in `kube/deployment.yaml` under `spec.template.spec.image`. Do **not** add a tag to those image names, because this will be done at runtime automatically. |
| 10 | + |
| 11 | +# Step 1: Start the devspace |
| 12 | + |
| 13 | +To deploy the application to the devspace-cloud simply run `devspace up`. The output of the command should look similar to this: |
| 14 | + |
| 15 | +``` |
| 16 | +[INFO] Building image 'fabian1991/quickstart' with engine 'docker' |
| 17 | +[DONE] √ Authentication successful (hub.docker.com) |
| 18 | +Sending build context to Docker daemon 20.99kB |
| 19 | +Step 1/7 : FROM node:8.11.4 |
| 20 | + ---> 8198006b2b57 |
| 21 | +Step 2/7 : RUN mkdir /app |
| 22 | + ---> Using cache |
| 23 | + ---> 2064997c60c5 |
| 24 | +Step 3/7 : WORKDIR /app |
| 25 | + ---> Using cache |
| 26 | + ---> 6faeba82e3d7 |
| 27 | +Step 4/7 : COPY package.json . |
| 28 | + ---> Using cache |
| 29 | + ---> cb24ee28e9eb |
| 30 | +Step 5/7 : RUN npm install |
| 31 | + ---> Using cache |
| 32 | + ---> a6ed836b6a83 |
| 33 | +Step 6/7 : COPY . . |
| 34 | + ---> f23d8c3c1c51 |
| 35 | +Step 7/7 : CMD ["npm", "start"] |
| 36 | + ---> Running in f1e2310d36e3 |
| 37 | + ---> 98fbe8f46c11 |
| 38 | +Successfully built 98fbe8f46c11 |
| 39 | +Successfully tagged fabian1991/quickstart:dk0dqqO |
| 40 | +The push refers to repository [docker.io/fabian1991/quickstart] |
| 41 | +28bb9f0f148c: Pushed |
| 42 | +090fce06793d: Layer already exists |
| 43 | +e342c5b21403: Layer already exists |
| 44 | +cbf8535e7a06: Layer already exists |
| 45 | +be0fb77bfb1f: Layer already exists |
| 46 | +63c810287aa2: Layer already exists |
| 47 | +2793dc0607dd: Layer already exists |
| 48 | +74800c25aa8c: Layer already exists |
| 49 | +ba504a540674: Layer already exists |
| 50 | +81101ce649d5: Layer already exists |
| 51 | +daf45b2cad9a: Layer already exists |
| 52 | +8c466bf4ca6f: Layer already exists |
| 53 | +dk0dqqO: digest: sha256:5e043c3d366676331f4ffe6a9b6f38cbc08338c25ef47789060564d3304153a2 size: 2839 |
| 54 | +[INFO] Image pushed to registry (hub.docker.com) |
| 55 | +[DONE] √ Done building and pushing image 'fabian1991/quickstart' |
| 56 | +[INFO] Deploying devspace-default with kubectl |
| 57 | +deployment.extensions/devspace created |
| 58 | +[DONE] √ Successfully deployed devspace-default |
| 59 | +[DONE] √ Port forwarding started on 3000:3000 |
| 60 | +[DONE] √ Sync started on /Users/fabiankramm/Programmieren/go-workspace/src/github.com/covexo/devspace/examples/quickstart-kubectl <-> /app (Pod:e388779b2b49465855bb0322057a9fff/devspace-5b5f977b77-49cjt) |
| 61 | +root@devspace-5b5f977b77-49cjt:/app# |
| 62 | +``` |
| 63 | + |
| 64 | +The command created a new kubernetes namespace for you in the devspace-cloud and deployed the `kube/deployment.yaml` to that namespace. It also created a new kubectl context for you. If you want to access kubernetes resources via kubectl in the devspace-cloud you can simply change your kubectl context via `kubectl config use-context $$devspace-context-name$$`. You can find the context name in `.devspace/config.yaml` under `cluster.kubeContext`. |
| 65 | + |
| 66 | +# Step 2: Start developing |
| 67 | + |
| 68 | +You can start the server now with `npm start` in the open terminal. Now navigate in your browser to `localhost:3000` and you should see the output 'Hello World!'. |
| 69 | + |
| 70 | +You can easily change any code within the `index.js` and restart the server with `npm start` and you should see the changes immediately, without the need of rebuilding the docker file or redeploying the chart. |
0 commit comments