mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
kubeadm: InitConfiguration.APIEndpoint -> LocalAPIEndpoint
This commit is contained in:
parent
8825843126
commit
731bcdc864
@ -46,8 +46,13 @@ type InitConfiguration struct {
|
|||||||
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
||||||
NodeRegistration NodeRegistrationOptions
|
NodeRegistration NodeRegistrationOptions
|
||||||
|
|
||||||
// APIEndpoint represents the endpoint of the instance of the API server to be deployed on this node.
|
// LocalAPIEndpoint represents the endpoint of the API server instance that's deployed on this control plane node
|
||||||
APIEndpoint APIEndpoint
|
// In HA setups, this differs from ClusterConfiguration.ControlPlaneEndpoint in the sense that ControlPlaneEndpoint
|
||||||
|
// is the global endpoint for the cluster, which then loadbalances the requests to each individual API server. This
|
||||||
|
// configuration object lets you customize what IP/DNS name and port the local API server advertises it's accessible
|
||||||
|
// on. By default, kubeadm tries to auto-detect the IP of the default interface and use that, but in case that process
|
||||||
|
// fails you may set the desired value here.
|
||||||
|
LocalAPIEndpoint APIEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
@ -24,6 +24,20 @@ import (
|
|||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Convert_v1alpha3_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error {
|
||||||
|
if err := autoConvert_v1alpha3_InitConfiguration_To_kubeadm_InitConfiguration(in, out, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return Convert_v1alpha3_APIEndpoint_To_kubeadm_APIEndpoint(&in.APIEndpoint, &out.LocalAPIEndpoint, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Convert_kubeadm_InitConfiguration_To_v1alpha3_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
||||||
|
if err := autoConvert_kubeadm_InitConfiguration_To_v1alpha3_InitConfiguration(in, out, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return Convert_kubeadm_APIEndpoint_To_v1alpha3_APIEndpoint(&in.LocalAPIEndpoint, &out.APIEndpoint, s)
|
||||||
|
}
|
||||||
|
|
||||||
func Convert_v1alpha3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
|
func Convert_v1alpha3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
|
||||||
if err := autoConvert_v1alpha3_JoinConfiguration_To_kubeadm_JoinConfiguration(in, out, s); err != nil {
|
if err := autoConvert_v1alpha3_JoinConfiguration_To_kubeadm_JoinConfiguration(in, out, s); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -70,7 +70,7 @@ func SetDefaults_InitConfiguration(obj *InitConfiguration) {
|
|||||||
SetDefaults_ClusterConfiguration(&obj.ClusterConfiguration)
|
SetDefaults_ClusterConfiguration(&obj.ClusterConfiguration)
|
||||||
SetDefaults_NodeRegistrationOptions(&obj.NodeRegistration)
|
SetDefaults_NodeRegistrationOptions(&obj.NodeRegistration)
|
||||||
SetDefaults_BootstrapTokens(obj)
|
SetDefaults_BootstrapTokens(obj)
|
||||||
SetDefaults_APIEndpoint(&obj.APIEndpoint)
|
SetDefaults_APIEndpoint(&obj.LocalAPIEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaults_ClusterConfiguration assigns default values for the ClusterConfiguration
|
// SetDefaults_ClusterConfiguration assigns default values for the ClusterConfiguration
|
||||||
|
@ -45,8 +45,13 @@ type InitConfiguration struct {
|
|||||||
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
||||||
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
||||||
|
|
||||||
// APIEndpoint represents the endpoint of the instance of the API server to be deployed on this node.
|
// LocalAPIEndpoint represents the endpoint of the API server instance that's deployed on this control plane node
|
||||||
APIEndpoint APIEndpoint `json:"apiEndpoint,omitempty"`
|
// In HA setups, this differs from ClusterConfiguration.ControlPlaneEndpoint in the sense that ControlPlaneEndpoint
|
||||||
|
// is the global endpoint for the cluster, which then loadbalances the requests to each individual API server. This
|
||||||
|
// configuration object lets you customize what IP/DNS name and port the local API server advertises it's accessible
|
||||||
|
// on. By default, kubeadm tries to auto-detect the IP of the default interface and use that, but in case that process
|
||||||
|
// fails you may set the desired value here.
|
||||||
|
LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
@ -49,7 +49,7 @@ func ValidateInitConfiguration(c *kubeadm.InitConfiguration) field.ErrorList {
|
|||||||
allErrs = append(allErrs, ValidateNodeRegistrationOptions(&c.NodeRegistration, field.NewPath("nodeRegistration"))...)
|
allErrs = append(allErrs, ValidateNodeRegistrationOptions(&c.NodeRegistration, field.NewPath("nodeRegistration"))...)
|
||||||
allErrs = append(allErrs, ValidateBootstrapTokens(c.BootstrapTokens, field.NewPath("bootstrapTokens"))...)
|
allErrs = append(allErrs, ValidateBootstrapTokens(c.BootstrapTokens, field.NewPath("bootstrapTokens"))...)
|
||||||
allErrs = append(allErrs, ValidateClusterConfiguration(&c.ClusterConfiguration)...)
|
allErrs = append(allErrs, ValidateClusterConfiguration(&c.ClusterConfiguration)...)
|
||||||
allErrs = append(allErrs, ValidateAPIEndpoint(&c.APIEndpoint, field.NewPath("apiEndpoint"))...)
|
allErrs = append(allErrs, ValidateAPIEndpoint(&c.LocalAPIEndpoint, field.NewPath("localAPIEndpoint"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
|
|||||||
|
|
||||||
// Add flags to the command
|
// Add flags to the command
|
||||||
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, "The path where certificates are stored")
|
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, "The path where certificates are stored")
|
||||||
cmd.Flags().StringVar(&cfg.APIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.APIEndpoint.AdvertiseAddress, "The IP address the API server is accessible on")
|
cmd.Flags().StringVar(&cfg.LocalAPIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.LocalAPIEndpoint.AdvertiseAddress, "The IP address the API server is accessible on")
|
||||||
cmd.Flags().Int32Var(&cfg.APIEndpoint.BindPort, "apiserver-bind-port", cfg.APIEndpoint.BindPort, "The port the API server is accessible on")
|
cmd.Flags().Int32Var(&cfg.LocalAPIEndpoint.BindPort, "apiserver-bind-port", cfg.LocalAPIEndpoint.BindPort, "The port the API server is accessible on")
|
||||||
cmd.Flags().StringVar(&token, "token", token, "The token that should be used as the authentication mechanism for this kubeconfig, instead of client certificates")
|
cmd.Flags().StringVar(&token, "token", token, "The token that should be used as the authentication mechanism for this kubeconfig, instead of client certificates")
|
||||||
cmd.Flags().StringVar(&clientName, "client-name", clientName, "The name of user. It will be used as the CN if client certificates are created")
|
cmd.Flags().StringVar(&clientName, "client-name", clientName, "The name of user. It will be used as the CN if client certificates are created")
|
||||||
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The orgnizations of the client certificate. It will be used as the O if client certificates are created")
|
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The orgnizations of the client certificate. It will be used as the O if client certificates are created")
|
||||||
|
@ -243,7 +243,7 @@ func getAllAPIObjectNames() []string {
|
|||||||
func getDefaultedInitConfig() (*kubeadmapi.InitConfiguration, error) {
|
func getDefaultedInitConfig() (*kubeadmapi.InitConfiguration, error) {
|
||||||
return configutil.ConfigFileAndDefaultsToInternalConfig("", &kubeadmapiv1beta1.InitConfiguration{
|
return configutil.ConfigFileAndDefaultsToInternalConfig("", &kubeadmapiv1beta1.InitConfiguration{
|
||||||
// TODO: Probably move to getDefaultedClusterConfig?
|
// TODO: Probably move to getDefaultedClusterConfig?
|
||||||
APIEndpoint: kubeadmapiv1beta1.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
LocalAPIEndpoint: kubeadmapiv1beta1.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
||||||
ClusterConfiguration: kubeadmapiv1beta1.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapiv1beta1.ClusterConfiguration{
|
||||||
KubernetesVersion: fmt.Sprintf("v1.%d.0", constants.MinimumControlPlaneVersion.Minor()+1),
|
KubernetesVersion: fmt.Sprintf("v1.%d.0", constants.MinimumControlPlaneVersion.Minor()+1),
|
||||||
},
|
},
|
||||||
|
@ -199,11 +199,11 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
// AddInitConfigFlags adds init flags bound to the config to the specified flagset
|
// AddInitConfigFlags adds init flags bound to the config to the specified flagset
|
||||||
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfiguration, featureGatesString *string) {
|
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfiguration, featureGatesString *string) {
|
||||||
flagSet.StringVar(
|
flagSet.StringVar(
|
||||||
&cfg.APIEndpoint.AdvertiseAddress, options.APIServerAdvertiseAddress, cfg.APIEndpoint.AdvertiseAddress,
|
&cfg.LocalAPIEndpoint.AdvertiseAddress, options.APIServerAdvertiseAddress, cfg.LocalAPIEndpoint.AdvertiseAddress,
|
||||||
"The IP address the API Server will advertise it's listening on. Specify '0.0.0.0' to use the address of the default network interface.",
|
"The IP address the API Server will advertise it's listening on. Specify '0.0.0.0' to use the address of the default network interface.",
|
||||||
)
|
)
|
||||||
flagSet.Int32Var(
|
flagSet.Int32Var(
|
||||||
&cfg.APIEndpoint.BindPort, options.APIServerBindPort, cfg.APIEndpoint.BindPort,
|
&cfg.LocalAPIEndpoint.BindPort, options.APIServerBindPort, cfg.LocalAPIEndpoint.BindPort,
|
||||||
"Port for the API Server to bind to.",
|
"Port for the API Server to bind to.",
|
||||||
)
|
)
|
||||||
flagSet.StringVar(
|
flagSet.StringVar(
|
||||||
@ -313,7 +313,7 @@ func newInitData(cmd *cobra.Command, options *initOptions, out io.Writer) (initD
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return initData{}, err
|
return initData{}, err
|
||||||
}
|
}
|
||||||
if err := configutil.VerifyAPIServerBindAddress(cfg.APIEndpoint.AdvertiseAddress); err != nil {
|
if err := configutil.VerifyAPIServerBindAddress(cfg.LocalAPIEndpoint.AdvertiseAddress); err != nil {
|
||||||
return initData{}, err
|
return initData{}, err
|
||||||
}
|
}
|
||||||
if err := features.ValidateVersion(features.InitFeatureGates, cfg.FeatureGates, cfg.KubernetesVersion); err != nil {
|
if err := features.ValidateVersion(features.InitFeatureGates, cfg.FeatureGates, cfg.KubernetesVersion); err != nil {
|
||||||
|
@ -602,7 +602,7 @@ func fetchInitConfigurationFromJoinConfiguration(cfg *kubeadmapi.JoinConfigurati
|
|||||||
|
|
||||||
// injects into the kubeadm configuration the information about the joining node
|
// injects into the kubeadm configuration the information about the joining node
|
||||||
initConfiguration.NodeRegistration = cfg.NodeRegistration
|
initConfiguration.NodeRegistration = cfg.NodeRegistration
|
||||||
initConfiguration.APIEndpoint = cfg.APIEndpoint
|
initConfiguration.LocalAPIEndpoint = cfg.APIEndpoint
|
||||||
|
|
||||||
return initConfiguration, tlsBootstrapCfg, nil
|
return initConfiguration, tlsBootstrapCfg, nil
|
||||||
}
|
}
|
||||||
|
@ -149,8 +149,8 @@ func getAddonsSubCommands() []*cobra.Command {
|
|||||||
cmd.Flags().StringVar(&cfg.ImageRepository, "image-repository", cfg.ImageRepository, `Choose a container registry to pull control plane images from`)
|
cmd.Flags().StringVar(&cfg.ImageRepository, "image-repository", cfg.ImageRepository, `Choose a container registry to pull control plane images from`)
|
||||||
|
|
||||||
if properties.use == "all" || properties.use == "kube-proxy" {
|
if properties.use == "all" || properties.use == "kube-proxy" {
|
||||||
cmd.Flags().StringVar(&cfg.APIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.APIEndpoint.AdvertiseAddress, `The IP address the API server is accessible on`)
|
cmd.Flags().StringVar(&cfg.LocalAPIEndpoint.AdvertiseAddress, "apiserver-advertise-address", cfg.LocalAPIEndpoint.AdvertiseAddress, `The IP address the API server is accessible on`)
|
||||||
cmd.Flags().Int32Var(&cfg.APIEndpoint.BindPort, "apiserver-bind-port", cfg.APIEndpoint.BindPort, `The port the API server is accessible on`)
|
cmd.Flags().Int32Var(&cfg.LocalAPIEndpoint.BindPort, "apiserver-bind-port", cfg.LocalAPIEndpoint.BindPort, `The port the API server is accessible on`)
|
||||||
cmd.Flags().StringVar(&cfg.Networking.PodSubnet, "pod-network-cidr", cfg.Networking.PodSubnet, `The range of IP addresses used for the Pod network`)
|
cmd.Flags().StringVar(&cfg.Networking.PodSubnet, "pod-network-cidr", cfg.Networking.PodSubnet, `The range of IP addresses used for the Pod network`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ func getCertPhaseFlags(name string) []string {
|
|||||||
func getSANDescription(certSpec *certsphase.KubeadmCert) string {
|
func getSANDescription(certSpec *certsphase.KubeadmCert) string {
|
||||||
//Defaulted config we will use to get SAN certs
|
//Defaulted config we will use to get SAN certs
|
||||||
defaultConfig := &kubeadmapiv1beta1.InitConfiguration{
|
defaultConfig := &kubeadmapiv1beta1.InitConfiguration{
|
||||||
APIEndpoint: kubeadmapiv1beta1.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapiv1beta1.APIEndpoint{
|
||||||
// GetAPIServerAltNames errors without an AdvertiseAddress; this is as good as any.
|
// GetAPIServerAltNames errors without an AdvertiseAddress; this is as good as any.
|
||||||
AdvertiseAddress: "127.0.0.1",
|
AdvertiseAddress: "127.0.0.1",
|
||||||
},
|
},
|
||||||
|
@ -60,7 +60,7 @@ func GetStaticPodSpecs(cfg *kubeadmapi.InitConfiguration, k8sVersion *version.Ve
|
|||||||
ImagePullPolicy: v1.PullIfNotPresent,
|
ImagePullPolicy: v1.PullIfNotPresent,
|
||||||
Command: getAPIServerCommand(cfg),
|
Command: getAPIServerCommand(cfg),
|
||||||
VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)),
|
VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)),
|
||||||
LivenessProbe: staticpodutil.ComponentProbe(cfg, kubeadmconstants.KubeAPIServer, int(cfg.APIEndpoint.BindPort), "/healthz", v1.URISchemeHTTPS),
|
LivenessProbe: staticpodutil.ComponentProbe(cfg, kubeadmconstants.KubeAPIServer, int(cfg.LocalAPIEndpoint.BindPort), "/healthz", v1.URISchemeHTTPS),
|
||||||
Resources: staticpodutil.ComponentResources("250m"),
|
Resources: staticpodutil.ComponentResources("250m"),
|
||||||
Env: getProxyEnvVars(),
|
Env: getProxyEnvVars(),
|
||||||
}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer)),
|
}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer)),
|
||||||
@ -122,7 +122,7 @@ func CreateStaticPodFiles(manifestDir string, cfg *kubeadmapi.InitConfiguration,
|
|||||||
// getAPIServerCommand builds the right API server command from the given config object and version
|
// getAPIServerCommand builds the right API server command from the given config object and version
|
||||||
func getAPIServerCommand(cfg *kubeadmapi.InitConfiguration) []string {
|
func getAPIServerCommand(cfg *kubeadmapi.InitConfiguration) []string {
|
||||||
defaultArguments := map[string]string{
|
defaultArguments := map[string]string{
|
||||||
"advertise-address": cfg.APIEndpoint.AdvertiseAddress,
|
"advertise-address": cfg.LocalAPIEndpoint.AdvertiseAddress,
|
||||||
"insecure-port": "0",
|
"insecure-port": "0",
|
||||||
"enable-admission-plugins": "NodeRestriction",
|
"enable-admission-plugins": "NodeRestriction",
|
||||||
"service-cluster-ip-range": cfg.Networking.ServiceSubnet,
|
"service-cluster-ip-range": cfg.Networking.ServiceSubnet,
|
||||||
@ -133,7 +133,7 @@ func getAPIServerCommand(cfg *kubeadmapi.InitConfiguration) []string {
|
|||||||
"kubelet-client-certificate": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientCertName),
|
"kubelet-client-certificate": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientCertName),
|
||||||
"kubelet-client-key": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientKeyName),
|
"kubelet-client-key": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientKeyName),
|
||||||
"enable-bootstrap-token-auth": "true",
|
"enable-bootstrap-token-auth": "true",
|
||||||
"secure-port": fmt.Sprintf("%d", cfg.APIEndpoint.BindPort),
|
"secure-port": fmt.Sprintf("%d", cfg.LocalAPIEndpoint.BindPort),
|
||||||
"allow-privileged": "true",
|
"allow-privileged": "true",
|
||||||
"kubelet-preferred-address-types": "InternalIP,ExternalIP,Hostname",
|
"kubelet-preferred-address-types": "InternalIP,ExternalIP,Hostname",
|
||||||
// add options to configure the front proxy. Without the generated client cert, this will never be useable
|
// add options to configure the front proxy. Without the generated client cert, this will never be useable
|
||||||
|
@ -90,7 +90,7 @@ func CreateStackedEtcdStaticPodManifestFile(client clientset.Interface, manifest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notifies the other members of the etcd cluster about the joining member
|
// notifies the other members of the etcd cluster about the joining member
|
||||||
etcdPeerAddress := fmt.Sprintf("https://%s:%d", cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort)
|
etcdPeerAddress := fmt.Sprintf("https://%s:%d", cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort)
|
||||||
|
|
||||||
glog.V(1).Infof("Adding etcd member: %s", etcdPeerAddress)
|
glog.V(1).Infof("Adding etcd member: %s", etcdPeerAddress)
|
||||||
initialCluster, err := etcdClient.AddMember(cfg.NodeRegistration.Name, etcdPeerAddress)
|
initialCluster, err := etcdClient.AddMember(cfg.NodeRegistration.Name, etcdPeerAddress)
|
||||||
@ -141,10 +141,10 @@ func GetEtcdPodSpec(cfg *kubeadmapi.InitConfiguration, initialCluster []etcdutil
|
|||||||
func getEtcdCommand(cfg *kubeadmapi.InitConfiguration, initialCluster []etcdutil.Member) []string {
|
func getEtcdCommand(cfg *kubeadmapi.InitConfiguration, initialCluster []etcdutil.Member) []string {
|
||||||
defaultArguments := map[string]string{
|
defaultArguments := map[string]string{
|
||||||
"name": cfg.GetNodeName(),
|
"name": cfg.GetNodeName(),
|
||||||
"listen-client-urls": fmt.Sprintf("https://127.0.0.1:%d,https://%s:%d", kubeadmconstants.EtcdListenClientPort, cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenClientPort),
|
"listen-client-urls": fmt.Sprintf("https://127.0.0.1:%d,https://%s:%d", kubeadmconstants.EtcdListenClientPort, cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenClientPort),
|
||||||
"advertise-client-urls": fmt.Sprintf("https://%s:%d", cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenClientPort),
|
"advertise-client-urls": fmt.Sprintf("https://%s:%d", cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenClientPort),
|
||||||
"listen-peer-urls": fmt.Sprintf("https://%s:%d", cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort),
|
"listen-peer-urls": fmt.Sprintf("https://%s:%d", cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort),
|
||||||
"initial-advertise-peer-urls": fmt.Sprintf("https://%s:%d", cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort),
|
"initial-advertise-peer-urls": fmt.Sprintf("https://%s:%d", cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort),
|
||||||
"data-dir": cfg.Etcd.Local.DataDir,
|
"data-dir": cfg.Etcd.Local.DataDir,
|
||||||
"cert-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.EtcdServerCertName),
|
"cert-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.EtcdServerCertName),
|
||||||
"key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.EtcdServerKeyName),
|
"key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.EtcdServerKeyName),
|
||||||
@ -158,7 +158,7 @@ func getEtcdCommand(cfg *kubeadmapi.InitConfiguration, initialCluster []etcdutil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(initialCluster) == 0 {
|
if len(initialCluster) == 0 {
|
||||||
defaultArguments["initial-cluster"] = fmt.Sprintf("%s=https://%s:%d", cfg.GetNodeName(), cfg.APIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort)
|
defaultArguments["initial-cluster"] = fmt.Sprintf("%s=https://%s:%d", cfg.GetNodeName(), cfg.LocalAPIEndpoint.AdvertiseAddress, kubeadmconstants.EtcdListenPeerPort)
|
||||||
} else {
|
} else {
|
||||||
// NB. the joining etcd instance should be part of the initialCluster list
|
// NB. the joining etcd instance should be part of the initialCluster list
|
||||||
endpoints := []string{}
|
endpoints := []string{}
|
||||||
|
@ -282,7 +282,7 @@ func performEtcdStaticPodUpgrade(client clientset.Interface, waiter apiclient.Wa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return true, errors.Wrap(err, "failed to retrieve the current etcd version")
|
return true, errors.Wrap(err, "failed to retrieve the current etcd version")
|
||||||
}
|
}
|
||||||
currentEtcdVersionStr, ok := currentEtcdVersions[fmt.Sprintf("https://%s:%d", cfg.APIEndpoint.AdvertiseAddress, constants.EtcdListenClientPort)]
|
currentEtcdVersionStr, ok := currentEtcdVersions[fmt.Sprintf("https://%s:%d", cfg.LocalAPIEndpoint.AdvertiseAddress, constants.EtcdListenClientPort)]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println(currentEtcdVersions)
|
fmt.Println(currentEtcdVersions)
|
||||||
return true, errors.Wrap(err, "failed to retrieve the current etcd version")
|
return true, errors.Wrap(err, "failed to retrieve the current etcd version")
|
||||||
|
@ -65,7 +65,7 @@ func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Int
|
|||||||
if clusterStatus.APIEndpoints == nil {
|
if clusterStatus.APIEndpoints == nil {
|
||||||
clusterStatus.APIEndpoints = map[string]kubeadmapi.APIEndpoint{}
|
clusterStatus.APIEndpoints = map[string]kubeadmapi.APIEndpoint{}
|
||||||
}
|
}
|
||||||
clusterStatus.APIEndpoints[cfg.NodeRegistration.Name] = cfg.APIEndpoint
|
clusterStatus.APIEndpoints[cfg.NodeRegistration.Name] = cfg.LocalAPIEndpoint
|
||||||
|
|
||||||
// Marshal the ClusterStatus back into YAML
|
// Marshal the ClusterStatus back into YAML
|
||||||
clusterStatusYaml, err := configutil.MarshalKubeadmConfigObject(clusterStatus)
|
clusterStatusYaml, err := configutil.MarshalKubeadmConfigObject(clusterStatus)
|
||||||
|
@ -875,15 +875,15 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigu
|
|||||||
checks := []Checker{
|
checks := []Checker{
|
||||||
NumCPUCheck{NumCPU: kubeadmconstants.MasterNumCPU},
|
NumCPUCheck{NumCPU: kubeadmconstants.MasterNumCPU},
|
||||||
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
||||||
FirewalldCheck{ports: []int{int(cfg.APIEndpoint.BindPort), 10250}},
|
FirewalldCheck{ports: []int{int(cfg.LocalAPIEndpoint.BindPort), 10250}},
|
||||||
PortOpenCheck{port: int(cfg.APIEndpoint.BindPort)},
|
PortOpenCheck{port: int(cfg.LocalAPIEndpoint.BindPort)},
|
||||||
PortOpenCheck{port: 10251},
|
PortOpenCheck{port: 10251},
|
||||||
PortOpenCheck{port: 10252},
|
PortOpenCheck{port: 10252},
|
||||||
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeAPIServer, manifestsDir)},
|
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeAPIServer, manifestsDir)},
|
||||||
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeControllerManager, manifestsDir)},
|
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeControllerManager, manifestsDir)},
|
||||||
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeScheduler, manifestsDir)},
|
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.KubeScheduler, manifestsDir)},
|
||||||
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.Etcd, manifestsDir)},
|
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.Etcd, manifestsDir)},
|
||||||
HTTPProxyCheck{Proto: "https", Host: cfg.APIEndpoint.AdvertiseAddress},
|
HTTPProxyCheck{Proto: "https", Host: cfg.LocalAPIEndpoint.AdvertiseAddress},
|
||||||
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.ServiceSubnet},
|
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.ServiceSubnet},
|
||||||
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.PodSubnet},
|
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.PodSubnet},
|
||||||
}
|
}
|
||||||
@ -919,7 +919,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigu
|
|||||||
checks = append(checks, ExternalEtcdVersionCheck{Etcd: cfg.Etcd})
|
checks = append(checks, ExternalEtcdVersionCheck{Etcd: cfg.Etcd})
|
||||||
}
|
}
|
||||||
|
|
||||||
if ip := net.ParseIP(cfg.APIEndpoint.AdvertiseAddress); ip != nil {
|
if ip := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress); ip != nil {
|
||||||
if ip.To4() == nil && ip.To16() != nil {
|
if ip.To4() == nil && ip.To16() != nil {
|
||||||
checks = append(checks,
|
checks = append(checks,
|
||||||
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
|
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
|
||||||
|
@ -121,7 +121,7 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// gets the APIEndpoint for the current node from then ClusterStatus in the kubeadm-config ConfigMap
|
// gets the APIEndpoint for the current node from then ClusterStatus in the kubeadm-config ConfigMap
|
||||||
if err := getAPIEndpoint(configMap.Data, initcfg.NodeRegistration.Name, &initcfg.APIEndpoint); err != nil {
|
if err := getAPIEndpoint(configMap.Data, initcfg.NodeRegistration.Name, &initcfg.LocalAPIEndpoint); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ func SetInitDynamicDefaults(cfg *kubeadmapi.InitConfiguration) error {
|
|||||||
if err := SetNodeRegistrationDynamicDefaults(&cfg.NodeRegistration, true); err != nil {
|
if err := SetNodeRegistrationDynamicDefaults(&cfg.NodeRegistration, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := SetAPIEndpointDynamicDefaults(&cfg.APIEndpoint); err != nil {
|
if err := SetAPIEndpointDynamicDefaults(&cfg.LocalAPIEndpoint); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := SetClusterDynamicDefaults(&cfg.ClusterConfiguration, cfg.APIEndpoint.AdvertiseAddress, cfg.APIEndpoint.BindPort); err != nil {
|
if err := SetClusterDynamicDefaults(&cfg.ClusterConfiguration, cfg.LocalAPIEndpoint.AdvertiseAddress, cfg.LocalAPIEndpoint.BindPort); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -34,15 +34,15 @@ import (
|
|||||||
// - Otherwise, in case the ControlPlaneEndpoint is not defined, use the api.AdvertiseAddress + the api.BindPort.
|
// - Otherwise, in case the ControlPlaneEndpoint is not defined, use the api.AdvertiseAddress + the api.BindPort.
|
||||||
func GetMasterEndpoint(cfg *kubeadmapi.InitConfiguration) (string, error) {
|
func GetMasterEndpoint(cfg *kubeadmapi.InitConfiguration) (string, error) {
|
||||||
// parse the bind port
|
// parse the bind port
|
||||||
bindPortString := strconv.Itoa(int(cfg.APIEndpoint.BindPort))
|
bindPortString := strconv.Itoa(int(cfg.LocalAPIEndpoint.BindPort))
|
||||||
if _, err := ParsePort(bindPortString); err != nil {
|
if _, err := ParsePort(bindPortString); err != nil {
|
||||||
return "", errors.Wrapf(err, "invalid value %q given for api.bindPort", cfg.APIEndpoint.BindPort)
|
return "", errors.Wrapf(err, "invalid value %q given for api.bindPort", cfg.LocalAPIEndpoint.BindPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the AdvertiseAddress
|
// parse the AdvertiseAddress
|
||||||
var ip = net.ParseIP(cfg.APIEndpoint.AdvertiseAddress)
|
var ip = net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return "", errors.Errorf("invalid value `%s` given for api.advertiseAddress", cfg.APIEndpoint.AdvertiseAddress)
|
return "", errors.Errorf("invalid value `%s` given for api.advertiseAddress", cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the master url using cfg.API.AdvertiseAddress + the cfg.API.BindPort
|
// set the master url using cfg.API.AdvertiseAddress + the cfg.API.BindPort
|
||||||
|
@ -256,10 +256,10 @@ func pathForPublicKey(pkiPath, name string) string {
|
|||||||
// GetAPIServerAltNames builds an AltNames object for to be used when generating apiserver certificate
|
// GetAPIServerAltNames builds an AltNames object for to be used when generating apiserver certificate
|
||||||
func GetAPIServerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
func GetAPIServerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
||||||
// advertise address
|
// advertise address
|
||||||
advertiseAddress := net.ParseIP(cfg.APIEndpoint.AdvertiseAddress)
|
advertiseAddress := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
if advertiseAddress == nil {
|
if advertiseAddress == nil {
|
||||||
return nil, errors.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
|
return nil, errors.Errorf("error parsing LocalAPIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
|
||||||
cfg.APIEndpoint.AdvertiseAddress)
|
cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal IP address for the API server
|
// internal IP address for the API server
|
||||||
@ -311,9 +311,9 @@ func GetAPIServerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames
|
|||||||
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.ServerCertSANs`.
|
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.ServerCertSANs`.
|
||||||
func GetEtcdAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
func GetEtcdAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
||||||
// advertise address
|
// advertise address
|
||||||
advertiseAddress := net.ParseIP(cfg.APIEndpoint.AdvertiseAddress)
|
advertiseAddress := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
if advertiseAddress == nil {
|
if advertiseAddress == nil {
|
||||||
return nil, errors.Errorf("error parsing APIEndpoint AdvertiseAddress %q: is not a valid textual representation of an IP address", cfg.APIEndpoint.AdvertiseAddress)
|
return nil, errors.Errorf("error parsing LocalAPIEndpoint AdvertiseAddress %q: is not a valid textual representation of an IP address", cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create AltNames with defaults DNSNames/IPs
|
// create AltNames with defaults DNSNames/IPs
|
||||||
@ -334,10 +334,10 @@ func GetEtcdAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, err
|
|||||||
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.PeerCertSANs`.
|
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.PeerCertSANs`.
|
||||||
func GetEtcdPeerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
func GetEtcdPeerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames, error) {
|
||||||
// advertise address
|
// advertise address
|
||||||
advertiseAddress := net.ParseIP(cfg.APIEndpoint.AdvertiseAddress)
|
advertiseAddress := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
if advertiseAddress == nil {
|
if advertiseAddress == nil {
|
||||||
return nil, errors.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
|
return nil, errors.Errorf("error parsing LocalAPIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
|
||||||
cfg.APIEndpoint.AdvertiseAddress)
|
cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create AltNames with defaults DNSNames/IPs
|
// create AltNames with defaults DNSNames/IPs
|
||||||
|
@ -238,8 +238,8 @@ func GetProbeAddress(cfg *kubeadmapi.InitConfiguration, componentName string) st
|
|||||||
// future hosts that do not have the same address. Furthermore, since liveness and readiness
|
// future hosts that do not have the same address. Furthermore, since liveness and readiness
|
||||||
// probes do not support the Downward API we cannot dynamically set the advertise address to
|
// probes do not support the Downward API we cannot dynamically set the advertise address to
|
||||||
// the node's IP. The only option then is to use localhost.
|
// the node's IP. The only option then is to use localhost.
|
||||||
if cfg.APIEndpoint.AdvertiseAddress != "" {
|
if cfg.LocalAPIEndpoint.AdvertiseAddress != "" {
|
||||||
return cfg.APIEndpoint.AdvertiseAddress
|
return cfg.LocalAPIEndpoint.AdvertiseAddress
|
||||||
}
|
}
|
||||||
case componentName == kubeadmconstants.KubeControllerManager:
|
case componentName == kubeadmconstants.KubeControllerManager:
|
||||||
if addr, exists := cfg.ControllerManager.ExtraArgs[kubeControllerManagerAddressArg]; exists {
|
if addr, exists := cfg.ControllerManager.ExtraArgs[kubeControllerManagerAddressArg]; exists {
|
||||||
|
@ -58,8 +58,8 @@ func SetupInitConfigurationFile(t *testing.T, tmpdir string, cfg *kubeadmapi.Ini
|
|||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta1
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
apiEndpoint:
|
apiEndpoint:
|
||||||
advertiseAddress: {{.APIEndpoint.AdvertiseAddress}}
|
advertiseAddress: {{.LocalAPIEndpoint.AdvertiseAddress}}
|
||||||
bindPort: {{.APIEndpoint.BindPort}}
|
bindPort: {{.LocalAPIEndpoint.BindPort}}
|
||||||
nodeRegistration:
|
nodeRegistration:
|
||||||
name: {{.NodeRegistration.Name}}
|
name: {{.NodeRegistration.Name}}
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user