Skip to content

Commit

Permalink
Merge branch 'main' into supportgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
khareyash05 authored Dec 31, 2023
2 parents c3175f3 + b4117dd commit 50f18a5
Show file tree
Hide file tree
Showing 1,698 changed files with 150,227 additions and 47,094 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
version: v1.54
vertify:
name: Vertify import alias, vendor, codegen, crds
runs-on: ubuntu-latest
Expand All @@ -31,9 +31,9 @@ jobs:
with:
path: ${{ env.WORKSPACE }}
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- run: hack/verify-import-aliases.sh
- run: hack/verify-vendor.sh
- run: hack/verify-codegen.sh
Expand All @@ -49,9 +49,9 @@ jobs:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- name: Compile
run: make all
test:
Expand All @@ -62,9 +62,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
- run: make test
e2e-test:
name: E2e test
Expand Down
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,30 @@
# OSX trash
.DS_Store

# Certificate related credential files
# Encoding of certificates and private keys
*.pem
*.der
# Certificate related
*.crt
*.cer
*.ca-bundle
# Certificate signing request
*.csr
# Certificate revoking list
*.crl
# Private key related
*.key
*.p12
*.pfx
# PKCS#7 related
*.p7b
*.p7r
*.p7r
*.spc

# apiserver local up cert trash
apiserver.local.config

# SQLite DB Files
*.db
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ linters-settings:
- Standard
- Default
- Prefix(github.com/clusterpedia-io)
staticcheck:
checks:
- all
- "-SA1019" # disable the rule SA1019(Using a deprecated function, variable, constant or field)
output:
sort-results: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG BIN_NAME
ARG TARGETARCH
RUN GOARCH=${TARGETARCH} /builder.sh ${BIN_NAME}

FROM alpine:3.18.4
FROM alpine:3.18.5
RUN apk add --no-cache gcompat

# https://pkg.go.dev/net#hdr-Name_Resolution
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ clean-controller-manager-manifest:
.PHONY: golangci-lint
golangci-lint:
ifeq (, $(shell which golangci-lint))
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54
GOLANGLINT_BIN=$(shell go env GOPATH)/bin/golangci-lint
else
GOLANGLINT_BIN=$(shell which golangci-lint)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Clusterpedia can synchronize resources with multiple clusters and provide more p

> The capability of Clusterpedia is not only to search for and view but also simply control resources in the future, just like Wikipedia that supports for editing entries.
<img src="https://github.com/cncf/artwork/blob/master/other/illustrations/ashley-mcnamara/transparent/cncf-cloud-gophers-transparent.png" style="width:600px;" />
<img src="https://github.com/cncf/artwork/blob/main/other/illustrations/ashley-mcnamara/transparent/cncf-cloud-gophers-transparent.png" style="width:600px;" />

