Skip to content

Commit 78bc627

Browse files
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents b72cbd9 + 7b7aad1 commit 78bc627

Some content is hidden

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

51 files changed

+753
-318
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ifeq ($(GCP_ONLY),true)
149149
--zone $(GKE_ZONE) \
150150
--project $(GCP_PROJECT)
151151
endif
152-
@ GCP_ONLY=$(GCP_ONLY) ./hack/gotest.sh -v $(REPOPATH)/integration/binpack $(REPOPATH)/integration -timeout 45m $(INTEGRATION_TEST_ARGS)
152+
@ GCP_ONLY=$(GCP_ONLY) ./hack/gotest.sh -v $(REPOPATH)/integration/binpack $(REPOPATH)/integration -timeout 50m $(INTEGRATION_TEST_ARGS)
153153

154154
.PHONY: integration
155155
integration: install integration-tests

cmd/skaffold/app/cmd/cmd.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"os"
2424
"strings"
2525

26-
"github.com/sirupsen/logrus"
2726
"github.com/spf13/cobra"
2827
"github.com/spf13/pflag"
2928
"k8s.io/kubectl/pkg/util/templates"
@@ -198,7 +197,7 @@ func NewSkaffoldCommand(out, errOut io.Writer) *cobra.Command {
198197
rootCmd.AddCommand(NewCmdInspect())
199198

200199
templates.ActsAsRootCommand(rootCmd, nil, groups...)
201-
rootCmd.PersistentFlags().StringVarP(&v, "verbosity", "v", constants.DefaultLogLevel.String(), fmt.Sprintf("Log level: one of %v", logrus.AllLevels))
200+
rootCmd.PersistentFlags().StringVarP(&v, "verbosity", "v", log.DefaultLogLevel.String(), fmt.Sprintf("Log level: one of %v", log.AllLevels))
202201
rootCmd.PersistentFlags().IntVar(&defaultColor, "color", int(output.DefaultColorCode), "Specify the default output color in ANSI escape codes")
203202
rootCmd.PersistentFlags().BoolVar(&forceColors, "force-colors", false, "Always print color codes (hidden)")
204203
rootCmd.PersistentFlags().BoolVar(&interactive, "interactive", true, "Allow user prompts for more information")
@@ -254,17 +253,7 @@ func FlagToEnvVarName(f *pflag.Flag) string {
254253
}
255254

256255
func setUpLogs(stdErr io.Writer, level string, timestamp bool) error {
257-
logrus.SetOutput(stdErr)
258-
lvl, err := logrus.ParseLevel(level)
259-
if err != nil {
260-
return fmt.Errorf("parsing log level: %w", err)
261-
}
262-
logrus.SetLevel(lvl)
263-
logrus.SetFormatter(&logrus.TextFormatter{
264-
FullTimestamp: timestamp,
265-
})
266-
logrus.AddHook(event.NewLogHook())
267-
return nil
256+
return log.SetupLogs(stdErr, level, timestamp, event.NewLogHook())
268257
}
269258

270259
// alwaysSucceedWhenCancelled returns nil if the context was cancelled.

cmd/skaffold/app/cmd/debug_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func TestNewCmdDebug(t *testing.T) {
4040

4141
t.CheckDeepEqual(true, opts.Tail)
4242
t.CheckDeepEqual(false, opts.Force)
43-
t.CheckDeepEqual(true, opts.EnableRPC)
4443
})
4544
}
4645

cmd/skaffold/app/cmd/dev_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,5 @@ func TestNewCmdDev(t *testing.T) {
176176

177177
t.CheckDeepEqual(true, opts.Tail)
178178
t.CheckDeepEqual(false, opts.Force)
179-
t.CheckDeepEqual(true, opts.EnableRPC)
180179
})
181180
}

cmd/skaffold/app/cmd/flags.go

+14-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/spf13/pflag"
2727

2828
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
29-
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
3029
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/instrumentation"
3130
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
3231
)
@@ -170,17 +169,14 @@ var flagRegistry = []Flag{
170169
DefinedOn: []string{"dev", "build", "run", "debug"},
171170
},
172171
{
173-
Name: "enable-rpc",
174-
Usage: "Enable gRPC for exposing Skaffold events",
175-
Value: &opts.EnableRPC,
176-
DefValue: false,
177-
DefValuePerCommand: map[string]interface{}{
178-
"dev": true,
179-
"debug": true,
180-
},
172+
Name: "enable-rpc",
173+
Usage: "Enable gRPC or HTTP APIs for exposing Skaffold events",
174+
Value: &opts.EnableRPC,
175+
DefValue: false,
181176
FlagAddMethod: "BoolVar",
182177
DefinedOn: []string{"dev", "build", "run", "debug", "deploy", "render", "apply", "test"},
183178
IsEnum: true,
179+
Deprecated: "flags --rpc-port or --rpc-http-port now imply --enable-rpc=true, so please use only those instead",
184180
},
185181
{
186182
Name: "wait-for-connection",
@@ -193,7 +189,7 @@ var flagRegistry = []Flag{
193189
},
194190
{
195191
Name: "event-log-file",
196-
Usage: "Save Skaffold events to the provided file after skaffold has finished executing, requires --enable-rpc=true",
192+
Usage: "Save Skaffold events to the provided file after skaffold has finished executing, requires --rpc-port or --rpc-http-port",
197193
Hidden: true,
198194
Value: &opts.EventLogFile,
199195
DefValue: "",
@@ -202,18 +198,18 @@ var flagRegistry = []Flag{
202198
},
203199
{
204200
Name: "rpc-port",
205-
Usage: "tcp port to expose event API",
201+
Usage: "tcp port to expose the Skaffold API over gRPC",
206202
Value: &opts.RPCPort,
207-
DefValue: constants.DefaultRPCPort,
208-
FlagAddMethod: "IntVar",
203+
DefValue: nil,
204+
FlagAddMethod: "Var",
209205
DefinedOn: []string{"dev", "build", "run", "debug", "deploy", "test"},
210206
},
211207
{
212208
Name: "rpc-http-port",
213-
Usage: "tcp port to expose event REST API over HTTP",
209+
Usage: "tcp port to expose the Skaffold API over HTTP REST",
214210
Value: &opts.RPCHTTPPort,
215-
DefValue: constants.DefaultRPCHTTPPort,
216-
FlagAddMethod: "IntVar",
211+
DefValue: nil,
212+
FlagAddMethod: "Var",
217213
DefinedOn: []string{"dev", "build", "run", "debug", "deploy", "test"},
218214
},
219215
{
@@ -601,6 +597,8 @@ func methodNameByType(v reflect.Value) string {
601597
switch t {
602598
case reflect.Bool:
603599
return "BoolVar"
600+
case reflect.Int:
601+
return "IntVar"
604602
case reflect.String:
605603
return "StringVar"
606604
case reflect.Slice:

cmd/skaffold/app/cmd/init_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestFlagsToConfigVersion(t *testing.T) {
157157

158158
// we ignore Skaffold options
159159
test.expectedConfig.Opts = capturedConfig.Opts
160-
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expectedConfig, capturedConfig, cmp.AllowUnexported(cfg.StringOrUndefined{}, cfg.BoolOrUndefined{}, cfg.SyncRemoteCacheOption{}))
160+
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expectedConfig, capturedConfig, cmp.AllowUnexported(cfg.StringOrUndefined{}, cfg.BoolOrUndefined{}, cfg.IntOrUndefined{}, cfg.SyncRemoteCacheOption{}))
161161
})
162162
}
163163
}

