1- From 3f3c59ff2c32ec2c9a74bcbc4312854d5aff1fee Mon Sep 17 00:00:00 2001
1+ From 241fc2a00be6fde3f7059ae61842cba44dff82a5 Mon Sep 17 00:00:00 2001
22From: Konstantinos Tsakalozos <kos.tsakalozos@canonical.com>
33Date: Wed, 3 Mar 2021 18:19:37 +0200
4- Subject: [PATCH 1/2 ] Kubelite integration
4+ Subject: [PATCH] Kubelite integration
55
66---
7- cmd/kube-apiserver/app/server.go | 9 ++-
8- cmd/kube-scheduler/app/server.go | 6 +-
9- cmd/kubelet/app/server.go | 13 +++--
10- cmd/kubelite/app/daemons/daemon.go | 85 +++++++++++++++++++++++++++++
11- cmd/kubelite/app/options/options.go | 79 +++++++++++++++++++++++++++
12- cmd/kubelite/app/server.go | 80 +++++++++++++++++++++++++++
13- cmd/kubelite/kubelite.go | 25 +++++++++
14- pkg/volume/csi/csi_plugin.go | 11 +++-
15- 8 files changed, 297 insertions(+), 11 deletions(-)
7+ cmd/kube-apiserver/app/server.go | 9 +-
8+ .../app/options/options.go | 10 --
9+ cmd/kube-scheduler/app/server.go | 6 +-
10+ cmd/kubelet/app/server.go | 4 -
11+ cmd/kubelite/app/daemons/daemon.go | 85 +++++++++++++++++
12+ cmd/kubelite/app/options/options.go | 79 ++++++++++++++++
13+ cmd/kubelite/app/server.go | 91 +++++++++++++++++++
14+ cmd/kubelite/kubelite.go | 25 +++++
15+ pkg/volume/csi/csi_plugin.go | 11 ++-
16+ 9 files changed, 300 insertions(+), 20 deletions(-)
1617 create mode 100644 cmd/kubelite/app/daemons/daemon.go
1718 create mode 100644 cmd/kubelite/app/options/options.go
1819 create mode 100644 cmd/kubelite/app/server.go
1920 create mode 100644 cmd/kubelite/kubelite.go
2021
2122diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go
22- index 4dc9d1f3e89..86a599996db 100644
23+ index 71ebb317461..86dc50ce671 100644
2324--- a/cmd/kube-apiserver/app/server.go
2425+++ b/cmd/kube-apiserver/app/server.go
25- @@ -65 ,9 +65 ,14 @@ func init() {
26+ @@ -67 ,9 +67 ,14 @@ func init() {
2627 }
2728
2829 // NewAPIServerCommand creates a *cobra.Command object with default parameters
@@ -39,11 +40,49 @@ index 4dc9d1f3e89..86a599996db 100644
3940 featureGate := s.GenericServerRunOptions.ComponentGlobalsRegistry.FeatureGateFor(basecompatibility.DefaultKubeComponent)
4041
4142 cmd := &cobra.Command{
43+ diff --git a/cmd/kube-controller-manager/app/options/options.go b/cmd/kube-controller-manager/app/options/options.go
44+ index 176b2a14bc1..5048b04014e 100644
45+ --- a/cmd/kube-controller-manager/app/options/options.go
46+ +++ b/cmd/kube-controller-manager/app/options/options.go
47+ @@ -25,11 +25,9 @@ import (
48+ v1 "k8s.io/api/core/v1"
49+ utilerrors "k8s.io/apimachinery/pkg/util/errors"
50+ utilruntime "k8s.io/apimachinery/pkg/util/runtime"
51+ - "k8s.io/apimachinery/pkg/util/version"
52+ apiserveroptions "k8s.io/apiserver/pkg/server/options"
53+ "k8s.io/apiserver/pkg/util/compatibility"
54+ utilfeature "k8s.io/apiserver/pkg/util/feature"
55+ - clientgofeaturegate "k8s.io/client-go/features"
56+ clientset "k8s.io/client-go/kubernetes"
57+ clientgokubescheme "k8s.io/client-go/kubernetes/scheme"
58+ restclient "k8s.io/client-go/rest"
59+ @@ -40,7 +38,6 @@ import (
60+ cpoptions "k8s.io/cloud-provider/options"
61+ cliflag "k8s.io/component-base/cli/flag"
62+ basecompatibility "k8s.io/component-base/compatibility"
63+ - "k8s.io/component-base/featuregate"
64+ "k8s.io/component-base/logs"
65+ logsapi "k8s.io/component-base/logs/api/v1"
66+ "k8s.io/component-base/metrics"
67+ @@ -298,13 +295,6 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
68+ fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
69+ fs.StringVar(&s.Generic.ClientConnection.Kubeconfig, "kubeconfig", s.Generic.ClientConnection.Kubeconfig, "Path to kubeconfig file with authorization and master location information (the master location can be overridden by the master flag).")
70+
71+ - if !utilfeature.DefaultFeatureGate.Enabled(featuregate.Feature(clientgofeaturegate.WatchListClient)) {
72+ - ver := version.MustParse("1.34")
73+ - if err := utilfeature.DefaultMutableFeatureGate.OverrideDefaultAtVersion(featuregate.Feature(clientgofeaturegate.WatchListClient), true, ver); err != nil {
74+ - panic(fmt.Sprintf("unable to set %s feature gate, err: %v", clientgofeaturegate.WatchListClient, err))
75+ - }
76+ - }
77+ -
78+ s.ComponentGlobalsRegistry.AddFlags(fss.FlagSet("generic"))
79+
80+ return fss
4281diff --git a/cmd/kube-scheduler/app/server.go b/cmd/kube-scheduler/app/server.go
43- index bf5a3077552..6f2abd5616f 100644
82+ index 803e0c37861..5b58d437d30 100644
4483--- a/cmd/kube-scheduler/app/server.go
4584+++ b/cmd/kube-scheduler/app/server.go
46- @@ -149 ,7 +149 ,11 @@ func runCommand(cmd *cobra.Command, opts *options.Options, registryOptions ...Op
85+ @@ -150 ,7 +150 ,11 @@ func runCommand(cmd *cobra.Command, opts *options.Options, registryOptions ...Op
4786 ctx, cancel := context.WithCancel(context.Background())
4887 defer cancel()
4988 go func() {
@@ -57,45 +96,27 @@ index bf5a3077552..6f2abd5616f 100644
5796 cancel()
5897 }()
5998diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go
60- index 3a2256f098a..044e55996c9 100644
99+ index f069f6b08b9..62f3ca58dc7 100644
61100--- a/cmd/kubelet/app/server.go
62101+++ b/cmd/kubelet/app/server.go
63- @@ -135,7 +135,7 @@ func init() {
64- }
65-
66- // NewKubeletCommand creates a *cobra.Command object with default parameters
67- - func NewKubeletCommand() *cobra.Command {
68- + func NewKubeletCommand(ctx ...context.Context) *cobra.Command {
69- cleanFlagSet := pflag.NewFlagSet(server.ComponentKubelet, pflag.ContinueOnError)
70- cleanFlagSet.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
71- kubeletFlags := options.NewKubeletFlags()
72- @@ -279,6 +279,12 @@ is checked every 20 seconds (also configurable with a flag).`,
73- if err := checkPermissions(); err != nil {
74- klog.ErrorS(err, "kubelet running with insufficient permissions")
75- }
76- + runctx := context.Background()
77- + if len(ctx) == 0 {
78- + runctx = genericapiserver.SetupSignalContext()
79- + } else {
80- + runctx = ctx[0]
81- + }
82-
83- // make the kubelet's config safe for logging
84- config := kubeletServer.KubeletConfiguration.DeepCopy()
85- @@ -288,12 +294,9 @@ is checked every 20 seconds (also configurable with a flag).`,
102+ @@ -63,7 +63,6 @@ import (
103+ "k8s.io/apimachinery/pkg/util/sets"
104+ "k8s.io/apimachinery/pkg/util/validation/field"
105+ "k8s.io/apimachinery/pkg/util/wait"
106+ - genericapiserver "k8s.io/apiserver/pkg/server"
107+ "k8s.io/apiserver/pkg/server/healthz"
108+ utilfeature "k8s.io/apiserver/pkg/util/feature"
109+ clientset "k8s.io/client-go/kubernetes"
110+ @@ -291,9 +290,6 @@ is checked every 20 seconds (also configurable with a flag).`,
86111 // log the kubelet's config for inspection
87- klog .V(5).InfoS ("KubeletConfiguration", "configuration", klog.Format(config))
112+ logger .V(5).Info ("KubeletConfiguration", "configuration", klog.Format(config))
88113
89114- // set up signal context for kubelet shutdown
90115- ctx := genericapiserver.SetupSignalContext()
91116-
92117 utilfeature.DefaultMutableFeatureGate.AddMetrics()
93118 // run the kubelet
94- - return Run(ctx, kubeletServer, kubeletDeps, utilfeature.DefaultFeatureGate)
95- + return Run(runctx, kubeletServer, kubeletDeps, utilfeature.DefaultFeatureGate)
96- },
97- }
98-
119+ return Run(ctx, kubeletServer, kubeletDeps, utilfeature.DefaultFeatureGate)
99120diff --git a/cmd/kubelite/app/daemons/daemon.go b/cmd/kubelite/app/daemons/daemon.go
100121new file mode 100644
101122index 00000000000..46c1af7fdb9
@@ -274,10 +295,10 @@ index 00000000000..80f1d8b09fc
274295+ }
275296diff --git a/cmd/kubelite/app/server.go b/cmd/kubelite/app/server.go
276297new file mode 100644
277- index 00000000000..4ff36cd6432
298+ index 00000000000..858a7c1094c
278299--- /dev/null
279300+++ b/cmd/kubelite/app/server.go
280- @@ -0,0 +1,80 @@
301+ @@ -0,0 +1,91 @@
281302+ /*
282303+ Copyright © 2020 NAME HERE <EMAIL ADDRESS>
283304+
@@ -301,7 +322,11 @@ index 00000000000..4ff36cd6432
301322+ "time"
302323+
303324+ "github.com/spf13/cobra"
325+ + "k8s.io/apimachinery/pkg/util/version"
304326+ genericapiserver "k8s.io/apiserver/pkg/server"
327+ + utilfeature "k8s.io/apiserver/pkg/util/feature"
328+ + clientgofeaturegate "k8s.io/client-go/features"
329+ + "k8s.io/component-base/featuregate"
305330+ daemon "k8s.io/kubernetes/cmd/kubelite/app/daemons"
306331+ "k8s.io/kubernetes/cmd/kubelite/app/options"
307332+ )
@@ -319,6 +344,13 @@ index 00000000000..4ff36cd6432
319344+ ctx := genericapiserver.SetupSignalContext()
320345+
321346+ if opts.StartControlPlane {
347+ + if !utilfeature.DefaultFeatureGate.Enabled(featuregate.Feature(clientgofeaturegate.WatchListClient)) {
348+ + ver := version.MustParse("1.34")
349+ + if err := utilfeature.DefaultMutableFeatureGate.OverrideDefaultAtVersion(featuregate.Feature(clientgofeaturegate.WatchListClient), true, ver); err != nil {
350+ + panic(fmt.Sprintf("unable to set %s feature gate, err: %v", clientgofeaturegate.WatchListClient, err))
351+ + }
352+ + }
353+ +
322354+ apiserverArgs := options.ReadArgsFromFile(opts.APIServerArgsFile)
323355+ go daemon.StartAPIServer(apiserverArgs, ctx)
324356+ daemon.WaitForAPIServer(opts.KubeconfigFile, 360*time.Second)
@@ -390,10 +422,10 @@ index 00000000000..30ab604f480
390422+ println("Stopping kubelite")
391423+ }
392424diff --git a/pkg/volume/csi/csi_plugin.go b/pkg/volume/csi/csi_plugin.go
393- index d09950bb45a..248022ef45d 100644
425+ index d2d830376da..fa6dbc91fef 100644
394426--- a/pkg/volume/csi/csi_plugin.go
395427+++ b/pkg/volume/csi/csi_plugin.go
396- @@ -345 ,18 +345 ,23 @@ func (p *csiPlugin) Init(host volume.VolumeHost) error {
428+ @@ -347 ,18 +347 ,23 @@ func (p *csiPlugin) Init(host volume.VolumeHost) error {
397429 }
398430
399431 // Initializing the label management channels
0 commit comments