Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ func (cmd *InitCmd) addDefaultSyncConfig() {

func (cmd *InitCmd) configureRegistry() {
dockerUsername := ""
createInternalRegistryDefaultAnswer := "yes"

imageBuilder, err := docker.NewBuilder("", "", "", false)
if err == nil {
Expand All @@ -406,9 +405,6 @@ func (cmd *InitCmd) configureRegistry() {

if err == nil {
dockerUsername = dockerAuthConfig.Username
if dockerUsername != "" {
createInternalRegistryDefaultAnswer = "no"
}
}
} else {
// Set default build engine to kaniko, if no docker is installed
Expand All @@ -420,26 +416,10 @@ func (cmd *InitCmd) configureRegistry() {
}
}

// Only deploy registry in minikube
// Don't push image in minikube
if kubectl.IsMinikube() {
createInternalRegistry := cmd.flags.skipQuestions || cmd.flags.createInternalRegistry
if !createInternalRegistry {
createInternalRegistryAnswer := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
Question: "Should we create a private registry within your Kubernetes cluster for you? (yes | no)",
DefaultValue: createInternalRegistryDefaultAnswer,
ValidationRegexPattern: "^(yes)|(no)$",
})
createInternalRegistry = *createInternalRegistryAnswer == "yes"
}

if createInternalRegistry {
err := configure.InternalRegistry()
if err != nil {
log.Fatal(err)
}

return
}
cmd.defaultImage.SkipPush = configutil.Bool(true)
return
}

err = configure.Image(dockerUsername, cmd.flags.skipQuestions, cmd.flags.registryURL, cmd.flags.defaultImageName, cmd.flags.createPullSecret)
Expand Down
1 change: 1 addition & 0 deletions docs/docs/configuration/config.yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ An image is defined by:
- `name` *string* name of the image with registry url prefixed (e.g. dockerhubname/image, gcr.io/googleprojectname/image etc.)
- `createPullSecret` *bool* creates a pull secret in the cluster namespace if the credentials are available in the docker credentials store or specified under `registries[].auth`
- `registry` *string* Optional: registry references one of the keys defined in the `registries` map. If defined do not prefix the image name with the registry url
- `skipPush` *bool* if true the image push step is skipped for this image (useful for minikube setups see [minikube-example](https://github.com/covexo/devspace/tree/master/examples/minikube))
- `build` *BuildConfig* defines the build procedure for this image

### images[].build
Expand Down
5 changes: 1 addition & 4 deletions examples/minikube/.devspace/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ devSpace:
images:
default:
name: devspace
createPullSecret: true
registry: internal
internalRegistry:
deploy: true
skipPush: true
5 changes: 0 additions & 5 deletions examples/minikube/.devspace/overwrite.yaml

This file was deleted.

70 changes: 28 additions & 42 deletions examples/minikube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,46 @@ In order to use this example, make sure you have a working minikube setup (you d
To deploy the application to minikube simply run `devspace up`. The output of the command should look similar to this:

```
[DONE] √ Tiller started
[DONE] √ Internal registry started
[INFO] Create namespace test
[INFO] Building image 'devspace' with engine 'docker'
[DONE] √ Authentication successful (10.102.46.101:5000)
Sending build context to Docker daemon 6.144kB
Step 1/7 : FROM node:8.11.4
[DONE] √ Authentication successful (hub.docker.com)
Sending build context to Docker daemon 7.077MB
Step 1/8 : FROM node:8.11.4
---> 8198006b2b57
Step 2/7 : RUN mkdir /app
Step 2/8 : RUN mkdir /app
---> Using cache
---> 1b6632b2da50
Step 3/7 : WORKDIR /app
---> be8130ce594c
Step 3/8 : WORKDIR /app
---> Using cache
---> 20b4e5a1df9b
Step 4/7 : COPY package.json .
---> ee7f6e81e51d
Step 5/7 : RUN npm install
---> Running in e6ef4c082b0c
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN node-js-sample@0.0.1 No repository field.

added 48 packages in 1.946s
---> ff5be7678a3d
Step 6/7 : COPY . .
---> b20037e9623f
Step 7/7 : CMD ["npm", "start"]
---> Running in abd0c9294587
---> f8d49e9378ff
Successfully built f8d49e9378ff
Successfully tagged 10.102.46.101:5000/devspace:oswQSfh
The push refers to repository [10.102.46.101:5000/devspace]
e4f99e03005a: Pushed
c9515cc05f90: Pushed
9ad0fa9ab2ad: Pushed
10959d10898a: Pushed
be0fb77bfb1f: Pushed
63c810287aa2: Pushed
2793dc0607dd: Pushed
74800c25aa8c: Pushed
ba504a540674: Pushed
81101ce649d5: Pushed
daf45b2cad9a: Pushed
8c466bf4ca6f: Pushed
oswQSfh: digest: sha256:af6f6f701136149dc303aad52c124ab8913015e8125ae68994e06325c327cc2e size: 2839
[INFO] Image pushed to registry (10.102.46.101:5000)
---> a66cd053d094
Step 4/8 : COPY package.json .
---> Using cache
---> e84f0c80a89d
Step 5/8 : RUN npm install
---> Using cache
---> b972ec2c40f8
Step 6/8 : COPY . .
---> 867b7c08b0f4
Step 7/8 : EXPOSE 3000
---> Running in 50767081a2b8
---> e43d3516a051
Step 8/8 : CMD ["npm", "start"]
---> Running in 974c711c9c81
---> 687b0db6e4d5
Successfully built 687b0db6e4d5
Successfully tagged devspace:amodlCX
[INFO] Skip image push for devspace
[DONE] √ Done building and pushing image 'devspace'
[INFO] Deploying devspace-default with helm
[DONE] √ Tiller started
[DONE] √ Deployed helm chart (Release revision: 1)
[DONE] √ Successfully deployed devspace-default
[DONE] √ Finished deploying devspace-default
[DONE] √ Port forwarding started on 3000:3000
[DONE] √ Sync started on /go-workspace/src/github.com/covexo/devspace/examples/minikube <-> /app (Pod: test/devspace-default-6446cb6b8c-c2l2q)
root@devspace-default-6446cb6b8c-c2l2q:/app#
```

The command deployed a tiller server and internal registry and used the minikube docker daemon to build the dockerfile.
The command deployed a tiller server and used the minikube docker daemon to build the dockerfile.

Furthermore a bi-directional sync was started between the local folder `/go-workspace/src/github.com/covexo/devspace/examples/minikube` and `/app` within the docker container. Whenever you change a file in either of those two folders the change will be synchronized. In addition the container port 3000 was forwarded to your local port 3000.

Expand Down
5 changes: 1 addition & 4 deletions examples/offline-development/.devspace/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ devSpace:
images:
default:
name: devspace
registry: internal
createPullSecret: true
internalRegistry:
deploy: true
skipPush: true
5 changes: 0 additions & 5 deletions examples/offline-development/.devspace/overwrite.yaml

This file was deleted.

70 changes: 28 additions & 42 deletions examples/offline-development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,46 @@ In order to use this example, make sure you have a working minikube setup (you d
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:

```
[DONE] √ Tiller started
[DONE] √ Internal registry started
[INFO] Create namespace test
[INFO] Building image 'devspace' with engine 'docker'
[DONE] √ Authentication successful (10.102.46.101:5000)
Sending build context to Docker daemon 6.144kB
Step 1/7 : FROM node:8.11.4
[DONE] √ Authentication successful (hub.docker.com)
Sending build context to Docker daemon 7.077MB
Step 1/8 : FROM node:8.11.4
---> 8198006b2b57
Step 2/7 : RUN mkdir /app
Step 2/8 : RUN mkdir /app
---> Using cache
---> 1b6632b2da50
Step 3/7 : WORKDIR /app
---> be8130ce594c
Step 3/8 : WORKDIR /app
---> Using cache
---> 20b4e5a1df9b
Step 4/7 : COPY package.json .
---> ee7f6e81e51d
Step 5/7 : RUN npm install
---> Running in e6ef4c082b0c
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN node-js-sample@0.0.1 No repository field.

added 48 packages in 1.946s
---> ff5be7678a3d
Step 6/7 : COPY . .
---> b20037e9623f
Step 7/7 : CMD ["npm", "start"]
---> Running in abd0c9294587
---> f8d49e9378ff
Successfully built f8d49e9378ff
Successfully tagged 10.102.46.101:5000/devspace:oswQSfh
The push refers to repository [10.102.46.101:5000/devspace]
e4f99e03005a: Pushed
c9515cc05f90: Pushed
9ad0fa9ab2ad: Pushed
10959d10898a: Pushed
be0fb77bfb1f: Pushed
63c810287aa2: Pushed
2793dc0607dd: Pushed
74800c25aa8c: Pushed
ba504a540674: Pushed
81101ce649d5: Pushed
daf45b2cad9a: Pushed
8c466bf4ca6f: Pushed
oswQSfh: digest: sha256:af6f6f701136149dc303aad52c124ab8913015e8125ae68994e06325c327cc2e size: 2839
[INFO] Image pushed to registry (10.102.46.101:5000)
---> a66cd053d094
Step 4/8 : COPY package.json .
---> Using cache
---> e84f0c80a89d
Step 5/8 : RUN npm install
---> Using cache
---> b972ec2c40f8
Step 6/8 : COPY . .
---> 867b7c08b0f4
Step 7/8 : EXPOSE 3000
---> Running in 50767081a2b8
---> e43d3516a051
Step 8/8 : CMD ["npm", "start"]
---> Running in 974c711c9c81
---> 687b0db6e4d5
Successfully built 687b0db6e4d5
Successfully tagged devspace:amodlCX
[INFO] Skip image push for devspace
[DONE] √ Done building and pushing image 'devspace'
[INFO] Deploying devspace-default with helm
[DONE] √ Tiller started
[DONE] √ Deployed helm chart (Release revision: 1)
[DONE] √ Successfully deployed devspace-default
[DONE] √ Finished deploying devspace-default
[DONE] √ Port forwarding started on 3000:3000
[DONE] √ Sync started on /go-workspace/src/github.com/covexo/devspace/examples/offline-development <-> /app (Pod: test/devspace-default-6446cb6b8c-c2l2q)
root@devspace-default-6446cb6b8c-c2l2q:/app#
```

The command deployed a tiller server, internal registry and used the minikube docker daemon to build the dockerfile.
The command deployed a tiller server and used the minikube docker daemon to build the dockerfile.

Furthermore a bi-directional sync was started between the local folder `/go-workspace/src/github.com/covexo/devspace/examples/offline-development` and `/app` within the docker container. Whenever you change a file in either of those two folders the change will be synchronized. In addition the container port 3000 was forwarded to your local port 3000.

Expand Down
1 change: 1 addition & 0 deletions pkg/devspace/config/v1/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type ImageConfig struct {
Tag *string `yaml:"tag"`
Registry *string `yaml:"registry"`
CreatePullSecret *bool `yaml:"createPullSecret,omitempty"`
SkipPush *bool `yaml:"skipPush"`
Build *BuildConfig `yaml:"build"`
}

Expand Down
15 changes: 10 additions & 5 deletions pkg/devspace/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,16 @@ func Build(client *kubernetes.Clientset, generatedConfig *generated.Config, imag
return false, fmt.Errorf("Error during image build: %v", err)
}

err = imageBuilder.PushImage()
if err != nil {
return false, fmt.Errorf("Error during image push: %v", err)
}
if imageConf.SkipPush == nil || *imageConf.SkipPush == false {
err = imageBuilder.PushImage()
if err != nil {
return false, fmt.Errorf("Error during image push: %v", err)
}

log.Info("Image pushed to registry (" + displayRegistryURL + ")")
log.Info("Image pushed to registry (" + displayRegistryURL + ")")
} else {
log.Infof("Skip image push for %s", imageName)
}

// Update config
if *registryConf.URL != "" {
Expand All @@ -192,6 +196,7 @@ func Build(client *kubernetes.Clientset, generatedConfig *generated.Config, imag
generatedConfig.ImageTags[imageName] = imageTag

log.Done("Done building and pushing image '" + imageName + "'")

} else {
log.Infof("Skip building image '%s'", imageName)
}
Expand Down