Skip to content

Commit

Permalink
Add ability to specify selector for cilium-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
grahambrereton-form3 committed Nov 13, 2023
1 parent d99e2d0 commit 75363b1
Show file tree
Hide file tree
Showing 17 changed files with 786 additions and 12 deletions.
16 changes: 16 additions & 0 deletions api/v1alpha1/ciliumchaos_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,27 @@ type CiliumChaosSpec struct {
// Duration represents the duration of the chaos action.
Duration *string `json:"duration" webhook:"Duration"`

// CiliumPodSelector provides a custom selector to find the cilium-agent pod for the node.
//
// If not specified, it will default to selecting pods from the `kube-system` namespace with labels
// `app.kubernetes.io/name=cilium-agent` and `app.kubernetes.io/part-of=cilium` (which are used by default by the cilium
// helm chart)
CiliumPodSelector *CiliumPodSelectorSpec `json:"ciliumPodSelector"`

// RemoteCluster represents the remote cluster where the chaos will be deployed
// +optional
RemoteCluster string `json:"remoteCluster,omitempty"`
}

type CiliumPodSelectorSpec struct {
// Namespace to restrict cilium-agent pod selection to
// +optional
Namespace string `json:"namespace,omitempty"`

// Map of label selector expressions that can be used to select the cilium-agent pods..
LabelSelectors map[string]string `json:"labelSelectors,omitempty"`
}

// CiliumChaosStatus represents the current status of the chaos experiment about pods.
type CiliumChaosStatus struct {
ChaosStatus `json:",inline"`
Expand Down
36 changes: 36 additions & 0 deletions api/v1alpha1/ciliumchaos_webhook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2023 Chaos Mesh Authors.
//
// 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 (
"reflect"
)

func (in *CiliumChaosSpec) Default(root interface{}, field *reflect.StructField) {
if in == nil {
return
}

if in.CiliumPodSelector == nil {
in.CiliumPodSelector = &CiliumPodSelectorSpec{
Namespace: "kube-system",
LabelSelectors: map[string]string{
"app.kubernetes.io/name": "cilium-agent",
"app.kubernetes.io/part-of": "cilium",
},
}
}
}
27 changes: 27 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

