Skip to content

Commit

Permalink
Merge pull request #89 from flaper87/openstack
Browse files Browse the repository at this point in the history
Add OpenStack as a supported platform
  • Loading branch information
openshift-merge-robot committed Oct 16, 2018
2 parents 812b9ab + b292eea commit 5e6bdb9
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 17 deletions.
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
- 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
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"`
}

type OpenStackConfig struct {
}

// 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

0 comments on commit 5e6bdb9

Please sign in to comment.