Skip to content

Commit 18d6d8a

Browse files
authored
Merge pull request #297 from covexo/examples
Examples
2 parents 73f7b33 + bfff6e7 commit 18d6d8a

126 files changed

Lines changed: 15596 additions & 518 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/enter.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ type EnterCmd struct {
1616

1717
// EnterCmdFlags are the flags available for the enter-command
1818
type EnterCmdFlags struct {
19-
container string
19+
container string
20+
namespace string
21+
labelSelector string
2022
}
2123

2224
func init() {
@@ -37,12 +39,16 @@ devspace:
3739
devspace enter
3840
devspace enter bash
3941
devspace enter -c myContainer
42+
devspace enter bash -n my-namespace
43+
devspace enter bash -l release=test
4044
#######################################################`,
4145
Run: cmd.Run,
4246
}
4347
rootCmd.AddCommand(cobraCmd)
4448

4549
cobraCmd.Flags().StringVarP(&cmd.flags.container, "container", "c", "", "Container name within pod where to execute command")
50+
cobraCmd.Flags().StringVarP(&cmd.flags.namespace, "namespace", "n", "", "Namespace where to select pods")
51+
cobraCmd.Flags().StringVarP(&cmd.flags.labelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
4652
}
4753

4854
// Run executes the command logic
@@ -55,5 +61,5 @@ func (cmd *EnterCmd) Run(cobraCmd *cobra.Command, args []string) {
5561
log.Fatalf("Unable to create new kubectl client: %v", err)
5662
}
5763

58-
services.StartTerminal(cmd.kubectl, cmd.flags.container, args, log.GetInstance())
64+
services.StartTerminal(cmd.kubectl, cmd.flags.container, cmd.flags.labelSelector, cmd.flags.namespace, args, log.GetInstance())
5965
}

cmd/reset.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func init() {
3434
#######################################################
3535
Resets your project by removing all DevSpace related
3636
data from your project and your cluster, including:
37-
1. DevSpace release (cluster)
38-
2. Docker registry (cluster)
37+
1. DevSpace deployments
38+
2. Docker registry (if deployed)
3939
3. DevSpace config files in .devspace/ (local)
4040
4141
Use the flag --all-data to also remove:
42-
1. Tiller server (cluster)
43-
2. Helm home (local)
42+
1. Tiller server (if deployed)
43+
2. Helm home (if helm is used)
4444
4545
If you simply want to shutdown your DevSpace, use the
4646
command: devspace down

cmd/up.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ type UpCmdFlags struct {
4242
build bool
4343
sync bool
4444
deploy bool
45+
switchContext bool
4546
portforwarding bool
4647
verboseSync bool
4748
container string
49+
labelSelector string
50+
namespace string
4851
}
4952

5053
//UpFlagsDefault are the default flags for UpCmdFlags
@@ -54,10 +57,13 @@ var UpFlagsDefault = &UpCmdFlags{
5457
initRegistries: true,
5558
build: false,
5659
sync: true,
60+
switchContext: false,
5761
deploy: false,
5862
portforwarding: true,
5963
verboseSync: false,
6064
container: "",
65+
namespace: "",
66+
labelSelector: "",
6167
}
6268

6369
const clusterRoleBindingName = "devspace-users"
@@ -75,9 +81,9 @@ func init() {
7581
#################### devspace up ######################
7682
#######################################################
7783
Starts and connects your DevSpace:
78-
1. Connects to the Tiller server
79-
2. Builds your Docker image (if your Dockerfile has changed)
80-
3. Deploys the Helm chart in /chart
84+
1. Builds your Docker images (if any Dockerfile has changed)
85+
2. Deploys your application via helm or kubectl
86+
3. Forwards container ports to the local computer
8187
4. Starts the sync client
8288
5. Enters the container shell
8389
#######################################################`,
@@ -93,6 +99,9 @@ Starts and connects your DevSpace:
9399
cobraCmd.Flags().BoolVar(&cmd.flags.verboseSync, "verbose-sync", cmd.flags.verboseSync, "When enabled the sync will log every file change")
94100
cobraCmd.Flags().BoolVar(&cmd.flags.portforwarding, "portforwarding", cmd.flags.portforwarding, "Enable port forwarding")
95101
cobraCmd.Flags().BoolVarP(&cmd.flags.deploy, "deploy", "d", cmd.flags.deploy, "Force chart deployment")
102+
cobraCmd.Flags().BoolVar(&cmd.flags.switchContext, "switch-context", cmd.flags.switchContext, "Switch kubectl context to the devspace context")
103+
cobraCmd.Flags().StringVarP(&cmd.flags.namespace, "namespace", "n", "", "Namespace where to select pods")
104+
cobraCmd.Flags().StringVarP(&cmd.flags.labelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
96105
}
97106

98107
// Run executes the command logic
@@ -114,7 +123,7 @@ func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {
114123
}
115124

116125
// Create kubectl client
117-
cmd.kubectl, err = kubectl.NewClient()
126+
cmd.kubectl, err = kubectl.NewClientWithContextSwitch(cmd.flags.switchContext)
118127
if err != nil {
119128
log.Fatalf("Unable to create new kubectl client: %v", err)
120129
}
@@ -155,7 +164,7 @@ func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {
155164
}()
156165
}
157166

158-
services.StartTerminal(cmd.kubectl, cmd.flags.container, args, log.GetInstance())
167+
services.StartTerminal(cmd.kubectl, cmd.flags.container, cmd.flags.labelSelector, cmd.flags.namespace, args, log.GetInstance())
159168
}
160169

