Skip to content

Commit e654879

Browse files
Merge pull request #1903 from r2d4/kubeadm-v2
Kubeadm bootstrapper
2 parents 2b7fd32 + b291b0f commit e654879

File tree

15 files changed

+727
-34
lines changed

15 files changed

+727
-34
lines changed

cmd/minikube/cmd/root.go

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
configCmd "k8s.io/minikube/cmd/minikube/cmd/config"
3535
"k8s.io/minikube/cmd/util"
3636
"k8s.io/minikube/pkg/minikube/bootstrapper"
37+
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
3738
"k8s.io/minikube/pkg/minikube/bootstrapper/localkube"
3839
"k8s.io/minikube/pkg/minikube/config"
3940
"k8s.io/minikube/pkg/minikube/constants"
@@ -174,6 +175,11 @@ func GetClusterBootstrapper(api libmachine.API, bootstrapperName string) (bootst
174175
if err != nil {
175176
return nil, errors.Wrap(err, "getting localkube bootstrapper")
176177
}
178+
case bootstrapper.BootstrapperTypeKubeadm:
179+
b, err = kubeadm.NewKubeadmBootstrapper(api)
180+
if err != nil {
181+
return nil, errors.Wrap(err, "getting kubeadm bootstrapper")
182+
}
177183
default:
178184
return nil, fmt.Errorf("Unknown bootstrapper: %s", bootstrapperName)
179185
}

cmd/minikube/cmd/start.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ assumes you have already installed one of the VM drivers: virtualbox/vmwarefusio
8888

