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 setting for nodeAffinity and pod(Anti)Affinity #116

Merged
merged 3 commits into from
May 19, 2020
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
580 changes: 580 additions & 0 deletions deploy/crds/app.stacks_runtimecomponents_crd.yaml

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions pkg/apis/appstacks/v1beta1/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ type RuntimeComponentSpec struct {
SidecarContainers []corev1.Container `json:"sidecarContainers,omitempty"`
Route *RuntimeComponentRoute `json:"route,omitempty"`
Bindings *RuntimeComponentBindings `json:"bindings,omitempty"`
Affinity *RuntimeComponentAffinity `json:"affinity,omitempty"`
}

// RuntimeComponentAffinity deployment affinity settings
// +k8s:openapi-gen=true
type RuntimeComponentAffinity struct {
NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty"`
PodAffinity *corev1.PodAffinity `json:"podAffinity,omitempty"`
PodAntiAffinity *corev1.PodAntiAffinity `json:"podAntiAffinity,omitempty"`
// +listType=set
Architecture []string `json:"architecture,omitempty"`
NodeAffinityLabels map[string]string `json:"nodeAffinityLabels,omitempty"`
}

// RuntimeComponentAutoScaling ...
Expand Down Expand Up @@ -379,6 +391,14 @@ func (cr *RuntimeComponent) GetBindings() common.BaseComponentBindings {
return cr.Spec.Bindings
}

// GetAffinity returns deployment's node and pod affinity settings
func (cr *RuntimeComponent) GetAffinity() common.BaseComponentAffinity {
if cr.Spec.Affinity == nil {
return nil
}
return cr.Spec.Affinity
}

// GetResolvedBindings returns a map of all the service names to be consumed by the application
func (s *RuntimeComponentStatus) GetResolvedBindings() []string {
return s.ResolvedBindings
Expand Down Expand Up @@ -630,6 +650,31 @@ func (r *RuntimeComponentBindings) GetEmbedded() *runtime.RawExtension {
return r.Embedded
}

// GetNodeAffinity returns node affinity
func (a *RuntimeComponentAffinity) GetNodeAffinity() *corev1.NodeAffinity {
return a.NodeAffinity
}

// GetPodAffinity returns pod affinity
func (a *RuntimeComponentAffinity) GetPodAffinity() *corev1.PodAffinity {
return a.PodAffinity
}

// GetPodAntiAffinity returns pod anti-affinity
func (a *RuntimeComponentAffinity) GetPodAntiAffinity() *corev1.PodAntiAffinity {
return a.PodAntiAffinity
}

// GetArchitecture returns list of architecture names
func (a *RuntimeComponentAffinity) GetArchitecture() []string {
return a.Architecture
}

// GetNodeAffinityLabels returns list of architecture names
func (a *RuntimeComponentAffinity) GetNodeAffinityLabels() map[string]string {
return a.NodeAffinityLabels
}

// Initialize the RuntimeComponent instance
func (cr *RuntimeComponent) Initialize() {
if cr.Spec.PullPolicy == nil {
Expand Down
48 changes: 48 additions & 0 deletions pkg/apis/appstacks/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 97 additions & 29 deletions pkg/apis/appstacks/v1beta1/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import (

func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponent": schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAutoScaling(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes": schema_pkg_apis_appstacks_v1beta1_ServiceBindingConsumes(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides": schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref),
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition": schema_pkg_apis_appstacks_v1beta1_StatusCondition(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponent": schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentAffinity": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAffinity(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAutoScaling(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentService": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref),
"./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus": schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref),
"./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes": schema_pkg_apis_appstacks_v1beta1_ServiceBindingConsumes(ref),
"./pkg/apis/appstacks/v1beta1.ServiceBindingProvides": schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref),
"./pkg/apis/appstacks/v1beta1.StatusCondition": schema_pkg_apis_appstacks_v1beta1_StatusCondition(ref),
}
}

Expand Down Expand Up @@ -51,19 +52,81 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponent(ref common.ReferenceCall
},
"spec": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus"),
},
},
},
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentSpec", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
"./pkg/apis/appstacks/v1beta1.RuntimeComponentSpec", "./pkg/apis/appstacks/v1beta1.RuntimeComponentStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}

