Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

make 6443 as a constant #76

Merged
merged 2 commits into from
Jul 10, 2019
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: 4 additions & 2 deletions kind/actions/cluster_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/pkg/errors"
k8sversion "k8s.io/apimachinery/pkg/util/version"
constkind "sigs.k8s.io/cluster-api-provider-docker/kind/constants"
"sigs.k8s.io/cluster-api-provider-docker/kind/kubeadm"
"sigs.k8s.io/cluster-api-provider-docker/third_party/forked/loadbalancer"
"sigs.k8s.io/kind/pkg/cluster/constants"
Expand Down Expand Up @@ -99,7 +100,7 @@ func ConfigureLoadBalancer(clusterName string) error {
if err != nil {
return errors.Wrapf(err, "failed to get IP for node %s", n.Name())
}
backendServers[n.Name()] = fmt.Sprintf("%s:%d", controlPlaneIPv4, 6443)
backendServers[n.Name()] = fmt.Sprintf("%s:%d", controlPlaneIPv4, constkind.APIServerPort)
}

// create loadbalancer config data
Expand All @@ -126,7 +127,8 @@ func KubeadmConfig(node *nodes.Node, clusterName, lbip string) error {
return errors.Wrap(err, "failed to get kubernetes version from node")
}

kubeadmConfig, err := kubeadm.InitConfiguration(kubeVersion, clusterName, fmt.Sprintf("%s:%d", lbip, 6443))
kubeadmConfig, err := kubeadm.InitConfiguration(kubeVersion, clusterName,
fmt.Sprintf("%s:%d", lbip, constkind.APIServerPort))

if err != nil {
return errors.Wrap(err, "failed to generate kubeadm config content")
Expand Down
3 changes: 2 additions & 1 deletion kind/actions/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"strings"

"github.com/pkg/errors"
constkind "sigs.k8s.io/cluster-api-provider-docker/kind/constants"
"sigs.k8s.io/cluster-api-provider-docker/third_party/forked/loadbalancer"
"sigs.k8s.io/kind/pkg/cluster/config/defaults"
"sigs.k8s.io/kind/pkg/cluster/constants"
Expand Down Expand Up @@ -247,7 +248,7 @@ func GetLoadBalancerHostAndPort(allNodes []nodes.Node) (string, int32, error) {
if err != nil {
return "", 0, err
}
port, err := node.Ports(6443)
port, err := node.Ports(constkind.APIServerPort)
return ipv4, port, err
}

Expand Down
21 changes: 21 additions & 0 deletions kind/constants/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2019 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 constants

// APIServerPort is the expected default APIServerPort on the control plane node(s)
// https://kubernetes.io/docs/reference/access-authn-authz/controlling-access/#api-server-ports-and-ips
const APIServerPort = 6443
3 changes: 2 additions & 1 deletion kind/kubeadm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeadmv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
"k8s.io/kubernetes/pkg/kubelet/apis/config"
"sigs.k8s.io/cluster-api-provider-docker/kind/constants"
)

const (
Expand Down Expand Up @@ -52,7 +53,7 @@ func InitConfiguration(version, name, controlPlaneEndpoint string) ([]byte, erro
},
},
LocalAPIEndpoint: kubeadmv1beta1.APIEndpoint{
BindPort: int32(6443),
BindPort: int32(constants.APIServerPort),
},
NodeRegistration: kubeadmv1beta1.NodeRegistrationOptions{
CRISocket: "/run/containerd/containerd.sock",
Expand Down