19 changes: 19 additions & 0 deletions config/crd/bases/chaos-mesh.org_ciliumchaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ spec:
spec:
description: Spec defines the behavior of a node chaos experiment
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom selector to find
the cilium-agent pod for the node. \n If not specified, it will
default to selecting pods from the `kube-system` namespace with
labels `app.kubernetes.io/name=cilium-agent` and `app.kubernetes.io/part-of=cilium`
(which are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions that can be used
to select the cilium-agent pods..
type: object
namespace:
description: Namespace to restrict cilium-agent pod selection
to
type: string
type: object
duration:
description: Duration represents the duration of the chaos action.
type: string
Expand Down Expand Up @@ -120,6 +138,7 @@ spec:
0-100 to specify the max percent of pods to do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down
61 changes: 61 additions & 0 deletions config/crd/bases/chaos-mesh.org_schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,24 @@ spec:
description: CiliumChaosSpec defines the attributes that a user creates
on a chaos experiment affecting cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom selector to
find the cilium-agent pod for the node. \n If not specified,
it will default to selecting pods from the `kube-system` namespace
with labels `app.kubernetes.io/name=cilium-agent` and `app.kubernetes.io/part-of=cilium`
(which are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions that can be
used to select the cilium-agent pods..
type: object
namespace:
description: Namespace to restrict cilium-agent pod selection
to
type: string
type: object
duration:
description: Duration represents the duration of the chaos action.
type: string
Expand Down Expand Up @@ -369,6 +387,7 @@ spec:
chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down Expand Up @@ -3641,6 +3660,25 @@ spec:
a user creates on a chaos experiment affecting cilium
CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom selector
to find the cilium-agent pod for the node. \n If not
specified, it will default to selecting pods from
the `kube-system` namespace with labels `app.kubernetes.io/name=cilium-agent`
and `app.kubernetes.io/part-of=cilium` (which are
used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions that
can be used to select the cilium-agent pods..
type: object
namespace:
description: Namespace to restrict cilium-agent
pod selection to
type: string
type: object
duration:
description: Duration represents the duration of the
chaos action.
Expand Down Expand Up @@ -3735,6 +3773,7 @@ spec:
pods to do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down Expand Up @@ -6835,6 +6874,27 @@ spec:
that a user creates on a chaos experiment affecting
cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom
selector to find the cilium-agent pod for the
node. \n If not specified, it will default to
selecting pods from the `kube-system` namespace
with labels `app.kubernetes.io/name=cilium-agent`
and `app.kubernetes.io/part-of=cilium` (which
are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions
that can be used to select the cilium-agent
pods..
type: object
namespace:
description: Namespace to restrict cilium-agent
pod selection to
type: string
type: object
duration:
description: Duration represents the duration of
the chaos action.
Expand Down Expand Up @@ -6932,6 +6992,7 @@ spec:
of pods to do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down
83 changes: 83 additions & 0 deletions config/crd/bases/chaos-mesh.org_workflownodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,24 @@ spec:
description: CiliumChaosSpec defines the attributes that a user creates
on a chaos experiment affecting cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom selector to
find the cilium-agent pod for the node. \n If not specified,
it will default to selecting pods from the `kube-system` namespace
with labels `app.kubernetes.io/name=cilium-agent` and `app.kubernetes.io/part-of=cilium`
(which are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions that can be
used to select the cilium-agent pods..
type: object
namespace:
description: Namespace to restrict cilium-agent pod selection
to
type: string
type: object
duration:
description: Duration represents the duration of the chaos action.
type: string
Expand Down Expand Up @@ -379,6 +397,7 @@ spec:
chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down Expand Up @@ -3281,6 +3300,25 @@ spec:
description: CiliumChaosSpec defines the attributes that a user
creates on a chaos experiment affecting cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom selector
to find the cilium-agent pod for the node. \n If not specified,
it will default to selecting pods from the `kube-system`
namespace with labels `app.kubernetes.io/name=cilium-agent`
and `app.kubernetes.io/part-of=cilium` (which are used by
default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions that can
be used to select the cilium-agent pods..
type: object
namespace:
description: Namespace to restrict cilium-agent pod selection
to
type: string
type: object
duration:
description: Duration represents the duration of the chaos
action.
Expand Down Expand Up @@ -3370,6 +3408,7 @@ spec:
do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down Expand Up @@ -6711,6 +6750,27 @@ spec:
that a user creates on a chaos experiment affecting
cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom
selector to find the cilium-agent pod for the
node. \n If not specified, it will default to
selecting pods from the `kube-system` namespace
with labels `app.kubernetes.io/name=cilium-agent`
and `app.kubernetes.io/part-of=cilium` (which
are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions
that can be used to select the cilium-agent
pods..
type: object
namespace:
description: Namespace to restrict cilium-agent
pod selection to
type: string
type: object
duration:
description: Duration represents the duration of
the chaos action.
Expand Down Expand Up @@ -6808,6 +6868,7 @@ spec:
of pods to do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down Expand Up @@ -10001,6 +10062,27 @@ spec:
that a user creates on a chaos experiment affecting
cilium CNI.
properties:
ciliumPodSelector:
description: "CiliumPodSelector provides a custom
selector to find the cilium-agent pod for
the node. \n If not specified, it will default
to selecting pods from the `kube-system` namespace
with labels `app.kubernetes.io/name=cilium-agent`
and `app.kubernetes.io/part-of=cilium` (which
are used by default by the cilium helm chart)"
properties:
labelSelectors:
additionalProperties:
type: string
description: Map of label selector expressions
that can be used to select the cilium-agent
pods..
type: object
namespace:
description: Namespace to restrict cilium-agent
pod selection to
type: string
type: object
duration:
description: Duration represents the duration
of the chaos action.
Expand Down Expand Up @@ -10101,6 +10183,7 @@ spec:
of pods to do chaos action
type: string
required:
- ciliumPodSelector
- duration
- mode
- selector
Expand Down
Loading

0 comments on commit 75363b1

Please sign in to comment.