func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "RuntimeComponentAffinity deployment affinity settings",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"nodeAffinity": {
SchemaProps: spec.SchemaProps{
Ref: ref("k8s.io/api/core/v1.NodeAffinity"),
},
},
"podAffinity": {
SchemaProps: spec.SchemaProps{
Ref: ref("k8s.io/api/core/v1.PodAffinity"),
},
},
"podAntiAffinity": {
SchemaProps: spec.SchemaProps{
Ref: ref("k8s.io/api/core/v1.PodAntiAffinity"),
},
},
"architecture": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "set",
},
},
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
"nodeAffinityLabels": {
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/core/v1.NodeAffinity", "k8s.io/api/core/v1.PodAffinity", "k8s.io/api/core/v1.PodAntiAffinity"},
}
}

Expand Down Expand Up @@ -133,7 +196,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref common.Referenc
},
"certificate": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"),
Ref: ref("./pkg/apis/appstacks/v1beta1.Certificate"),
},
},
"certificateSecretRef": {
Expand All @@ -158,7 +221,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentRoute(ref common.Referenc
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"},
"./pkg/apis/appstacks/v1beta1.Certificate"},
}
}

Expand Down Expand Up @@ -236,20 +299,20 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes"),
Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes"),
},
},
},
},
},
"provides": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides"),
Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingProvides"),
},
},
"certificate": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate"),
Ref: ref("./pkg/apis/appstacks/v1beta1.Certificate"),
},
},
"certificateSecretRef": {
Expand All @@ -262,7 +325,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentService(ref common.Refere
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.Certificate", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingConsumes", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingProvides", "k8s.io/api/core/v1.ServicePort"},
"./pkg/apis/appstacks/v1beta1.Certificate", "./pkg/apis/appstacks/v1beta1.ServiceBindingConsumes", "./pkg/apis/appstacks/v1beta1.ServiceBindingProvides", "k8s.io/api/core/v1.ServicePort"},
}
}

Expand Down Expand Up @@ -293,7 +356,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference
},
"autoscaling": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling"),
},
},
"pullPolicy": {
Expand Down Expand Up @@ -360,7 +423,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference
},
"service": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentService"),
},
},
"expose": {
Expand Down Expand Up @@ -430,7 +493,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference
},
"storage": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStorage"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentStorage"),
},
},
"createKnativeService": {
Expand All @@ -441,7 +504,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference
},
"monitoring": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring"),
},
},
"createAppDefinition": {
Expand Down Expand Up @@ -494,20 +557,25 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentSpec(ref common.Reference
},
"route": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute"),
},
},
"bindings": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentBindings"),
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentBindings"),
},
},
"affinity": {
SchemaProps: spec.SchemaProps{
Ref: ref("./pkg/apis/appstacks/v1beta1.RuntimeComponentAffinity"),
},
},
},
Required: []string{"applicationImage"},
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentBindings", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentRoute", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentService", "github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.RuntimeComponentStorage", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"},
"./pkg/apis/appstacks/v1beta1.RuntimeComponentAffinity", "./pkg/apis/appstacks/v1beta1.RuntimeComponentAutoScaling", "./pkg/apis/appstacks/v1beta1.RuntimeComponentBindings", "./pkg/apis/appstacks/v1beta1.RuntimeComponentMonitoring", "./pkg/apis/appstacks/v1beta1.RuntimeComponentRoute", "./pkg/apis/appstacks/v1beta1.RuntimeComponentService", "./pkg/apis/appstacks/v1beta1.RuntimeComponentStorage", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"},
}
}

Expand All @@ -529,7 +597,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref common.Referen
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition"),
Ref: ref("./pkg/apis/appstacks/v1beta1.StatusCondition"),
},
},
},
Expand Down Expand Up @@ -584,7 +652,7 @@ func schema_pkg_apis_appstacks_v1beta1_RuntimeComponentStatus(ref common.Referen
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.StatusCondition"},
"./pkg/apis/appstacks/v1beta1.StatusCondition"},
}
}

Expand Down Expand Up @@ -653,15 +721,15 @@ func schema_pkg_apis_appstacks_v1beta1_ServiceBindingProvides(ref common.Referen
},
"auth": {
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingAuth"),
Ref: ref("./pkg/apis/appstacks/v1beta1.ServiceBindingAuth"),
},
},
},
Required: []string{"category"},
},
},
Dependencies: []string{
"github.com/application-stacks/runtime-component-operator/pkg/apis/appstacks/v1beta1.ServiceBindingAuth"},
"./pkg/apis/appstacks/v1beta1.ServiceBindingAuth"},
}
}

Expand Down
Loading