Skip to content

Commit

Permalink
Take into account possible lack of public IPs
Browse files Browse the repository at this point in the history
Signed-off-by: Artiom Diomin <[email protected]>
  • Loading branch information
kron4eg committed Jul 8, 2019
1 parent 4781f8a commit ae10a46
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/kubeone/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"k8s.io/apimachinery/pkg/runtime"

kubeoneapi "github.com/kubermatic/kubeone/pkg/apis/kubeone"
kubeonescheme "github.com/kubermatic/kubeone/pkg/apis/kubeone/scheme"
kubeonev1alpha1 "github.com/kubermatic/kubeone/pkg/apis/kubeone/v1alpha1"
"github.com/kubermatic/kubeone/pkg/apis/kubeone/validation"
"github.com/kubermatic/kubeone/pkg/credentials"
"github.com/kubermatic/kubeone/pkg/terraform"

"k8s.io/apimachinery/pkg/runtime"
)

// SetKubeOneClusterDynamicDefaults sets the dynamic defaults for a given KubeOneCluster object
Expand Down
33 changes: 22 additions & 11 deletions pkg/terraform/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,14 @@ func (c *Config) Apply(cluster *kubeonev1alpha1.KubeOneCluster) error {
privateIP = cp.PrivateAddress[i]
}

hosts = append(hosts, kubeonev1alpha1.HostConfig{
ID: i,
PublicAddress: publicIP,
PrivateAddress: privateIP,
SSHUsername: cp.SSHUser,
SSHPort: cp.SSHPort,
SSHPrivateKeyFile: cp.SSHPrivateKeyFile,
SSHAgentSocket: cp.SSHAgentSocket,
Bastion: cp.Bastion,
BastionPort: cp.BastionPort,
})
hosts = append(hosts, newHostConfig(i, publicIP, privateIP, cp))
}

if len(hosts) == 0 {
// there was no public IPs available
for i, privateIP := range cp.PrivateAddress {
hosts = append(hosts, newHostConfig(i, "", privateIP, cp))
}
}

if len(hosts) > 0 {
Expand Down Expand Up @@ -166,6 +163,20 @@ func (c *Config) Apply(cluster *kubeonev1alpha1.KubeOneCluster) error {
return nil
}

func newHostConfig(id int, publicIP, privateIP string, cp controlPlane) kubeonev1alpha1.HostConfig {
return kubeonev1alpha1.HostConfig{
ID: id,
PublicAddress: publicIP,
PrivateAddress: privateIP,
SSHUsername: cp.SSHUser,
SSHPort: cp.SSHPort,
SSHPrivateKeyFile: cp.SSHPrivateKeyFile,
SSHAgentSocket: cp.SSHAgentSocket,
Bastion: cp.Bastion,
BastionPort: cp.BastionPort,
}
}

func (c *Config) updateAWSWorkerset(existingWorkerSet *kubeonev1alpha1.WorkerConfig, cfg json.RawMessage) error {
var awsCloudConfig machinecontroller.AWSSpec

Expand Down

0 comments on commit ae10a46

Please sign in to comment.