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(service-insights): add external service in api #5119

Merged
merged 2 commits into from
Oct 10, 2022
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
201 changes: 144 additions & 57 deletions api/mesh/v1alpha1/service_insight.pb.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions api/mesh/v1alpha1/service_insight.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ message ServiceInsight {
offline = 1;
partially_degraded = 2;
online = 3;
not_available = 4;
}

Status status = 1;
Expand All @@ -42,6 +43,15 @@ message ServiceInsight {
DataplaneStat dataplanes = 2;

map<string, uint32> issuedBackends = 3;

enum Type {
internal = 0;
external = 1;
gateway_delegated = 2;
gateway_builtin = 3;
}
Type serviceType = 4;
string addressPort = 5;
}

map<string, Service> services = 2;
Expand Down
1 change: 1 addition & 0 deletions pkg/api-server/api_server_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func tryStartApiServer(t *testApiServerConfigurer) (*api_server.ApiServer, kuma_
cfg.Multizone.Zone.Name,
vips.NewPersistence(resManager, config_manager.NewConfigManager(t.store)),
cfg.DNSServer.Domain,
80,
),
customization.NewAPIList(),
append(registry.Global().ObjectDescriptors(model.HasWsEnabled()), sample_model.TrafficRouteResourceTypeDescriptor),
Expand Down
1 change: 1 addition & 0 deletions pkg/api-server/customization/customization_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func createTestApiServer(store store.ResourceStore, config *config_api_server.Ap
cfg.Multizone.Zone.Name,
vips.NewPersistence(resManager, config_manager.NewConfigManager(store)),
cfg.DNSServer.Domain,
cfg.DNSServer.ServiceVipPort,
),
wsManager,
registry.Global().ObjectDescriptors(core_model.HasWsEnabled()),
Expand Down
1 change: 1 addition & 0 deletions pkg/api-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ func SetupServer(rt runtime.Runtime) error {
cfg.Multizone.Zone.Name,
vips.NewPersistence(rt.ResourceManager(), rt.ConfigManager()),
cfg.DNSServer.Domain,
cfg.DNSServer.ServiceVipPort,
),
rt.APIInstaller(),
registry.Global().ObjectDescriptors(model.HasWsEnabled()),
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/app/kuma-cp/kuma-cp.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ dnsServer:
CIDR: "240.0.0.0/4" # ENV: KUMA_DNS_SERVER_CIDR
# Will create a service "<kuma.io/service>.mesh" dns entry for every service.
serviceVipEnabled: true # ENV: KUMA_DNS_SERVER_SERVICE_VIP_ENABLED
# The port to use along with the `<kuma.io/service>.mesh` dns entry
serviceVipPort: 80 # ENV: KUMA_DNS_SERVICE_SERVICE_VIP_PORT

# Multizone mode
multizone:
Expand Down
8 changes: 7 additions & 1 deletion pkg/config/dns-server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
CIDR string `yaml:"CIDR" envconfig:"kuma_dns_server_cidr"`
// ServiceVipEnabled will create a service "<kuma.io/service>.mesh" dns entry for every service.
ServiceVipEnabled bool `yaml:"serviceVipEnabled" envconfig:"kuma_dns_server_service_vip_enabled"`
// ServiceVipPort the port to use for virtual IP
ServiceVipPort uint32 `yaml:"serviceVipPort" envconfig:"kuma_dns_server_service_vip_port"`
}

func (g *Config) Sanitize() {
Expand All @@ -23,7 +25,10 @@ func (g *Config) Sanitize() {
func (g *Config) Validate() error {
_, _, err := net.ParseCIDR(g.CIDR)
if err != nil {
return errors.New("Must provide a valid CIDR")
return errors.New("CIDR must be valid")
}
if g.ServiceVipPort == 0 {
return errors.New("port can't be 0")
}
return nil
}
Expand All @@ -35,5 +40,6 @@ func DefaultDNSServerConfig() *Config {
ServiceVipEnabled: true,
Domain: "mesh",
CIDR: "240.0.0.0/4",
ServiceVipPort: 80,
}
}
3 changes: 3 additions & 0 deletions pkg/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ var _ = Describe("Config loader", func() {
Expect(cfg.DNSServer.Domain).To(Equal("test-domain"))
Expect(cfg.DNSServer.CIDR).To(Equal("127.1.0.0/16"))
Expect(cfg.DNSServer.ServiceVipEnabled).To(BeFalse())
Expect(cfg.DNSServer.ServiceVipPort).To(Equal(uint32(9090)))

Expect(cfg.XdsServer.DataplaneStatusFlushInterval).To(Equal(7 * time.Second))
Expect(cfg.XdsServer.DataplaneConfigurationRefreshInterval).To(Equal(21 * time.Second))
Expand Down Expand Up @@ -439,6 +440,7 @@ dnsServer:
domain: test-domain
CIDR: 127.1.0.0/16
serviceVipEnabled: false
serviceVipPort: 9090
defaults:
skipMeshCreation: true
enableLocalhostInboundClusters: true
Expand Down Expand Up @@ -615,6 +617,7 @@ proxy:
"KUMA_DNS_SERVER_DOMAIN": "test-domain",
"KUMA_DNS_SERVER_CIDR": "127.1.0.0/16",
"KUMA_DNS_SERVER_SERVICE_VIP_ENABLED": "false",
"KUMA_DNS_SERVER_SERVICE_VIP_PORT": "9090",
"KUMA_MODE": "zone",
"KUMA_MULTIZONE_GLOBAL_KDS_GRPC_PORT": "1234",
"KUMA_MULTIZONE_GLOBAL_KDS_REFRESH_INTERVAL": "2s",
Expand Down
7 changes: 7 additions & 0 deletions pkg/insights/components.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package insights

import (
"fmt"

"golang.org/x/time/rate"

config_core "github.com/kumahq/kuma/pkg/config/core"
"github.com/kumahq/kuma/pkg/core"
"github.com/kumahq/kuma/pkg/core/resources/registry"
"github.com/kumahq/kuma/pkg/core/runtime"
"github.com/kumahq/kuma/pkg/core/runtime/component"
Expand All @@ -22,6 +25,10 @@ func Setup(rt runtime.Runtime) error {
return rate.NewLimiter(rate.Every(rt.Config().Metrics.Mesh.MinResyncTimeout), 0)
},
Registry: registry.Global(),
AddressPortGenerator: func(svc string) string {
return fmt.Sprintf("%s.%s:%d", svc, rt.Config().DNSServer.Domain, rt.Config().DNSServer.ServiceVipPort)
},
Now: core.Now,
})
return rt.Add(component.NewResilientComponent(log, resyncer))
}
Loading