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 support for overrides for generated pods #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
43 changes: 43 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
)

type IronicStatusConditionType string

const (
Expand All @@ -12,3 +16,42 @@ const (

IronicOperatorLabel = "metal3.io/ironic-standalone-operator"
)

type Overrides struct {
// Extra annotations to add to each container.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// Extra containers to add to the deployment or daemon set.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
// +listType=map
// +listMapKey=name
Containers []corev1.Container `json:"containers,omitempty"`

// Extra environment variables to add to each container.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
// +listType=map
// +listMapKey=name
Env []corev1.EnvVar `json:"env,omitempty"`

// Extra environment variables (with sources) to add to each container.
// +optional
// +listType=atomic
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`

// Extra init containers to add to the deployment or daemon set.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
// +listType=map
// +listMapKey=name
InitContainers []corev1.Container `json:"initContainers,omitempty"`

// Extra labels to add to each container.
// +optional
Labels map[string]string `json:"labels,omitempty"`
}
2 changes: 2 additions & 0 deletions api/v1alpha1/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (

const (
FeatureHighAvailability featuregate.Feature = "HighAvailability"
FeatureOverrides featuregate.Feature = "Overrides"
)

var (
availableFeatures = map[featuregate.Feature]featuregate.FeatureSpec{
FeatureHighAvailability: {Default: false, PreRelease: featuregate.Alpha},
FeatureOverrides: {Default: false, PreRelease: featuregate.Beta},
}

CurrentFeatureGate = featuregate.NewFeatureGate()
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/ironic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ type IronicSpec struct {
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Overrides for the generated Deployment or Daemon Set.
// EXPERIMENTAL: requires feature gate Overrides.
// +optional
Overrides *Overrides `json:"overrides,omitempty"`

// TLS defines TLS-related settings for various network interactions.
// +optional
TLS TLS `json:"tls,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/ironic_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,9 @@ func ValidateIronic(ironic *IronicSpec, old *IronicSpec) error {
return errors.New("highly available architecture is disabled via feature gate")
}

if ironic.Overrides != nil && !CurrentFeatureGate.Enabled(FeatureOverrides) {
return errors.New("overrides are disabled via feature gate")
}

return nil
}
5 changes: 5 additions & 0 deletions api/v1alpha1/ironicdatabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ type IronicDatabaseSpec struct {
// +optional
Image string `json:"image,omitempty"`

// Overrides for the generated Deployment or Daemon Set.
// EXPERIMENTAL: requires feature gate Overrides.
// +optional
Overrides *Overrides `json:"overrides,omitempty"`

// TLSCertificateName is a reference to the secret with the database TLS certificate.
// +optional
TLSCertificateName string `json:"tlsCertificateName,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/ironicdatabase_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1alpha1

import (
"errors"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -62,5 +64,9 @@ func (r *IronicDatabase) ValidateDelete() (warnings admission.Warnings, err erro
}

func validateDatabase(db *IronicDatabaseSpec, old *IronicDatabaseSpec) error {
if db.Overrides != nil && !CurrentFeatureGate.Enabled(FeatureOverrides) {
return errors.New("overrides are disabled via feature gate")
}

return nil
}
76 changes: 72 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading
Loading