Skip to content

Commit 005d712

Browse files
jichenjck8s-ci-robot
authored andcommitted
fix api port issue (#459)
1 parent 54bb062 commit 005d712

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

controllers/openstackcluster_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,17 @@ func (r *OpenStackClusterReconciler) reconcileCluster(logger logr.Logger, cluste
170170
return reconcile.Result{}, errors.Errorf("failed to get control plane machine: %v", err)
171171
}
172172
if controlPlaneMachine != nil {
173+
var apiPort int
174+
if cluster.Spec.ClusterNetwork.APIServerPort == nil {
175+
logger.Info("No API endpoint given, default to 6443")
176+
apiPort = 6443
177+
} else {
178+
apiPort = int(*cluster.Spec.ClusterNetwork.APIServerPort)
179+
}
173180
openStackCluster.Status.APIEndpoints = []infrav1.APIEndpoint{
174181
{
175182
Host: controlPlaneMachine.Spec.FloatingIP,
176-
Port: int(*cluster.Spec.ClusterNetwork.APIServerPort),
183+
Port: apiPort,
177184
},
178185
}
179186
} else {

examples/cluster/cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
# * Disable the apiServerPort property
1616
# single-node control-plane:
1717
# * Enable the apiServerPort property
18-
#apiServerPort: 6443
18+
apiServerPort: <disable when multi-node control-plane>
1919
infrastructureRef:
2020
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
2121
kind: OpenStackCluster

0 commit comments

Comments
 (0)