docs/content/en/docs/design/api.md

+19-21
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,36 @@ To retrieve information about the Skaffold pipeline, the Skaffold API provides t
2121
To control the individual phases of the Skaffold, the Skaffold API provides [fine-grained control]({{< relref "#control-api" >}})
2222
over the individual phases of the pipeline (build, deploy, and sync).
2323

24-
2524
## Connecting to the Skaffold API
2625
The Skaffold API is `gRPC` based, and it is also exposed via the gRPC gateway as a JSON over HTTP service.
27-
The server is hosted locally on the same host where the skaffold process is running, and will serve by default on ports 50051 and 50052.
28-
These ports can be configured through the `--rpc-port` and `--rpc-http-port` flags.
2926

30-
For reference, we generate the server's [gRPC service definitions and message protos]({{< relref "/docs/references/api/grpc" >}}) as well as the [Swagger based HTTP API Spec]({{< relref "/docs/references/api/swagger" >}}).
27+
The API can be enabled via setting the `--rpc-port` or `--rpc-http-port` flags (or both)
28+
depending on whether you want to enable the gRPC API or the HTTP REST API, respectively.
3129

3230

33-
### HTTP server
34-
The HTTP API is exposed on port `50052` by default. The default HTTP port can be overridden with the `--rpc-http-port` flag.
35-
If the HTTP API port is taken, Skaffold will find the next available port.
36-
The final port can be found from Skaffold's startup logs.
31+
{{< alert title="Note">}}
32+
The `--enable-rpc` flag is now deprecated in favor of `--rpc-port` and `--rpc-http-port` flags.
33+
{{</alert>}}
3734

38-
```code
39-
$ skaffold dev
40-
WARN[0000] port 50052 for gRPC HTTP server already in use: using 50055 instead
41-
```
4235

43-
### gRPC Server
36+
For reference, we generate the server's [gRPC service definitions and message protos]({{< relref "/docs/references/api/grpc" >}}) as well as the [Swagger based HTTP API Spec]({{< relref "/docs/references/api/swagger" >}}).
37+
38+
## gRPC Server
4439

45-
The gRPC API is exposed on port `50051` by default and can be overridden with the `--rpc-port` flag.
46-
As with the HTTP API, if this port is taken, Skaffold will find the next available port.
47-
You can find this port from Skaffold's logs on startup.
40+
The gRPC API can be started by specifying the `--rpc-port` flag. If the specified port is not available, Skaffold will
41+
exit with failure.
4842

49-
```code
50-
$ skaffold dev
51-
WARN[0000] port 50051 for gRPC server already in use: using 50053 instead
52-
```
43+
### HTTP server
44+
45+
The HTTP REST API can be started by specifying the `--rpc-http-port` flag. If the specified port is not available,
46+
Skaffold will exit with failure.
47+
48+
Starting the HTTP REST API will also start the gRPC API as it proxies the requests to the gRPC API. By default, Skaffold
49+
chooses a random available port for gRPC, but it can be customized (see below).
5350

5451
#### Creating a gRPC Client
55-
To connect to the `gRPC` server at default port `50051`, create a client using the following code snippet.
52+
53+
To connect to the `gRPC` server at the specified port, create a client using the following code snippet.
5654

5755
{{< alert title="Note" >}}
5856
The skaffold gRPC server is not compatible with HTTPS, so connections need to be marked as insecure with `grpc.WithInsecure()`

docs/content/en/docs/pipeline-stages/deployers/helm.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Associating the Helm image key allows Skaffold to track the image being built, a
4848

4949
```yaml
5050
build:
51-
artifact:
52-
- name: gcr.io/my-project/my-image # must match in artifactOverrides
51+
artifacts:
52+
- image: gcr.io/my-project/my-image # must match in artifactOverrides
5353
deploy:
5454
helm:
5555
releases:

0 commit comments

Comments
 (0)