Skip to content

Commit a43afe4

Browse files
authored
Merge pull request #243 from covexo/sync
Sync
2 parents 660e0c8 + b697412 commit a43afe4

3 files changed

Lines changed: 121 additions & 66 deletions

File tree

docs/docs/configuration/config.yaml.md

Lines changed: 110 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,57 @@ title: /.devspace/config.yaml
44

55
This is an example of a [.devspace/config.yaml](#)
66
```yaml
7+
# Devspace version, currently is always v1
78
version: v1
89
devSpace:
910
release:
11+
# Name of helm release that is used for deploying
12+
# the devspace chart (contents of /chart)
1013
name: my-project
14+
# Release namespace
1115
namespace: my-namespace
16+
# Automatically forwarded ports on `devspace up` (same functionality as running manually kubectl port-forward)
1217
portForwarding:
18+
# Currently only pod is supported
1319
- resourceType: pod
20+
# Map of key value matchLabel selectors
1421
labelSelector:
1522
release: my-app
23+
# Array of port mappings
1624
portMappings:
25+
# The local machine port
1726
- localPort: 3000
27+
# The selected pod port
1828
remotePort: 3000
1929
- localPort: 8080
2030
remotePort: 80
2131
sync:
32+
# Currently only resource type pod is supported
2233
- resourceType: pod
2334
labelSelector:
2435
release: my-app
36+
# Sync the complete local project path
2537
localSubPath: ./
38+
# Into the remote container path /app
2639
containerPath: /app
40+
# Exclude node_modules from up and download
41+
excludePaths:
42+
- node_modules/
43+
# A list of images that should be build during devspace up
2744
images:
2845
default:
46+
# Image name
2947
name: devspace-user/devspace
48+
# Image tag (auto-generated)
3049
tag: 9u5ye0G
50+
# Registry where the build image will be pushed to
3151
registry: default
3252
build:
3353
engine:
3454
docker:
55+
# Use docker for image building
3556
enabled: true
57+
# Use the minikube docker daemon, if the current kubectl context is minikube
3658
preferMinikube: true
3759
database:
3860
name: devspace-user/devspace
@@ -41,101 +63,149 @@ images:
4163
build:
4264
engine:
4365
kaniko:
66+
# Use kaniko within the target cluster to build the image
67+
# instead of local or minikube docker
4468
enabled: true
69+
# The registries the images should be pushed to
4570
registries:
4671
default:
4772
url: hub.docker.com
73+
# Internal registry that will be automatically deployed to the target
74+
# cluster if desired
4875
internal:
76+
# Auto-generated user and password
4977
user:
5078
username: user-XXXXX
5179
password: XXXXXXXXXX
80+
# Services that are used within the target cluster
5281
services:
82+
# The deployed internal registry within the cluster
5383
internalRegistry:
5484
release:
85+
# The helm release name of the internal registry
5586
name: devspace-registry
5687
namespace: my-namespace
88+
# Tiller server that should be used within the cluster
5789
tiller:
90+
# A list of namespaces where tiller is allowed to deploy namespaces to
5891
appNamespaces:
5992
- my-namespace
6093
release:
94+
# Namespace where the tiller server is located
6195
namespace: my-namespace
96+
# Target cluster configuration
6297
cluster:
98+
# Use the local kubectl client config
6399
useKubeConfig: true
64100
```
65101
A [.devspace/config.yaml](#) contains any public/shared configuration for running a DevSpace for the respective project. It is highly recommended to put this file under version control (e.g. git add).
66102
67103
**Note: You can easily re-configure your DevSpace by running `devspace init -r`.**
68104

69105
## devspace
70-
Defines your DevSpace including everything related to portForwarding, sync, and the release config.
106+
Defines the DevSpace including everything related to portForwarding, sync, and the helm release config.
71107

72108
### devspace.release
73109
Defines how the DevSpace is deployed to your cluster. See [Type: Release](#type-release) for details.
74110

75111
### devspace.portForwarding
76112
To access applications running inside a DevSpace, the DevSpace CLI allows to configure port forwardings. A port forwarding consists of the following:
77-
- `resourceType` (currently only `pod` is supported)
78-
- `labelSelector` (usually the release/app name)
79-
- a list of `portMappings` (each specifying a `localPort` on localhost and a `remotePort` within the DevSpace)
113+
- `resourceType` _string_ kubernetes resource type that is selected (currently only `pod` is supported)
114+
- `labelSelector` _map[string]string_ usually the release/app name
115+
- `portMappings` _PortMapping array_
116+
117+
### devspace.portForwarding[*].portMappings[*]
118+
PortMapping:
119+
- `localPort` _string_ on localhost
120+
- `remotePort` _string_ remote pod port
80121

81122
In the example above, you could open `localhost:8080` inside your browser to see the output of the application listening on port 80 within your DevSpace.
82123

83124
### devspace.sync
84125
To comfortably sync code to a DevSpace, the DevSpace CLI allows to configure real-time code synchronizations. A sync config consists of the following:
85-
- `resourceType` (currently only `pod` is supported)
86-
- `labelSelector` (usually the release/app name)
87-
- `localSubPath` (relative to your local project root)
88-
- `containerPath` (absolute path within your DevSpace)
89-
- `excludePaths` (for excluding files/folders from sync in .gitignore syntax)
90-
- `DownloadExcludePaths` (for excluding files/folders from download in .gitignore syntax)
91-
- `UploadExcludePaths` (for excluding files/folders from upload in .gitignore syntax)
126+
- `resourceType` _string_ kubernetes resource type that is selected (currently only `pod` is supported)
127+
- `labelSelector` _map[string]string_ usually the release/app name
128+
- `localSubPath` _string_ relative path to the folder that should be synced (default: path to your local project root)
129+
- `containerPath` _string_ absolute path within the container
130+
- `excludePaths` _string array_ paths to exclude files/folders from sync in .gitignore syntax
131+
- `downloadExcludePaths` _string array_ paths to exclude files/folders from download in .gitignore syntax
132+
- `uploadExcludePaths` _string array_ paths to exclude files/folders from upload in .gitignore syntax
92133

93-
In the example above, the entire code within the project would be synchronized with the folder `/app` inside the DevSpace.
134+
In the example above, the entire code within the project would be synchronized with the folder `/app` inside the DevSpace, with the exception of the `node_modules/` folder.
94135

95136
## images
96-
This section of the config defines a map of images that can be used in the helm chart that is deployed during `devspace up`. An image is defined by:
97-
- `name` of the image that is being pushed to the registry
98-
- `tag` stating the latest tag pushed to the registry
99-
- `registry` referencing one of the keys defined in the `registries` map
100-
- `build` defining the build procedure for this image
101-
102-
## images[*].build
103-
An image build is mainly defined by the build engine. There are 2 build engines currently supported:
104-
- `docker` uses the local Docker daemon or a Docker daemon running inside a Minikube cluster (if `preferMinikube` == true)
105-
- `kaniko` builds images in userspace within a build pod running inside the Kubernetes cluster
137+
This section of the config defines a map of images that can be used in the helm chart that is deployed during `devspace up`.
138+
139+
### images[*]
140+
An image is defined by:
141+
- `name` _string_ of the image that is being pushed to the registry
142+
- `tag` _string_ stating the latest tag pushed to the registry (auto-generated)
143+
- `registry` _string_ referencing one of the keys defined in the `registries` map
144+
- `build` _BuildConfig_ defines the build procedure for this image
145+
146+
### images[*].build
147+
BuildConfig:
148+
- `engine` _Engine_ The engine that should be used for building the image
149+
150+
### images[*].build.engine
151+
Engine:
152+
An image build is mainly defined by the build engine. There are 2 build engines currently supported (choose only one):
153+
- `docker` _DockerConfig_ uses the local Docker daemon or a Docker daemon running inside a Minikube cluster (if `preferMinikube` == true)
154+
- `kaniko` _KanikoConfig_ builds images in userspace within a build pod running inside the Kubernetes cluster
155+
156+
### images[*].build.engine.docker
157+
DockerConfig:
158+
- `enabled` _bool_ if true the local docker daemon is used for image building
159+
- `preferMinikube` _bool_ if true and the current kubectl context is minikube, the minikube docker daemon is used for image building
160+
161+
### images[*].build.engine.kaniko
162+
KanikoConfig:
163+
- `enabled` _bool_ if true a kaniko build pod is used for image building
164+
- `namespace` _string_ specifies the namespace where the build pod should be started
106165

107166
## registries
108167
This section of the config defines a map of image registries. You can use any external registry or link to the [services.internalRegistry](#services-internal-registry)
109-
- `url` of the registry (format: myregistry.com:port)
110-
- `user` credentials (`username`, `password`) for pushing to / pulling from the registry
111-
- `insecure` flag to allow pushing to registries without HTTPS
168+
169+
### registries[*]
170+
ImageRegistry:
171+
- `url` _string_ of the registry (format: myregistry.com:port)
172+
- `insecure` _bool_ flag to allow pushing to registries without HTTPS
173+
- `user` _RegistryUser_ credentials for pushing to / pulling from the registry
174+
175+
### registries[*].user
176+
RegistryUser:
177+
- `username` _string_ that should be used for pushing and pulling from the registry
178+
- `password` _string_ that should be used for pushing and pulling from the registry
112179

113180
## services
114-
Defines additional services for your DevSpace.
181+
Defines cluster services that the DevSpace uses.
115182

116183
### services.internalRegistry
117184
The `internalRegistry` is used to tell the DevSpace CLI to deploy a private registry inside the Kubernetes cluster:
118-
- `release` for deploying the registry (see [Type: Release](#type-release))
185+
- `release` _Release_ for deploying the registry (see [Type: Release](#type-release))
119186

120187
### services.tiller
121188
The `tiller` service is defined by:
122-
- `release` definition for tiller (see [Type: Release](#type-release))
123-
- `appNamespaces` defining a list of namespace that tiller may deploy applications to
189+
- `release` _Release_ definition for tiller (see [Type: Release](#type-release))
190+
- `appNamespaces` _string array_ defines a list of namespace that tiller may deploy applications to
124191

125192
## cluster
126193
The `cluster` field specifies:
127-
- `useKubeConfig` (yes to use the credentials defined in $HOME/.kube/config)
194+
- `useKubeConfig` _bool_ if true use the credentials defined in $HOME/.kube/config
195+
196+
If `useKubeConfig` is `false`, the following fields need to be specified:
197+
- `apiServer` _string_ (Kubernetes API-Server URL)
198+
- `caCert` _string_ (CaCert for the Kubernetes API-Server in PEM format)
199+
- `user` _ClusterUser_
128200

129-
If `useKubeConfig: false` is used, the following fields need to be specified:
130-
- `apiServer` (Kubernetes API-Server URL)
131-
- `caCert` (CaCert for the Kubernetes API-Server in PEM format)
132-
- `user` specifying the following:
133-
- `username`
134-
- `clientCert` (PEM format)
135-
- `clientKey` (PEM format)
201+
### cluster.user
202+
ClusterUser:
203+
- `username` _string_
204+
- `clientCert` _string_ (PEM format)
205+
- `clientKey` _string_ (PEM format)
136206

137207
## Type: Release
138208
A `release` is specified through:
139-
- `name` of the release
140-
- `namespace` to deploy the release to
141-
- `values` that are set during the deployment (contents of the values.yaml in helm)
209+
- `name` _string_ of the release
210+
- `namespace` _string_ to deploy the release to
211+
- `values` _map[string] any_ that are set during the deployment (contents of the values.yaml in helm)

pkg/devspace/sync/sync_config_test.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func createTestSyncClient(testLocalPath, testRemotePath string) *SyncConfig {
6363
}
6464

6565
func TestInitialSync(t *testing.T) {
66-
if runtime.GOOS == "windows" {
67-
t.Skip("Skipping test on windows")
66+
if runtime.GOOS != "linux" {
67+
t.Skip("Skipping test on non linux platform")
6868
}
6969

7070
remote, local, outside := initTestDirs(t)
@@ -116,13 +116,12 @@ func TestInitialSync(t *testing.T) {
116116
return
117117
}
118118

119-
//This seems to hang in travis
120119
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 10*time.Second)
121120
}
122121

123122
func TestNormalSync(t *testing.T) {
124-
if runtime.GOOS == "windows" {
125-
t.Skip("Skipping test on windows")
123+
if runtime.GOOS != "linux" {
124+
t.Skip("Skipping test on non linux systems")
126125
}
127126

128127
remote, local, outside := initTestDirs(t)
@@ -187,16 +186,12 @@ func TestNormalSync(t *testing.T) {
187186
t.Error(err)
188187
return
189188
}
190-
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 10*time.Second)
191-
189+
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 20*time.Second)
192190
}
193191

194192
func setExcludePaths(syncClient *SyncConfig, testCases testCaseList) {
195-
196193
syncClient.ExcludePaths = []string{}
197-
198194
syncClient.DownloadExcludePaths = []string{}
199-
200195
syncClient.UploadExcludePaths = []string{}
201196

202197
for _, testCase := range testCases {
@@ -298,7 +293,6 @@ func makeBasicTestCases() (testCaseList, testCaseList) {
298293
}
299294

300295
func makeRemoveAndRenameTestCases(filesToCheck testCaseList, foldersToCheck testCaseList) (testCaseList, testCaseList) {
301-
302296
for n, array := range [2]testCaseList{filesToCheck, foldersToCheck} {
303297
for _, f := range array {
304298

@@ -406,13 +400,10 @@ func makeRemoveAndRenameTestCases(filesToCheck testCaseList, foldersToCheck test
406400
foldersToCheck = append(foldersToCheck, renameFolderFromOutside...)
407401

408402
return filesToCheck, foldersToCheck
409-
410403
}
411404

412405
func makeRemoteTestCases(testCases testCaseList) testCaseList {
413-
414406
for _, f := range testCases {
415-
416407
if strings.Contains(f.path, "Upload") {
417408
f.path = strings.Replace(f.path, "Upload", "Download", -1)
418409
} else if strings.Contains(f.path, "Download") {
@@ -432,9 +423,7 @@ func makeRemoteTestCases(testCases testCaseList) testCaseList {
432423
}
433424

434425
func makeDeepTestCases(testCases testCaseList) testCaseList {
435-
436426
for _, f := range testCases {
437-
438427
if f.path == "testFolder" {
439428
continue
440429
}
@@ -452,7 +441,6 @@ func makeDeepTestCases(testCases testCaseList) testCaseList {
452441
}
453442

454443
func createTestFilesAndFolders(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList) error {
455-
456444
for _, f := range foldersToCheck {
457445
parentDir, err := getParentDir(local, remote, outside, f.editLocation)
458446
if err != nil {
@@ -482,7 +470,6 @@ func createTestFilesAndFolders(local string, remote string, outside string, file
482470
}
483471

484472
func removeSomeTestFilesAndFolders(local string, remote string, filesToCheck testCaseList, foldersToCheck testCaseList, removeSuffix string) (testCaseList, testCaseList, error) {
485-
486473
var completeSuffix string
487474
removeIfSuffixMatch := func(path string, f os.FileInfo, err error) error {
488475
if strings.HasSuffix(path, completeSuffix) {
@@ -520,11 +507,8 @@ func removeSomeTestFilesAndFolders(local string, remote string, filesToCheck tes
520507
}
521508

522509
func renameSomeTestFilesAndFolders(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList) (testCaseList, testCaseList, error) {
523-
524510
for n, array := range [2]testCaseList{filesToCheck, foldersToCheck} {
525-
526511
for n, f := range array {
527-
528512
if !strings.Contains(f.path, "_Rename") {
529513
continue
530514
}
@@ -572,7 +556,6 @@ func renameSomeTestFilesAndFolders(local string, remote string, outside string,
572556
}
573557

574558
array[n] = f
575-
576559
}
577560

578561
if n == 0 {

0 commit comments

Comments
 (0)