Skip to content

Commit

Permalink
feat: Add NodeSelectorChaos
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolaj-krzyzanowski-f3 committed Jan 13, 2025
1 parent 6a30e2e commit 09780bd
Show file tree
Hide file tree
Showing 34 changed files with 2,191 additions and 13 deletions.
58 changes: 58 additions & 0 deletions api/v1alpha1/nodeselectorchaos_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 Chaos Mesh Authors.PodPVCChaos
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
_ InnerObject = (*NodeSelectorChaos)(nil)
_ InnerObjectWithSelector = (*NodeSelectorChaos)(nil)
)

// +kubebuilder:object:root=true
// +chaos-mesh:experiment
type NodeSelectorChaos struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NodeSelectorChaosSpec `json:"spec"`
Status NodeSelectorChaosStatus `json:"status"`
}

type NodeSelectorChaosSpec struct {
DeploymentSelectorSpec `json:"selector"`
// Key is the name of the key that will be applied to the deployment's nodeSelector field.
Key string `json:"key"`
// Value is the value assigned to the provided key.
Value string `json:"value"`
// Duration represents the duration of the chaos
// +optional
Duration *string `json:"duration,omitempty"`
// RemoteCluster represents the remote cluster where the chaos will be deployed
// +optional
RemoteCluster string `json:"remoteCluster,omitempty"`
}
type NodeSelectorChaosStatus struct {
ChaosStatus `json:",inline"`
}

func (obj *NodeSelectorChaos) GetSelectorSpecs() map[string]interface{} {
return map[string]interface{}{
".": &obj.Spec.DeploymentSelector,
}
}
9 changes: 9 additions & 0 deletions api/v1alpha1/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ type NodeSelectorSpec struct {
// +optional
ExpressionSelectors LabelSelectorRequirements `json:"expressionSelectors,omitempty" swaggerignore:"true"`
}

type DeploymentSelector struct {
// Map of namespace names to a list of deployments in that namespace.
Deployments map[string][]string `json:"deployments,omitempty"`
}

type DeploymentSelectorSpec struct {
DeploymentSelector `json:",inline"`
}
149 changes: 149 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh.go

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

63 changes: 63 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh_test.go

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

Loading

0 comments on commit 09780bd

Please sign in to comment.