Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - KubeAPIServerVirtualIP #5555

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions api/hypershift/v1beta1/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ type OpenStackPlatformSpec struct {
// +kubebuilder:validation:XValidation:rule="isIP(self)",message="floatingIP must be a valid IPv4 or IPv6 address"
// +optional
IngressFloatingIP string `json:"ingressFloatingIP,omitempty"`

// KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
// be associated with the kubeapi-server load balancer port.
//
// +kubebuilder:validation:XValidation:rule="isIP(self)",message="kubeAPIServerVirtualIP must be a valid IPv4 or IPv6 address"
// +optional
KubeAPIServerVirtualIP string `json:"kubeAPIServerVirtualIP,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brain dump idea: create a type that has an IP and a hostname as well.
The hostname would be used to update HostedCluster.Status.ControlPlaneEndpoint (if it's possible) or at least generate a kubeconfig using that hostname (a hostname is prettier than an IP).
And I think we would need to create the Service annotation to give the hostname, so the certificate would be valid.

}

// OpenStackIdentityReference is a reference to an infrastructure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3434,6 +3434,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3336,6 +3336,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions cmd/cluster/openstack/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ func bindCoreOptions(opts *RawCreateOptions, flags *pflag.FlagSet) {
flags.StringVar(&opts.OpenStackCACertFile, "openstack-ca-cert-file", opts.OpenStackCACertFile, "Path to the OpenStack CA certificate file (optional)")
flags.StringVar(&opts.OpenStackExternalNetworkID, "openstack-external-network-id", opts.OpenStackExternalNetworkID, "ID of the OpenStack external network (optional)")
flags.StringVar(&opts.OpenStackIngressFloatingIP, "openstack-ingress-floating-ip", opts.OpenStackIngressFloatingIP, "An available floating IP in your OpenStack cluster that will be associated with the OpenShift ingress port (optional)")
flags.StringVar(&opts.OpenStackKubeAPIServerVirtualIP, "openstack-kube-apiserver-virtual-ip", opts.OpenStackKubeAPIServerVirtualIP, "Virtual IP address for the kubeapi-server (optional)")
flags.StringSliceVar(&opts.OpenStackDNSNameservers, "openstack-dns-nameservers", opts.OpenStackDNSNameservers, "List of DNS nameservers to use for the cluster (optional)")
}

type RawCreateOptions struct {
OpenStackCredentialsFile string
OpenStackCloud string
OpenStackCACertFile string
OpenStackExternalNetworkID string
OpenStackIngressFloatingIP string
OpenStackDNSNameservers []string
OpenStackCredentialsFile string
OpenStackCloud string
OpenStackCACertFile string
OpenStackExternalNetworkID string
OpenStackIngressFloatingIP string
OpenStackKubeAPIServerVirtualIP string
OpenStackDNSNameservers []string

NodePoolOpts *openstacknodepool.RawOpenStackPlatformCreateOptions
}
Expand Down Expand Up @@ -172,6 +174,10 @@ func (o *RawCreateOptions) ApplyPlatformSpecifics(cluster *hyperv1.HostedCluster
cluster.Spec.Platform.OpenStack.IngressFloatingIP = o.OpenStackIngressFloatingIP
}

if o.OpenStackKubeAPIServerVirtualIP != "" {
cluster.Spec.Platform.OpenStack.KubeAPIServerVirtualIP = o.OpenStackKubeAPIServerVirtualIP
}

// If the user has specified DNS nameservers, it'll be used when creating the managed subnet(s).
// In the case where the user wants to override the other fields of the managed subnets, they can
// first render the cluster spec and then provide the needed configuration as API allows (for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4353,6 +4353,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4242,6 +4242,15 @@ spec:
x-kubernetes-validations:
- message: floatingIP must be a valid IPv4 or IPv6 address
rule: isIP(self)
kubeAPIServerVirtualIP:
description: |-
KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.
type: string
x-kubernetes-validations:
- message: kubeAPIServerVirtualIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
managedSubnets:
description: |-
ManagedSubnets describe the OpenStack Subnet to be created. Cluster actuator will create a network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func ReconcileService(svc *corev1.Service, strategy *hyperv1.ServicePublishingSt
} else {
svc.Spec.Type = corev1.ServiceTypeClusterIP
}
// OpenStack Load Balancer Virtual IP can be specified to expose the loadbalancer on a specific network instead
// of a default public network.
if hcp.Spec.Platform.Type == hyperv1.OpenStackPlatform && hcp.Spec.Platform.OpenStack != nil && hcp.Spec.Platform.OpenStack.KubeAPIServerVirtualIP != "" {
svc.Spec.LoadBalancerIP = hcp.Spec.Platform.OpenStack.KubeAPIServerVirtualIP
}
case hyperv1.NodePort:
svc.Spec.Type = corev1.ServiceTypeNodePort
if portSpec.NodePort == 0 && strategy.NodePort != nil {
Expand Down
13 changes: 13 additions & 0 deletions docs/content/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9254,6 +9254,19 @@ balancer.
This value must be a valid IPv4 or IPv6 address.</p>
</td>
</tr>
<tr>
<td>
<code>kubeAPIServerVirtualIP</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>KubeAPIServerVirtualIP is an available floating IP in your OpenStack cluster that will
be associated with the kubeapi-server load balancer port.</p>
</td>
</tr>
</tbody>
</table>
###PayloadArchType { #hypershift.openshift.io/v1beta1.PayloadArchType }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.