Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kuma-dp): rework on the virtual probes to support probing tcp and grpc ports #10624

Merged
merged 50 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b69d058
feat(kuma-dp): add the virtual probes component in kuma-dp
jijiechen Jun 11, 2024
22caff4
feat(kuma-dp): improve ipv6 compatibilities in virtual probes
jijiechen Jun 14, 2024
ebd1cb4
feat(kuma-dp): add virtual probes component into kuma-dp component ma…
jijiechen Jun 14, 2024
dd3896a
feat(kuma-dp): support overriding TCP & GRPC probes when injecting
jijiechen Jun 18, 2024
f08d874
feat(kuma-dp): remove probes properties from data plane object
jijiechen Jun 18, 2024
f8deb5e
feat(kuma-cni): exclude virtual probe port from CNI
jijiechen Jun 18, 2024
c5bc88f
feat(kuma-dp): test virtual probes - HTTP
jijiechen Jun 20, 2024
733024d
feat(kuma-dp): test virtual probes - TCP & gRPC
jijiechen Jun 21, 2024
17b1f92
feat(kuma-dp): test virtual probe converting
jijiechen Jun 24, 2024
593dd44
feat(kuma-dp): test virtual probe converting on pod
jijiechen Jun 24, 2024
653c32a
Merge branch 'master' into tcp-grpc-probes
jijiechen Jun 24, 2024
9b72e87
feat(kuma-cni): fix syntax errors
jijiechen Jun 24, 2024
a1cc8fc
feat(kuma-cni): log probe errors for tcpSocket probes
jijiechen Jun 24, 2024
3f8610b
feat(kuma-cni): fix logic for excluding virtual porbes port
jijiechen Jun 24, 2024
7139cb2
feat(kuma-dp): virtual probes server listen based on kuma-cp injector…
jijiechen Jun 25, 2024
ccc9d61
feat(kuma-dp): improve code formatting
jijiechen Jun 25, 2024
a1a919a
feat(kuma-dp): fix annotation assignment issue
jijiechen Jun 25, 2024
62a6694
feat(kuma-dp): support query in http virtual probes
jijiechen Jun 26, 2024
81efa48
feat(kuma-dp): fix failed unit tests
jijiechen Jun 26, 2024
b471f49
bring back field 'probes' back on Dataplane
jijiechen Jul 26, 2024
72a35de
add back probes_generator and take care of existing probes data on Da…
jijiechen Jul 26, 2024
2bf0931
Merge branch 'master' into tcp-grpc-probes
jijiechen Jul 29, 2024
1990387
fix probe fields in proto & schema files
jijiechen Jul 29, 2024
ee13481
fix virutal probes path
jijiechen Jul 29, 2024
8a59daf
fix inject golden files
jijiechen Jul 30, 2024
fd4fabf
improve probe test structure
jijiechen Jul 30, 2024
42ed8d0
don't run e2e when there is no runner
jijiechen Jul 30, 2024
89b6aa4
fix review suggestions and tests
jijiechen Aug 6, 2024
7aa979e
Merge branch 'master' into tcp-grpc-probes
jijiechen Aug 6, 2024
412d8e1
fix lint errors
jijiechen Aug 6, 2024
6207c49
fix review suggestions
jijiechen Aug 7, 2024
49c4386
Merge branch 'master' into tcp-grpc-probes
jijiechen Aug 7, 2024
8fdc388
try to fix unit tests
jijiechen Aug 7, 2024
fe445a5
fix failed unit test using different virt probe port
jijiechen Aug 7, 2024
a56273e
fix logging format
jijiechen Aug 7, 2024
76b05af
fix format
jijiechen Aug 7, 2024
e162b55
Merge branch 'master' into tcp-grpc-probes
jijiechen Aug 8, 2024
589f046
feat(kuma-dp): introduce a new annotation/configuration to support th…
jijiechen Aug 14, 2024
fa48bf1
feat(kuma-dp): fix tests: don't include virtual-probes env variables …
jijiechen Aug 14, 2024
4d019b8
feat(kuma-dp): add back virtual probes
jijiechen Aug 14, 2024
082fcae
feat(kuma-dp): fix tests when virtual probes and application probe pr…
jijiechen Aug 14, 2024
cfb9ae2
feat(kuma-dp): support explicitly enable probe proxy on certain pods
jijiechen Aug 14, 2024
2d6d0b1
feat(kuma-dp): fix test: add back probes data on Dataplane objects
jijiechen Aug 14, 2024
4477ca5
feat(kuma-dp): add deprecate notice for virtual probe annotations
jijiechen Aug 14, 2024
6bb046a
feat(kuma-dp): fix format issues
jijiechen Aug 14, 2024
1750fe6
feat(kuma-dp): fix failed tests
jijiechen Aug 14, 2024
1925856
feat(kuma-dp): fix format issues
jijiechen Aug 14, 2024
cea79a7
feat(kuma-dp): update UPGRADE.md
jijiechen Aug 14, 2024
ebebbf1
feat(kuma-dp): improve UPGRADE.md
jijiechen Aug 14, 2024
1c56071
feat(kuma-dp): improve UPGRADE.md
jijiechen Aug 14, 2024
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: 26 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ Migration step:
3. Deploy the gateway and verify if traffic works correctly.
4. Remove the old resources.

