|
| 1 | +/* |
| 2 | +Copyright 2019 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha3 |
| 18 | + |
| 19 | +import ( |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" |
| 23 | +) |
| 24 | + |
| 25 | +const ( |
| 26 | + // ClusterFinalizer allows ReconcileOpenStackCluster to clean up OpenStack resources associated with OpenStackCluster before |
| 27 | + // removing it from the apiserver. |
| 28 | + ClusterFinalizer = "openstackcluster.infrastructure.cluster.x-k8s.io" |
| 29 | +) |
| 30 | + |
| 31 | +// OpenStackClusterSpec defines the desired state of OpenStackCluster |
| 32 | +type OpenStackClusterSpec struct { |
| 33 | + |
| 34 | + // The name of the secret containing the openstack credentials |
| 35 | + // +optional |
| 36 | + CloudsSecret *corev1.SecretReference `json:"cloudsSecret"` |
| 37 | + |
| 38 | + // The name of the cloud to use from the clouds secret |
| 39 | + // +optional |
| 40 | + CloudName string `json:"cloudName"` |
| 41 | + |
| 42 | + // NodeCIDR is the OpenStack Subnet to be created. Cluster actuator will create a |
| 43 | + // network, a subnet with NodeCIDR, and a router connected to this subnet. |
| 44 | + // If you leave this empty, no network will be created. |
| 45 | + NodeCIDR string `json:"nodeCidr,omitempty"` |
| 46 | + |
| 47 | + // If NodeCIDR cannot be set this can be used to detect an existing network. |
| 48 | + Network Filter `json:"network,omitempty"` |
| 49 | + |
| 50 | + // If NodeCIDR cannot be set this can be used to detect an existing subnet. |
| 51 | + Subnet SubnetFilter `json:"subnet,omitempty"` |
| 52 | + |
| 53 | + // DNSNameservers is the list of nameservers for OpenStack Subnet being created. |
| 54 | + // Set this value when you need create a new network/subnet while the access |
| 55 | + // through DNS is required. |
| 56 | + DNSNameservers []string `json:"dnsNameservers,omitempty"` |
| 57 | + // ExternalRouterIPs is an array of externalIPs on the respective subnets. |
| 58 | + // This is necessary if the router needs a fixed ip in a specific subnet. |
| 59 | + ExternalRouterIPs []ExternalRouterIPParam `json:"externalRouterIPs,omitempty"` |
| 60 | + // ExternalNetworkID is the ID of an external OpenStack Network. This is necessary |
| 61 | + // to get public internet to the VMs. |
| 62 | + ExternalNetworkID string `json:"externalNetworkId,omitempty"` |
| 63 | + |
| 64 | + // UseOctavia is weather LoadBalancer Service is Octavia or not |
| 65 | + // +optional |
| 66 | + UseOctavia bool `json:"useOctavia,omitempty"` |
| 67 | + |
| 68 | + // ManagedAPIServerLoadBalancer defines whether a LoadBalancer for the |
| 69 | + // APIServer should be created. If set to true the following properties are |
| 70 | + // mandatory: APIServerLoadBalancerFloatingIP, APIServerLoadBalancerPort |
| 71 | + // +optional |
| 72 | + ManagedAPIServerLoadBalancer bool `json:"managedAPIServerLoadBalancer"` |
| 73 | + |
| 74 | + // APIServerLoadBalancerFloatingIP is the floatingIP which will be associated |
| 75 | + // to the APIServer loadbalancer. The floatingIP will be created if it not |
| 76 | + // already exists. |
| 77 | + APIServerLoadBalancerFloatingIP string `json:"apiServerLoadBalancerFloatingIP,omitempty"` |
| 78 | + |
| 79 | + // APIServerLoadBalancerPort is the port on which the listener on the APIServer |
| 80 | + // loadbalancer will be created |
| 81 | + APIServerLoadBalancerPort int `json:"apiServerLoadBalancerPort,omitempty"` |
| 82 | + |
| 83 | + // APIServerLoadBalancerAdditionalPorts adds additional ports to the APIServerLoadBalancer |
| 84 | + APIServerLoadBalancerAdditionalPorts []int `json:"apiServerLoadBalancerAdditionalPorts,omitempty"` |
| 85 | + |
| 86 | + // ManagedSecurityGroups defines that kubernetes manages the OpenStack security groups |
| 87 | + // for now, that means that we'll create two security groups, one allowing SSH |
| 88 | + // and API access from everywhere, and another one that allows all traffic to/from |
| 89 | + // machines belonging to that group. In the future, we could make this more flexible. |
| 90 | + // +optional |
| 91 | + ManagedSecurityGroups bool `json:"managedSecurityGroups"` |
| 92 | + |
| 93 | + // DisablePortSecurity disables the port security of the network created for the |
| 94 | + // Kubernetes cluster, which also disables SecurityGroups |
| 95 | + DisablePortSecurity bool `json:"disablePortSecurity,omitempty"` |
| 96 | + |
| 97 | + // Tags for all resources in cluster |
| 98 | + Tags []string `json:"tags,omitempty"` |
| 99 | + |
| 100 | + // Default: True. In case of server tag errors, set to False |
| 101 | + DisableServerTags bool `json:"disableServerTags,omitempty"` |
| 102 | + |
| 103 | + // CAKeyPair is the key pair for ca certs. |
| 104 | + CAKeyPair KeyPair `json:"caKeyPair,omitempty"` |
| 105 | + |
| 106 | + //EtcdCAKeyPair is the key pair for etcd. |
| 107 | + EtcdCAKeyPair KeyPair `json:"etcdCAKeyPair,omitempty"` |
| 108 | + |
| 109 | + // FrontProxyCAKeyPair is the key pair for FrontProxyKeyPair. |
| 110 | + FrontProxyCAKeyPair KeyPair `json:"frontProxyCAKeyPair,omitempty"` |
| 111 | + |
| 112 | + // SAKeyPair is the service account key pair. |
| 113 | + SAKeyPair KeyPair `json:"saKeyPair,omitempty"` |
| 114 | + |
| 115 | + // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. |
| 116 | + // +optional |
| 117 | + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` |
| 118 | +} |
| 119 | + |
| 120 | +// OpenStackClusterStatus defines the observed state of OpenStackCluster |
| 121 | +type OpenStackClusterStatus struct { |
| 122 | + Ready bool `json:"ready"` |
| 123 | + // APIEndpoints represents the endpoints to communicate with the control plane. |
| 124 | + // +optional |
| 125 | + APIEndpoints []APIEndpoint `json:"apiEndpoints,omitempty"` |
| 126 | + |
| 127 | + // Network contains all information about the created OpenStack Network. |
| 128 | + // It includes Subnets and Router. |
| 129 | + Network *Network `json:"network,omitempty"` |
| 130 | + |
| 131 | + // ControlPlaneSecurityGroups contains all the information about the OpenStack |
| 132 | + // Security Group that needs to be applied to control plane nodes. |
| 133 | + // TODO: Maybe instead of two properties, we add a property to the group? |
| 134 | + ControlPlaneSecurityGroup *SecurityGroup `json:"controlPlaneSecurityGroup,omitempty"` |
| 135 | + |
| 136 | + // GlobalSecurityGroup contains all the information about the OpenStack Security |
| 137 | + // Group that needs to be applied to all nodes, both control plane and worker nodes. |
| 138 | + GlobalSecurityGroup *SecurityGroup `json:"globalSecurityGroup,omitempty"` |
| 139 | +} |
| 140 | + |
| 141 | +// +kubebuilder:object:root=true |
| 142 | +// +kubebuilder:resource:path=openstackclusters,scope=Namespaced |
| 143 | +// +kubebuilder:storageversion |
| 144 | +// +kubebuilder:subresource:status |
| 145 | + |
| 146 | +// OpenStackCluster is the Schema for the openstackclusters API |
| 147 | +type OpenStackCluster struct { |
| 148 | + metav1.TypeMeta `json:",inline"` |
| 149 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 150 | + |
| 151 | + Spec OpenStackClusterSpec `json:"spec,omitempty"` |
| 152 | + Status OpenStackClusterStatus `json:"status,omitempty"` |
| 153 | +} |
| 154 | + |
| 155 | +// +kubebuilder:object:root=true |
| 156 | + |
| 157 | +// OpenStackClusterList contains a list of OpenStackCluster |
| 158 | +type OpenStackClusterList struct { |
| 159 | + metav1.TypeMeta `json:",inline"` |
| 160 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 161 | + Items []OpenStackCluster `json:"items"` |
| 162 | +} |
| 163 | + |
| 164 | +func init() { |
| 165 | + SchemeBuilder.Register(&OpenStackCluster{}, &OpenStackClusterList{}) |
| 166 | +} |
0 commit comments