Skip to content

Commit

Permalink
adapt openyurt for k8s v1.18.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch committed May 18, 2021
1 parent b7f937c commit a6f84c2
Show file tree
Hide file tree
Showing 53 changed files with 1,093 additions and 896 deletions.
2 changes: 1 addition & 1 deletion cmd/yurt-controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/cli/globalflag"
"k8s.io/component-base/version"
"k8s.io/klog"
genericcontrollermanager "k8s.io/kubernetes/cmd/controller-manager/app"
"k8s.io/kubernetes/pkg/controller"
utilflag "k8s.io/kubernetes/pkg/util/flag"
"k8s.io/kubernetes/pkg/version"
)

const (
Expand Down
6 changes: 1 addition & 5 deletions cmd/yurt-controller-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ import (
"time"

lifecyclecontroller "github.com/openyurtio/openyurt/pkg/controller/nodelifecycle"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)

func startNodeLifecycleController(ctx ControllerContext) (http.Handler, bool, error) {
lifecycleController, err := lifecyclecontroller.NewNodeLifecycleController(
ctx.InformerFactory.Coordination().V1beta1().Leases(),
ctx.InformerFactory.Coordination().V1().Leases(),
ctx.InformerFactory.Core().V1().Pods(),
ctx.InformerFactory.Core().V1().Nodes(),
ctx.InformerFactory.Apps().V1().DaemonSets(),
Expand All @@ -48,8 +46,6 @@ func startNodeLifecycleController(ctx ControllerContext) (http.Handler, bool, er
ctx.ComponentConfig.NodeLifecycleController.LargeClusterSizeThreshold,
ctx.ComponentConfig.NodeLifecycleController.UnhealthyZoneThreshold,
ctx.ComponentConfig.NodeLifecycleController.EnableTaintManager,
utilfeature.DefaultFeatureGate.Enabled(features.TaintBasedEvictions),
utilfeature.DefaultFeatureGate.Enabled(features.TaintNodesByCondition),
)
if err != nil {
return nil, true, err
Expand Down
4 changes: 2 additions & 2 deletions cmd/yurt-controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

"github.com/openyurtio/openyurt/cmd/yurt-controller-manager/app"
"k8s.io/component-base/logs"
_ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugin
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugin
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
)

func main() {
Expand Down
15 changes: 15 additions & 0 deletions cmd/yurthub/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import (

"github.com/openyurtio/openyurt/cmd/yurthub/app/options"
"github.com/openyurtio/openyurt/pkg/projectinfo"
"github.com/openyurtio/openyurt/pkg/yurthub/cachemanager"
"github.com/openyurtio/openyurt/pkg/yurthub/kubernetes/serializer"
"github.com/openyurtio/openyurt/pkg/yurthub/storage/factory"

"k8s.io/klog"
)
Expand All @@ -48,6 +51,8 @@ type YurtHubConfiguration struct {
EnableDummyIf bool
EnableIptables bool
HubAgentDummyIfName string
StorageWrapper cachemanager.StorageWrapper
SerializerManager *serializer.SerializerManager
}

// Complete converts *options.YurtHubOptions to *YurtHubConfiguration
Expand All @@ -57,6 +62,14 @@ func Complete(options *options.YurtHubOptions) (*YurtHubConfiguration, error) {
return nil, err
}

storageManager, err := factory.CreateStorage()
if err != nil {
klog.Errorf("could not create storage manager, %v", err)
return nil, err
}
storageWrapper := cachemanager.NewStorageWrapper(storageManager)
serializerManager := serializer.NewSerializerManager()

hubServerAddr := net.JoinHostPort(options.YurtHubHost, options.YurtHubPort)
proxyServerAddr := net.JoinHostPort(options.YurtHubHost, options.YurtHubProxyPort)
proxyServerDummyAddr := net.JoinHostPort(options.HubAgentDummyIfIP, options.YurtHubProxyPort)
Expand All @@ -79,6 +92,8 @@ func Complete(options *options.YurtHubOptions) (*YurtHubConfiguration, error) {
EnableDummyIf: options.EnableDummyIf,
EnableIptables: options.EnableIptables,
HubAgentDummyIfName: options.HubAgentDummyIfName,
StorageWrapper: storageWrapper,
SerializerManager: serializerManager,
}

return cfg, nil
Expand Down
49 changes: 13 additions & 36 deletions cmd/yurthub/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ import (
"github.com/openyurtio/openyurt/pkg/yurthub/certificate/kubelet"
"github.com/openyurtio/openyurt/pkg/yurthub/gc"
"github.com/openyurtio/openyurt/pkg/yurthub/healthchecker"
"github.com/openyurtio/openyurt/pkg/yurthub/kubernetes/serializer"
"github.com/openyurtio/openyurt/pkg/yurthub/network"
"github.com/openyurtio/openyurt/pkg/yurthub/proxy"
"github.com/openyurtio/openyurt/pkg/yurthub/server"
"github.com/openyurtio/openyurt/pkg/yurthub/storage/factory"
"github.com/openyurtio/openyurt/pkg/yurthub/transport"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -81,35 +79,6 @@ func NewCmdStartYurtHub(stopCh <-chan struct{}) *cobra.Command {
// Run runs the YurtHubConfiguration. This should never exit
func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
trace := 1
klog.Infof("%d. new transport manager for healthz client", trace)
transportManager, err := transport.NewTransportManager(cfg.HeartbeatTimeoutSeconds, stopCh)
if err != nil {
klog.Errorf("could not new transport manager, %v", err)
return err
}
trace++

klog.Infof("%d. create storage manager", trace)
storageManager, err := factory.CreateStorage()
if err != nil {
klog.Errorf("could not create storage manager, %v", err)
return err
}
storageWrapper := cachemanager.NewStorageWrapper(storageManager)
trace++

klog.Infof("%d. new serializer manager", trace)
serializerManager := serializer.NewSerializerManager()
trace++

klog.Infof("%d. new cache manager with storage wrapper and serializer manager", trace)
cacheMgr, err := cachemanager.NewCacheManager(storageWrapper, serializerManager)
if err != nil {
klog.Errorf("could not new cache manager, %v", err)
return err
}
trace++

klog.Infof("%d. register cert managers", trace)
cmr := certificate.NewCertificateManagerRegistry()
kubelet.Register(cmr)
Expand All @@ -124,25 +93,33 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
}
trace++

klog.Infof("%d. update transport manager", trace)
err = transportManager.UpdateTransport(certManager)
klog.Infof("%d. new transport manager", trace)
transportManager, err := transport.NewTransportManager(certManager, stopCh)
if err != nil {
klog.Errorf("could not update transport manager, %v", err)
klog.Errorf("could not new transport manager, %v", err)
return err
}
trace++

klog.Infof("%d. create health checker for remote servers ", trace)
healthChecker, err := healthchecker.NewHealthChecker(cfg, transportManager, storageWrapper, stopCh)
healthChecker, err := healthchecker.NewHealthChecker(cfg, transportManager, stopCh)
if err != nil {
klog.Errorf("could not new health checker, %v", err)
return err
}
healthChecker.Run()
trace++

klog.Infof("%d. new cache manager with storage wrapper and serializer manager", trace)
cacheMgr, err := cachemanager.NewCacheManager(cfg.StorageWrapper, cfg.SerializerManager)
if err != nil {
klog.Errorf("could not new cache manager, %v", err)
return err
}
trace++

klog.Infof("%d. new gc manager for node %s, and gc frequency is a random time between %d min and %d min", trace, cfg.NodeName, cfg.GCFrequency, 3*cfg.GCFrequency)
gcMgr, err := gc.NewGCManager(cfg, storageManager, transportManager, stopCh)
gcMgr, err := gc.NewGCManager(cfg, transportManager, stopCh)
if err != nil {
klog.Errorf("could not new gc manager, %v", err)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CacheManager provides methods for managing resources cached on edge nodes, which
```go
// CacheManager is an adaptor to cache runtime object data into backend storage
type CacheManager interface {
CacheResponse(ctx context.Context, prc io.ReadCloser, stopCh <-chan struct{}) error
CacheResponse(req *http.Request, prc io.ReadCloser, stopCh <-chan struct{}) error
QueryCache(req *http.Request) (runtime.Object, error)
UpdateCacheAgents(agents []string) error
ListCacheAgents() []string
Expand Down Expand Up @@ -440,4 +440,4 @@ func (hl *HandlerLayer) SelectAndProcess(obj runtime.Object) (runtime.Object, bo

- [ ] 03/01/2021: Proposed idea.
- [ ] 03/01/2021: Commit the PR about delete [resourceToKindMap](https://github.com/openyurtio/openyurt/blob/4d7463a40801c29d09c4f7d10ba46b73cb019915/pkg/yurthub/cachemanager/cache_manager.go#L46) and [resourceToListKindMap](https://github.com/openyurtio/openyurt/blob/4d7463a40801c29d09c4f7d10ba46b73cb019915/pkg/yurthub/cachemanager/cache_manager.go#L62) (https://github.com/openyurtio/openyurt/pull/225)
- [ ] 03/28/2021: Update this proposal
- [ ] 03/28/2021: Update this proposal
65 changes: 31 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,66 @@ require (
github.com/emicklei/go-restful v2.12.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/go-openapi/spec v0.19.8 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/mux v1.7.4
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo v1.13.0
github.com/onsi/gomega v1.10.1
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/procfs v0.0.11 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e
github.com/vishvananda/netlink v1.0.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
google.golang.org/grpc v1.27.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
k8s.io/api v0.17.7
k8s.io/apiextensions-apiserver v0.17.7 // indirect
k8s.io/apimachinery v0.17.7
k8s.io/apiserver v0.16.9
k8s.io/client-go v0.17.7
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/apiserver v0.18.8
k8s.io/client-go v0.18.8
k8s.io/cluster-bootstrap v0.0.0
k8s.io/component-base v0.16.9
k8s.io/component-base v0.18.8
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.0.0
k8s.io/kubernetes v1.18.3
k8s.io/kubernetes v1.18.8
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
sigs.k8s.io/apiserver-network-proxy v0.0.15
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace (
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2
google.golang.org/grpc v1.27.0 => google.golang.org/grpc v1.26.0
k8s.io/api => k8s.io/api v0.16.9
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.16.9
k8s.io/apimachinery => k8s.io/apimachinery v0.16.10-beta.0
k8s.io/apiserver => k8s.io/apiserver v0.16.9
k8s.io/cli-runtime => k8s.io/cli-runtime v0.16.9
k8s.io/client-go => k8s.io/client-go v0.16.9
k8s.io/cloud-provider => k8s.io/cloud-provider v0.16.9
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.16.9
k8s.io/code-generator => k8s.io/code-generator v0.16.10-beta.0
k8s.io/component-base => k8s.io/component-base v0.16.9
k8s.io/cri-api => k8s.io/cri-api v0.16.13-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.16.9
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.16.9
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.16.9
k8s.io/kube-proxy => k8s.io/kube-proxy v0.16.9
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.16.9
k8s.io/kubectl => k8s.io/kubectl v0.16.9
k8s.io/kubelet => k8s.io/kubelet v0.16.9
k8s.io/kubernetes => github.com/kubernetes/kubernetes v1.16.9
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.16.9
k8s.io/metrics => k8s.io/metrics v0.16.9
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.16.9
sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15
k8s.io/api => k8s.io/api v0.18.8
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.8
k8s.io/apimachinery => k8s.io/apimachinery v0.18.9-rc.0
k8s.io/apiserver => k8s.io/apiserver v0.18.8
k8s.io/cli-runtime => k8s.io/cli-runtime v0.18.8
k8s.io/client-go => k8s.io/client-go v0.18.8
k8s.io/cloud-provider => k8s.io/cloud-provider v0.18.8
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.18.8
k8s.io/code-generator => k8s.io/code-generator v0.18.18-rc.0
k8s.io/component-base => k8s.io/component-base v0.18.8
k8s.io/cri-api => k8s.io/cri-api v0.18.18-rc.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.18.8
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.18.8
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.18.8
k8s.io/kube-proxy => k8s.io/kube-proxy v0.18.8
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.8
k8s.io/kubectl => k8s.io/kubectl v0.18.8
k8s.io/kubelet => k8s.io/kubelet v0.18.8
k8s.io/kubernetes => github.com/kubernetes/kubernetes v1.18.8
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.18.8
k8s.io/metrics => k8s.io/metrics v0.18.8
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.8
sigs.k8s.io/apiserver-network-proxy => github.com/openyurtio/apiserver-network-proxy v1.18.8
sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.5.7
sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v1.0.2
)
Loading

0 comments on commit a6f84c2

Please sign in to comment.