WIP: Fixed sample CR
This commit is contained in:
parent
df2a9f73d1
commit
e8688c5606
@ -5,31 +5,39 @@ metadata:
|
|||||||
namespace: clusterA
|
namespace: clusterA
|
||||||
spec:
|
spec:
|
||||||
nodes:
|
nodes:
|
||||||
- vm-role: 'worker'
|
worker:
|
||||||
vm-flavor: 'foobar'
|
vm-flavor: 'airshipit.org/vino-flavor=worker'
|
||||||
scheduling-constraints: ['per-node'] # Support dont'care option.
|
scheduling-constraints: ['per-node'] # Support dont'care option.
|
||||||
count:
|
count:
|
||||||
active: 3 #driven by capi node number
|
active: 3 #driven by capi node number
|
||||||
standby: 1 #slew for upgrades etc
|
standby: 1 #slew for upgrades etc
|
||||||
- vm-role: 'master'
|
master:
|
||||||
vm-flavor: 'goober'
|
vm-flavor: 'airshipit.org/vino-flavor=master'
|
||||||
scheduling-constraints: ['per-node','per-rack']
|
scheduling-constraints: ['per-node','per-rack']
|
||||||
count:
|
count:
|
||||||
active: 3
|
active: 3
|
||||||
standby: 1
|
standby: 1
|
||||||
infra:
|
infra:
|
||||||
loadbalancer:
|
loadbalancer:
|
||||||
|
optional:
|
||||||
clusterIp: 1.2.3.4 #<-- this aligns to the VIP IP for undercloud k8s
|
clusterIp: 1.2.3.4 #<-- this aligns to the VIP IP for undercloud k8s
|
||||||
image: haproxy:foo
|
image: haproxy:foo
|
||||||
nodeLabels:
|
nodeLabels:
|
||||||
- airship-masters
|
- airship-masters
|
||||||
nodePort: 7000
|
nodePort: 7000
|
||||||
nodeInterfaceId: oam-ipv4
|
nodeInterfaceId: oam-ipv4
|
||||||
jump:
|
jumppod:
|
||||||
|
optional:
|
||||||
sshKey: rsa.... #<-- this needs to align to the ssh keys provided to cluster api objects
|
sshKey: rsa.... #<-- this needs to align to the ssh keys provided to cluster api objects
|
||||||
image: sshpod:foo
|
image: sshpod:foo
|
||||||
nodeLabels:
|
nodeLabels:
|
||||||
- airship-masters
|
- airship-masters
|
||||||
nodePort: 7022
|
nodePort: 7022
|
||||||
nodeInterfaceId: oam-ipv4
|
nodeInterfaceId: oam-ipv4
|
||||||
|
authpod:
|
||||||
|
image: sshpod:foo
|
||||||
|
nodeLabels:
|
||||||
|
- airship-masters
|
||||||
|
nodePort: 7022
|
||||||
|
nodeInterfaceId: oam-ipv4
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ type InfraService string
|
|||||||
// Possible Infra Structure Services
|
// Possible Infra Structure Services
|
||||||
const (
|
const (
|
||||||
// LoadBalancer Service
|
// LoadBalancer Service
|
||||||
LoadBalancerService InfraService = "LoadBalancer"
|
LoadBalancerService InfraService = "loadbalancer"
|
||||||
|
|
||||||
// JumpHostService Service
|
// JumpHostService Service
|
||||||
JumpHostService InfraService = "JumpHost"
|
JumpHostService InfraService = "jumppod"
|
||||||
|
|
||||||
// AuthHostService Service
|
// AuthHostService Service
|
||||||
AuthHostService InfraService = "AuthHost"
|
AuthHostService InfraService = "authpod"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeSet are the the list of Nodes objects workers,
|
// NodeSet are the the list of Nodes objects workers,
|
||||||
@ -87,45 +87,12 @@ type SchedulingOptions string
|
|||||||
// Possible Node or VM Roles for a Tenant
|
// Possible Node or VM Roles for a Tenant
|
||||||
const (
|
const (
|
||||||
// RackAntiAffinity means the state is unknown
|
// RackAntiAffinity means the state is unknown
|
||||||
RackAntiAffinity SchedulingOptions = "rack"
|
RackAntiAffinity SchedulingOptions = "per-rack"
|
||||||
|
|
||||||
// ServerAntiAffinity means the state is unknown
|
// ServerAntiAffinity means the state is unknown
|
||||||
ServerAntiAffinity SchedulingOptions = "server"
|
ServerAntiAffinity SchedulingOptions = "per-node"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
|
||||||
type InfraSet struct {
|
|
||||||
// Load Balancer Infrastrcture Service that fronts a Tenant Cluster
|
|
||||||
// Kubernetes API Servers
|
|
||||||
// These provides the configuration expectations
|
|
||||||
LoadBalancer *LoadBalancerConfig `json:"loadbalancer,omitempty"`
|
|
||||||
// Jump Host is an Operation POD that allows operators to
|
|
||||||
// Manage the VM Node infrastcuture
|
|
||||||
// These provides the configuration expectations
|
|
||||||
JumpHost *JumpHostConfig `json:"jumphost,omitempty"`
|
|
||||||
// AuthHost is an Service POD that provides an OIDC provider
|
|
||||||
// interface to the Tenant Cluster
|
|
||||||
// These provides the configuration expectations
|
|
||||||
AuthHost *AuthConfig `json:"authhost,omitempty"`
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
type LoadBalancerConfig struct {
|
|
||||||
ClusterIp string `json:"clusterIp,omitempty"`
|
|
||||||
Config *InfraConfig `json:"config,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type JumpHostConfig struct {
|
|
||||||
SshKey string `json:"sshkey,omitempty"`
|
|
||||||
Config *InfraConfig `json:"config,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthConfig struct {
|
|
||||||
Config *InfraConfig `json:"config,omitempty"`
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
type InfraConfig struct {
|
type InfraConfig struct {
|
||||||
OptionalData *OptsConfig `json:"optional,omitempty"`
|
OptionalData *OptsConfig `json:"optional,omitempty"`
|
||||||
Image string `json:"image,omitempty"`
|
Image string `json:"image,omitempty"`
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
metal3 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
|
metal3 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
airshipv1 "sipcluster/pkg/api/v1"
|
airshipv1 "sipcluster/pkg/api/v1"
|
||||||
|
"strings"
|
||||||
//corev1 "k8s.io/api/core/v1"
|
//corev1 "k8s.io/api/core/v1"
|
||||||
//rbacv1 "k8s.io/api/rbac/v1"
|
//rbacv1 "k8s.io/api/rbac/v1"
|
||||||
//"k8s.io/apimachinery/pkg/api/errors"
|
//"k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -161,16 +162,16 @@ func (ml *MachineList) initScheduleMaps(constraints []airshipv1.SchedulingOption
|
|||||||
for _, constraint := range constraints {
|
for _, constraint := range constraints {
|
||||||
if constraint == airshipv1.RackAntiAffinity {
|
if constraint == airshipv1.RackAntiAffinity {
|
||||||
setMap[constraint] = &ScheduleSet{
|
setMap[constraint] = &ScheduleSet{
|
||||||
active: true,
|
active: true,
|
||||||
set: make(map[string]bool),
|
set: make(map[string]bool),
|
||||||
label: RackLabel,
|
labelName: RackLabel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if constraint == airshipv1.ServerAntiAffinity {
|
if constraint == airshipv1.ServerAntiAffinity {
|
||||||
setMap[constraint] = &ScheduleSet{
|
setMap[constraint] = &ScheduleSet{
|
||||||
active: true,
|
active: true,
|
||||||
set: make(map[string]bool),
|
set: make(map[string]bool),
|
||||||
label: ServerLabel,
|
labelName: ServerLabel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,9 +193,9 @@ func (ml *MachineList) scheduleIt(nodeRole airshipv1.VmRoles, nodeCfg airshipv1.
|
|||||||
// Check if bmh has the label
|
// Check if bmh has the label
|
||||||
// There is a func (host *BareMetalHost) getLabel(name string) string {
|
// There is a func (host *BareMetalHost) getLabel(name string) string {
|
||||||
// Not sure why its not Public, so sing our won method
|
// Not sure why its not Public, so sing our won method
|
||||||
cLabelValue, cFlavorValue := scheduleSetMap[constraint].GetLabels(bmh.Labels, nodeCfg.VmFlavor)
|
cLabelValue, cFlavorMatches := scheduleSetMap[constraint].GetLabels(bmh.Labels, nodeCfg.VmFlavor)
|
||||||
|
|
||||||
if cLabelValue != "" && cFlavorValue != "" {
|
if cLabelValue != "" && cFlavorMatches {
|
||||||
// If its in th elist , theen this bmh is disqualified. Skip it
|
// If its in th elist , theen this bmh is disqualified. Skip it
|
||||||
if scheduleSetMap[constraint].Exists(cLabelValue) {
|
if scheduleSetMap[constraint].Exists(cLabelValue) {
|
||||||
validBmh = false
|
validBmh = false
|
||||||
@ -236,8 +237,8 @@ type ScheduleSet struct {
|
|||||||
active bool
|
active bool
|
||||||
// Holds list of elements in teh Set
|
// Holds list of elements in teh Set
|
||||||
set map[string]bool
|
set map[string]bool
|
||||||
// Holds the label that identifies the constraint
|
// Holds the label name that identifies the constraint
|
||||||
label string
|
labelName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *ScheduleSet) Active() bool {
|
func (ss *ScheduleSet) Active() bool {
|
||||||
@ -250,10 +251,13 @@ func (ss *ScheduleSet) Exists(value string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *ScheduleSet) GetLabels(labels map[string]string, customLabel string) (string, string) {
|
func (ss *ScheduleSet) GetLabels(labels map[string]string, flavorLabel string) (string, bool) {
|
||||||
if labels == nil {
|
if labels == nil {
|
||||||
return "", ""
|
return "", false
|
||||||
}
|
}
|
||||||
return labels[ss.label], labels[customLabel]
|
cl := strings.Split(flavorLabel, "=")
|
||||||
|
if len(cl) > 0 {
|
||||||
|
return labels[ss.labelName], labels[cl[0]] == cl[1]
|
||||||
|
}
|
||||||
|
return labels[ss.labelName], false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user