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

Kubeadm bootstrapper #1903

Merged
merged 5 commits into from
Sep 14, 2017
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
6 changes: 6 additions & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
configCmd "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/cmd/util"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/bootstrapper/localkube"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
Expand Down Expand Up @@ -174,6 +175,11 @@ func GetClusterBootstrapper(api libmachine.API, bootstrapperName string) (bootst
if err != nil {
return nil, errors.Wrap(err, "getting localkube bootstrapper")
}
case bootstrapper.BootstrapperTypeKubeadm:
b, err = kubeadm.NewKubeadmBootstrapper(api)
if err != nil {
return nil, errors.Wrap(err, "getting kubeadm bootstrapper")
}
default:
return nil, fmt.Errorf("Unknown bootstrapper: %s", bootstrapperName)
}
Expand Down
19 changes: 11 additions & 8 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ assumes you have already installed one of the VM drivers: virtualbox/vmwarefusio

func runStart(cmd *cobra.Command, args []string) {
shouldCacheImages := viper.GetBool(cacheImages)
k8sVersion := viper.GetString(kubernetesVersion)
clusterBootstrapper := viper.GetString(cmdcfg.Bootstrapper)

if shouldCacheImages {
go machine.CacheImagesForBootstrapper(viper.GetString(cmdcfg.Bootstrapper))
go machine.CacheImagesForBootstrapper(k8sVersion, clusterBootstrapper)
}
api, err := machine.NewAPIClient()
if err != nil {
Expand All @@ -112,8 +115,8 @@ func runStart(cmd *cobra.Command, args []string) {
os.Exit(1)
}

if dv := viper.GetString(kubernetesVersion); dv != constants.DefaultKubernetesVersion {
validateK8sVersion(dv)
if k8sVersion != constants.DefaultKubernetesVersion {
validateK8sVersion(k8sVersion)
}

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

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

fmt.Println("Moving files into cluster...")
if err := clusterBootstrapper.UpdateCluster(kubernetesConfig); err != nil {
if err := k8sBootstrapper.UpdateCluster(kubernetesConfig); err != nil {
glog.Errorln("Error updating cluster: ", err)
cmdUtil.MaybeReportErrorAndExit(err)
}

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

if !exists {
if err := clusterBootstrapper.StartCluster(kubernetesConfig); err != nil {
if err := k8sBootstrapper.StartCluster(kubernetesConfig); err != nil {
glog.Errorln("Error starting cluster: ", err)
cmdUtil.MaybeReportErrorAndExit(err)
}
} else {
if err := clusterBootstrapper.RestartCluster(kubernetesConfig); err != nil {
if err := k8sBootstrapper.RestartCluster(kubernetesConfig); err != nil {
glog.Errorln("Error restarting cluster: ", err)
cmdUtil.MaybeReportErrorAndExit(err)
}
Expand Down
34 changes: 34 additions & 0 deletions hack/jenkins/linux_integration_tests_kvm_alt_kubeadm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# This script runs the integration tests on a Linux machine for the KVM Driver

# The script expects the following env variables:
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build.
# COMMIT: Actual commit ID from upstream build
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests
# access_token: The Github API access token. Injected by the Jenkins credential provider.

set -e

OS_ARCH="linux-amd64"
VM_DRIVER="kvm2"
JOB_NAME="Linux-KVM-Kubeadm"
EXTRA_ARGS="--bootstrapper=kubeadm"

# Download files and set permissions
source common.sh
2 changes: 1 addition & 1 deletion hack/jenkins/minikube_set_pending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
set -e
set +x

for job in "OSX-Virtualbox" "OSX-XHyve" "OSX-Hyperkit" "Linux-Virtualbox" "Linux-KVM" "Linux-KVM-Alt" "Linux-None" "Windows-HyperV"; do
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
target_url="https://storage.googleapis.com/minikube-builds/logs/${ghprbPullId}/${job}.txt"
curl "https://api.github.com/repos/kubernetes/minikube/statuses/${ghprbActualCommit}?access_token=$access_token" \
-H "Content-Type: application/json" \
Expand Down
34 changes: 34 additions & 0 deletions hack/jenkins/osx_integration_tests_virtualbox_kubeadm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# This script runs the integration tests on an OSX machine for the Virtualbox Driver

# The script expects the following env variables:
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build.
# COMMIT: Actual commit ID from upstream build
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests
# access_token: The Github API access token. Injected by the Jenkins credential provider.


set -e
OS_ARCH="darwin-amd64"
VM_DRIVER="virtualbox"
JOB_NAME="OSX-Virtualbox-Kubeadm"
EXTRA_ARGS="--bootstrapper=kubeadm"

# Download files and set permissions
source common.sh
5 changes: 5 additions & 0 deletions pkg/minikube/assets/vm_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"io"
"os"
"path/filepath"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -63,6 +64,10 @@ type FileAsset struct {
BaseAsset
}

func NewMemoryAssetTarget(d []byte, targetPath, permissions string) *MemoryAsset {
return NewMemoryAsset(d, filepath.Dir(targetPath), filepath.Base(targetPath), permissions)
}

func NewFileAsset(assetName, targetDir, targetName, permissions string) (*FileAsset, error) {
f := &FileAsset{
BaseAsset{
Expand Down
12 changes: 10 additions & 2 deletions pkg/minikube/bootstrapper/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ type KubernetesConfig struct {

const (
BootstrapperTypeLocalkube = "localkube"
BootstrapperTypeKubeadm = "kubeadm"
)

var CachedImagesForBootstrapper = map[string][]string{
BootstrapperTypeLocalkube: constants.LocalkubeCachedImages,
func GetCachedImageList(version string, bootstrapper string) []string {
switch bootstrapper {
case BootstrapperTypeLocalkube:
return constants.LocalkubeCachedImages
case BootstrapperTypeKubeadm:
return constants.GetKubeadmCachedImages(version)
default:
return []string{}
}
}
Loading