Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0a4b6dfe
Unverified
Commit
0a4b6dfe
authored
Jun 04, 2018
by
Chuck Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix kubeadm for v1alpha1 configs
Signed-off-by:
Chuck Ha
<
ha.chuck@gmail.com
>
parent
1635393b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
7 deletions
+117
-7
BUILD
cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD
+10
-0
conversion.go
cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go
+3
-5
conversion_test.go
cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go
+103
-0
init.go
cmd/kubeadm/app/cmd/init.go
+1
-1
.golint_failures
hack/.golint_failures
+0
-1
No files found.
cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD
View file @
0a4b6dfe
...
@@ -91,3 +91,13 @@ go_test(
...
@@ -91,3 +91,13 @@ go_test(
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = ["//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library"],
deps = ["//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library"],
)
)
go_test(
name = "go_default_xtest",
srcs = ["conversion_test.go"],
deps = [
":go_default_library",
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go
View file @
0a4b6dfe
...
@@ -145,13 +145,11 @@ func UpgradeNodeRegistrationOptionsForMaster(in *MasterConfiguration, out *kubea
...
@@ -145,13 +145,11 @@ func UpgradeNodeRegistrationOptionsForMaster(in *MasterConfiguration, out *kubea
}
}
}
}
// UpgradeBootstrapTokens should create at least one empty bootstrap token in the out config.
func
UpgradeBootstrapTokens
(
in
*
MasterConfiguration
,
out
*
kubeadm
.
MasterConfiguration
)
error
{
func
UpgradeBootstrapTokens
(
in
*
MasterConfiguration
,
out
*
kubeadm
.
MasterConfiguration
)
error
{
if
len
(
in
.
Token
)
==
0
{
return
nil
}
bts
,
err
:=
kubeadm
.
NewBootstrapTokenString
(
in
.
Token
)
bts
,
err
:=
kubeadm
.
NewBootstrapTokenString
(
in
.
Token
)
if
err
!=
nil
{
// Ignore the error if the incoming token was empty.
if
err
!=
nil
&&
in
.
Token
!=
""
{
return
fmt
.
Errorf
(
"can't parse .Token, and hence can't convert v1alpha1 API to a newer version: %v"
,
err
)
return
fmt
.
Errorf
(
"can't parse .Token, and hence can't convert v1alpha1 API to a newer version: %v"
,
err
)
}
}
...
...
cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go
0 → 100644
View file @
0a4b6dfe
/*
Copyright 2018 The Kubernetes Authors.
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.
*/
package
v1alpha1_test
import
(
"reflect"
"testing"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1"
)
func
TestUpgradeBootstrapTokens
(
t
*
testing
.
T
)
{
testcases
:=
[]
struct
{
name
string
in
*
v1alpha1
.
MasterConfiguration
expectedOut
*
kubeadm
.
MasterConfiguration
expectError
bool
}{
{
name
:
"empty configs should create at least one token"
,
in
:
&
v1alpha1
.
MasterConfiguration
{},
expectedOut
:
&
kubeadm
.
MasterConfiguration
{
BootstrapTokens
:
[]
kubeadm
.
BootstrapToken
{
{
Token
:
nil
,
},
},
},
expectError
:
false
,
},
{
name
:
"fail at parsing incoming token"
,
in
:
&
v1alpha1
.
MasterConfiguration
{
Token
:
"some fake token"
,
},
expectError
:
true
,
},
{
name
:
"input has values"
,
in
:
&
v1alpha1
.
MasterConfiguration
{
Token
:
"abcdef.abcdefghijklmnop"
,
TokenTTL
:
&
metav1
.
Duration
{
Duration
:
time
.
Duration
(
10
*
time
.
Hour
),
},
TokenUsages
:
[]
string
{
"action"
},
TokenGroups
:
[]
string
{
"group"
,
"group2"
},
},
expectedOut
:
&
kubeadm
.
MasterConfiguration
{
BootstrapTokens
:
[]
kubeadm
.
BootstrapToken
{
{
Token
:
&
kubeadm
.
BootstrapTokenString
{
ID
:
"abcdef"
,
Secret
:
"abcdefghijklmnop"
,
},
TTL
:
&
metav1
.
Duration
{
Duration
:
time
.
Duration
(
10
*
time
.
Hour
),
},
Usages
:
[]
string
{
"action"
},
Groups
:
[]
string
{
"group"
,
"group2"
},
},
},
},
expectError
:
false
,
},
}
for
_
,
tc
:=
range
testcases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
out
:=
&
kubeadm
.
MasterConfiguration
{}
err
:=
v1alpha1
.
UpgradeBootstrapTokens
(
tc
.
in
,
out
)
if
tc
.
expectError
{
if
err
==
nil
{
t
.
Fatal
(
"expected an error but did not get one."
)
}
// do not continue if we got an expected error
return
}
if
!
reflect
.
DeepEqual
(
out
.
BootstrapTokens
,
tc
.
expectedOut
.
BootstrapTokens
)
{
t
.
Fatalf
(
"
\n
expected: %v
\n
got: %v"
,
tc
.
expectedOut
.
BootstrapTokens
,
out
.
BootstrapTokens
)
}
})
}
}
cmd/kubeadm/app/cmd/init.go
View file @
0a4b6dfe
...
@@ -482,8 +482,8 @@ func (i *Init) Run(out io.Writer) error {
...
@@ -482,8 +482,8 @@ func (i *Init) Run(out io.Writer) error {
}
}
// PHASE 7: Make the control plane self-hosted if feature gate is enabled
// PHASE 7: Make the control plane self-hosted if feature gate is enabled
glog
.
V
(
1
)
.
Infof
(
"[init] feature gate is enabled. Making control plane self-hosted"
)
if
features
.
Enabled
(
i
.
cfg
.
FeatureGates
,
features
.
SelfHosting
)
{
if
features
.
Enabled
(
i
.
cfg
.
FeatureGates
,
features
.
SelfHosting
)
{
glog
.
V
(
1
)
.
Infof
(
"[init] feature gate is enabled. Making control plane self-hosted"
)
// Temporary control plane is up, now we create our self hosted control
// Temporary control plane is up, now we create our self hosted control
// plane components and remove the static manifests:
// plane components and remove the static manifests:
glog
.
Infoln
(
"[self-hosted] creating self-hosted control plane"
)
glog
.
Infoln
(
"[self-hosted] creating self-hosted control plane"
)
...
...
hack/.golint_failures
View file @
0a4b6dfe
...
@@ -6,7 +6,6 @@ cmd/kube-controller-manager/app
...
@@ -6,7 +6,6 @@ cmd/kube-controller-manager/app
cmd/kube-proxy/app
cmd/kube-proxy/app
cmd/kube-scheduler/app
cmd/kube-scheduler/app
cmd/kubeadm/app
cmd/kubeadm/app
cmd/kubeadm/app/apis/kubeadm/v1alpha1
cmd/kubeadm/app/apis/kubeadm/v1alpha2
cmd/kubeadm/app/apis/kubeadm/v1alpha2
cmd/kubeadm/app/util/config
cmd/kubeadm/app/util/config
cmd/kubelet/app
cmd/kubelet/app
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment