Skip to content
Closed
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
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version: "1"
domain: k8s.io
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api-provider-openstack
701 changes: 701 additions & 0 deletions config/crds/infrastructure_v1alpha2_openstackcluster.yaml

Large diffs are not rendered by default.

544 changes: 544 additions & 0 deletions config/crds/infrastructure_v1alpha2_openstackmachine.yaml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions config/samples/infrastructure_v1alpha2_openstackcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: OpenStackCluster
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: openstackcluster-sample
spec:
# Add fields here
foo: bar
9 changes: 9 additions & 0 deletions config/samples/infrastructure_v1alpha2_openstackmachine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: OpenStackMachine
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: openstackmachine-sample
spec:
# Add fields here
foo: bar
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ require (
github.com/coreos/ignition v0.33.0 // indirect
github.com/gophercloud/gophercloud v0.3.0
github.com/gophercloud/utils v0.0.0-20190527093828-25f1b77b8c03
github.com/onsi/gomega v1.5.0
github.com/pkg/errors v0.8.1
github.com/vincent-petithory/dataurl v0.0.0-20160330182126-9a301d65acbb // indirect
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20190814101207-0772a1bdf941
k8s.io/apimachinery v0.0.0-20190814100815-533d101be9a6
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/infrastructure/group.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2018 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package infrastructure contains infrastructure API versions
package infrastructure
23 changes: 23 additions & 0 deletions pkg/apis/infrastructure/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2018 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha2 contains API Schema definitions for the infrastructure v1alpha2 API group
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/infrastructure
// +k8s:defaulter-gen=TypeMeta
// +groupName=infrastructure.cluster.x-k8s.io
package v1alpha2
153 changes: 153 additions & 0 deletions pkg/apis/infrastructure/v1alpha2/openstackcluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
Copyright 2018 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

kubeadmv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// OpenStackClusterSpec defines the desired state of OpenStackCluster
type OpenStackClusterSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// The name of the secret containing the openstack credentials
CloudsSecret *corev1.SecretReference `json:"cloudsSecret"`

// The name of the cloud to use from the clouds secret
CloudName string `json:"cloudName"`

// NodeCIDR is the OpenStack Subnet to be created. Cluster actuator will create a
// network, a subnet with NodeCIDR, and a router connected to this subnet.
// If you leave this empty, no network will be created.
NodeCIDR string `json:"nodeCidr,omitempty"`
// DNSNameservers is the list of nameservers for OpenStack Subnet being created.
DNSNameservers []string `json:"dnsNameservers,omitempty"`
// ExternalRouterIPs is an array of externalIPs on the respective subnets.
// This is necessary if the router needs a fixed ip in a specific subnet.
ExternalRouterIPs []ExternalRouterIPParam `json:"externalRouterIPs,omitempty"`
// ExternalNetworkID is the ID of an external OpenStack Network. This is necessary
// to get public internet to the VMs.
ExternalNetworkID string `json:"externalNetworkId,omitempty"`
// UseOctavia is weather LoadBalancer Service is Octavia or not
UseOctavia bool `json:"useOctavia"`

// ManagedAPIServerLoadBalancer defines whether a LoadBalancer for the
// APIServer should be created. If set to true the following properties are
// mandatory: APIServerLoadBalancerFloatingIP, APIServerLoadBalancerPort
ManagedAPIServerLoadBalancer bool `json:"managedAPIServerLoadBalancer"`

// APIServerLoadBalancerFloatingIP is the floatingIP which will be associated
// to the APIServer loadbalancer. The floatingIP will be created if it not
// already exists.
APIServerLoadBalancerFloatingIP string `json:"apiServerLoadBalancerFloatingIP,omitempty"`

// APIServerLoadBalancerPort is the port on which the listener on the APIServer
// loadbalancer will be created
APIServerLoadBalancerPort int `json:"apiServerLoadBalancerPort,omitempty"`

// APIServerLoadBalancerAdditionalPorts adds additional ports to the APIServerLoadBalancer
APIServerLoadBalancerAdditionalPorts []int `json:"apiServerLoadBalancerAdditionalPorts,omitempty"`

// ManagedSecurityGroups defines that kubernetes manages the OpenStack security groups
// for now, that means that we'll create two security groups, one allowing SSH
// and API access from everywhere, and another one that allows all traffic to/from
// machines belonging to that group. In the future, we could make this more flexible.
ManagedSecurityGroups bool `json:"managedSecurityGroups"`

// DisablePortSecurity disables the port security of the network created for the
// Kubernetes cluster, which also disables SecurityGroups
DisablePortSecurity bool `json:"disablePortSecurity,omitempty"`

// Tags for all resources in cluster
Tags []string `json:"tags,omitempty"`

// Default: True. In case of server tag errors, set to False
DisableServerTags bool `json:"disableServerTags,omitempty"`

// CAKeyPair is the key pair for ca certs.
CAKeyPair KeyPair `json:"caKeyPair,omitempty"`

//EtcdCAKeyPair is the key pair for etcd.
EtcdCAKeyPair KeyPair `json:"etcdCAKeyPair,omitempty"`

// FrontProxyCAKeyPair is the key pair for FrontProxyKeyPair.
FrontProxyCAKeyPair KeyPair `json:"frontProxyCAKeyPair,omitempty"`

// SAKeyPair is the service account key pair.
SAKeyPair KeyPair `json:"saKeyPair,omitempty"`

// ClusterConfiguration holds the cluster-wide information used during a
// kubeadm init call.
ClusterConfiguration kubeadmv1beta1.ClusterConfiguration `json:"clusterConfiguration,omitempty"`
}

