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

Add OpenStack as a supported platform #89

Merged
merged 1 commit into from
Oct 16, 2018
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
An Operator for managing the cluster-api stack and the Openshift owned machineSets:
- Aggregated API server
- Controller manager
- Machine controller (AWS/Libvirt actuator)
- Machine controller (AWS/OpenStack/Libvirt actuator)

# Manual deployment (for Kubernetes cluster)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: machine-api-operator-images
namespace: openshift-cluster-api
data:
images.json: '{"clusterAPIControllerAWS": "openshift/origin-aws-machine-controllers:v4.0.0", "clusterAPIControllerManagerAWS": "openshift/origin-aws-machine-controllers:v4.0.0" , "clusterAPIControllerManagerLibvirt": "gcr.io/k8s-cluster-api/controller-manager:0.0.7", "clusterAPIControllerLibvirt": "quay.io/coreos/cluster-api-provider-libvirt:cd386e4", "clusterAPIServer": "gcr.io/k8s-cluster-api/cluster-apiserver:0.0.6", "Etcd": "quay.io/coreos/etcd:latest"}'
images.json: '{"clusterAPIControllerAWS": "openshift/origin-aws-machine-controllers:v4.0.0", "clusterAPIControllerManagerAWS": "openshift/origin-aws-machine-controllers:v4.0.0", "clusterAPIControllerOpenStack": "openshift/origin-openstack-machine-controllers:v4.0.0", "clusterAPIControllerManagerOpenStack": "openshift/origin-openstack-machine-controllers:v4.0.0", "clusterAPIControllerManagerLibvirt": "gcr.io/k8s-cluster-api/controller-manager:0.0.7", "clusterAPIControllerLibvirt": "quay.io/coreos/cluster-api-provider-libvirt:cd386e4", "clusterAPIServer": "gcr.io/k8s-cluster-api/cluster-apiserver:0.0.6", "Etcd": "quay.io/coreos/etcd:latest"}'
6 changes: 5 additions & 1 deletion install/image-references
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ spec:
from:
kind: DockerImage
name: docker.io/openshift/origin-aws-machine-controllers:v4.0.0
- name: openstack-machine-controllers
from:
kind: DockerImage
name: registry.svc.ci.openshift.org/openshift/origin-v4.0:openstack-machine-controllers
flaper87 marked this conversation as resolved.
Show resolved Hide resolved
- name: libvirt-machine-controllers
from:
kind: DockerImage
name: docker.io/openshift/origin-libvirt-machine-controllers:v4.0.0
name: docker.io/openshift/origin-libvirt-machine-controllers:v4.0.0
flaper87 marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions machines/openstack/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: "cluster.k8s.io/v1alpha1"
kind: Cluster
metadata:
namespace: {{ .TargetNamespace }}
spec:
clusterNetwork:
services:
cidrBlocks:
- "10.0.0.1/24"
pods:
cidrBlocks:
- "10.0.0.2/24"
serviceDomain: unused
5 changes: 5 additions & 0 deletions owned-manifests/clusterapi-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
- name: controller-manager
{{- if .AWS }}
image: {{ .Images.ClusterAPIControllerManagerAWS }}
{{- else if .OpenStack}}
image: {{ .Images.ClusterAPIControllerManagerOpenStack }}
{{- else if .Libvirt}}
image: {{ .Images.ClusterAPIControllerManagerLibvirt }}
{{- end}}
Expand All @@ -54,6 +56,9 @@ spec:
{{- if .AWS }}
- name: aws-machine-controller
image: {{ .Images.ClusterAPIControllerAWS }}
{{- else if .OpenStack }}
- name: openstack-machine-controller
image: {{ .Images.ClusterAPIControllerOpenStack }}
{{- else if .Libvirt}}
- name: libvirt-machine-controller
image: {{ .Images.ClusterAPIControllerLibvirt }}
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
// 5ms, 10ms, 20ms, 40ms, 80ms, 160ms, 320ms, 640ms, 1.3s, 2.6s, 5.1s, 10.2s, 20.4s, 41s, 82s
maxRetries = 15
providerAWS = "aws"
providerOpenStack = "openstack"
providerLibvirt = "libvirt"
ownedManifestsDir = "owned-manifests"
)
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (optr *Operator) syncCluster(config render.OperatorConfig) error {
clusters = []string{
"machines/aws/cluster.yaml",
}
case providerOpenStack:
clusters = []string{
"machines/openstack/cluster.yaml",
}
case providerLibvirt:
clusters = []string{
"machines/libvirt/cluster.yaml",
Expand Down
30 changes: 18 additions & 12 deletions pkg/render/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const (
// OperatorConfig contains configuration for MAO
type OperatorConfig struct {
metav1.TypeMeta `json:",inline"`
TargetNamespace string `json:"targetNamespace"`
APIServiceCA string `json:"apiServiceCA"`
Provider string `json:"provider"`
AWS *AWSConfig `json:"aws"`
Libvirt *LibvirtConfig `json:"libvirt"`
Images *Images `json:"images"`
TargetNamespace string `json:"targetNamespace"`
APIServiceCA string `json:"apiServiceCA"`
Provider string `json:"provider"`
AWS *AWSConfig `json:"aws"`
OpenStack *OpenStackConfig `json:"openstack,omitempty"`
Libvirt *LibvirtConfig `json:"libvirt"`
Images *Images `json:"images"`
}

// LibvirtConfig contains specific config for Libvirt
Expand All @@ -42,12 +43,17 @@ type AWSConfig struct {
WithCreds bool `json:"withCreds"`
Copy link
Member

Choose a reason for hiding this comment

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

WithCreds is used in aws so if set the actuator use those credentials to interact with the aws api, otherwise it uses the ami role in the given machine. How would this be handle for openstack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be handled by reading a clouds.yaml file from the system. It's a similar architecture to AWS, just different file format.

}

type OpenStackConfig struct {
flaper87 marked this conversation as resolved.
Show resolved Hide resolved
}

// Images allows build systems to inject images for MAO components.
type Images struct {
ClusterAPIControllerAWS string `json:"clusterAPIControllerAWS"`
ClusterAPIControllerLibvirt string `json:"clusterAPIControllerLibvirt"`
ClusterAPIControllerManagerAWS string `json:"clusterAPIControllerManagerAWS"`
ClusterAPIControllerManagerLibvirt string `json:"clusterAPIControllerManagerLibvirt"`
ClusterAPIServer string `json:"clusterAPIServer"`
Etcd string `json:"Etcd"`
ClusterAPIControllerAWS string `json:"clusterAPIControllerAWS"`
ClusterAPIControllerOpenStack string `json:"clusterAPIControllerOpenStack"`
ClusterAPIControllerLibvirt string `json:"clusterAPIControllerLibvirt"`
ClusterAPIControllerManagerAWS string `json:"clusterAPIControllerManagerAWS"`
ClusterAPIControllerManagerOpenStack string `json:"clusterAPIControllerManagerOpenStack"`
ClusterAPIControllerManagerLibvirt string `json:"clusterAPIControllerManagerLibvirt"`
ClusterAPIServer string `json:"clusterAPIServer"`
Etcd string `json:"Etcd"`
}
5 changes: 3 additions & 2 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
)

const (
providerAWS = "aws"
providerLibvirt = "libvirt"
providerAWS = "aws"
providerOpenStack = "openstack"
providerLibvirt = "libvirt"
)

// Manifests takes the config object that contains the templated value,
Expand Down
24 changes: 24 additions & 0 deletions pkg/render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,30 @@ spec:
controlPlane: ""`)
}

func TestClusterOpenStackManifest(t *testing.T) {
config := OperatorConfig{
TargetNamespace: "go-test",
Provider: "OpenStack",
}

testRenderManifest(t, "../../machines/openstack/cluster.yaml", &config, `
---
apiVersion: "cluster.k8s.io/v1alpha1"
kind: Cluster
metadata:
namespace: go-test
spec:
clusterNetwork:
services:
cidrBlocks:
- "10.0.0.1/24"
pods:
cidrBlocks:
- "10.0.0.2/24"
serviceDomain: unused
`)
}

func TestMachineSetLibvirtManifest(t *testing.T) {
config := OperatorConfig{
TargetNamespace: "go-test",
Expand Down