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
26c4f593
Unverified
Commit
26c4f593
authored
Sep 07, 2016
by
Lucas Käldström
Committed by
Ilya Dmitrichenko
Sep 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup/refactor some things, make it possible to use individual images, hide unused flags
parent
b48df06a
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
153 additions
and
68 deletions
+153
-68
kubeadm.go
cmd/kubeadm/app/kubeadm.go
+7
-5
kubeadm.go
cmd/kubeadm/kubeadm.go
+1
-0
types.go
pkg/kubeadm/api/types.go
+7
-2
init.go
pkg/kubeadm/cmd/init.go
+9
-5
manual.go
pkg/kubeadm/cmd/manual.go
+8
-6
images.go
pkg/kubeadm/images/images.go
+76
-0
addons.go
pkg/kubeadm/master/addons.go
+10
-19
apiclient.go
pkg/kubeadm/master/apiclient.go
+1
-1
discovery.go
pkg/kubeadm/master/discovery.go
+1
-1
kubeconfig.go
pkg/kubeadm/master/kubeconfig.go
+1
-1
manifests.go
pkg/kubeadm/master/manifests.go
+23
-19
pki.go
pkg/kubeadm/master/pki.go
+3
-3
tokens.go
pkg/kubeadm/master/tokens.go
+1
-1
csr.go
pkg/kubeadm/node/csr.go
+1
-1
discovery.go
pkg/kubeadm/node/discovery.go
+2
-2
kubeconfig.go
pkg/kubeadm/util/kubeconfig.go
+1
-1
tokens.go
pkg/kubeadm/util/tokens.go
+1
-1
No files found.
cmd/kubeadm/app/kubeadm.go
View file @
26c4f593
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"fmt"
"fmt"
"os"
"os"
"path"
"path"
"runtime"
"strings"
"strings"
"github.com/spf13/pflag"
"github.com/spf13/pflag"
...
@@ -43,12 +42,11 @@ func getEnvParams() map[string]string {
...
@@ -43,12 +42,11 @@ func getEnvParams() map[string]string {
envParams
:=
map
[
string
]
string
{
envParams
:=
map
[
string
]
string
{
"prefix"
:
globalPrefix
,
"prefix"
:
globalPrefix
,
"host_pki_path"
:
path
.
Join
(
globalPrefix
,
"pki"
),
"host_pki_path"
:
path
.
Join
(
globalPrefix
,
"pki"
),
"hyperkube_image"
:
fmt
.
Sprintf
(
"gcr.io/google_containers/hyperkube-%s:%s"
,
runtime
.
GOARCH
,
"v1.4.0-alpha.3"
)
,
"hyperkube_image"
:
""
,
"discovery_image"
:
"dgoodwin/kubediscovery:latest"
,
"discovery_image"
:
"dgoodwin/kubediscovery:latest"
,
// TODO(phase1): fmt.Sprintf("gcr.io/google_containers/kube-discovery-%s:%s", runtime.GOARCH, "1.0"),
"etcd_image"
:
fmt
.
Sprintf
(
"gcr.io/google_containers/etcd-%s:%s"
,
runtime
.
GOARCH
,
"2.2.5"
)
,
"etcd_image"
:
""
,
"component_loglevel"
:
"--v=4"
,
"component_loglevel"
:
"--v=4"
,
"dns_domain"
:
"cluster.local"
,
"dns_domain"
:
"cluster.local"
,
"dns_replicas"
:
"1"
,
}
}
for
k
:=
range
envParams
{
for
k
:=
range
envParams
{
...
@@ -65,6 +63,10 @@ func Run() error {
...
@@ -65,6 +63,10 @@ func Run() error {
logs
.
InitLogs
()
logs
.
InitLogs
()
defer
logs
.
FlushLogs
()
defer
logs
.
FlushLogs
()
// We do not want these flags to show up in --help
pflag
.
CommandLine
.
MarkHidden
(
"google-json-key"
)
pflag
.
CommandLine
.
MarkHidden
(
"log-flush-frequency"
)
cmd
:=
cmd
.
NewKubeadmCommand
(
cmdutil
.
NewFactory
(
nil
),
os
.
Stdin
,
os
.
Stdout
,
os
.
Stderr
,
getEnvParams
())
cmd
:=
cmd
.
NewKubeadmCommand
(
cmdutil
.
NewFactory
(
nil
),
os
.
Stdin
,
os
.
Stdout
,
os
.
Stderr
,
getEnvParams
())
return
cmd
.
Execute
()
return
cmd
.
Execute
()
}
}
cmd/kubeadm/kubeadm.go
View file @
26c4f593
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/cmd/kubeadm/app"
"k8s.io/kubernetes/cmd/kubeadm/app"
)
)
// TODO(phase1): check for root
func
main
()
{
func
main
()
{
if
err
:=
app
.
Run
();
err
!=
nil
{
if
err
:=
app
.
Run
();
err
!=
nil
{
os
.
Exit
(
1
)
os
.
Exit
(
1
)
...
...
pkg/kubeadm/api/types.go
View file @
26c4f593
...
@@ -14,7 +14,11 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kubeadmapi
package
api
import
(
"net"
)
type
BootstrapParams
struct
{
type
BootstrapParams
struct
{
// TODO this is mostly out of date and bloated now, let's revisit this soon
// TODO this is mostly out of date and bloated now, let's revisit this soon
...
@@ -32,7 +36,8 @@ type OutOfBandDiscovery struct {
...
@@ -32,7 +36,8 @@ type OutOfBandDiscovery struct {
BearerToken
string
// set based on Token
BearerToken
string
// set based on Token
// 'init-master' side
// 'init-master' side
ApiServerDNSName
string
// optional, used in master bootstrap
ApiServerDNSName
string
// optional, used in master bootstrap
ListenIP
string
// optional IP for master to listen on, rather than autodetect
ListenIP
net
.
IP
// optional IP for master to listen on, rather than autodetect
UseHyperkubeImage
bool
}
}
type
ClusterInfo
struct
{
type
ClusterInfo
struct
{
...
...
pkg/kubeadm/cmd/init.go
View file @
26c4f593
...
@@ -42,7 +42,7 @@ var (
...
@@ -42,7 +42,7 @@ var (
func
NewCmdInit
(
out
io
.
Writer
,
params
*
kubeadmapi
.
BootstrapParams
)
*
cobra
.
Command
{
func
NewCmdInit
(
out
io
.
Writer
,
params
*
kubeadmapi
.
BootstrapParams
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"init
--token <secret> [--listen-ip <addr>]
"
,
Use
:
"init"
,
Short
:
"Run this on the first server you deploy onto."
,
Short
:
"Run this on the first server you deploy onto."
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
err
:=
RunInit
(
out
,
cmd
,
args
,
params
)
err
:=
RunInit
(
out
,
cmd
,
args
,
params
)
...
@@ -50,21 +50,25 @@ func NewCmdInit(out io.Writer, params *kubeadmapi.BootstrapParams) *cobra.Comman
...
@@ -50,21 +50,25 @@ func NewCmdInit(out io.Writer, params *kubeadmapi.BootstrapParams) *cobra.Comman
},
},
}
}
cmd
.
PersistentFlags
()
.
StringVarP
(
&
params
.
Discovery
.
ListenIP
,
"listen-ip"
,
""
,
""
,
cmd
.
PersistentFlags
()
.
IPVar
(
&
params
.
Discovery
.
ListenIP
,
"listen-ip"
,
nil
,
`(optional) IP address to listen on, in case autodetection fails.`
)
`(optional) IP address to listen on, in case autodetection fails.`
)
cmd
.
PersistentFlags
()
.
StringVar
P
(
&
params
.
Discovery
.
GivenToken
,
"token"
,
"
"
,
""
,
cmd
.
PersistentFlags
()
.
StringVar
(
&
params
.
Discovery
.
GivenToken
,
"token
"
,
""
,
`(optional) Shared secret used to secure bootstrap. Will be generated and displayed if not provided.`
)
`(optional) Shared secret used to secure bootstrap. Will be generated and displayed if not provided.`
)
cmd
.
PersistentFlags
()
.
BoolVar
(
&
params
.
Discovery
.
UseHyperkubeImage
,
"use-hyperkube"
,
false
,
`(optional) Use the hyperkube image for running the apiserver, controller-manager, scheduler and proxy.`
)
return
cmd
return
cmd
}
}
func
RunInit
(
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
params
*
kubeadmapi
.
BootstrapParams
)
error
{
func
RunInit
(
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
params
*
kubeadmapi
.
BootstrapParams
)
error
{
if
params
.
Discovery
.
ListenIP
==
""
{
// Auto-detect the IP
if
params
.
Discovery
.
ListenIP
==
nil
{
ip
,
err
:=
netutil
.
ChooseHostInterface
()
ip
,
err
:=
netutil
.
ChooseHostInterface
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
params
.
Discovery
.
ListenIP
=
ip
.
String
()
params
.
Discovery
.
ListenIP
=
ip
}
}
if
err
:=
kubemaster
.
CreateTokenAuthFile
(
params
);
err
!=
nil
{
if
err
:=
kubemaster
.
CreateTokenAuthFile
(
params
);
err
!=
nil
{
return
err
return
err
...
...
pkg/kubeadm/cmd/manual.go
View file @
26c4f593
...
@@ -107,25 +107,27 @@ func NewCmdManualBootstrapInitMaster(out io.Writer, params *kubeadmapi.Bootstrap
...
@@ -107,25 +107,27 @@ func NewCmdManualBootstrapInitMaster(out io.Writer, params *kubeadmapi.Bootstrap
}
}
params
.
Discovery
.
ApiServerURLs
=
"http://127.0.0.1:8080/"
// On the master, assume you can talk to the API server
params
.
Discovery
.
ApiServerURLs
=
"http://127.0.0.1:8080/"
// On the master, assume you can talk to the API server
cmd
.
PersistentFlags
()
.
StringVar
P
(
&
params
.
Discovery
.
ApiServerDNSName
,
"api-dns-name"
,
"
"
,
""
,
cmd
.
PersistentFlags
()
.
StringVar
(
&
params
.
Discovery
.
ApiServerDNSName
,
"api-dns-name
"
,
""
,
`(optional) DNS name for the API server, will be encoded into
`(optional) DNS name for the API server, will be encoded into
subjectAltName in the resulting (generated) TLS certificates`
)
subjectAltName in the resulting (generated) TLS certificates`
)
cmd
.
PersistentFlags
()
.
StringVarP
(
&
params
.
Discovery
.
ListenIP
,
"listen-ip"
,
""
,
""
,
cmd
.
PersistentFlags
()
.
IPVar
(
&
params
.
Discovery
.
ListenIP
,
"listen-ip"
,
nil
,
`(optional) IP address to listen on, in case autodetection fails.`
)
`(optional) IP address to listen on, in case autodetection fails.`
)
cmd
.
PersistentFlags
()
.
StringVar
P
(
&
params
.
Discovery
.
BearerToken
,
"token"
,
"
"
,
""
,
cmd
.
PersistentFlags
()
.
StringVar
(
&
params
.
Discovery
.
BearerToken
,
"token
"
,
""
,
`(optional) Shared secret used to secure bootstrap. Will be generated and displayed if not provided.`
)
`(optional) Shared secret used to secure bootstrap. Will be generated and displayed if not provided.`
)
return
cmd
return
cmd
}
}
func
RunManualBootstrapInitMaster
(
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
params
*
kubeadmapi
.
BootstrapParams
)
error
{
func
RunManualBootstrapInitMaster
(
out
io
.
Writer
,
cmd
*
cobra
.
Command
,
args
[]
string
,
params
*
kubeadmapi
.
BootstrapParams
)
error
{
if
params
.
Discovery
.
ListenIP
==
""
{
// Auto-detect the IP
if
params
.
Discovery
.
ListenIP
==
nil
{
ip
,
err
:=
netutil
.
ChooseHostInterface
()
ip
,
err
:=
netutil
.
ChooseHostInterface
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"<cmd/join> unable to autodetect IP address [%s], please specify with --listen-ip"
,
err
)
return
err
}
}
params
.
Discovery
.
ListenIP
=
ip
.
String
()
params
.
Discovery
.
ListenIP
=
ip
}
}
if
err
:=
kubemaster
.
CreateTokenAuthFile
(
params
);
err
!=
nil
{
if
err
:=
kubemaster
.
CreateTokenAuthFile
(
params
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubeadm/images/images.go
0 → 100644
View file @
26c4f593
/*
Copyright 2016 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
images
import
(
"fmt"
"runtime"
)
const
(
KubeEtcdImage
=
"etcd"
KubeApiServerImage
=
"apiserver"
KubeControllerManagerImage
=
"controller-manager"
KubeSchedulerImage
=
"scheduler"
KubeProxyImage
=
"proxy"
KubeDnsImage
=
"kube-dns"
KubeDnsmasqImage
=
"dnsmasq"
KubeExechealthzImage
=
"exechealthz"
gcrPrefix
=
"gcr.io/google_containers"
etcdVersion
=
"2.2.5"
kubeVersion
=
"v1.4.0-alpha.3"
kubeDnsVersion
=
"1.7"
dnsmasqVersion
=
"1.3"
exechealthzVersion
=
"1.1"
)
func
GetCoreImage
(
image
string
,
overrideImage
string
,
useHyperkube
bool
)
string
{
if
overrideImage
!=
""
{
return
overrideImage
}
if
useHyperkube
{
return
map
[
string
]
string
{
KubeEtcdImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"etcd"
,
runtime
.
GOARCH
,
etcdVersion
),
KubeApiServerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"hyperkube"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeControllerManagerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"hyperkube"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeSchedulerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"hyperkube"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeProxyImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"hyperkube"
,
runtime
.
GOARCH
,
kubeVersion
),
}[
image
]
}
return
map
[
string
]
string
{
KubeEtcdImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"etcd"
,
runtime
.
GOARCH
,
etcdVersion
),
KubeApiServerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-apiserver"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeControllerManagerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-controller-manager"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeSchedulerImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-scheduler"
,
runtime
.
GOARCH
,
kubeVersion
),
KubeProxyImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-proxy"
,
runtime
.
GOARCH
,
kubeVersion
),
}[
image
]
}
func
GetAddonImage
(
image
string
)
string
{
return
map
[
string
]
string
{
KubeDnsImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-dns"
,
runtime
.
GOARCH
,
kubeDnsVersion
),
KubeDnsmasqImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"kube-dnsmasq"
,
runtime
.
GOARCH
,
dnsmasqVersion
),
KubeExechealthzImage
:
fmt
.
Sprintf
(
"%s/%s-%s:%s"
,
gcrPrefix
,
"exechealthz"
,
runtime
.
GOARCH
,
exechealthzVersion
),
}[
image
]
}
pkg/kubeadm/master/addons.go
View file @
26c4f593
...
@@ -14,18 +14,17 @@ See the License for the specific language governing permissions and
...
@@ -14,18 +14,17 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"fmt"
"fmt"
"path"
"path"
"runtime"
"strconv"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
"k8s.io/kubernetes/pkg/kubeadm/images"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/intstr"
)
)
...
@@ -35,13 +34,11 @@ func createKubeProxyPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
...
@@ -35,13 +34,11 @@ func createKubeProxyPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
SecurityContext
:
&
api
.
PodSecurityContext
{
HostNetwork
:
true
},
SecurityContext
:
&
api
.
PodSecurityContext
{
HostNetwork
:
true
},
Containers
:
[]
api
.
Container
{{
Containers
:
[]
api
.
Container
{{
Name
:
"kube-proxy"
,
Name
:
"kube-proxy"
,
Image
:
params
.
EnvParams
[
"hyperkube_image"
],
Image
:
images
.
GetCoreImage
(
images
.
KubeProxyImage
,
params
.
EnvParams
[
"hyperkube_image"
],
params
.
Discovery
.
UseHyperkubeImage
),
Command
:
[]
string
{
Command
:
append
(
getImageEntrypoint
(
"proxy"
,
params
.
Discovery
.
UseHyperkubeImage
),
[]
string
{
"/hyperkube"
,
"proxy"
,
"--kubeconfig=/run/kubeconfig"
,
"--kubeconfig=/run/kubeconfig"
,
params
.
EnvParams
[
"component_loglevel"
],
params
.
EnvParams
[
"component_loglevel"
],
},
}
...
)
,
SecurityContext
:
&
api
.
SecurityContext
{
Privileged
:
&
privilegedTrue
},
SecurityContext
:
&
api
.
SecurityContext
{
Privileged
:
&
privilegedTrue
},
VolumeMounts
:
[]
api
.
VolumeMount
{
VolumeMounts
:
[]
api
.
VolumeMount
{
{
{
...
@@ -83,6 +80,7 @@ func createKubeProxyPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
...
@@ -83,6 +80,7 @@ func createKubeProxyPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
}
}
}
}
// TODO(phase1): Create the DNS service as well
func
createKubeDNSPodSpec
(
params
*
kubeadmapi
.
BootstrapParams
)
api
.
PodSpec
{
func
createKubeDNSPodSpec
(
params
*
kubeadmapi
.
BootstrapParams
)
api
.
PodSpec
{
dnsPodResources
:=
api
.
ResourceList
{
dnsPodResources
:=
api
.
ResourceList
{
...
@@ -100,7 +98,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
...
@@ -100,7 +98,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
// DNS server
// DNS server
{
{
Name
:
"kube-dns"
,
Name
:
"kube-dns"
,
Image
:
"gcr.io/google_containers/kubedns-"
+
runtime
.
GOARCH
+
":1.7"
,
Image
:
images
.
GetAddonImage
(
images
.
KubeDnsImage
)
,
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
dnsPodResources
,
Limits
:
dnsPodResources
,
Requests
:
dnsPodResources
,
Requests
:
dnsPodResources
,
...
@@ -152,7 +150,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
...
@@ -152,7 +150,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
// dnsmasq
// dnsmasq
{
{
Name
:
"dnsmasq"
,
Name
:
"dnsmasq"
,
Image
:
"gcr.io/google_containers/kube-dnsmasq-"
+
runtime
.
GOARCH
+
":1.3"
,
Image
:
images
.
GetAddonImage
(
images
.
KubeDnsmasqImage
)
,
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
dnsPodResources
,
Limits
:
dnsPodResources
,
Requests
:
dnsPodResources
,
Requests
:
dnsPodResources
,
...
@@ -178,7 +176,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
...
@@ -178,7 +176,7 @@ func createKubeDNSPodSpec(params *kubeadmapi.BootstrapParams) api.PodSpec {
// healthz
// healthz
{
{
Name
:
"healthz"
,
Name
:
"healthz"
,
Image
:
"gcr.io/google_containers/exechealthz-"
+
runtime
.
GOARCH
+
":1.1"
,
Image
:
images
.
GetAddonImage
(
images
.
KubeExechealthzImage
)
,
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
healthzPodResources
,
Limits
:
healthzPodResources
,
Requests
:
healthzPodResources
,
Requests
:
healthzPodResources
,
...
@@ -219,14 +217,7 @@ func CreateEssentialAddons(params *kubeadmapi.BootstrapParams, client *clientset
...
@@ -219,14 +217,7 @@ func CreateEssentialAddons(params *kubeadmapi.BootstrapParams, client *clientset
fmt
.
Println
(
"<master/addons> created essential addon: kube-proxy"
)
fmt
.
Println
(
"<master/addons> created essential addon: kube-proxy"
)
// TODO should we wait for it to become ready at least on the master?
kubeDNSDeployment
:=
NewDeployment
(
"kube-dns"
,
1
,
createKubeDNSPodSpec
(
params
))
dnsReplicas
,
err
:=
strconv
.
Atoi
(
params
.
EnvParams
[
"dns_replicas"
])
if
err
!=
nil
{
dnsReplicas
=
1
}
kubeDNSDeployment
:=
NewDeployment
(
"kube-dns"
,
int32
(
dnsReplicas
),
createKubeDNSPodSpec
(
params
))
SetMasterTaintTolerations
(
&
kubeDNSDeployment
.
Spec
.
Template
.
ObjectMeta
)
SetMasterTaintTolerations
(
&
kubeDNSDeployment
.
Spec
.
Template
.
ObjectMeta
)
if
_
,
err
:=
client
.
Extensions
()
.
Deployments
(
api
.
NamespaceSystem
)
.
Create
(
kubeDNSDeployment
);
err
!=
nil
{
if
_
,
err
:=
client
.
Extensions
()
.
Deployments
(
api
.
NamespaceSystem
)
.
Create
(
kubeDNSDeployment
);
err
!=
nil
{
...
...
pkg/kubeadm/master/apiclient.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"encoding/json"
"encoding/json"
...
...
pkg/kubeadm/master/discovery.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"crypto/x509"
"crypto/x509"
...
...
pkg/kubeadm/master/kubeconfig.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"crypto/rsa"
"crypto/rsa"
...
...
pkg/kubeadm/master/manifests.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"bytes"
"bytes"
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
api
"k8s.io/kubernetes/pkg/api/v1"
api
"k8s.io/kubernetes/pkg/api/v1"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
"k8s.io/kubernetes/pkg/kubeadm/images"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/intstr"
)
)
...
@@ -50,11 +51,11 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
...
@@ -50,11 +51,11 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
"etcd"
:
componentPod
(
api
.
Container
{
"etcd"
:
componentPod
(
api
.
Container
{
Command
:
[]
string
{
Command
:
[]
string
{
"/usr/local/bin/etcd"
,
"/usr/local/bin/etcd"
,
"--listen-client-urls=http://127.0.0.1:2379
,http://127.0.0.1:4001
"
,
"--listen-client-urls=http://127.0.0.1:2379"
,
"--advertise-client-urls=http://127.0.0.1:2379
,http://127.0.0.1:4001
"
,
"--advertise-client-urls=http://127.0.0.1:2379"
,
"--data-dir=/var/etcd/data"
,
"--data-dir=/var/etcd/data"
,
},
},
Image
:
params
.
EnvParams
[
"etcd_image"
]
,
Image
:
images
.
GetCoreImage
(
images
.
KubeEtcdImage
,
params
.
EnvParams
[
"etcd_image"
],
params
.
Discovery
.
UseHyperkubeImage
)
,
LivenessProbe
:
componentProbe
(
2379
,
"/health"
),
LivenessProbe
:
componentProbe
(
2379
,
"/health"
),
Name
:
"etcd-server"
,
Name
:
"etcd-server"
,
Resources
:
componentResources
(
"200m"
),
Resources
:
componentResources
(
"200m"
),
...
@@ -62,10 +63,8 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
...
@@ -62,10 +63,8 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
// TODO bind-mount certs in
// TODO bind-mount certs in
"kube-apiserver"
:
componentPod
(
api
.
Container
{
"kube-apiserver"
:
componentPod
(
api
.
Container
{
Name
:
"kube-apiserver"
,
Name
:
"kube-apiserver"
,
Image
:
params
.
EnvParams
[
"hyperkube_image"
],
Image
:
images
.
GetCoreImage
(
images
.
KubeApiServerImage
,
params
.
EnvParams
[
"hyperkube_image"
],
params
.
Discovery
.
UseHyperkubeImage
),
Command
:
[]
string
{
Command
:
append
(
getImageEntrypoint
(
"apiserver"
,
params
.
Discovery
.
UseHyperkubeImage
),
[]
string
{
"/hyperkube"
,
"apiserver"
,
"--address=127.0.0.1"
,
"--address=127.0.0.1"
,
"--etcd-servers=http://127.0.0.1:2379"
,
"--etcd-servers=http://127.0.0.1:2379"
,
"--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,ResourceQuota"
,
"--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,ResourceQuota"
,
...
@@ -78,17 +77,15 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
...
@@ -78,17 +77,15 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
"--allow-privileged"
,
"--allow-privileged"
,
params
.
EnvParams
[
"component_loglevel"
],
params
.
EnvParams
[
"component_loglevel"
],
"--token-auth-file=/etc/kubernetes/pki/tokens.csv"
,
"--token-auth-file=/etc/kubernetes/pki/tokens.csv"
,
},
}
...
)
,
VolumeMounts
:
[]
api
.
VolumeMount
{
pkiVolumeMount
()},
VolumeMounts
:
[]
api
.
VolumeMount
{
pkiVolumeMount
()},
LivenessProbe
:
componentProbe
(
8080
,
"/healthz"
),
LivenessProbe
:
componentProbe
(
8080
,
"/healthz"
),
Resources
:
componentResources
(
"250m"
),
Resources
:
componentResources
(
"250m"
),
},
pkiVolume
(
params
)),
},
pkiVolume
(
params
)),
"kube-controller-manager"
:
componentPod
(
api
.
Container
{
"kube-controller-manager"
:
componentPod
(
api
.
Container
{
Name
:
"kube-controller-manager"
,
Name
:
"kube-controller-manager"
,
Image
:
params
.
EnvParams
[
"hyperkube_image"
],
Image
:
images
.
GetCoreImage
(
images
.
KubeControllerManagerImage
,
params
.
EnvParams
[
"hyperkube_image"
],
params
.
Discovery
.
UseHyperkubeImage
),
Command
:
[]
string
{
Command
:
append
(
getImageEntrypoint
(
"controller-manager"
,
params
.
Discovery
.
UseHyperkubeImage
),
[]
string
{
"/hyperkube"
,
"controller-manager"
,
"--leader-elect"
,
"--leader-elect"
,
MASTER
,
MASTER
,
CLUSTER_NAME
,
CLUSTER_NAME
,
...
@@ -97,22 +94,21 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
...
@@ -97,22 +94,21 @@ func WriteStaticPodManifests(params *kubeadmapi.BootstrapParams) error {
"--cluster-signing-cert-file=/etc/kubernetes/pki/ca.pem"
,
"--cluster-signing-cert-file=/etc/kubernetes/pki/ca.pem"
,
"--cluster-signing-key-file=/etc/kubernetes/pki/ca-key.pem"
,
"--cluster-signing-key-file=/etc/kubernetes/pki/ca-key.pem"
,
"--insecure-experimental-approve-all-kubelet-csrs-for-group=system:kubelet-bootstrap"
,
"--insecure-experimental-approve-all-kubelet-csrs-for-group=system:kubelet-bootstrap"
,
"--cluster-cidr=10.2.0.0/16"
,
params
.
EnvParams
[
"component_loglevel"
],
params
.
EnvParams
[
"component_loglevel"
],
},
}
...
)
,
VolumeMounts
:
[]
api
.
VolumeMount
{
pkiVolumeMount
()},
VolumeMounts
:
[]
api
.
VolumeMount
{
pkiVolumeMount
()},
LivenessProbe
:
componentProbe
(
10252
,
"/healthz"
),
LivenessProbe
:
componentProbe
(
10252
,
"/healthz"
),
Resources
:
componentResources
(
"200m"
),
Resources
:
componentResources
(
"200m"
),
},
pkiVolume
(
params
)),
},
pkiVolume
(
params
)),
"kube-scheduler"
:
componentPod
(
api
.
Container
{
"kube-scheduler"
:
componentPod
(
api
.
Container
{
Name
:
"kube-scheduler"
,
Name
:
"kube-scheduler"
,
Image
:
params
.
EnvParams
[
"hyperkube_image"
],
Image
:
images
.
GetCoreImage
(
images
.
KubeSchedulerImage
,
params
.
EnvParams
[
"hyperkube_image"
],
params
.
Discovery
.
UseHyperkubeImage
),
Command
:
[]
string
{
Command
:
append
(
getImageEntrypoint
(
"scheduler"
,
params
.
Discovery
.
UseHyperkubeImage
),
[]
string
{
"/hyperkube"
,
"scheduler"
,
"--leader-elect"
,
"--leader-elect"
,
MASTER
,
MASTER
,
params
.
EnvParams
[
"component_loglevel"
],
params
.
EnvParams
[
"component_loglevel"
],
},
}
...
)
,
LivenessProbe
:
componentProbe
(
10251
,
"/healthz"
),
LivenessProbe
:
componentProbe
(
10251
,
"/healthz"
),
Resources
:
componentResources
(
"100m"
),
Resources
:
componentResources
(
"100m"
),
}),
}),
...
@@ -192,3 +188,11 @@ func componentPod(container api.Container, volumes ...api.Volume) api.Pod {
...
@@ -192,3 +188,11 @@ func componentPod(container api.Container, volumes ...api.Volume) api.Pod {
},
},
}
}
}
}
func
getImageEntrypoint
(
component
string
,
useHyperkube
bool
)
[]
string
{
if
useHyperkube
{
return
[]
string
{
"/hyperkube"
,
component
}
}
return
[]
string
{
"/usr/local/bin/kube-"
+
component
}
}
pkg/kubeadm/master/pki.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"crypto/rsa"
"crypto/rsa"
...
@@ -137,8 +137,8 @@ func CreatePKIAssets(params *kubeadmapi.BootstrapParams) (*rsa.PrivateKey, *x509
...
@@ -137,8 +137,8 @@ func CreatePKIAssets(params *kubeadmapi.BootstrapParams) (*rsa.PrivateKey, *x509
altNames
certutil
.
AltNames
// TODO actual SANs
altNames
certutil
.
AltNames
// TODO actual SANs
)
)
if
params
.
Discovery
.
ListenIP
!=
""
{
if
params
.
Discovery
.
ListenIP
!=
nil
{
altNames
.
IPs
=
append
(
altNames
.
IPs
,
net
.
ParseIP
(
params
.
Discovery
.
ListenIP
)
)
altNames
.
IPs
=
append
(
altNames
.
IPs
,
params
.
Discovery
.
ListenIP
)
}
}
if
params
.
Discovery
.
ApiServerDNSName
!=
""
{
if
params
.
Discovery
.
ApiServerDNSName
!=
""
{
...
...
pkg/kubeadm/master/tokens.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
master
package
master
import
(
import
(
"bytes"
"bytes"
...
...
pkg/kubeadm/node/csr.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
node
package
node
import
(
import
(
"fmt"
"fmt"
...
...
pkg/kubeadm/node/discovery.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kube
node
package
node
import
(
import
(
"bytes"
"bytes"
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"net/url"
"net/url"
"strings"
"strings"
"github.com/square/go-jose"
jose
"github.com/square/go-jose"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
kubeadmapi
"k8s.io/kubernetes/pkg/kubeadm/api"
)
)
...
...
pkg/kubeadm/util/kubeconfig.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kubeadm
util
package
util
import
(
import
(
"fmt"
"fmt"
...
...
pkg/kubeadm/util/tokens.go
View file @
26c4f593
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
kubeadm
util
package
util
import
(
import
(
"crypto/rand"
"crypto/rand"
...
...
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