// OpenStackClusterStatus defines the observed state of OpenStackCluster
type OpenStackClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

Ready bool `json:"ready"`
// APIEndpoints represents the endpoints to communicate with the control plane.
// +optional
APIEndpoints []APIEndpoint `json:"apiEndpoints,omitempty"`

// Network contains all information about the created OpenStack Network.
// It includes Subnets and Router.
Network *Network `json:"network,omitempty"`

// ControlPlaneSecurityGroups contains all the information about the OpenStack
// Security Group that needs to be applied to control plane nodes.
// TODO: Maybe instead of two properties, we add a property to the group?
ControlPlaneSecurityGroup *SecurityGroup `json:"controlPlaneSecurityGroup,omitempty"`

// GlobalSecurityGroup contains all the information about the OpenStack Security
// Group that needs to be applied to all nodes, both control plane and worker nodes.
GlobalSecurityGroup *SecurityGroup `json:"globalSecurityGroup,omitempty"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// OpenStackCluster is the Schema for the openstackclusters API
// +k8s:openapi-gen=true
type OpenStackCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec OpenStackClusterSpec `json:"spec,omitempty"`
Status OpenStackClusterStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// OpenStackClusterList contains a list of OpenStackCluster
type OpenStackClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []OpenStackCluster `json:"items"`
}

func init() {
SchemeBuilder.Register(&OpenStackCluster{}, &OpenStackClusterList{})
}
61 changes: 61 additions & 0 deletions pkg/apis/infrastructure/v1alpha2/openstackcluster_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2018 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
"testing"

"github.com/onsi/gomega"
"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

func TestStorageOpenStackCluster(t *testing.T) {
// For now, until the migration to v1alpha2 is finished
t.Skip()

key := types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created := &OpenStackCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
}}
g := gomega.NewGomegaWithT(t)

// Test Create
fetched := &OpenStackCluster{}
g.Expect(c.Create(context.TODO(), created)).To(gomega.Succeed())

g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.Succeed())
g.Expect(fetched).To(gomega.Equal(created))

// Test Updating the Labels
updated := fetched.DeepCopy()
updated.Labels = map[string]string{"hello": "world"}
g.Expect(c.Update(context.TODO(), updated)).To(gomega.Succeed())

g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.Succeed())
g.Expect(fetched).To(gomega.Equal(updated))

// Test Delete
g.Expect(c.Delete(context.TODO(), fetched)).To(gomega.Succeed())
g.Expect(c.Get(context.TODO(), key, fetched)).ToNot(gomega.Succeed())
}
Loading