Skip to content

Commit

Permalink
Take static networking into account when contructing machineDeployment (
Browse files Browse the repository at this point in the history
#606)

Signed-off-by: Artiom Diomin <[email protected]>
  • Loading branch information
kron4eg authored and kubermatic-bot committed Jul 31, 2019
1 parent 3df2b12 commit feca96c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pkg/templates/machinecontroller/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ import (
clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

type providerSpec struct {
SSHPublicKeys []string `json:"sshPublicKeys"`
CloudProvider kubeoneapi.CloudProviderName `json:"cloudProvider"`
CloudProviderSpec interface{} `json:"cloudProviderSpec"`
OperatingSystem string `json:"operatingSystem"`
OperatingSystemSpec interface{} `json:"operatingSystemSpec"`
}

// DeployMachineDeployments deploys MachineDeployments that create appropriate machines
func DeployMachineDeployments(s *state.State) error {
if s.DynamicClient == nil {
Expand Down Expand Up @@ -75,15 +67,20 @@ func createMachineDeployment(cluster *kubeoneapi.KubeOneCluster, workerset kubeo
return nil, errors.Wrap(err, "failed to generate machineSpec")
}

config := providerSpec{
CloudProvider: provider,
CloudProviderSpec: cloudProviderSpec,
OperatingSystem: workerset.Config.OperatingSystem,
OperatingSystemSpec: workerset.Config.OperatingSystemSpec,
SSHPublicKeys: workerset.Config.SSHPublicKeys,
cloudProviderSpecJSON, err := json.Marshal(cloudProviderSpec)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal cloudProviderSpec to JSON")
}

encoded, err := json.Marshal(config)
workerset.Config.CloudProviderSpec = cloudProviderSpecJSON

encoded, err := json.Marshal(struct {
kubeoneapi.ProviderSpec
CloudProvider kubeoneapi.CloudProviderName `json:"cloudProvider"`
}{
ProviderSpec: workerset.Config,
CloudProvider: provider,
})
if err != nil {
return nil, errors.Wrap(err, "failed to JSON marshal providerSpec")
}
Expand All @@ -96,6 +93,12 @@ func createMachineDeployment(cluster *kubeoneapi.KubeOneCluster, workerset kubeo
"workerset": workerset.Name,
}

if workerset.Config.Network != nil {
// we have static network config
maxSurge = intstr.FromInt(0)
maxUnavailable = intstr.FromInt(1)
}

return &clusterv1alpha1.MachineDeployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: metav1.NamespaceSystem,
Expand All @@ -121,9 +124,6 @@ func createMachineDeployment(cluster *kubeoneapi.KubeOneCluster, workerset kubeo
Labels: labels.Merge(workerset.Config.Labels, workersetNameLabels),
},
Spec: clusterv1alpha1.MachineSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels.Merge(workerset.Config.Labels, workersetNameLabels),
},
Versions: clusterv1alpha1.MachineVersionInfo{
Kubelet: cluster.Versions.Kubernetes,
},
Expand Down

0 comments on commit feca96c

Please sign in to comment.