**Clusterpedia is a [Cloud Native Computing Foundation](https://cncf.io/) sandbox project.**
> If you want to join the clusterpedia channel on CNCF slack, please **[get invite to CNCF slack](https://slack.cncf.io/)** and then join the [#clusterpedia](https://cloud-native.slack.com/messages/clusterpedia) channel.
Expand Down
2 changes: 1 addition & 1 deletion builder.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.7
FROM golang:1.21.5

# FROM golang:1.19.2-alpine
# RUN apk add --no-cache build-base git bash
Expand Down
31 changes: 24 additions & 7 deletions cmd/apiserver/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import (

utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericrequest "k8s.io/apiserver/pkg/endpoints/request"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/featuregate"
"k8s.io/component-base/logs"
logsapi "k8s.io/component-base/logs/api/v1"

"github.com/clusterpedia-io/clusterpedia/pkg/apiserver"
generatedopenapi "github.com/clusterpedia-io/clusterpedia/pkg/generated/openapi"
"github.com/clusterpedia-io/clusterpedia/pkg/storage"
storageoptions "github.com/clusterpedia-io/clusterpedia/pkg/storage/options"
)
Expand All @@ -35,7 +39,7 @@ type ClusterPediaServerOptions struct {
CoreAPI *genericoptions.CoreAPIOptions
FeatureGate featuregate.FeatureGate
Admission *genericoptions.AdmissionOptions
// Traces *genericoptions.TracingOptions
Traces *genericoptions.TracingOptions

Storage *storageoptions.StorageOptions
}
Expand All @@ -62,7 +66,7 @@ func NewServerOptions() *ClusterPediaServerOptions {
CoreAPI: genericoptions.NewCoreAPIOptions(),
FeatureGate: feature.DefaultFeatureGate,
Admission: genericoptions.NewAdmissionOptions(),
// Traces: genericoptions.NewTracingOptions(),
Traces: genericoptions.NewTracingOptions(),

Storage: storageoptions.NewStorageOptions(),
}
Expand Down Expand Up @@ -95,9 +99,14 @@ func (o *ClusterPediaServerOptions) Config() (*apiserver.Config, error) {
o.Admission.DisablePlugins = append(o.Admission.DisablePlugins, lifecycle.PluginName)

genericConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
// genericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(openapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme))
// genericConfig.OpenAPIConfig.Info.Title = openAPITitle
// genericConfig.OpenAPIConfig.Info.Version= openAPIVersion

genericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(apiserver.Scheme))
genericConfig.OpenAPIConfig.Info.Title = "clusterpedia apiserver"
genericConfig.OpenAPIConfig.Info.Version = ""

genericConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(apiserver.Scheme))
genericConfig.OpenAPIV3Config.Info.Title = "clusterpedia apiserver"
genericConfig.OpenAPIV3Config.Info.Version = ""

// todo
// support watch to LongRunningFunc
Expand Down Expand Up @@ -137,7 +146,15 @@ func (o *ClusterPediaServerOptions) genericOptionsApplyTo(config *genericapiserv
if err := o.CoreAPI.ApplyTo(config); err != nil {
return err
}
if err := o.Admission.ApplyTo(&config.Config, config.SharedInformerFactory, config.ClientConfig, o.FeatureGate); err != nil {
client, err := kubernetes.NewForConfig(config.ClientConfig)
if err != nil {
return err
}
dynamicClient := dynamic.NewForConfigOrDie(config.ClientConfig)
if err := o.Admission.ApplyTo(&config.Config, config.SharedInformerFactory, client, dynamicClient, o.FeatureGate); err != nil {
return err
}
if err := o.Traces.ApplyTo(nil, &config.Config); err != nil {
return err
}

Expand All @@ -162,7 +179,7 @@ func (o *ClusterPediaServerOptions) Flags() cliflag.NamedFlagSets {
logsapi.AddFlags(o.Logs, fss.FlagSet("logs"))

// o.Admission.AddFlags(fss.FlagSet("admission"))
// o.Traces.AddFlags(fss.FlagSet("traces"))
o.Traces.AddFlags(fss.FlagSet("traces"))

o.Storage.AddFlags(fss.FlagSet("storage"))
return fss
Expand Down
3 changes: 2 additions & 1 deletion cmd/binding-apiserver/app/binding_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/clusterpedia-io/clusterpedia/pkg/generated/clientset/versioned"
"github.com/clusterpedia-io/clusterpedia/pkg/storage"
"github.com/clusterpedia-io/clusterpedia/pkg/synchromanager"
"github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro"
clusterpediafeature "github.com/clusterpedia-io/clusterpedia/pkg/utils/feature"
"github.com/clusterpedia-io/clusterpedia/pkg/version/verflag"
)
Expand Down Expand Up @@ -56,7 +57,7 @@ func NewClusterPediaServerCommand(ctx context.Context) *cobra.Command {
return err
}

synchromanager := synchromanager.NewManager(crdclient, config.StorageFactory, nil)
synchromanager := synchromanager.NewManager(crdclient, config.StorageFactory, clustersynchro.ClusterSyncConfig{}, "")
go synchromanager.Run(1, ctx.Done())

server, err := completedConfig.New()
Expand Down
4 changes: 3 additions & 1 deletion cmd/clustersynchro-manager/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
kubestatemetrics "github.com/clusterpedia-io/clusterpedia/pkg/kube_state_metrics"
metrics "github.com/clusterpedia-io/clusterpedia/pkg/metrics"
"github.com/clusterpedia-io/clusterpedia/pkg/storage"
"github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro"
)

type Config struct {
Expand All @@ -17,10 +18,11 @@ type Config struct {
EventRecorder record.EventRecorder

WorkerNumber int
ShardingName string
MetricsServerConfig metrics.Config
KubeMetricsServerConfig *kubestatemetrics.ServerConfig
MetricsStoreBuilder *kubestatemetrics.MetricsStoreBuilder
StorageFactory storage.StorageFactory
ClusterSyncConfig clustersynchro.ClusterSyncConfig

LeaderElection componentbaseconfig.LeaderElectionConfiguration
ClientConnection componentbaseconfig.ClientConnectionConfiguration
Expand Down
20 changes: 18 additions & 2 deletions cmd/clustersynchro-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/clusterpedia-io/clusterpedia/pkg/metrics"
"github.com/clusterpedia-io/clusterpedia/pkg/storage"
storageoptions "github.com/clusterpedia-io/clusterpedia/pkg/storage/options"
"github.com/clusterpedia-io/clusterpedia/pkg/synchromanager/clustersynchro"
)

const (
Expand All @@ -44,7 +45,9 @@ type Options struct {
Metrics *metrics.Options
KubeStateMetrics *kubestatemetrics.Options

WorkerNumber int // WorkerNumber is the number of worker goroutines
WorkerNumber int // WorkerNumber is the number of worker goroutines
PageSizeForResourceSync int64
ShardingName string
}

func NewClusterSynchroManagerOptions() (*Options, error) {
Expand Down Expand Up @@ -88,6 +91,10 @@ func (o *Options) Flags() cliflag.NamedFlagSets {
genericfs.Float32Var(&o.ClientConnection.QPS, "kube-api-qps", o.ClientConnection.QPS, "QPS to use while talking with kubernetes apiserver.")
genericfs.Int32Var(&o.ClientConnection.Burst, "kube-api-burst", o.ClientConnection.Burst, "Burst to use while talking with kubernetes apiserver.")
genericfs.IntVar(&o.WorkerNumber, "worker-number", o.WorkerNumber, "The number of worker goroutines.")
genericfs.StringVar(&o.ShardingName, "sharding-name", o.ShardingName, "The sharding name of manager.")

syncfs := fss.FlagSet("resource sync")
syncfs.Int64Var(&o.PageSizeForResourceSync, "page-size", o.PageSizeForResourceSync, "The requested chunk size of initial and resync watch lists for resource sync")

options.BindLeaderElectionFlags(&o.LeaderElection, genericfs)

Expand Down Expand Up @@ -155,17 +162,26 @@ func (o *Options) Config() (*config.Config, error) {
}
kubeStateMetricsServerConfig := o.KubeStateMetrics.ServerConfig(metricsConfig)

if o.ShardingName != "" {
o.LeaderElection.ResourceName = fmt.Sprintf("%s-%s", o.LeaderElection.ResourceName, o.ShardingName)
}

return &config.Config{
CRDClient: crdclient,
Kubeconfig: kubeconfig,
EventRecorder: eventRecorder,

StorageFactory: storagefactory,
WorkerNumber: o.WorkerNumber,
ShardingName: o.ShardingName,

MetricsServerConfig: metricsConfig,
KubeMetricsServerConfig: kubeStateMetricsServerConfig,
MetricsStoreBuilder: metricsStoreBuilder,

ClusterSyncConfig: clustersynchro.ClusterSyncConfig{
MetricsStoreBuilder: metricsStoreBuilder,
PageSizeForResourceSync: o.PageSizeForResourceSync,
},

LeaderElection: o.LeaderElection,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/clustersynchro-manager/app/synchro.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewClusterSynchroManagerCommand(ctx context.Context) *cobra.Command {
}

func Run(ctx context.Context, c *config.Config) error {
synchromanager := synchromanager.NewManager(c.CRDClient, c.StorageFactory, c.MetricsStoreBuilder)
synchromanager := synchromanager.NewManager(c.CRDClient, c.StorageFactory, c.ClusterSyncConfig, c.ShardingName)

go func() {
metrics.RunServer(c.MetricsServerConfig)
Expand Down
7 changes: 5 additions & 2 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ func run(config *restclient.Config, stopCh <-chan struct{}) error {
if err != nil {
return err
}

mapper, err := apiutil.NewDynamicRESTMapper(config)
httpClient, err := restclient.HTTPClientFor(config)
if err != nil {
return err
}
mapper, err := apiutil.NewDynamicRESTMapper(config, httpClient)
if err != nil {
return err
}
Expand Down
20 changes: 20 additions & 0 deletions deploy/clusterpedia_apiserver_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
- /usr/local/bin/apiserver
- --secure-port=443
- --storage-config=/etc/clusterpedia/storage/internalstorage-config.yaml
- --tracing-config-file=/etc/clusterpedia/trace/tracing-config.yaml
- -v=3
env:
- name: DB_PASSWORD
Expand All @@ -52,8 +53,27 @@ spec:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
readOnly: true
- name: tracing-config
mountPath: /etc/clusterpedia/trace
readOnly: true
serviceAccountName: clusterpedia-apiserver
volumes:
- name: internalstorage-config
configMap:
name: clusterpedia-internalstorage
- name: tracing-config
configMap:
name: clusterpedia-tracing-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: clusterpedia-tracing-config
namespace: clusterpedia-system
data:
tracing-config.yaml: |
apiVersion: apiserver.config.k8s.io/v1beta1
kind: TracingConfiguration
# default
# endpoint: localhost:4317
samplingRatePerMillion: 1000000
Loading

0 comments on commit 50f18a5

Please sign in to comment.