WIP: Fixed sample CR
This commit is contained in:
parent
df2a9f73d1
commit
e8688c5606
@ -5,31 +5,39 @@ metadata:
|
||||
namespace: clusterA
|
||||
spec:
|
||||
nodes:
|
||||
- vm-role: 'worker'
|
||||
vm-flavor: 'foobar'
|
||||
scheduling-constraints: ['per-node'] # Support dont'care option.
|
||||
count:
|
||||
active: 3 #driven by capi node number
|
||||
standby: 1 #slew for upgrades etc
|
||||
- vm-role: 'master'
|
||||
vm-flavor: 'goober'
|
||||
scheduling-constraints: ['per-node','per-rack']
|
||||
count:
|
||||
active: 3
|
||||
standby: 1
|
||||
worker:
|
||||
vm-flavor: 'airshipit.org/vino-flavor=worker'
|
||||
scheduling-constraints: ['per-node'] # Support dont'care option.
|
||||
count:
|
||||
active: 3 #driven by capi node number
|
||||
standby: 1 #slew for upgrades etc
|
||||
master:
|
||||
vm-flavor: 'airshipit.org/vino-flavor=master'
|
||||
scheduling-constraints: ['per-node','per-rack']
|
||||
count:
|
||||
active: 3
|
||||
standby: 1
|
||||
infra:
|
||||
loadbalancer:
|
||||
optional:
|
||||
clusterIp: 1.2.3.4 #<-- this aligns to the VIP IP for undercloud k8s
|
||||
image: haproxy:foo
|
||||
nodeLabels:
|
||||
image: haproxy:foo
|
||||
nodeLabels:
|
||||
- airship-masters
|
||||
nodePort: 7000
|
||||
nodeInterfaceId: oam-ipv4
|
||||
jump:
|
||||
nodePort: 7000
|
||||
nodeInterfaceId: oam-ipv4
|
||||
jumppod:
|
||||
optional:
|
||||
sshKey: rsa.... #<-- this needs to align to the ssh keys provided to cluster api objects
|
||||
image: sshpod:foo
|
||||
nodeLabels:
|
||||
- airship-masters
|
||||
nodePort: 7022
|
||||
nodeInterfaceId: oam-ipv4
|
||||
image: sshpod:foo
|
||||
nodeLabels:
|
||||
- airship-masters
|
||||
nodePort: 7022
|
||||
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
|
||||
const (
|
||||
// LoadBalancer Service
|
||||
LoadBalancerService InfraService = "LoadBalancer"
|
||||
LoadBalancerService InfraService = "loadbalancer"
|
||||
|
||||
// JumpHostService Service
|
||||
JumpHostService InfraService = "JumpHost"
|
||||
JumpHostService InfraService = "jumppod"
|
||||
|
||||
// AuthHostService Service
|
||||
AuthHostService InfraService = "AuthHost"
|
||||
AuthHostService InfraService = "authpod"
|
||||
)
|
||||
|
||||
// NodeSet are the the list of Nodes objects workers,
|
||||
@ -87,45 +87,12 @@ type SchedulingOptions string
|
||||
// Possible Node or VM Roles for a Tenant
|
||||
const (
|
||||
// RackAntiAffinity means the state is unknown
|
||||
RackAntiAffinity SchedulingOptions = "rack"
|
||||
RackAntiAffinity SchedulingOptions = "per-rack"
|
||||
|
||||
// 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 {
|
||||
OptionalData *OptsConfig `json:"optional,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
metal3 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
airshipv1 "sipcluster/pkg/api/v1"
|
||||
"strings"
|
||||
//corev1 "k8s.io/api/core/v1"
|
||||
//rbacv1 "k8s.io/api/rbac/v1"
|
||||
//"k8s.io/apimachinery/pkg/api/errors"
|
||||
@ -161,16 +162,16 @@ func (ml *MachineList) initScheduleMaps(constraints []airshipv1.SchedulingOption
|
||||
for _, constraint := range constraints {
|
||||
if constraint == airshipv1.RackAntiAffinity {
|
||||
setMap[constraint] = &ScheduleSet{
|
||||
active: true,
|
||||
set: make(map[string]bool),
|
||||
label: RackLabel,
|
||||
active: true,
|
||||
set: make(map[string]bool),
|
||||
labelName: RackLabel,
|
||||
}
|
||||
}
|
||||
if constraint == airshipv1.ServerAntiAffinity {
|
||||
setMap[constraint] = &ScheduleSet{
|
||||
active: true,
|
||||
set: make(map[string]bool),
|
||||
label: ServerLabel,
|
||||
active: true,
|
||||
set: make(map[string]bool),
|
||||
labelName: ServerLabel,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,9 +193,9 @@ func (ml *MachineList) scheduleIt(nodeRole airshipv1.VmRoles, nodeCfg airshipv1.
|
||||
// Check if bmh has the label
|
||||
// There is a func (host *BareMetalHost) getLabel(name string) string {
|
||||
// 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 scheduleSetMap[constraint].Exists(cLabelValue) {
|
||||
validBmh = false
|
||||
@ -236,8 +237,8 @@ type ScheduleSet struct {
|
||||
active bool
|
||||
// Holds list of elements in teh Set
|
||||
set map[string]bool
|
||||
// Holds the label that identifies the constraint
|
||||
label string
|
||||
// Holds the label name that identifies the constraint
|
||||
labelName string
|
||||
}
|
||||
|
||||
func (ss *ScheduleSet) Active() bool {
|
||||
@ -250,10 +251,13 @@ func (ss *ScheduleSet) Exists(value string) bool {
|
||||
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 {
|
||||
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