Skip to content

Commit

Permalink
feat(kuma-cp) add CP config to ZoneInsights (#2661)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
jakubdyszkiewicz authored Aug 25, 2021
1 parent 4582f3e commit 5af5cf0
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 95 deletions.
108 changes: 59 additions & 49 deletions api/system/v1alpha1/zone_insight.pb.go

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

3 changes: 3 additions & 0 deletions api/system/v1alpha1/zone_insight.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ message KDSSubscription {
// Generation is an integer number which is periodically increased by the
// status sink
uint32 generation = 7;

// Config of Zone Kuma CP
string config = 8;
}

// KDSSubscriptionStatus defines status of an KDS subscription.
Expand Down
25 changes: 23 additions & 2 deletions app/kumactl/cmd/inspect/inspect_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package inspect

import (
"context"
"encoding/json"
"io"
"time"

Expand Down Expand Up @@ -49,8 +50,9 @@ func newInspectZonesCmd(ctx *cmd.RootContext) *cobra.Command {
}

func printZoneOverviews(now time.Time, zoneOverviews *system.ZoneOverviewResourceList, out io.Writer) error {
var unmarshallErr error
data := printers.Table{
Headers: []string{"NAME", "STATUS", "LAST CONNECTED AGO", "LAST UPDATED AGO", "TOTAL UPDATES", "TOTAL ERRORS", "ZONE-CP VERSION"},
Headers: []string{"NAME", "STATUS", "LAST CONNECTED AGO", "LAST UPDATED AGO", "TOTAL UPDATES", "TOTAL ERRORS", "ZONE-CP VERSION", "BACKEND"},
NextRow: func() func() []string {
i := 0
return func() []string {
Expand Down Expand Up @@ -82,6 +84,21 @@ func printZoneOverviews(now time.Time, zoneOverviews *system.ZoneOverviewResourc
}
}

var backend string
if lastSubscription.GetConfig() != "" {
// Unmarshall only what we need to avoid dependency on the whole config
cfg := struct {
Store struct {
Type string `json:"type"`
} `json:"store"`
}{}
if err := json.Unmarshal([]byte(lastSubscription.GetConfig()), &cfg); err != nil {
unmarshallErr = errors.Wrap(err, "could not unmarshal CP config")
} else {
backend = cfg.Store.Type
}
}

return []string{
meta.GetName(), // NAME,
onlineStatus, // STATUS
Expand All @@ -90,9 +107,13 @@ func printZoneOverviews(now time.Time, zoneOverviews *system.ZoneOverviewResourc
table.Number(totalResponsesSent), // TOTAL UPDATES
table.Number(totalResponsesRejected), // TOTAL ERRORS
zoneCPVersion, // ZONE-CP VERSION
backend, // BACKEND
}
}
}(),
}
return printers.NewTablePrinter().Print(data, out)
if err := printers.NewTablePrinter().Print(data, out); err != nil {
return err
}
return unmarshallErr
}
1 change: 1 addition & 0 deletions app/kumactl/cmd/inspect/inspect_zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ var _ = Describe("kumactl inspect zones", func() {
BuildDate: "2019-08-07T11:26:06Z",
},
},
Config: `{"apiServer":{"auth":{"allowFromLocalhost":true,"clientCertsDir":""},"corsAllowedDomains":[".*"],"http":{"enabled":true,"interface":"0.0.0.0","port":15681},"https":{"enabled":false,"interface":"0.0.0.0","port":5682,"tlsCertFile":"/Users/jakob/.kuma/kuma-cp.crt","tlsKeyFile":"/Users/jakob/.kuma/kuma-cp.key"},"readOnly":false},"bootstrapServer":{"apiVersion":"v3","params":{"adminAccessLogPath":"/dev/null","adminAddress":"127.0.0.1","adminPort":0,"xdsConnectTimeout":"1s","xdsHost":"","xdsPort":15678}},"defaults":{"skipMeshCreation":false},"diagnostics":{"debugEndpoints":false,"serverPort":15680},"dnsServer":{"CIDR":"240.0.0.0/4","domain":"mesh","port":15653},"dpServer":{"auth":{"type":"dpToken"},"hds":{"checkDefaults":{"healthyThreshold":1,"interval":"1s","noTrafficInterval":"1s","timeout":"2s","unhealthyThreshold":1},"enabled":true,"interval":"5s","refreshInterval":"10s"},"port":15678,"tlsCertFile":"/Users/jakob/.kuma/kuma-cp.crt","tlsKeyFile":"/Users/jakob/.kuma/kuma-cp.key"},"environment":"universal","general":{"dnsCacheTTL":"10s","tlsCertFile":"/Users/jakob/.kuma/kuma-cp.crt","tlsKeyFile":"/Users/jakob/.kuma/kuma-cp.key","workDir":"/Users/jakob/.kuma"},"guiServer":{"apiServerUrl":""},"metrics":{"dataplane":{"enabled":true,"idleTimeout":"5m0s","subscriptionLimit":2},"mesh":{"maxResyncTimeout":"20s","minResyncTimeout":"1s"},"zone":{"enabled":true,"idleTimeout":"5m0s","subscriptionLimit":10}},"mode":"zone","monitoringAssignmentServer":{"apiVersions":["v1"],"assignmentRefreshInterval":"1s","defaultFetchTimeout":"30s","grpcPort":15676,"port":5676},"multizone":{"global":{"kds":{"grpcPort":5685,"maxMsgSize":10485760,"refreshInterval":"1s","tlsCertFile":"/Users/jakob/.kuma/kuma-cp.crt","tlsKeyFile":"/Users/jakob/.kuma/kuma-cp.key","zoneInsightFlushInterval":"10s"}},"zone":{"globalAddress":"grpcs://localhost:35685","kds":{"maxMsgSize":10485760,"refreshInterval":"1s","rootCaFile":""},"name":"cluster-1"}},"reports":{"enabled":false},"runtime":{"kubernetes":{"admissionServer":{"address":"","certDir":"","port":5443},"controlPlaneServiceName":"kuma-control-plane","injector":{"builtinDNS":{"enabled":true,"port":15053},"caCertFile":"","cniEnabled":false,"exceptions":{"labels":{"openshift.io/build.name":"*","openshift.io/deployer-pod-for.name":"*"}},"initContainer":{"image":"kuma/kuma-init:latest"},"sidecarContainer":{"adminPort":9901,"drainTime":"30s","envVars":{},"gid":5678,"image":"kuma/kuma-dp:latest","livenessProbe":{"failureThreshold":12,"initialDelaySeconds":60,"periodSeconds":5,"timeoutSeconds":3},"readinessProbe":{"failureThreshold":12,"initialDelaySeconds":1,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":3},"redirectPortInbound":15006,"redirectPortInboundV6":15010,"redirectPortOutbound":15001,"resources":{"limits":{"cpu":"1000m","memory":"512Mi"},"requests":{"cpu":"50m","memory":"64Mi"}},"uid":5678},"sidecarTraffic":{"excludeInboundPorts":[],"excludeOutboundPorts":[]},"virtualProbesEnabled":true,"virtualProbesPort":9000},"marshalingCacheExpirationTime":"5m0s"},"universal":{"dataplaneCleanupAge":"72h0m0s"}},"store":{"cache":{"enabled":true,"expirationTime":"1s"},"kubernetes":{"systemNamespace":"kuma-system"},"postgres":{"connectionTimeout":5,"dbName":"kuma","host":"127.0.0.1","maxIdleConnections":0,"maxOpenConnections":0,"maxReconnectInterval":"1m0s","minReconnectInterval":"10s","password":"*****","port":15432,"tls":{"caPath":"","certPath":"","keyPath":"","mode":"disable"},"user":"kuma"},"type":"memory","upsert":{"conflictRetryBaseBackoff":"100ms","conflictRetryMaxTimes":5}},"xdsServer":{"dataplaneConfigurationRefreshInterval":"1s","dataplaneStatusFlushInterval":"10s","nackBackoff":"5s"}}`,
},
},
},
Expand Down
Loading

0 comments on commit 5af5cf0

Please sign in to comment.