### Introduction to Application Probe Proxy and deprecation of Virtual Probes

To support more types of application probes on Kubernetes, in version 2.9, we introduced a new feature named "Application Probe Proxy" which supports HTTP Get, TCP Socket and gRPC application probes. Starting from `2.9.x`, Virtual Probes is deprecated, and Application Probe Proxy is enabled by default.

Application workloads using Virtual Probes will be migrated to Application Probe Proxy automatically on next restart/redeploy on Kubernetes, without other operations.

Application Probe Proxy will by default listen on port `9000`, the same port that Virtual Probes Listener uses. If you'd customized the Virtual Probes port, you might also want to customize the port of Application Probe Proxy. You may do so using one of these methods:

1. Configuring on the control plane to apply on all dataplanes: set the port onto configuration key `runtime.kubernetes.injector.sidecarContainer.applicationProbeProxyPort`
1. Configuring on the control plane to apply on all dataplanes: set the port using environment variable `KUMA_RUNTIME_KUBERNETES_APPLICATION_PROBE_PROXY_PORT`
1. Configuring for certain dataplanes: set the port using pod annotation `kuma.io/application-probe-proxy-port`

By setting the port to `0`, Application Probe Proxy feature will be disabled.

When the Application Probe Proxy is disabled, Virtual Probes still works as usual before Virtual Probes is removed.

Because of deprecation of Virtual Probes, the following items are considered deprecated:

- Pod annotation `kuma.io/virtual-probes`
- Pod annotation `kuma.io/virtual-probes-port`
- Control plane configuration key `runtime.kubernetes.injector.sidecarContainer.virtualProbesEnabled`
- Control plane configuration key `runtime.kubernetes.injector.sidecarContainer.virtualProbesPort`
- Control plane environment variable `KUMA_RUNTIME_KUBERNETES_VIRTUAL_PROBES_ENABLED`
- Control plane environment variable `KUMA_RUNTIME_KUBERNETES_VIRTUAL_PROBES_PORT`
- Data field `probes` on `Dataplane` objects

### kumactl

#### Default prometheus scrape config removes `service`
Expand Down
2 changes: 2 additions & 0 deletions api/mesh/v1alpha1/dataplane.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/mesh/v1alpha1/dataplane.proto
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,7 @@ message Dataplane {
// See
// https://kuma.io/docs/latest/policies/service-health-probes/#virtual-probes
// for more information.
// Deprecated: this feature will be removed for Universal; on Kubernetes, it's
// not needed anymore.
Probes probes = 3;
}
27 changes: 27 additions & 0 deletions app/cni/pkg/cni/annotations_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
defaultIPFamilyMode = "dualstack"
defaultBuiltinDNSPort = "15053"
defaultNoRedirectUID = "5678"
defaultAppProbeProxyPort = "9000"
defaultRedirectExcludePort = defaultProxyStatusPort
)

