Skip to content

Commit

Permalink
Merge pull request #603 from JarHMJ/feature/support_tracing
Browse files Browse the repository at this point in the history
[kwokctl] Integrate jaeger
  • Loading branch information
k8s-ci-robot authored Aug 9, 2023
2 parents 5f3ca4f + 11a8b7a commit 95aa17a
Show file tree
Hide file tree
Showing 32 changed files with 957 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ linters-settings:
# Use sigs.k8s.io/kwok/pkg/utils/slices, which is a wrapper around slices
- k8s.io/utils/strings/slices: "please use `sigs.k8s.io/kwok/pkg/utils/slices` instead"
gocyclo:
min-complexity: 50
min-complexity: 60
gosec:
excludes:
- G110
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/config/v1alpha1/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ type KwokctlConfigurationOptions struct {
// is the default value for flag --prometheus-port and env KWOK_PROMETHEUS_PORT
PrometheusPort uint32 `json:"prometheusPort,omitempty"`

// JaegerPort is the port to expose Jaeger UI.
// is the default value for flag --jaeger-port and env KWOK_JAEGER_PORT
JaegerPort uint32 `json:"jaegerPort,omitempty"`

// JaegerOtlpGrpcPort is the port to expose OTLP GRPC collector.
JaegerOtlpGrpcPort uint32 `json:"jaegerOtlpGrpcPort,omitempty"`

// KwokVersion is the version of Kwok to use.
// is the default value for env KWOK_VERSION
KwokVersion string `json:"kwokVersion,omitempty"`
Expand All @@ -109,6 +116,10 @@ type KwokctlConfigurationOptions struct {
// is the default value for env KWOK_PROMETHEUS_VERSION
PrometheusVersion string `json:"prometheusVersion,omitempty"`

// JaegerVersion is the version of Jaeger to use.
// is the default value for env KWOK_JAEGER_VERSION
JaegerVersion string `json:"jaegerVersion,omitempty"`

// DockerComposeVersion is the version of docker-compose to use.
// is the default value for env KWOK_DOCKER_COMPOSE_VERSION
// Deprecated: docker compose will be removed in a future release
Expand Down Expand Up @@ -162,6 +173,11 @@ type KwokctlConfigurationOptions struct {
//+k8s:conversion-gen=false
PrometheusImagePrefix string `json:"prometheusImagePrefix,omitempty"`

// JaegerImagePrefix is the prefix of the Jaeger image.
// is the default value for env KWOK_JAEGER_IMAGE_PREFIX
//+k8s:conversion-gen=false
JaegerImagePrefix string `json:"jaegerImagePrefix,omitempty"`

// EtcdImage is the image of etcd.
// is the default value for flag --etcd-image and env KWOK_ETCD_IMAGE
EtcdImage string `json:"etcdImage,omitempty"`
Expand All @@ -186,6 +202,10 @@ type KwokctlConfigurationOptions struct {
// is the default value for flag --prometheus-image and env KWOK_PROMETHEUS_IMAGE
PrometheusImage string `json:"prometheusImage,omitempty"`

// JaegerImage is the image of Jaeger.
// is the default value for flag --jaeger-image and env KWOK_JAEGER_IMAGE
JaegerImage string `json:"jaegerImage,omitempty"`

// KindNodeImagePrefix is the prefix of the kind node image.
// is the default value for env KWOK_KIND_NODE_IMAGE_PREFIX
//+k8s:conversion-gen=false
Expand Down Expand Up @@ -255,6 +275,19 @@ type KwokctlConfigurationOptions struct {
// is the default value for env KWOK_PROMETHEUS_BINARY_TAR
PrometheusBinaryTar string `json:"prometheusBinaryTar,omitempty"`

// JaegerBinaryPrefix is the prefix of the Jaeger binary.
// is the default value for env KWOK_JAEGER_PREFIX
//+k8s:conversion-gen=false
JaegerBinaryPrefix string `json:"jaegerBinaryPrefix,omitempty"`

// JaegerBinary is the binary of Jaeger.
// is the default value for flag --jaeger-binary and env KWOK_JAEGER_BINARY
JaegerBinary string `json:"jaegerBinary,omitempty"`

// JaegerBinaryTar is the tar of binary of Jaeger.
// is the default value for env KWOK_JAEGER_TAR
JaegerBinaryTar string `json:"jaegerBinaryTar,omitempty"`

// DockerComposeBinaryPrefix is the binary of docker-compose.
// is the default value for env KWOK_DOCKER_COMPOSE_BINARY_PREFIX
// Deprecated: docker compose will be removed in a future release
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/internalversion/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ type KwokctlConfigurationOptions struct {
// PrometheusPort is the port to expose Prometheus metrics.
PrometheusPort uint32

// JaegerPort is the port to expose Jaeger UI.
JaegerPort uint32

// JaegerOtlpGrpcPort is the port to expose OTLP GRPC collector.
JaegerOtlpGrpcPort uint32

// KwokVersion is the version of Kwok to use.
KwokVersion string

Expand All @@ -89,6 +95,9 @@ type KwokctlConfigurationOptions struct {
// PrometheusVersion is the version of Prometheus to use.
PrometheusVersion string

// JaegerVersion is the version of Jaeger to use.
JaegerVersion string

// DockerComposeVersion is the version of docker-compose to use.
DockerComposeVersion string

Expand Down Expand Up @@ -129,6 +138,9 @@ type KwokctlConfigurationOptions struct {
// PrometheusImage is the image of Prometheus.
PrometheusImage string

// JaegerImage is the image of Jaeger
JaegerImage string

// KindNodeImage is the image of kind node.
KindNodeImage string

Expand Down Expand Up @@ -163,6 +175,12 @@ type KwokctlConfigurationOptions struct {
// PrometheusBinaryTar is the tar of binary of Prometheus.
PrometheusBinaryTar string

// JaegerBinary is the binary of Jaeger.
JaegerBinary string

// JaegerBinaryTar is the tar of binary of Jaeger.
JaegerBinaryTar string

// DockerComposeBinary is the binary of Docker compose.
DockerComposeBinary string

Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/internalversion/zz_generated.conversion.go

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

66 changes: 58 additions & 8 deletions pkg/config/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ var (

// GOARCH is the architecture target for which the code is compiled.
GOARCH = runtime.GOARCH

// windows is the windows system
windows = "windows"

// linux is the linux system
linux = "linux"

// binarySuffixTar is the file suffix tar.gz
binarySuffixTar = "tar.gz"

// binarySuffixZip is the file suffix zip
binarySuffixZip = "zip"
)

// ClusterName returns the cluster name.
Expand Down Expand Up @@ -185,7 +197,7 @@ func setKwokctlConfigurationDefaults(config *configv1alpha1.KwokctlConfiguration
conf.Runtimes = []string{
consts.RuntimeTypeDocker,
}
if GOOS == "linux" {
if GOOS == linux {
// TODO: Move to above after test coverage
conf.Runtimes = append(conf.Runtimes,
consts.RuntimeTypePodman,
Expand All @@ -205,7 +217,7 @@ func setKwokctlConfigurationDefaults(config *configv1alpha1.KwokctlConfiguration
}

if conf.BinSuffix == "" {
if GOOS == "windows" {
if GOOS == windows {
conf.BinSuffix = ".exe"
}
}
Expand All @@ -230,6 +242,8 @@ func setKwokctlConfigurationDefaults(config *configv1alpha1.KwokctlConfiguration

setKwokctlPrometheusConfig(conf)

setKwokctlJaegerConfig(conf)

return config
}

Expand Down Expand Up @@ -346,10 +360,10 @@ func setKwokctlEtcdConfig(conf *configv1alpha1.KwokctlConfigurationOptions) {

if conf.EtcdBinaryTar == "" {
conf.EtcdBinaryTar = conf.EtcdBinaryPrefix + "/etcd-v" + strings.TrimSuffix(conf.EtcdVersion, "-0") + "-" + GOOS + "-" + GOARCH + "." + func() string {
if GOOS == "linux" {
return "tar.gz"
if GOOS == linux {
return binarySuffixTar
}
return "zip"
return binarySuffixZip
}()
}
conf.EtcdBinaryTar = envs.GetEnvWithPrefix("ETCD_BINARY_TAR", conf.EtcdBinaryTar)
Expand Down Expand Up @@ -438,15 +452,51 @@ func setKwokctlPrometheusConfig(conf *configv1alpha1.KwokctlConfigurationOptions

if conf.PrometheusBinaryTar == "" {
conf.PrometheusBinaryTar = conf.PrometheusBinaryPrefix + "/prometheus-" + strings.TrimPrefix(conf.PrometheusVersion, "v") + "." + GOOS + "-" + GOARCH + "." + func() string {
if GOOS == "windows" {
return "zip"
if GOOS == windows {
return binarySuffixZip
}
return "tar.gz"
return binarySuffixTar
}()
}
conf.PrometheusBinaryTar = envs.GetEnvWithPrefix("PROMETHEUS_BINARY_TAR", conf.PrometheusBinaryTar)
}

func setKwokctlJaegerConfig(conf *configv1alpha1.KwokctlConfigurationOptions) {
conf.JaegerPort = envs.GetEnvWithPrefix("JAEGER_PORT", conf.JaegerPort)

if conf.JaegerVersion == "" {
conf.JaegerVersion = consts.JaegerVersion
}
conf.JaegerVersion = version.AddPrefixV(envs.GetEnvWithPrefix("JAEGER_VERSION", conf.JaegerVersion))

if conf.JaegerImagePrefix == "" {
conf.JaegerImagePrefix = consts.JaegerImagePrefix
}
conf.JaegerImagePrefix = envs.GetEnvWithPrefix("JAEGER_IMAGE_PREFIX", conf.JaegerImagePrefix)

if conf.JaegerImage == "" {
conf.JaegerImage = joinImageURI(conf.JaegerImagePrefix, "all-in-one", strings.TrimPrefix(conf.JaegerVersion, "v"))
}
conf.JaegerImage = envs.GetEnvWithPrefix("JAEGER_IMAGE", conf.JaegerImage)

if conf.JaegerBinaryPrefix == "" {
conf.JaegerBinaryPrefix = consts.JaegerBinaryPrefix + "/" + conf.JaegerVersion
}
conf.JaegerBinaryPrefix = envs.GetEnvWithPrefix("JAEGER_BINARY_PREFIX", conf.JaegerBinaryPrefix)

conf.JaegerBinary = envs.GetEnvWithPrefix("JAEGER_BINARY", conf.JaegerBinary)

if conf.JaegerBinaryTar == "" {
conf.JaegerBinaryTar = conf.JaegerBinaryPrefix + "/jaeger-" + strings.TrimPrefix(conf.JaegerVersion, "v") + "-" + GOOS + "-" + GOARCH + "." + func() string {
if GOOS == windows {
return binarySuffixZip
}
return binarySuffixTar
}()
}
conf.JaegerBinaryTar = envs.GetEnvWithPrefix("JAEGER_BINARY_TAR", conf.JaegerBinaryTar)
}

// joinImageURI joins the image URI.
func joinImageURI(prefix, name, version string) string {
return prefix + "/" + name + ":" + version
Expand Down
4 changes: 4 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ var (
PrometheusBinaryPrefix = "https://github.com/prometheus/prometheus/releases/download"
PrometheusImagePrefix = "docker.io/prom"

JaegerVersion = "1.45.0"
JaegerBinaryPrefix = "https://github.com/jaegertracing/jaeger/releases/download"
JaegerImagePrefix = "docker.io/jaegertracing"

KindNodeImagePrefix = "docker.io/kindest"

DefaultUnlimitedQPS = 5000.0
Expand Down
7 changes: 7 additions & 0 deletions pkg/kwokctl/cmd/create/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func NewCommand(ctx context.Context) *cobra.Command {

cmd.Flags().Uint32Var(&flags.Options.KubeApiserverPort, "kube-apiserver-port", flags.Options.KubeApiserverPort, `Port of the apiserver (default random)`)
cmd.Flags().Uint32Var(&flags.Options.PrometheusPort, "prometheus-port", flags.Options.PrometheusPort, `Port to expose Prometheus metrics`)
cmd.Flags().Uint32Var(&flags.Options.JaegerPort, "jaeger-port", flags.Options.JaegerPort, `Port to expose Jaeger UI`)
cmd.Flags().BoolVar(&flags.Options.SecurePort, "secure-port", flags.Options.SecurePort, `The apiserver port on which to serve HTTPS with authentication and authorization, is not available before Kubernetes 1.13.0`)
cmd.Flags().BoolVar(&flags.Options.QuietPull, "quiet-pull", flags.Options.QuietPull, `Pull without printing progress information`)
cmd.Flags().StringVar(&flags.Options.KubeSchedulerConfig, "kube-scheduler-config", flags.Options.KubeSchedulerConfig, `Path to a kube-scheduler configuration file`)
Expand All @@ -87,6 +88,9 @@ func NewCommand(ctx context.Context) *cobra.Command {
`)
cmd.Flags().StringVar(&flags.Options.PrometheusImage, "prometheus-image", flags.Options.PrometheusImage, `Image of Prometheus, only for docker/podman/nerdctl/kind/kind-podman runtime
'${KWOK_PROMETHEUS_IMAGE_PREFIX}/prometheus:${KWOK_PROMETHEUS_VERSION}'
`)
cmd.Flags().StringVar(&flags.Options.JaegerImage, "jaeger-image", flags.Options.JaegerImage, `Image of Jaeger, only for docker/podman/nerdctl/kind/kind-podman runtime
'${KWOK_JAEGER_IMAGE_PREFIX}/all-in-one:${KWOK_JAEGER_VERSION}'
`)
cmd.Flags().Uint32Var(&flags.Options.KwokControllerPort, "controller-port", flags.Options.KwokControllerPort, `Port of kwok-controller given to the host`)
cmd.Flags().StringVar(&flags.Options.KindNodeImage, "kind-node-image", flags.Options.KindNodeImage, `Image of kind node, only for kind/kind-podman runtime
Expand All @@ -105,6 +109,9 @@ func NewCommand(ctx context.Context) *cobra.Command {
`)
cmd.Flags().StringVar(&flags.Options.PrometheusBinary, "prometheus-binary", flags.Options.PrometheusBinary, `Binary of Prometheus, only for binary runtime`)
cmd.Flags().StringVar(&flags.Options.PrometheusBinaryTar, "prometheus-binary-tar", flags.Options.PrometheusBinaryTar, `Tar of Prometheus, if --prometheus-binary is set, this is ignored, only for binary runtime
`)
cmd.Flags().StringVar(&flags.Options.JaegerBinary, "jaeger-binary", flags.Options.JaegerBinary, `Binary of Jaeger, only for binary runtime`)
cmd.Flags().StringVar(&flags.Options.JaegerBinaryTar, "jaeger-binary-tar", flags.Options.JaegerBinaryTar, `Tar of Jaeger, if --jaeger-binary is set, this is ignored, only for binary runtime
`)
cmd.Flags().StringVar(&flags.Options.DockerComposeBinary, "docker-compose-binary", flags.Options.DockerComposeBinary, `Binary of Docker-compose, only for docker runtime
`)
Expand Down
Loading

0 comments on commit 95aa17a

Please sign in to comment.