Skip to content

Commit 263bfbf

Browse files
jichenjck8s-ci-robot
authored andcommitted
Add v1alpha3 support
1 parent 97f2759 commit 263bfbf

23 files changed

+2465
-621
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ resources:
1111
- group: infrastructure
1212
version: v1alpha2
1313
kind: OpenStackMachineTemplate
14+
- group: infrastructure
15+
version: v1alpha3
16+
kind: OpenStackCluster
17+
- group: infrastructure
18+
version: v1alpha3
19+
kind: OpenStackMachine
20+
- group: infrastructure
21+
version: v1alpha3
22+
kind: OpenStackMachineTemplate

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha3/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 contains API Schema definitions for the infrastructure v1alpha3 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=infrastructure.cluster.x-k8s.io
20+
package v1alpha3
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha3"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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+
"sigs.k8s.io/cluster-api/errors"
23+
)
24+
25+
const (
26+
// MachineFinalizer allows ReconcileOpenStackMachine to clean up OpenStack resources associated with OpenStackMachine before
27+
// removing it from the apiserver.
28+
MachineFinalizer = "openstackmachine.infrastructure.cluster.x-k8s.io"
29+
)
30+
31+
// OpenStackMachineSpec defines the desired state of OpenStackMachine
32+
type OpenStackMachineSpec struct {
33+
34+
// ProviderID is the unique identifier as specified by the cloud provider.
35+
ProviderID *string `json:"providerID,omitempty"`
36+
37+
// The name of the secret containing the openstack credentials
38+
// +optional
39+
CloudsSecret *corev1.SecretReference `json:"cloudsSecret"`
40+
41+
// The name of the cloud to use from the clouds secret
42+
// +optional
43+
CloudName string `json:"cloudName"`
44+
45+
// The flavor reference for the flavor for your server instance.
46+
Flavor string `json:"flavor"`
47+
48+
// The name of the image to use for your server instance.
49+
// If the RootVolume is specified, this will be ignored and use rootVolume directly.
50+
Image string `json:"image"`
51+
52+
// The ssh key to inject in the instance
53+
SSHKeyName string `json:"sshKeyName,omitempty"`
54+
55+
// A networks object. Required parameter when there are multiple networks defined for the tenant.
56+
// When you do not specify the networks parameter, the server attaches to the only network created for the current tenant.
57+
Networks []NetworkParam `json:"networks,omitempty"`
58+
// The floatingIP which will be associated to the machine, only used for master.
59+
// The floatingIP should have been created and haven't been associated.
60+
FloatingIP string `json:"floatingIP,omitempty"`
61+
62+
// The availability zone from which to launch the server.
63+
AvailabilityZone string `json:"availabilityZone,omitempty"`
64+
65+
// The names of the security groups to assign to the instance
66+
SecurityGroups []SecurityGroupParam `json:"securityGroups,omitempty"`
67+
68+
// The name of the secret containing the user data (startup script in most cases)
69+
UserDataSecret *corev1.SecretReference `json:"userDataSecret,omitempty"`
70+
71+
// Whether the server instance is created on a trunk port or not.
72+
Trunk bool `json:"trunk,omitempty"`
73+
74+
// Machine tags
75+
// Requires Nova api 2.52 minimum!
76+
Tags []string `json:"tags,omitempty"`
77+
78+
// Metadata mapping. Allows you to create a map of key value pairs to add to the server instance.
79+
ServerMetadata map[string]string `json:"serverMetadata,omitempty"`
80+
81+
// Config Drive support
82+
ConfigDrive *bool `json:"configDrive,omitempty"`
83+
84+
// The volume metadata to boot from
85+
RootVolume *RootVolume `json:"rootVolume,omitempty"`
86+
}
87+
88+
// OpenStackMachineStatus defines the observed state of OpenStackMachine
89+
type OpenStackMachineStatus struct {
90+
91+
// Ready is true when the provider resource is ready.
92+
// +optional
93+
Ready bool `json:"ready"`
94+
95+
// Addresses contains the OpenStack instance associated addresses.
96+
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`
97+
98+
// InstanceState is the state of the OpenStack instance for this machine.
99+
// +optional
100+
InstanceState *InstanceState `json:"instanceState,omitempty"`
101+
102+
ErrorReason *errors.MachineStatusError `json:"errorReason,omitempty"`
103+
104+
// ErrorMessage will be set in the event that there is a terminal problem
105+
// reconciling the Machine and will contain a more verbose string suitable
106+
// for logging and human consumption.
107+
//
108+
// This field should not be set for transitive errors that a controller
109+
// faces that are expected to be fixed automatically over
110+
// time (like service outages), but instead indicate that something is
111+
// fundamentally wrong with the Machine's spec or the configuration of
112+
// the controller, and that manual intervention is required. Examples
113+
// of terminal errors would be invalid combinations of settings in the
114+
// spec, values that are unsupported by the controller, or the
115+
// responsible controller itself being critically misconfigured.
116+
//
117+
// Any transient errors that occur during the reconciliation of Machines
118+
// can be added as events to the Machine object and/or logged in the
119+
// controller's output.
120+
// +optional
121+
ErrorMessage *string `json:"errorMessage,omitempty"`
122+
}
123+
124+
// +kubebuilder:object:root=true
125+
// +kubebuilder:resource:path=openstackmachines,scope=Namespaced
126+
// +kubebuilder:storageversion
127+
// +kubebuilder:subresource:status
128+
129+
// OpenStackMachine is the Schema for the openstackmachines API
130+
type OpenStackMachine struct {
131+
metav1.TypeMeta `json:",inline"`
132+
metav1.ObjectMeta `json:"metadata,omitempty"`
133+
134+
Spec OpenStackMachineSpec `json:"spec,omitempty"`
135+
Status OpenStackMachineStatus `json:"status,omitempty"`
136+
}
137+
138+
// +kubebuilder:object:root=true
139+
140+
// OpenStackMachineList contains a list of OpenStackMachine
141+
type OpenStackMachineList struct {
142+
metav1.TypeMeta `json:",inline"`
143+
metav1.ListMeta `json:"metadata,omitempty"`
144+
Items []OpenStackMachine `json:"items"`
145+
}
146+
147+
func init() {
148+
SchemeBuilder.Register(&OpenStackMachine{}, &OpenStackMachineList{})
149+
}

0 commit comments

Comments
 (0)