Expand All @@ -36,6 +37,7 @@ var annotationRegistry = map[string]*annotationParam{
"iptablesLogs": {"traffic.kuma.io/iptables-logs", "false", alwaysValidFunc},
"excludeInboundIPs": {"traffic.kuma.io/exclude-inbound-ips", "", validateIPs},
"excludeOutboundIPs": {"traffic.kuma.io/exclude-outbound-ips", "", validateIPs},
"applicationProbeProxyPort": {"kuma.io/application-probe-proxy-port", defaultAppProbeProxyPort, validateSinglePort},
}

type IntermediateConfig struct {
Expand Down Expand Up @@ -148,6 +150,13 @@ func validatePortList(ports string) error {
return nil
}

func validateSinglePort(portString string) error {
if _, err := parsePort(portString); err != nil {
return err
}
return nil
}

func validateIpFamilyMode(val string) error {
if val == "" {
return errors.New("value is empty")
Expand Down Expand Up @@ -181,6 +190,7 @@ func getAnnotationOrDefault(name string, annotations map[string]string) (string,
// NewIntermediateConfig returns a new IntermediateConfig Object constructed from a list of ports and annotations
func NewIntermediateConfig(annotations map[string]string) (*IntermediateConfig, error) {
intermediateConfig := &IntermediateConfig{}
valDefaultProbeProxyPort := defaultAppProbeProxyPort

allFields := map[string]*string{
"outboundPort": &intermediateConfig.targetPort,
Expand All @@ -193,6 +203,7 @@ func NewIntermediateConfig(annotations map[string]string) (*IntermediateConfig,
"builtinDNSPort": &intermediateConfig.builtinDNSPort,
"excludeOutboundPortsForUIDs": &intermediateConfig.excludeOutboundPortsForUIDs,
"noRedirectUID": &intermediateConfig.noRedirectUID,
"applicationProbeProxyPort": &valDefaultProbeProxyPort,
"dropInvalidPackets": &intermediateConfig.dropInvalidPackets,
"iptablesLogs": &intermediateConfig.iptablesLogs,
"excludeInboundIPs": &intermediateConfig.excludeInboundIPs,
Expand All @@ -205,6 +216,7 @@ func NewIntermediateConfig(annotations map[string]string) (*IntermediateConfig,
}
}

excludeAppProbeProxyPort(allFields)
return intermediateConfig, nil
}

Expand All @@ -216,3 +228,18 @@ func mapAnnotation(annotations map[string]string, field *string, fieldName strin
*field = val
return nil
}

func excludeAppProbeProxyPort(allFields map[string]*string) {
inboundPortsToExclude := allFields["excludeInboundPorts"]
applicationProbeProxyPort := *allFields["applicationProbeProxyPort"]
if applicationProbeProxyPort == "0" {
return
}

existingExcludes := *inboundPortsToExclude
if existingExcludes == "" {
*inboundPortsToExclude = applicationProbeProxyPort
} else {
*inboundPortsToExclude = fmt.Sprintf("%s,%s", existingExcludes, applicationProbeProxyPort)
}
}
10 changes: 10 additions & 0 deletions app/cni/pkg/cni/annotations_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ var _ = Describe("NewIntermediateConfig", func() {
Expect(err).ToNot(HaveOccurred())
Expect(cfg.inboundPort).To(Equal("1234"))
})

It("should exclude application probe proxy ports", func() {
a := map[string]string{
"kuma.io/application-probe-proxy-port": "19988",
"traffic.kuma.io/exclude-inbound-ports": "3355",
}
cfg, err := NewIntermediateConfig(a)
Expect(err).ToNot(HaveOccurred())
Expect(cfg.excludeInboundPorts).To(Equal("3355,19988"))
})
})
15 changes: 10 additions & 5 deletions app/cni/pkg/cni/main_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func cmdAdd(args *skel.CmdArgs) error {
ctx := context.Background()
conf, err := parseConfig(args.StdinData)
if err != nil {
return errors.Wrap(err, "error parsing kuma-cni cmdAdd config")
return errorLogged(log, err, "error parsing kuma-cni cmdAdd config")
}

mainProcessStderr, err := hijackMainProcessStderr(conf.LogLevel)
Expand All @@ -139,7 +139,7 @@ func cmdAdd(args *skel.CmdArgs) error {
// Determine if running under k8s by checking the CNI args
k8sArgs := K8sArgs{}
if err := types.LoadArgs(args.Args, &k8sArgs); err != nil {
return errors.Wrap(err, "error loading kuma-cni cmdAdd args")
return errorLogged(log, err, "error loading kuma-cni cmdAdd args")
}
logger := log.WithValues(
"pod", string(k8sArgs.K8S_POD_NAME),
Expand All @@ -162,7 +162,7 @@ func cmdAdd(args *skel.CmdArgs) error {

containerCount, initContainersMap, annotations, err := getPodInfoWithRetries(ctx, conf, k8sArgs)
if err != nil {
return errors.Wrap(err, "pod excluded - error getting pod info")
return errorLogged(logger, err, "pod excluded - error getting pod info")
}

if isInitContainerPresent(initContainersMap) {
Expand All @@ -184,10 +184,10 @@ func cmdAdd(args *skel.CmdArgs) error {
}

if intermediateConfig, configErr := NewIntermediateConfig(annotations); configErr != nil {
return errors.Wrap(configErr, "pod excluded - pod intermediateConfig failed due to bad params")
return errorLogged(logger, configErr, "pod excluded - pod intermediateConfig failed due to bad params")
} else {
if err := Inject(ctx, args.Netns, intermediateConfig, logger); err != nil {
return errors.Wrap(err, "pod excluded - could not inject rules into namespace")
return errorLogged(logger, err, "pod excluded - could not inject rules into namespace")
}
}
logger.Info("successfully injected iptables rules")
Expand All @@ -208,6 +208,11 @@ func prepareResult(conf *PluginConf, logger logr.Logger) error {
return types.PrintResult(result, conf.CNIVersion)
}

func errorLogged(logger logr.Logger, err error, message string) error {
jijiechen marked this conversation as resolved.
Show resolved Hide resolved
logger.Info(fmt.Sprintf("[WARNING] %s", message), "err", err)
return errors.Wrap(err, message)
}

func excludeByMissingSidecarInjectedAnnotation(annotations map[string]string) bool {
excludePod := false
val, ok := annotations[metadata.KumaSidecarInjectedAnnotation]
Expand Down
8 changes: 8 additions & 0 deletions app/kuma-dp/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/kumahq/kuma/app/kuma-dp/pkg/dataplane/envoy"
"github.com/kumahq/kuma/app/kuma-dp/pkg/dataplane/meshmetrics"
"github.com/kumahq/kuma/app/kuma-dp/pkg/dataplane/metrics"
"github.com/kumahq/kuma/app/kuma-dp/pkg/dataplane/probes"
kuma_cmd "github.com/kumahq/kuma/pkg/cmd"
"github.com/kumahq/kuma/pkg/config"
kumadp "github.com/kumahq/kuma/pkg/config/app/kuma-dp"
Expand Down Expand Up @@ -240,6 +241,13 @@ func newRunCmd(opts kuma_cmd.RunCmdOpts, rootCtx *RootContext) *cobra.Command {
return err
}

if opts.Config.ApplicationProbeProxyServer.Port > 0 {
prober := probes.NewProber(kumaSidecarConfiguration.Networking.Address, opts.Config.ApplicationProbeProxyServer.Port)
if err := rootCtx.ComponentManager.Add(prober); err != nil {
return err
}
}

stopComponents := make(chan struct{})
go func() {
var draining bool
Expand Down
Loading
Loading