8989
func runStart(cmd *cobra.Command, args []string) {
9090
shouldCacheImages := viper.GetBool(cacheImages)
91+
k8sVersion := viper.GetString(kubernetesVersion)
92+
clusterBootstrapper := viper.GetString(cmdcfg.Bootstrapper)
93+
9194
if shouldCacheImages {
92-
go machine.CacheImagesForBootstrapper(viper.GetString(cmdcfg.Bootstrapper))
95+
go machine.CacheImagesForBootstrapper(k8sVersion, clusterBootstrapper)
9396
}
9497
api, err := machine.NewAPIClient()
9598
if err != nil {
@@ -112,8 +115,8 @@ func runStart(cmd *cobra.Command, args []string) {
112115
os.Exit(1)
113116
}
114117

115-
if dv := viper.GetString(kubernetesVersion); dv != constants.DefaultKubernetesVersion {
116-
validateK8sVersion(dv)
118+
if k8sVersion != constants.DefaultKubernetesVersion {
119+
validateK8sVersion(k8sVersion)
117120
}
118121

119122
config := cluster.MachineConfig{
@@ -195,7 +198,7 @@ func runStart(cmd *cobra.Command, args []string) {
195198
ShouldLoadCachedImages: shouldCacheImages,
196199
}
197200

198-
clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
201+
k8sBootstrapper, err := GetClusterBootstrapper(api, clusterBootstrapper)
199202
if err != nil {
200203
glog.Exitf("Error getting cluster bootstrapper: %s", err)
201204
}
@@ -211,13 +214,13 @@ func runStart(cmd *cobra.Command, args []string) {
211214
}
212215

213216
fmt.Println("Moving files into cluster...")
214-
if err := clusterBootstrapper.UpdateCluster(kubernetesConfig); err != nil {
217+
if err := k8sBootstrapper.UpdateCluster(kubernetesConfig); err != nil {
215218
glog.Errorln("Error updating cluster: ", err)
216219
cmdUtil.MaybeReportErrorAndExit(err)
217220
}
218221

219222
fmt.Println("Setting up certs...")
220-
if err := clusterBootstrapper.SetupCerts(kubernetesConfig); err != nil {
223+
if err := k8sBootstrapper.SetupCerts(kubernetesConfig); err != nil {
221224
glog.Errorln("Error configuring authentication: ", err)
222225
cmdUtil.MaybeReportErrorAndExit(err)
223226
}
@@ -253,12 +256,12 @@ func runStart(cmd *cobra.Command, args []string) {
253256
fmt.Println("Starting cluster components...")
254257

255258
if !exists {
256-
if err := clusterBootstrapper.StartCluster(kubernetesConfig); err != nil {
259+
if err := k8sBootstrapper.StartCluster(kubernetesConfig); err != nil {
257260
glog.Errorln("Error starting cluster: ", err)
258261
cmdUtil.MaybeReportErrorAndExit(err)
259262
}
260263
} else {
261-
if err := clusterBootstrapper.RestartCluster(kubernetesConfig); err != nil {
264+
if err := k8sBootstrapper.RestartCluster(kubernetesConfig); err != nil {
262265
glog.Errorln("Error restarting cluster: ", err)
263266
cmdUtil.MaybeReportErrorAndExit(err)
264267
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# This script runs the integration tests on a Linux machine for the KVM Driver
19+
20+
# The script expects the following env variables:
21+
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build.
22+
# COMMIT: Actual commit ID from upstream build
23+
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests
24+
# access_token: The Github API access token. Injected by the Jenkins credential provider.
25+
26+
set -e
27+
28+
OS_ARCH="linux-amd64"
29+
VM_DRIVER="kvm2"
30+
JOB_NAME="Linux-KVM-Kubeadm"
31+
EXTRA_ARGS="--bootstrapper=kubeadm"
32+
33+
# Download files and set permissions
34+
source common.sh

hack/jenkins/minikube_set_pending.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
set -e
2828
set +x
2929

30-
for job in "OSX-Virtualbox" "OSX-XHyve" "OSX-Hyperkit" "Linux-Virtualbox" "Linux-KVM" "Linux-KVM-Alt" "Linux-None" "Windows-HyperV"; do
30+
for job in "Linux-KVM-Kubeadm" "OSX-Virtualbox-Kubeadm" "OSX-Virtualbox" "OSX-XHyve" "OSX-Hyperkit" "Linux-Virtualbox" "Linux-KVM" "Linux-KVM-Alt" "Linux-None" "Windows-HyperV"; do
3131
target_url="https://storage.googleapis.com/minikube-builds/logs/${ghprbPullId}/${job}.txt"
3232
curl "https://api.github.com/repos/kubernetes/minikube/statuses/${ghprbActualCommit}?access_token=$access_token" \
3333
-H "Content-Type: application/json" \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# This script runs the integration tests on an OSX machine for the Virtualbox Driver
19+
20+
# The script expects the following env variables:
21+
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build.
22+
# COMMIT: Actual commit ID from upstream build
23+
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests
24+
# access_token: The Github API access token. Injected by the Jenkins credential provider.
25+
26+
27+
set -e
28+
OS_ARCH="darwin-amd64"
29+
VM_DRIVER="virtualbox"
30+
JOB_NAME="OSX-Virtualbox-Kubeadm"
31+
EXTRA_ARGS="--bootstrapper=kubeadm"
32+
33+
# Download files and set permissions
34+
source common.sh

pkg/minikube/assets/vm_assets.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"io"
2222
"os"
23+
"path/filepath"
2324

2425
"github.com/pkg/errors"
2526
)
@@ -63,6 +64,10 @@ type FileAsset struct {
6364
BaseAsset
6465
}
6566

67+
func NewMemoryAssetTarget(d []byte, targetPath, permissions string) *MemoryAsset {
68+
return NewMemoryAsset(d, filepath.Dir(targetPath), filepath.Base(targetPath), permissions)
69+
}
70+
6671
func NewFileAsset(assetName, targetDir, targetName, permissions string) (*FileAsset, error) {
6772
f := &FileAsset{
6873
BaseAsset{

pkg/minikube/bootstrapper/bootstrapper.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,16 @@ type KubernetesConfig struct {
4848

4949
const (
5050
BootstrapperTypeLocalkube = "localkube"
51+
BootstrapperTypeKubeadm = "kubeadm"
5152
)
5253

53-
var CachedImagesForBootstrapper = map[string][]string{
54-
BootstrapperTypeLocalkube: constants.LocalkubeCachedImages,
54+
func GetCachedImageList(version string, bootstrapper string) []string {
55+
switch bootstrapper {
56+
case BootstrapperTypeLocalkube:
57+
return constants.LocalkubeCachedImages
58+
case BootstrapperTypeKubeadm:
59+
return constants.GetKubeadmCachedImages(version)
60+
default:
61+
return []string{}
62+
}
5563
}

0 commit comments

Comments
 (0)