161170
func (cmd *UpCmd) ensureNamespace() error {
@@ -189,7 +198,7 @@ func (cmd *UpCmd) ensureClusterRoleBinding() error {
189198

190199
_, err := cmd.kubectl.RbacV1beta1().ClusterRoleBindings().Get(clusterRoleBindingName, metav1.GetOptions{})
191200
if err != nil {
192-
clusterConfig, _ := kubectl.GetClientConfig()
201+
clusterConfig, _ := kubectl.GetClientConfig(false)
193202
if clusterConfig.AuthProvider != nil && clusterConfig.AuthProvider.Name == "gcp" {
194203
createRoleBinding := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
195204
Question: "Do you want the ClusterRoleBinding '" + clusterRoleBindingName + "' to be created automatically? (yes|no)",

docs/docs/cli/add.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
title: devspace add
33
---
44

5-
With `devspace add`, you can add ports for portForwarding and paths to the sync configuration.
5+
With `devspace add`, you can add ports for portForwarding, deployments, packages and paths to the sync configuration.
66

77
```bash
88
Usage:
99
devspace add [command]
1010

1111
Available Commands:
12+
deployment Add a deployment
1213
package Add a helm chart
13-
port Lists port forwarding configuration
14+
port Add a new port forward configuration
1415
sync Add a sync path to the devspace
1516

1617
Flags:
1718
-h, --help help for add
19+
20+
Use "devspace add [command] --help" for more information about a command.
1821
```

docs/docs/cli/add_package.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: devspace add package
33
---
44

5-
With `devspace add package`, you can easily add a package (helm chart) like mysql, nginx etc. to your devspace. To view all available packages run `devspace add package`.
5+
With `devspace add package`, you can easily add a package (helm chart) like mysql, nginx etc. to a deployment in your devspace (Only works if deployment method is helm). To view all available packages run `devspace add package`.
66

77
The devspace add package command adds the helm chart as a dependency in the requirements.yaml and calls the internal `helm dependency update` (helm doesn't need to be installed), which downloads the chart and places it in the chart/charts folder. To remove the dependency call `devspace remove package PACKAGE`.
88

@@ -15,12 +15,13 @@ Usage:
1515
Flags:
1616
--app-version string App version
1717
--chart-version string Chart version
18+
-d, --deployment string The deployment name to use
1819
-h, --help help for package
1920
--skip-question Skips the question to show the readme in a browser
2021
2122
Examples:
2223
devspace add package # Shows all available packages
2324
devspace add package mysql # Adds the mysql chart to the devspace
2425
devspace add package mysql --app-version=5.7.14 # Adds the mysql chart with app version 5.7.14 to the devspace
25-
devspace add package mysql --chart-version=0.10.3 # Adds the mysql chart with chart version 0.10.3 to the devspace
26+
devspace add package mysql --chart-version=0.10.3 -d devspace-default # Adds the mysql chart with chart version 0.10.3 to the devspace
2627
```

docs/docs/cli/down.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: devspace down
33
---
44

5-
Run `devspace down` to shutdown your DevSpace.
5+
Run `devspace down` to shutdown your DevSpace. Stops your DevSpace by removing the release via helm (if deployment method is helm) or by running kubectl delete over the manifests. If you want to remove all DevSpace related data from your project, use: devspace reset.
66

77
```bash
88
Usage:

docs/docs/cli/enter.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ Usage:
99
devspace enter [flags]
1010

1111
Flags:
12-
-c, --container string Container name within pod where to execute command
13-
-h, --help help for enter
12+
-c, --container string Container name within pod where to execute command
13+
-h, --help help for enter
14+
-l, --label-selector string Comma separated key=value selector list (e.g. release=test)
15+
-n, --namespace string Namespace where to select pods
1416

1517
Examples:
1618
devspace enter
1719
devspace enter bash
18-
devspace enter echo 123
1920
devspace enter -c myContainer
21+
devspace enter echo 123 -n my-namespace
22+
devspace enter bash -l release=test
2023
```

docs/docs/cli/init.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: devspace init
44

55
Run `devspace init` to get your project ready to start a DevSpace.
66

7-
```bash
7+
```
88
Usage:
99
devspace init [flags]
1010
@@ -13,15 +13,14 @@ Flags:
1313
-l, --language string Programming language of your project
1414
-o, --overwrite Overwrite existing chart files and Dockerfile
1515
-r, --reconfigure Change existing configuration
16-
--templateRepoPath string Local path for cloning chart template repository (uses temp folder
17-
if not specified)
16+
--templateRepoPath string Local path for cloning chart template repository (uses temp folder if not specified)
1817
--templateRepoUrl string Git repository for chart templates (default "https://github.com/covexo/devspace-templates.git")
1918
```
2019

2120
## File Structure
2221
Running `devspace init` will create the following files for you:
2322

24-
```bash
23+
```
2524
YOUR_PROJECT_PATH/
2625
|
2726
|-- Dockerfile
@@ -31,11 +30,8 @@ YOUR_PROJECT_PATH/
3130
| |-- values.yaml
3231
| |-- templates/
3332
| |-- deployment.yaml
34-
| |-- service.yaml
35-
| |-- ingress.yaml
3633
|
3734
|-- .devspace/
3835
| |-- .gitignore
39-
| |-- cluster.yaml
4036
| |-- config.yaml
4137
```

docs/docs/cli/remove_package.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: devspace remove package
33
---
44

5-
With `devspace remove package`, you can remove a package from the devspace.
5+
With `devspace remove package`, you can remove a package from a devspace deployment.
66

77
`devspace remove package` deletes the specified packagename from the chart/requirements.yaml and executes the internal `helm dependency update` function.
88

@@ -11,6 +11,7 @@ Usage:
1111
devspace remove package [flags]
1212
1313
Flags:
14-
--all Remove all packages
15-
-h, --help help for package
14+
--all Remove all packages
15+
-d, --deployment string The deployment name to use
16+
-h, --help help for package
1617
```

docs/docs/cli/up.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,36 @@
22
title: devspace up
33
---
44

5-
With `devspace up`, you build your image, start your DevSpace and connect to it.
5+
With `devspace up`, the defined images are build, deployments are deployed and services started.
66

77
The command will do the following:
88

9-
1. Ensure that a tiller server is available (if not it will automatically deploy one to the specified namespace)
10-
2. Optionally it will deploy a docker registry if this was desired
11-
3. Build the docker image if changed or forced by -b
12-
* Push the built image to the specified registry
13-
5. Redeploy the chart if release was not found, image was rebuilt or -d option was specified
14-
6. Establish port forwarding and sync
15-
7. Execute the specified command in the container (default: open a terminal)
9+
1. Build the specified images using docker or kaniko
10+
2. Push the built images to the corresponding registries (either to a local or remote registry)
11+
3. Deploy the configured deployments via helm or kubectl
12+
4. Establish port forwarding and sync
13+
5. Execute the specified command in the selected container (default: open a terminal)
1614

17-
```bash
15+
```
1816
Usage:
1917
devspace up [flags]
2018
2119
Flags:
22-
-b, --build Force image build
23-
-c, --container string Container name where to open the shell
24-
-d, --deploy Force chart deployment
25-
-h, --help help for up
26-
--init-registries Initialize registries (and install internal one) (default true)
27-
--no-sleep Enable no-sleep (Override the containers.default.command and containers.default.args values with empty strings)
28-
--portforwarding Enable port forwarding (default true)
29-
--sync Enable code synchronization (default true)
30-
--tiller Install/upgrade tiller (default true)
31-
--verbose-sync When enabled the sync will log every file change
20+
-b, --build Force image build
21+
-c, --container string Container name where to open the shell
22+
-d, --deploy Force chart deployment
23+
-h, --help help for up
24+
--init-registries Initialize registries (and install internal one) (default true)
25+
-l, --label-selector string Comma separated key=value selector list (e.g. release=test)
26+
-n, --namespace string Namespace where to select pods
27+
--portforwarding Enable port forwarding (default true)
28+
--switch-context Switch kubectl context to the devspace context
29+
--sync Enable code synchronization (default true)
30+
--tiller Install/upgrade tiller (default true)
31+
--verbose-sync When enabled the sync will log every file change
3232
3333
Examples:
34-
devspace up # Start the devspace
35-
devspace up bash # Execute bash command after deploying
34+
devspace up # Start the devspace
35+
devspace up bash # Execute bash command after deploying
36+
devspace up --switch-context # Change kubectl context to devspace context that is used
3637
```
37-
38-
**Note**: Every time you run `devspace up`, your containers will be re-deployed. This way, you will always start with a clean state.

0 commit comments

Comments
 (0)