Skip to content

Commit ba4d0c9

Browse files
committed
Add examples
1 parent 1ed5614 commit ba4d0c9

18 files changed

Lines changed: 978 additions & 0 deletions

File tree

examples/kaniko/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Kaniko example
2+
3+
In this example is shown, how kaniko can be used instead of docker to build and push an docker image.

examples/kaniko/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
)
7+
8+
func handler(w http.ResponseWriter, r *http.Request) {
9+
fmt.Fprintf(w, "Hello World, I'm Golang!")
10+
}
11+
12+
func main() {
13+
http.HandleFunc("/", handler)
14+
http.ListenAndServe(":8080", nil)
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
logs/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: v1alpha1
2+
cluster:
3+
kubeContext: minikube
4+
namespace: test
5+
devSpace:
6+
deployments:
7+
- helm:
8+
chartPath: ./chart
9+
name: devspace-default
10+
ports:
11+
- labelSelector:
12+
release: devspace-default
13+
portMappings:
14+
- localPort: 3000
15+
remotePort: 3000
16+
sync:
17+
- containerPath: /app
18+
labelSelector:
19+
release: devspace-default
20+
localSubPath: ./
21+
uploadExcludePaths:
22+
- Dockerfile
23+
- .devspace/
24+
- chart/
25+
- node_modules/
26+
images:
27+
default:
28+
name: devspace
29+
registry: internal
30+
internalRegistry:
31+
deploy: true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
registries:
2+
internal:
3+
auth:
4+
password: 58prtrR8tjNS
5+
username: user-7IS6l
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Dockerfile
2+
.devspace/
3+
chart/
4+
node_modules/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:8.11.4
2+
3+
RUN mkdir /app
4+
WORKDIR /app
5+
6+
COPY package.json .
7+
RUN npm install
8+
9+
COPY . .
10+
11+
CMD ["npm", "start"]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Offline-Development example
2+
3+
This example shows you how to develop offline with a minikube setup. You have to run `devspace up` once while online to setup the environment correctly in your minikube cluster, but you can afterwards develop offline.
4+
5+
# Step 0: Prerequisites
6+
7+
In order to use this example, make sure you have a working minikube setup (you don't need an additional docker daemon, because devspace can use the internal minikube docker daemon). See [install minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) for more details.
8+
9+
# Step 1: Start DevSpace
10+
11+
This step has to be done once while being online. To deploy the application to minikube simply run `devspace up`. The output of the command should look similar to this:
12+
13+
```
14+
[DONE] √ Tiller started
15+
[DONE] √ Internal registry started
16+
[INFO] Building image 'devspace' with engine 'docker'
17+
[DONE] √ Authentication successful (10.102.46.101:5000)
18+
Sending build context to Docker daemon 6.144kB
19+
Step 1/7 : FROM node:8.11.4
20+
---> 8198006b2b57
21+
Step 2/7 : RUN mkdir /app
22+
---> Using cache
23+
---> 1b6632b2da50
24+
Step 3/7 : WORKDIR /app
25+
---> Using cache
26+
---> 20b4e5a1df9b
27+
Step 4/7 : COPY package.json .
28+
---> ee7f6e81e51d
29+
Step 5/7 : RUN npm install
30+
---> Running in e6ef4c082b0c
31+
npm notice created a lockfile as package-lock.json. You should commit this file.
32+
npm WARN node-js-sample@0.0.1 No repository field.
33+
34+
added 48 packages in 1.946s
35+
---> ff5be7678a3d
36+
Step 6/7 : COPY . .
37+
---> b20037e9623f
38+
Step 7/7 : CMD ["npm", "start"]
39+
---> Running in abd0c9294587
40+
---> f8d49e9378ff
41+
Successfully built f8d49e9378ff
42+
Successfully tagged 10.102.46.101:5000/devspace:oswQSfh
43+
The push refers to repository [10.102.46.101:5000/devspace]
44+
e4f99e03005a: Pushed
45+
c9515cc05f90: Pushed
46+
9ad0fa9ab2ad: Pushed
47+
10959d10898a: Pushed
48+
be0fb77bfb1f: Pushed
49+
63c810287aa2: Pushed
50+
2793dc0607dd: Pushed
51+
74800c25aa8c: Pushed
52+
ba504a540674: Pushed
53+
81101ce649d5: Pushed
54+
daf45b2cad9a: Pushed
55+
8c466bf4ca6f: Pushed
56+
oswQSfh: digest: sha256:af6f6f701136149dc303aad52c124ab8913015e8125ae68994e06325c327cc2e size: 2839
57+
[INFO] Image pushed to registry (10.102.46.101:5000)
58+
[DONE] √ Done building and pushing image 'devspace'
59+
[INFO] Deploying devspace-default with helm
60+
[DONE] √ Deployed helm chart (Release revision: 1)
61+
[DONE] √ Successfully deployed devspace-default
62+
[DONE] √ Port forwarding started on 3000:3000
63+
[DONE] √ Sync started on /go-workspace/src/github.com/covexo/devspace/examples/minikube <-> /app (Pod: test/devspace-default-6446cb6b8c-c2l2q)
64+
root@devspace-default-6446cb6b8c-c2l2q:/app#
65+
```
66+
67+
The command deployed a tiller server and internal registry and used the minikube docker daemon to build the dockerfile.
68+
69+
# Step 2: Start developing
70+
71+
You can now disconnect from the internet. 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!'.
72+
73+
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.
74+
75+
You can also exit the terminal and reopen it with `devspace up` without the need of an internet connection.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: my-app
2+
version: v0.0.1
3+
description: A Kubernetes-Native Application
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}
5+
labels:
6+
release: "{{ .Release.Name }}"
7+
spec:
8+
replicas: 1
9+
template:
10+
metadata:
11+
annotations:
12+
revision: "{{ .Release.Revision }}"
13+
labels:
14+
release: "{{ .Release.Name }}"
15+
spec:
16+
containers:
17+
- name: default
18+
image: "{{ .Values.containers.default.image }}"
19+
command:
20+
{{- range $index, $command := .Values.containers.default.command }}
21+
- "{{ $command }}"
22+
{{- end }}
23+
args:
24+
{{- range $index, $arg := .Values.containers.default.args }}
25+
- "{{ $arg }}"
26+
{{- end }}
27+
imagePullSecrets:
28+
{{- range $index, $secretName := .Values.pullSecrets }}
29+
- name: "{{ $secretName }}"
30+
{{- end }}

0 commit comments

Comments
 (0)