Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to not start the control plane in kubelite #2023

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions build-scripts/patches/0001-kubelite-single-binary-k8s.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 43d97aabd7c927790641b37e0ec2dcb8e59635a9 Mon Sep 17 00:00:00 2001
From 7136e0646e50d26d40db49ae0f6606775d11a56a Mon Sep 17 00:00:00 2001
From: Konstantinos <[email protected]>
Date: Thu, 24 Sep 2020 21:06:03 +0300
Subject: [PATCH] kubelite, single binary k8s
Subject: [PATCH 1/2] kubelite, single binary k8s

---
cmd/kube-apiserver/app/server.go | 9 ++--
Expand Down Expand Up @@ -385,3 +385,81 @@ index 00000000000..667b24f68e6
--
2.25.1


From 7d9c9921a6c646cb254c3eb312babb56784af952 Mon Sep 17 00:00:00 2001
From: Konstantinos Tsakalozos <[email protected]>
Date: Wed, 17 Feb 2021 11:00:26 +0200
Subject: [PATCH 2/2] Option to not start the control plane on kubelite

---
cmd/kubelite/app/options/options.go | 5 +++--
cmd/kubelite/app/server.go | 20 ++++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/cmd/kubelite/app/options/options.go b/cmd/kubelite/app/options/options.go
index ca5e7b3d207..80f1d8b09fc 100644
--- a/cmd/kubelite/app/options/options.go
+++ b/cmd/kubelite/app/options/options.go
@@ -30,8 +30,8 @@ type Options struct {
ProxyArgsFile string
KubeletArgsFile string
APIServerArgsFile string
-
- KubeconfigFile string
+ KubeconfigFile string
+ StartControlPlane bool
}

func NewOptions() (*Options){
@@ -42,6 +42,7 @@ func NewOptions() (*Options){
"/var/snap/microk8s/current/args/kubelet",
"/var/snap/microk8s/current/args/kube-apiserver",
"/var/snap/microk8s/current/credentials/client.config",
+ true,
}
return &o
}
diff --git a/cmd/kubelite/app/server.go b/cmd/kubelite/app/server.go
index e70f19194a4..e7452a09e3e 100644
--- a/cmd/kubelite/app/server.go
+++ b/cmd/kubelite/app/server.go
@@ -36,19 +36,22 @@ var liteCmd = &cobra.Command{
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
ctx := genericapiserver.SetupSignalContext()
- apiserverArgs := options.ReadArgsFromFile(opts.APIServerArgsFile)
- go daemon.StartAPIServer(apiserverArgs, ctx.Done())
- daemon.WaitForAPIServer(opts.KubeconfigFile, 360 * time.Second)

- controllerArgs := options.ReadArgsFromFile(opts.ControllerManagerArgsFile)
- go daemon.StartControllerManager(controllerArgs, ctx)
+ if opts.StartControlPlane {
+ apiserverArgs := options.ReadArgsFromFile(opts.APIServerArgsFile)
+ go daemon.StartAPIServer(apiserverArgs, ctx.Done())
+ daemon.WaitForAPIServer(opts.KubeconfigFile, 360 * time.Second)
+
+ controllerArgs := options.ReadArgsFromFile(opts.ControllerManagerArgsFile)
+ go daemon.StartControllerManager(controllerArgs, ctx)
+
+ schedulerArgs := options.ReadArgsFromFile(opts.SchedulerArgsFile)
+ go daemon.StartScheduler(schedulerArgs, ctx)
+ }

proxyArgs := options.ReadArgsFromFile(opts.ProxyArgsFile)
go daemon.StartProxy(proxyArgs)

- schedulerArgs := options.ReadArgsFromFile(opts.SchedulerArgsFile)
- go daemon.StartScheduler(schedulerArgs, ctx)
-
kubeletArgs := options.ReadArgsFromFile(opts.KubeletArgsFile)
daemon.StartKubelet(kubeletArgs, ctx)
},
@@ -72,4 +75,5 @@ func init() {
liteCmd.Flags().StringVar(&opts.KubeletArgsFile, "kubelet-args-file", opts.KubeletArgsFile, "file with the arguments for kubelet")
liteCmd.Flags().StringVar(&opts.APIServerArgsFile, "apiserver-args-file", opts.APIServerArgsFile, "file with the arguments for the API server")
liteCmd.Flags().StringVar(&opts.KubeconfigFile , "kubeconfig-file", opts.KubeconfigFile, "the kubeconfig file to use to healthcheck the API server")
+ liteCmd.Flags().BoolVar(&opts.StartControlPlane, "start-control-plane", opts.StartControlPlane, "start the control plane (API server, scheduler and controller manager)")
}
--
2.25.1

1 change: 1 addition & 0 deletions microk8s-resources/default-args/kubelite
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
--kubelet-args-file=$SNAP_DATA/args/kubelet
--apiserver-args-file=$SNAP_DATA/args/kube-apiserver
--kubeconfig-file=$SNAP_DATA/credentials/client.config
--start-control-plane=true
7 changes: 7 additions & 0 deletions microk8s-resources/wrappers/run-kubelite-with-args
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ then
exit 0
fi

if [ -e ${SNAP_DATA}/var/lock/clustered.lock ]
then
refresh_opt_in_local_config "start-control-plane" "false" kubelite
else
refresh_opt_in_local_config "start-control-plane" "true" kubelite
fi

## API server configuration
# wait up to two minutes for the default network interface to appear.
n=0
Expand Down